summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2015-07-10 17:22:13 -0400
committerJoey Grover <joeygrover@gmail.com>2015-07-10 17:22:13 -0400
commit6786a90a2bec22b00b882be951f48e47a023287c (patch)
tree612ba5f3d5ab40125a7cd3a1ff68d57d191819b4
parent4f4c0d6760a4fd6bdbe75d51b94f3df0993d02b4 (diff)
parent680113b090397410123b05be2d9ae3b4a4d71234 (diff)
downloadsdl_android-feature/logging_consolidation.tar.gz
Merged from remote and add tags to log functionsfeature/logging_consolidation
Conflicts: sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java
-rw-r--r--CONTRIBUTING.md31
-rw-r--r--README.md18
-rw-r--r--sdl_android_lib/AndroidManifest.xml2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java4
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java4
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java63
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java7
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/exception/SdlException.java100
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java8
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java4
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java40
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameData.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameDataControlFrameType.java9
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameType.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/enums/FunctionID.java287
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/enums/SessionType.java10
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java19
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/RPCNotification.java14
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java588
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/RPCResponse.java22
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/RPCStreamController.java32
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java9008
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java11
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IPutFileResponseListener.java9
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java27
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommandResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenu.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenuResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AirbagStatus.java85
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java118
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java120
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java33
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BeltStatus.java153
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BodyInformation.java23
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java13
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java108
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistrationResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java25
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java33
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java60
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSetResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DIDResult.java13
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommand.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommandResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFile.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSetResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenuResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeviceStatus.java33
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java23
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java21
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DialNumber.java51
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DialNumberResponse.java23
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java705
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ECallInfo.java33
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EmergencyEvent.java43
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThru.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThruResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GPSData.java24
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GenericResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCs.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java23
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleData.java10
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java80
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMICapabilities.java49
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java333
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HeadLampStatus.java13
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Image.java13
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java240
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java60
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFiles.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java25
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/MyKey.java13
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonEvent.java25
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonPress.java25
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnCommand.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java18
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHMIStatus.java35
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHashChange.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java18
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLanguageChange.java25
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java3
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java60
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnStreamRPC.java47
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java85
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTBTClientState.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java79
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnVehicleData.java80
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java38
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java93
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThruResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java276
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PermissionItem.java6
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFile.java58
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFileResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java23
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java61
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java1149
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java1439
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java234
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalPropertiesResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScreenParams.java8
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java60
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessageResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java50
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIcon.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIconResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java118
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java182
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalPropertiesResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimerResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java108
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java70
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SingleTireStatus.java13
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java23
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SliderResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SoftButton.java24
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java60
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SpeakResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java41
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButton.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButtonResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java10
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java71
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java46
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequestResponse.java6
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TTSChunk.java13
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TextField.java23
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TireStatus.java24
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java82
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterface.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterfaceResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButtonResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java10
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java71
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java124
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VehicleDataResult.java23
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VrHelpItem.java4
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/AppInterfaceUnregisteredReason.java9
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/GearShiftAdviceStatus.java18
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java9
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/KeyboardEvent.java7
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/LightSwitchStatus.java16
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/MaintenanceModeStatus.java16
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/MessageType.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/PermissionStatus.java25
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/RequestType.java59
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/Result.java44
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/SdlDisconnectedReason.java3
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java27
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TirePressureTellTale.java15
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataActiveStatus.java17
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataResultCode.java6
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java12
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java45
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java211
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/Mime.java137
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java923
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java6
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java26
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/BTTransportConfig.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/BaseTransportConfig.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java16
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/SiphonServer.java384
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/TCPTransport.java7
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/TCPTransportConfig.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java222
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/USBTransportConfig.java2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/enums/TransportType.java (renamed from sdl_android_lib/src/com/smartdevicelink/transport/TransportType.java)2
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/Base64.java111
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/ByteEnumer.java18
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/IConsole.java10
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/LogTool.java643
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/Mime.java183
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/SdlDataTypeConverter.java33
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java202
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/StringEnumer.java47
193 files changed, 11384 insertions, 10413 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 899abaf49..5949da48d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,16 +1,29 @@
-# Contributing to sdl_android
+# Contributing to SDL Projects
-Third party contributions are essential for making this repository great. However, we do have a few guidelines we need contributors to follow.
+Third party contributions are essential for making SDL great. However, we do have a few guidelines we need contributors to follow.
+
+### Issues
+If writing a bug report, please make sure <a href="http://yourbugreportneedsmore.info" target="_blank">it has enough info</a>. Include all relevant information.
+
+If requesting a feature, understand that we appreciate the input! However, it may not immediately fit our roadmap, and it may take a while for us to get to your request.
### Gitflow
-We use Gitflow as our branch management system. Please read up on it [here](https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow). The main points you should know are:
+We use <a href="http://nvie.com/posts/a-successful-git-branching-model/">Gitflow</a> as our branch management system. Please follow gitflow's guidelines while contributing to any SDL project.
+### Pull Requests
+* Please follow the repository's for all code and documentation.
* All feature branches should be based on `develop` and have the format `feature/branch_name`.
-* Minor bug fixes should be based on `master` and have the format `hotfix/branch_name`.
-* All commits should involve logical units. Please do not put all changed code in one commit, unless it is a very minor change.
-* Work in progress pull requests should have "[WIP]" in front of the Pull Request title. When you are ready to merge, remove this tag and @mention `smartdevicelink/developers` to get it scheduled for review.
-* If applicable, follow [this Pull Request's format](https://github.com/smartdevicelink/SmartDeviceLink-iOS/pull/45).
-* Please document all code written. Write [JavaDoc style documentation](http://www.oracle.com/technetwork/articles/java/index-137868.html) for methods, and use inline code comments where it makes sense, i.e. for non-obvious code chunks.
+* Minor bug fixes, that is bug fixes that do not change, add, or remove any public API, should be based on `master` and have the format `hotfix/branch_name`.
+* All pull requests should implement a single feature or fix a single bug. Pull Requests that involve multiple changes (it is our discretion what precisely this means) will be rejected with a reason.
+* All commits should separated into logical units, i.e. unrelated changes should be in different commits within a pull request.
+* Work in progress pull requests should have "[WIP]" in front of the Pull Request title. When you believe the pull request is ready to merge, remove this tag and @mention the appropriate SDL team to schedule a review.
+* All new code *must* include unit tests. Bug fixes should have a test that fails previously and now passes. All new features should be covered. If your code does not have tests, or regresses old tests, it will be rejected.
+* A great example of a <a href="https://github.com/smartdevicelink/SmartDeviceLink-iOS/pull/45" "_target>pull request can be found here</a>.
### Contributor's License Agreement (CLA)
-Coming Soon! We unfortunately cannot accept third party contributions until this is ready. \ No newline at end of file
+In order to accept Pull Requests from contributors, you must first sign [the Contributor's License Agreement](https://docs.google.com/forms/d/1VNR8EUd5b46cQ7uNbCq1fJmnu0askNpUp5dudLKRGpU/viewform). If you need to make a change to information that you entered, [please contact us](mailto:justin@livio.io).
+
+### Repository Specific Guidelines
+ * <a href="https://github.com/smartdevicelink/sdl_android/wiki/Style-Guide" target="blank">Android Style Guide</a>
+ * Please document all code written. Write [JavaDoc style documentation](http://www.oracle.com/technetwork/articles/java/index-137868.html) for methods, and use inline code comments where it makes sense, i.e. for non-obvious code chunks.
+
diff --git a/README.md b/README.md
index b9a47c7a5..9849a118e 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,19 @@
-sdl_android
-===========
+##### Note: Please use the [develop](https://github.com/smartdevicelink/sdl_android/tree/develop) branch of sdl_android for the most stable versions.
-SmartDeviceLink Android Proxy
+# SmartDeviceLink (SDL)
+
+SmartDeviceLink (SDL) is a standard set of protocols and messages that connect applications on a smartphone to a vehicle head unit. This messaging enables a consumer to interact with their application using common in-vehicle interfaces such as a touch screen display, embedded voice recognition, steering wheel controls and various vehicle knobs and buttons. There are three main components that make up the SDL ecosystem.
+
+ * The [Core](https://github.com/smartdevicelink/sdl_core) component is the software which Vehicle Manufacturers (OEMs) implement in their vehicle head units. Integrating this component into their head unit and HMI based on a set of guidelines and templates enables access to various smartphone applications.
+ * The optional [SDL Server](https://github.com/smartdevicelink/sdl_server) can be used by Vehicle OEMs to update application policies and gather usage information for connected applications.
+ * The [iOS](https://github.com/smartdevicelink/sdl_ios) and [Android](https://github.com/smartdevicelink/sdl_android) libraries are implemented by app developers into their applications to enable command and control via the connected head unit.
+
+Pull Requests Welcome!
+##Mobile Proxy
+
+The mobile library component of SDL is meant to run on the end user’s smart-device from within SDL enabled apps. The library allows the apps to connect to SDL enabled head-units and hardware through bluetooth, USB, and TCP. Once the library establishes a connection between the smart device and head-unit through the preferred method of transport, the two components are able to communicate using the SDL defined protocol. The app integrating this library project is then able to expose its functionality to the head-unit through text, media, and other interactive elements.
+
+##SmartDeviceLink Android
We're still working on creating documentation for each of these individual repositories, but in the meantime, you can find more information about SmartDeviceLink [here](https://github.com/smartdevicelink/sdl_core/blob/master/README.md) and [here](http://projects.genivi.org/smartdevicelink/about).
diff --git a/sdl_android_lib/AndroidManifest.xml b/sdl_android_lib/AndroidManifest.xml
index 8c2db539b..8ba1f30b3 100644
--- a/sdl_android_lib/AndroidManifest.xml
+++ b/sdl_android_lib/AndroidManifest.xml
@@ -1,5 +1,7 @@
<manifest package="com.smartdevicelink" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="12"/>
+ <!-- Required to use the log to file feature. -->
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Required to use the USB Accessory mode -->
<uses-feature android:name="android.hardware.usb.accessory"/>
<application android:debuggable="true"/>
diff --git a/sdl_android_lib/src/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java b/sdl_android_lib/src/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java
index da89754c5..14077d289 100644
--- a/sdl_android_lib/src/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java
+++ b/sdl_android_lib/src/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java
@@ -3,7 +3,7 @@ package com.smartdevicelink.Dispatcher;
import java.util.Comparator;
import java.util.concurrent.PriorityBlockingQueue;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
public class ProxyMessageDispatcher<T> {
PriorityBlockingQueue<T> _queue = null;
@@ -48,7 +48,7 @@ public class ProxyMessageDispatcher<T> {
// Thread was interrupted by dispose() method, no action required
return;
} catch (Exception e) {
- LogTool.logError("Error occurred dispating message.", e);
+ SdlLog.e("Error occurred dispating message.", e);
_strategy.handleDispatchingError("Error occurred dispating message.", e);
}
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
index 7ccf2d939..8e0170447 100644
--- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
+++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
@@ -3,6 +3,7 @@ package com.smartdevicelink.SdlConnection;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
+
public interface ISdlConnectionListener {
public void onTransportDisconnected(String info);
@@ -21,5 +22,6 @@ public interface ISdlConnectionListener {
public void onProtocolError(String info, Exception e);
- public void onHeartbeatTimedOut(byte sessionID);
+ public void onHeartbeatTimedOut(byte sessionID);
+
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
index ab275b919..600b3d553 100644
--- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
+++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlConnection.java
@@ -5,8 +5,10 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
-import java.util.Vector;
+import java.util.concurrent.CopyOnWriteArrayList;
+
import android.util.Log;
+
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.protocol.AbstractProtocol;
import com.smartdevicelink.protocol.IProtocolListener;
@@ -19,6 +21,7 @@ import com.smartdevicelink.streaming.IStreamListener;
import com.smartdevicelink.streaming.StreamPacketizer;
import com.smartdevicelink.streaming.StreamRPCPacketizer;
import com.smartdevicelink.transport.*;
+import com.smartdevicelink.transport.enums.TransportType;
public class SdlConnection implements IProtocolListener, ITransportListener, IStreamListener {
@@ -31,8 +34,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
Object TRANSPORT_REFERENCE_LOCK = new Object();
Object PROTOCOL_REFERENCE_LOCK = new Object();
- private Object SESSION_LOCK = new Object();
- private Vector<SdlSession> listenerList = new Vector<SdlSession>();
+ private CopyOnWriteArrayList<SdlSession> listenerList = new CopyOnWriteArrayList<SdlSession>();
/**
* Constructor.
@@ -250,12 +252,10 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
return null;
}
-
-
-
+
public void startRPCStream(InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion) {
try {
- mPacketizer = new StreamRPCPacketizer(this, is, request, sType, rpcSessionID, wiproVersion);
+ mPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0);
mPacketizer.start();
} catch (Exception e) {
Log.e("SdlConnection", "Unable to start streaming:" + e.toString());
@@ -266,7 +266,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
try {
OutputStream os = new PipedOutputStream();
InputStream is = new PipedInputStream((PipedOutputStream) os);
- mPacketizer = new StreamRPCPacketizer(this, is, request, sType, rpcSessionID, wiproVersion);
+ mPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0);
mPacketizer.start();
return os;
} catch (Exception e) {
@@ -274,8 +274,24 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
return null;
}
-
- public void stopStream()
+
+ public void pauseRPCStream()
+ {
+ if (mPacketizer != null)
+ {
+ mPacketizer.pause();
+ }
+ }
+
+ public void resumeRPCStream()
+ {
+ if (mPacketizer != null)
+ {
+ mPacketizer.resume();
+ }
+ }
+
+ public void stopRPCStream()
{
if (mPacketizer != null)
{
@@ -283,7 +299,6 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
}
-
@Override
public void sendStreamPacket(ProtocolMessage pm) {
sendMessage(pm);
@@ -305,11 +320,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
}
void registerSession(SdlSession registerListener) throws SdlException {
- synchronized (SESSION_LOCK) {
- if (!listenerList.contains(registerListener)) {
- listenerList.add(registerListener); //TODO: check if we need to sort the list.
- }
- }
+ listenerList.addIfAbsent(registerListener);
if (!this.getIsConnected()) {
this.startTransport();
@@ -324,12 +335,8 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
}
public void unregisterSession(SdlSession registerListener) {
- synchronized (SESSION_LOCK) {
- listenerList.remove(registerListener);
-
-
+ listenerList.remove(registerListener);
closeConnection(listenerList.size() == 0, registerListener.getSessionId());
- }
}
@@ -353,13 +360,9 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
@Override
public void onTransportError(String info, Exception e) {
- SdlSession mySession = null;
- for (int z=0; z<listenerList.size(); z++) {
-
- mySession = listenerList.get(0);
- if (mySession == null) continue;
- mySession.onTransportError(info, e);
- }
+ for (SdlSession session : listenerList) {
+ session.onTransportError(info, e);
+ }
}
@Override
@@ -411,7 +414,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
session.onHeartbeatTimedOut(sessionID);
}
- }
+ }
}
public int getRegisterCount() {
@@ -439,6 +442,4 @@ public class SdlConnection implements IProtocolListener, ITransportListener, ISt
mySession._heartbeatMonitor.notifyTransportActivity();
}
}
-
-
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
index c90ce2318..42841ce0b 100644
--- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
+++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
@@ -11,7 +11,7 @@ import com.smartdevicelink.protocol.heartbeat.IHeartbeatMonitor;
import com.smartdevicelink.protocol.heartbeat.IHeartbeatMonitorListener;
import com.smartdevicelink.proxy.LockScreenManager;
import com.smartdevicelink.transport.BaseTransportConfig;
-import com.smartdevicelink.transport.TransportType;
+import com.smartdevicelink.transport.enums.TransportType;
public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorListener {
private static CopyOnWriteArrayList<SdlConnection> shareConnections = new CopyOnWriteArrayList<SdlConnection>();
@@ -213,8 +213,5 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
public void onProtocolSessionNACKed(SessionType sessionType,
byte sessionID, byte version, String correlationID) {
this.sessionListener.onProtocolSessionNACKed(sessionType, sessionID, version, correlationID);
- }
-
-
-
+ }
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/exception/SdlException.java b/sdl_android_lib/src/com/smartdevicelink/exception/SdlException.java
index a67549515..4be9f5afc 100644
--- a/sdl_android_lib/src/com/smartdevicelink/exception/SdlException.java
+++ b/sdl_android_lib/src/com/smartdevicelink/exception/SdlException.java
@@ -3,45 +3,95 @@ package com.smartdevicelink.exception;
public class SdlException extends Exception {
+ /**
+ * A serializable class can declare its own serialVersionUID explicitly by
+ * declaring a field named "serialVersionUID" that must be static, final,
+ * and of type long.
+ *
+ * @see java.io.Serializable
+ */
private static final long serialVersionUID = 5922492291870772815L;
- protected Throwable detail = null;
- private SdlExceptionCause _sdlExceptionCause = null;
+ /**
+ * The diagnostic details of an exception or error thrown by the
+ * application.
+ */
+ protected Throwable details = null;
- public SdlException(String msg, SdlExceptionCause exceptionCause) {
- super(msg);
- _sdlExceptionCause = exceptionCause;
+ /**
+ * The reason for this specific SDL related exception.
+ */
+ protected SdlExceptionCause cause = null;
+
+ /**
+ * Constructor for an SDL specific exception.
+ *
+ * @param details The diagnostic details of the exception.
+ */
+ public SdlException (Throwable details) {
+ super(details.getMessage());
+ this.details = details;
}
- public SdlException(String msg, Throwable ex, SdlExceptionCause exceptionCause) {
- super(msg + " --- Check inner exception for diagnostic details");
- detail = ex;
- _sdlExceptionCause = exceptionCause;
+ /**
+ * Constructor for an SDL specific exception.
+ *
+ * @param message The information to be stored.
+ * @param cause The reason for the specific SDL related exception.
+ */
+ public SdlException (String message, SdlExceptionCause cause) {
+ super(message);
+ this.cause = cause;
}
- public SdlException(Throwable ex) {
- super(ex.getMessage());
- detail = ex;
+ /**
+ * Constructor for an SDL specific exception.
+ *
+ * @param message The information to be stored.
+ * @param details The diagnostic details of the exception.
+ * @param cause The reason for the specific SDL related exception.
+ */
+ public SdlException (String message, Throwable details, SdlExceptionCause cause) {
+ super(message + " --- Check inner exception for diagnostic details.");
+ this.details = details;
+ this.cause = cause;
}
- public SdlExceptionCause getSdlExceptionCause() {
- return _sdlExceptionCause;
+ /**
+ * Provides the cause title of this specific SDL related exception.
+ *
+ * @return The enum associated with the specific SDL related exception.
+ */
+ public SdlExceptionCause getSdlExceptionCause () {
+ return cause;
}
- public Throwable getInnerException() {
- return detail;
+ /**
+ * Provides the diagnostic details of this specific SDL related exception.
+ *
+ * @return The throwable containing diagnostic details of the exception.
+ */
+ public Throwable getInnerException () {
+ return details;
}
+ /**
+ * Provides a formatted string containing detailed exception information.
+ */
public String toString() {
- String ret = this.getClass().getName();
- ret += ": " + this.getMessage();
- if(this.getSdlExceptionCause() != null){
- ret += "\nSdlExceptionCause: " + this.getSdlExceptionCause().name();
+ StringBuilder build = new StringBuilder("SdlException: ");
+ build.append(getMessage());
+
+ if(getSdlExceptionCause() != null){
+ build.append("\nSdlExceptionCause: ");
+ build.append(getSdlExceptionCause().name());
}
- if (detail != null) {
- ret += "\nnested: " + detail.toString();
- detail.printStackTrace();
+
+ if (details != null) {
+ build.append("\nDetails: ");
+ build.append(details.toString());
}
- return ret;
+
+ return build.toString();
}
-}
+} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java b/sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java
index 1bfcd800c..841bf9153 100644
--- a/sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java
+++ b/sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java
@@ -11,9 +11,9 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.trace.*;
+import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
/*
* Responsible for marshalling and unmarshing between RPC Objects and byte streams that are sent
@@ -32,7 +32,7 @@ public class JsonRPCMarshaller {
SdlTrace.logMarshallingEvent(InterfaceActivityDirection.Transmit, jsonBytes, SDL_LIB_PRIVATE_KEY);
} catch (JSONException e) {
- LogTool.logError("Failed to encode messages to JSON.", e);
+ SdlLog.e("Failed to encode messages to JSON.", e);
}
return jsonBytes;
}
@@ -45,7 +45,7 @@ public class JsonRPCMarshaller {
JSONObject jsonObject = new JSONObject(jsonString);
ret = deserializeJSONObject(jsonObject);
} catch (JSONException e) {
- LogTool.logError("Failed to parse JSON", e);
+ SdlLog.e("Failed to parse JSON.", e);
}
return ret;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java b/sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java
index b33c89631..c63f560d5 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/ProtocolMessage.java
@@ -55,6 +55,10 @@ public class ProtocolMessage {
return _bulkData;
}
+ public void setBulkDataNoCopy(byte[] bulkData) {
+ this._bulkData = bulkData;
+ }
+
public void setBulkData(byte[] bulkData) {
if (this._bulkData != null)
this._bulkData = null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java b/sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java
index e1c796205..b28a82105 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/WiProProtocol.java
@@ -5,10 +5,14 @@ import java.util.Hashtable;
import android.util.Log;
-import com.smartdevicelink.exception.*;
-import com.smartdevicelink.protocol.enums.*;
+import com.smartdevicelink.exception.SdlException;
+import com.smartdevicelink.exception.SdlExceptionCause;
+import com.smartdevicelink.protocol.enums.FrameDataControlFrameType;
+import com.smartdevicelink.protocol.enums.FrameType;
+import com.smartdevicelink.protocol.enums.MessageType;
+import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.util.BitConverter;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
public class WiProProtocol extends AbstractProtocol {
byte _version = 1;
@@ -93,7 +97,7 @@ public class WiProProtocol extends AbstractProtocol {
if (_version > 1 && sessionType != SessionType.NAV) {
if (protocolMsg.getBulkData() != null) {
data = new byte[12 + protocolMsg.getJsonSize() + protocolMsg.getBulkData().length];
- sessionType = SessionType.Bulk_Data;
+ sessionType = SessionType.BULK_DATA;
} else data = new byte[12 + protocolMsg.getJsonSize()];
BinaryFrameHeader binFrameHeader = new BinaryFrameHeader();
binFrameHeader = ProtocolFrameHeaderFactory.createBinaryFrameHeader(protocolMsg.getRPCType(), protocolMsg.getFunctionID(), protocolMsg.getCorrID(), protocolMsg.getJsonSize());
@@ -172,6 +176,15 @@ public class WiProProtocol extends AbstractProtocol {
}
public void HandleReceivedBytes(byte[] receivedBytes, int receivedBytesLength) {
+
+ byte[] remainingBytes = processReceivedBytes(receivedBytes, receivedBytesLength);
+ while (remainingBytes != null)
+ {
+ remainingBytes = processReceivedBytes(remainingBytes, remainingBytes.length);
+ }
+ }
+
+ private byte[] processReceivedBytes(byte[] receivedBytes, int receivedBytesLength) {
int receivedBytesReadPos = 0;
//Check for a version difference
@@ -200,7 +213,7 @@ public class WiProProtocol extends AbstractProtocol {
System.arraycopy(receivedBytes, receivedBytesReadPos,
_headerBuf, _headerBufWritePos, receivedBytesLength);
_headerBufWritePos += receivedBytesLength;
- return;
+ return null;
} else {
// If I got the size, allocate the buffer
System.arraycopy(receivedBytes, receivedBytesReadPos,
@@ -229,7 +242,7 @@ public class WiProProtocol extends AbstractProtocol {
Log.e("HandleReceivedBytes", "headerBytesNeeded: " + headerBytesNeeded);
handleProtocolError("Error handling protocol message from sdl, header invalid.",
new SdlException("Error handling protocol message from sdl, header invalid.", SdlExceptionCause.INVALID_HEADER));
- return;
+ return null;
}
_dataBufWritePos = 0;
}
@@ -254,7 +267,7 @@ public class WiProProtocol extends AbstractProtocol {
handleProtocolError("Error handling protocol message from sdl, header invalid.",
new SdlException("Error handling protocol message from sdl, data buffer is null.", SdlExceptionCause.DATA_BUFFER_NULL));
- return;
+ return null;
}
int bytesLeft = receivedBytesLength - receivedBytesReadPos;
@@ -264,7 +277,7 @@ public class WiProProtocol extends AbstractProtocol {
System.arraycopy(receivedBytes, receivedBytesReadPos, _dataBuf,
_dataBufWritePos, bytesLeft);
_dataBufWritePos += bytesLeft;
- return;
+ return null;
} else {
// Fill the buffer and call the handler!
System.arraycopy(receivedBytes, receivedBytesReadPos, _dataBuf, _dataBufWritePos, bytesNeeded);
@@ -287,9 +300,10 @@ public class WiProProtocol extends AbstractProtocol {
byte[] moreBytes = new byte[moreBytesLeft];
System.arraycopy(receivedBytes, receivedBytesReadPos,
moreBytes, 0, moreBytesLeft);
- HandleReceivedBytes(moreBytes, moreBytesLeft);
+ return moreBytes;
}
}
+ return null;
}
protected MessageFrameAssembler getFrameAssemblerForFrame(ProtocolFrameHeader header) {
@@ -356,7 +370,7 @@ public class WiProProtocol extends AbstractProtocol {
try {
handleProtocolMessageReceived(message);
} catch (Exception excp) {
- LogTool.logError(FailurePropagating_Msg + "onProtocolMessageReceived: " + excp.toString(), excp);
+ SdlLog.e(FailurePropagating_Msg + "onProtocolMessageReceived: " + excp.toString(), excp);
} // end-catch
hasFirstFrame = false;
@@ -444,7 +458,7 @@ public class WiProProtocol extends AbstractProtocol {
ProtocolMessage message = new ProtocolMessage();
if (header.getSessionType() == SessionType.RPC) {
message.setMessageType(MessageType.RPC);
- } else if (header.getSessionType() == SessionType.Bulk_Data) {
+ } else if (header.getSessionType() == SessionType.BULK_DATA) {
message.setMessageType(MessageType.BULK);
} // end-if
message.setSessionType(header.getSessionType());
@@ -466,7 +480,7 @@ public class WiProProtocol extends AbstractProtocol {
try {
handleProtocolMessageReceived(message);
} catch (Exception ex) {
- LogTool.logError(FailurePropagating_Msg + "onProtocolMessageReceived: " + ex.toString(), ex);
+ SdlLog.e(FailurePropagating_Msg + "onProtocolMessageReceived: " + ex.toString(), ex);
handleProtocolError(FailurePropagating_Msg + "onProtocolMessageReceived: ", ex);
} // end-catch
} // end-method
@@ -493,7 +507,7 @@ public class WiProProtocol extends AbstractProtocol {
@Override
public void SendHeartBeat(byte sessionID) {
- final ProtocolFrameHeader heartbeat = ProtocolFrameHeaderFactory.createHeartbeat(SessionType.Heartbeat, sessionID, _version);
+ final ProtocolFrameHeader heartbeat = ProtocolFrameHeaderFactory.createHeartbeat(SessionType.CONTROL, sessionID, _version);
sendFrameToTransport(heartbeat);
}
} // end-class \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameData.java b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameData.java
index 6dbdcc9b7..ee83215a5 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameData.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameData.java
@@ -34,6 +34,6 @@ public class FrameData extends ByteEnumer {
}
public static FrameData[] values() {
- return (FrameData[]) theList.toArray();
+ return theList.toArray(new FrameData[theList.size()]);
}
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameDataControlFrameType.java b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameDataControlFrameType.java
index 50db24803..b9296fdfb 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameDataControlFrameType.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameDataControlFrameType.java
@@ -34,9 +34,10 @@ public class FrameDataControlFrameType extends ByteEnumer {
public static FrameDataControlFrameType valueOf(String passedButton) {
return (FrameDataControlFrameType) get(theList, passedButton);
- } // end-method
+ }
public static FrameDataControlFrameType[] values() {
- return (FrameDataControlFrameType[]) theList.toArray();
- } // end-method
-} // end-class \ No newline at end of file
+ return theList.toArray(new FrameDataControlFrameType[theList.size()]);
+ }
+
+} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameType.java b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameType.java
index fc037e930..8f8abedf2 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameType.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FrameType.java
@@ -29,6 +29,6 @@ public class FrameType extends ByteEnumer {
}
public static FrameType[] values() {
- return (FrameType[]) theList.toArray();
+ return theList.toArray(new FrameType[theList.size()]);
}
}
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 e3e017114..04517d329 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FunctionID.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/FunctionID.java
@@ -1,186 +1,135 @@
package com.smartdevicelink.protocol.enums;
+import java.util.EnumSet;
import java.util.HashMap;
-import java.util.Map;
-
-public class FunctionID {
- private static Map<String, Integer> functionIDMap = null;
- public static final String SYNC_P_DATA = "SyncPData";
- public static final String SHOW_CONSTANT_TBT = "ShowConstantTBT";
- public static final String ALERT_MANEUVER = "AlertManeuver";
- public static final String UPDATE_TURN_LIST = "UpdateTurnList";
- public static final String ON_SYNC_P_DATA = "OnSyncPData";
- public static final String REGISTER_APP_INTERFACE = "RegisterAppInterface";
- public static final String UNREGISTER_APP_INTERFACE = "UnregisterAppInterface";
- public static final String ALERT = "Alert";
- public static final String SHOW = "Show";
- public static final String SPEAK = "Speak";
- public static final String ADD_COMMAND = "AddCommand";
- public static final String DELETE_COMMAND = "DeleteCommand";
- public static final String ADD_SUB_MENU = "AddSubMenu";
- public static final String DELETE_SUB_MENU = "DeleteSubMenu";
- public static final String CREATE_INTERACTION_CHOICE_SET = "CreateInteractionChoiceSet";
- public static final String DELETE_INTERACTION_CHOICE_SET = "DeleteInteractionChoiceSet";
- public static final String PERFORM_INTERACTION = "PerformInteraction";
- public static final String ENCODED_SYNC_P_DATA = "EncodedSyncPData";
- public static final String SUBSCRIBE_BUTTON = "SubscribeButton";
- public static final String UNSUBSCRIBE_BUTTON = "UnsubscribeButton";
- public static final String SUBSCRIBE_VEHICLE_DATA = "SubscribeVehicleData";
- public static final String UNSUBSCRIBE_VEHICLE_DATA = "UnsubscribeVehicleData";
- public static final String SET_MEDIA_CLOCK_TIMER = "SetMediaClockTimer";
- public static final String SET_GLOBAL_PROPERTIES = "SetGlobalProperties";
- public static final String GENERIC_RESPONSE = "GenericResponse";
- public static final String SCROLLABLE_MESSAGE = "ScrollableMessage";
- public static final String GET_DTCS = "GetDTCs";
- public static final String DIAGNOSTIC_MESSAGE = "DiagnosticMessage";
- public static final String SYSTEM_REQUEST = "SystemRequest";
- public static final String READ_DID = "ReadDID";
- public static final String ON_VEHICLE_DATA = "OnVehicleData";
- public static final String PUT_FILE = "PutFile";
- public static final String DELETE_FILE = "DeleteFile";
- public static final String LIST_FILES = "ListFiles";
- public static final String GET_VEHICLE_DATA = "GetVehicleData";
- public static final String RESET_GLOBAL_PROPERTIES = "ResetGlobalProperties";
- public static final String SET_APP_ICON = "SetAppIcon";
- public static final String CHANGE_REGISTRATION = "ChangeRegistration";
- public static final String SET_DISPLAY_LAYOUT = "SetDisplayLayout";
- public static final String ON_LANGUAGE_CHANGE = "OnLanguageChange";
- public static final String PERFORM_AUDIO_PASS_THRU = "PerformAudioPassThru";
- public static final String END_AUDIO_PASS_THRU = "EndAudioPassThru";
- public static final String ON_AUDIO_PASS_THRU = "OnAudioPassThru";
- public static final String ON_COMMAND = "OnCommand";
- public static final String ON_BUTTON_PRESS = "OnButtonPress";
- public static final String ON_BUTTON_EVENT = "OnButtonEvent";
- public static final String ON_HMI_STATUS = "OnHMIStatus";
- public static final String ON_TBT_CLIENT_STATE = "OnTBTClientState";
- public static final String ON_ENCODED_SYNC_P_DATA = "OnEncodedSyncPData";
- public static final String ON_DRIVER_DISTRACTION = "OnDriverDistraction";
- public static final String ON_APP_INTERFACE_UNREGISTERED = "OnAppInterfaceUnregistered";
- public static final String ON_KEYBOARD_INPUT = "OnKeyboardInput";
- public static final String ON_TOUCH_EVENT = "OnTouchEvent";
- public static final String ON_SYSTEM_REQUEST = "OnSystemRequest";
- public static final String ON_HASH_CHANGE = "OnHashChange";
- public static final String ON_PERMISSIONS_CHANGE = "OnPermissionsChange";
- 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() {
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+public enum FunctionID{
+ // DEPRECATED FUNCTIONS
+ SYNC_P_DATA(65537, "SyncPData"),
+ ON_SYNC_P_DATA(98305, "OnSyncPData"),
+ ENCODED_SYNC_P_DATA(65536, "EncodedSyncPData"),
+ ON_ENCODED_SYNC_P_DATA(98304, "OnEncodedSyncPData"),
+
+ // REQUESTS & RESPONSES
+ REGISTER_APP_INTERFACE(1, "RegisterAppInterface"),
+ UNREGISTER_APP_INTERFACE(2, "UnregisterAppInterface"),
+ SET_GLOBAL_PROPERTIES(3, "SetGlobalProperties"),
+ RESET_GLOBAL_PROPERTIES(4, "ResetGlobalProperties"),
+ ADD_COMMAND(5, "AddCommand"),
+ DELETE_COMMAND(6, "DeleteCommand"),
+ ADD_SUB_MENU(7, "AddSubMenu"),
+ DELETE_SUB_MENU(8, "DeleteSubMenu"),
+ CREATE_INTERACTION_CHOICE_SET(9, "CreateInteractionChoiceSet"),
+ PERFORM_INTERACTION(10, "PerformInteraction"),
+ DELETE_INTERACTION_CHOICE_SET(11, "DeleteInteractionChoiceSet"),
+ ALERT(12, "Alert"),
+ SHOW(13, "Show"),
+ SPEAK(14, "Speak"),
+ SET_MEDIA_CLOCK_TIMER(15, "SetMediaClockTimer"),
+ PERFORM_AUDIO_PASS_THRU(16, "PerformAudioPassThru"),
+ END_AUDIO_PASS_THRU(17, "EndAudioPassThru"),
+ SUBSCRIBE_BUTTON(18, "SubscribeButton"),
+ UNSUBSCRIBE_BUTTON(19, "UnsubscribeButton"),
+ SUBSCRIBE_VEHICLE_DATA(20, "SubscribeVehicleData"),
+ UNSUBSCRIBE_VEHICLE_DATA(21, "UnsubscribeVehicleData"),
+ GET_VEHICLE_DATA(22, "GetVehicleData"),
+ READ_DID(23, "ReadDID"),
+ GET_DTCS(24, "GetDTCs"),
+ SCROLLABLE_MESSAGE(25, "ScrollableMessage"),
+ SLIDER(26, "Slider"),
+ SHOW_CONSTANT_TBT(27, "ShowConstantTBT"),
+ ALERT_MANEUVER(28, "AlertManeuver"),
+ UPDATE_TURN_LIST(29, "UpdateTurnList"),
+ CHANGE_REGISTRATION(30, "ChangeRegistration"),
+ GENERIC_RESPONSE(31, "GenericResponse"),
+ PUT_FILE(32, "PutFile"),
+ DELETE_FILE(33, "DeleteFile"),
+ LIST_FILES(34, "ListFiles"),
+ SET_APP_ICON(35, "SetAppIcon"),
+ SET_DISPLAY_LAYOUT(36, "SetDisplayLayout"),
+ DIAGNOSTIC_MESSAGE(37, "DiagnosticMessage"),
+ SYSTEM_REQUEST(38, "SystemRequest"),
+ SEND_LOCATION(39, "SendLocation"),
+ DIAL_NUMBER(40, "DialNumber"),
+
+ // NOTIFICATIONS
+ ON_HMI_STATUS(32768, "OnHMIStatus"),
+ ON_APP_INTERFACE_UNREGISTERED(32769, "OnAppInterfaceUnregistered"),
+ ON_BUTTON_EVENT(32770, "OnButtonEvent"),
+ ON_BUTTON_PRESS(32771, "OnButtonPress"),
+ ON_VEHICLE_DATA(32772, "OnVehicleData"),
+ ON_COMMAND(32773, "OnCommand"),
+ ON_TBT_CLIENT_STATE(32774, "OnTBTClientState"),
+ ON_DRIVER_DISTRACTION(32775, "OnDriverDistraction"),
+ ON_PERMISSIONS_CHANGE(32776, "OnPermissionsChange"),
+ ON_AUDIO_PASS_THRU(32777, "OnAudioPassThru"),
+ ON_LANGUAGE_CHANGE(32778, "OnLanguageChange"),
+ ON_KEYBOARD_INPUT(32779, "OnKeyboardInput"),
+ ON_TOUCH_EVENT(32780, "OnTouchEvent"),
+ ON_SYSTEM_REQUEST(32781, "OnSystemRequest"),
+ ON_HASH_CHANGE(32782, "OnHashChange"),
+
+ // MOCKED FUNCTIONS (NOT SENT FROM HEAD-UNIT)
+ ON_LOCK_SCREEN_STATUS(-1, "OnLockScreenStatus"),
+ ON_SDL_CHOICE_CHOSEN(-1, "OnSdlChoiceChosen"),
+ ON_STREAM_RPC(-1, "OnStreamRPC"),
+ STREAM_RPC(-1, "StreamRPC"),
+
+ ;
+
+ public static final int INVALID_ID = -1;
+
+ private static HashMap<String, Integer> functionMap;
+
+ private final int ID;
+ private final String JSON_NAME;
+
+ private FunctionID(int id, String jsonName){
+ this.ID = id;
+ this.JSON_NAME = jsonName;
}
- static public String getFunctionName(int i) {
- if (null == functionIDMap) {
- initFunctionIds();
+ public int getId(){
+ return this.ID;
+ }
+
+ @Override
+ public String toString(){
+ return this.JSON_NAME;
+ }
+
+ private static void initFunctionMap(){
+ functionMap = new HashMap<String, Integer>(values().length);
+
+ for(FunctionID value : EnumSet.allOf(FunctionID.class)){
+ functionMap.put(value.toString(), value.getId());
}
+ }
- for (Map.Entry<String, Integer> entry : functionIDMap.entrySet()) {
- if (i == entry.getValue()) {
- return entry.getKey();
+ public static String getFunctionName(int i){
+ if(functionMap == null){
+ initFunctionMap();
+ }
+
+ Iterator<Entry<String, Integer>> iterator = functionMap.entrySet().iterator();
+ while(iterator.hasNext()){
+ Entry<String, Integer> thisEntry = iterator.next();
+ if(Integer.valueOf(i).equals(thisEntry.getValue())){
+ return thisEntry.getKey();
}
}
return null;
}
- static public int getFunctionID(String functionName) {
- if (null == functionIDMap) {
- initFunctionIds();
+ public static int getFunctionId(String functionName){
+ if(functionMap == null){
+ initFunctionMap();
}
- final Integer functionID = functionIDMap.get(functionName);
- return (functionID != null) ? functionID : -1;
- }
-
- static public void initFunctionIds() {
-
- functionIDMap = new HashMap<String, Integer>(60) {/**
- *
- */
- private static final long serialVersionUID = 6301013743706264910L;
-
- {
- /*
- Base Request / Response RPCs
- Range = 0x 0000 0001 - 0x 0000 7FFF
- */
- put(FunctionID.REGISTER_APP_INTERFACE, 1);
- put(FunctionID.UNREGISTER_APP_INTERFACE, 2);
- put(FunctionID.SET_GLOBAL_PROPERTIES, 3);
- put(FunctionID.RESET_GLOBAL_PROPERTIES, 4);
- put(FunctionID.ADD_COMMAND, 5);
- put(FunctionID.DELETE_COMMAND, 6);
- put(FunctionID.ADD_SUB_MENU, 7);
- put(FunctionID.DELETE_SUB_MENU, 8);
- put(FunctionID.CREATE_INTERACTION_CHOICE_SET, 9);
- put(FunctionID.PERFORM_INTERACTION, 10);
- put(FunctionID.DELETE_INTERACTION_CHOICE_SET, 11);
- put(FunctionID.ALERT, 12);
- put(FunctionID.SHOW, 13);
- put(FunctionID.SPEAK, 14);
- put(FunctionID.SET_MEDIA_CLOCK_TIMER, 15);
- put(FunctionID.PERFORM_AUDIO_PASS_THRU, 16);
- put(FunctionID.END_AUDIO_PASS_THRU, 17);
- put(FunctionID.SUBSCRIBE_BUTTON, 18);
- put(FunctionID.UNSUBSCRIBE_BUTTON, 19);
- put(FunctionID.SUBSCRIBE_VEHICLE_DATA, 20);
- put(FunctionID.UNSUBSCRIBE_VEHICLE_DATA, 21);
- put(FunctionID.GET_VEHICLE_DATA, 22);
- put(FunctionID.READ_DID, 23);
- put(FunctionID.GET_DTCS, 24);
- put(FunctionID.SCROLLABLE_MESSAGE, 25);
- put(FunctionID.SLIDER, 26);
- put(FunctionID.SHOW_CONSTANT_TBT, 27);
- put(FunctionID.ALERT_MANEUVER, 28);
- put(FunctionID.UPDATE_TURN_LIST, 29);
- put(FunctionID.CHANGE_REGISTRATION, 30);
- put(FunctionID.GENERIC_RESPONSE, 31);
- put(FunctionID.PUT_FILE, 32);
- put(FunctionID.DELETE_FILE, 33);
- put(FunctionID.LIST_FILES, 34);
- put(FunctionID.SET_APP_ICON, 35);
- put(FunctionID.SET_DISPLAY_LAYOUT, 36);
- put(FunctionID.DIAGNOSTIC_MESSAGE, 37);
- put(FunctionID.SYSTEM_REQUEST, 38);
- put(FunctionID.SEND_LOCATION, 39);
-
- /*
- Base Notifications
- Range = 0x 0000 8000 - 0x 0000 FFFF
- */
- put(FunctionID.ON_HMI_STATUS, 32768);
- put(FunctionID.ON_APP_INTERFACE_UNREGISTERED, 32769);
- put(FunctionID.ON_BUTTON_EVENT, 32770);
- put(FunctionID.ON_BUTTON_PRESS, 32771);
- put(FunctionID.ON_VEHICLE_DATA, 32772);
- put(FunctionID.ON_COMMAND, 32773);
- put(FunctionID.ON_TBT_CLIENT_STATE, 32774);
- put(FunctionID.ON_DRIVER_DISTRACTION, 32775);
- put(FunctionID.ON_PERMISSIONS_CHANGE, 32776);
- put(FunctionID.ON_AUDIO_PASS_THRU, 32777);
- put(FunctionID.ON_LANGUAGE_CHANGE, 32778);
- put(FunctionID.ON_SYSTEM_REQUEST, 32781);
- put(FunctionID.ON_HASH_CHANGE, 32782);
-
- /*
- Ford Specific Request / Response RPCs
- Range = 0x 0001 0000 - 0x 0001 7FFF
- */
- put(FunctionID.ENCODED_SYNC_P_DATA, 65536);
- put(FunctionID.SYNC_P_DATA, 65537);
-
- /*
- Ford Specific Notifications
- Range = 0x 0001 8000 - 0x 0001 FFFF
- */
- put(FunctionID.ON_ENCODED_SYNC_P_DATA, 98304);
- put(FunctionID.ON_SYNC_P_DATA, 98305);
-
- // OnKeyboardInput
- put(FunctionID.ON_KEYBOARD_INPUT, 32779);
- // OnTouchEvent
- put(FunctionID.ON_TOUCH_EVENT, 32780);
- }};
+ Integer result = functionMap.get(functionName);
+ return ( result == null ) ? INVALID_ID : result;
}
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/SessionType.java b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/SessionType.java
index 433eb8527..f6cd888b4 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/enums/SessionType.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/enums/SessionType.java
@@ -13,18 +13,18 @@ public class SessionType extends ByteEnumer {
byte i = 0x00;
protected SessionType(byte value, String name) {super(value, name);}
- public final static SessionType Heartbeat = new SessionType((byte) 0, "Heartbeat_Service");
+ public final static SessionType CONTROL = new SessionType((byte) 0, "CONTROL");
public final static SessionType RPC = new SessionType((byte)0x07, "RPC");
public final static SessionType PCM = new SessionType((byte)0x0A, "PCM");
public final static SessionType NAV = new SessionType((byte)0x0B, "NAV");
- public final static SessionType Bulk_Data = new SessionType((byte)0xF, "Bulk_Data");
+ public final static SessionType BULK_DATA = new SessionType((byte)0xF, "BULK_DATA");
static {
theList.addElement(RPC);
theList.addElement(PCM);
theList.addElement(NAV);
- theList.addElement(Bulk_Data);
- theList.addElement(Heartbeat);
+ theList.addElement(BULK_DATA);
+ theList.addElement(CONTROL);
}
public static SessionType valueOf(byte passedButton) {
@@ -32,6 +32,6 @@ public class SessionType extends ByteEnumer {
}
public static SessionType[] values() {
- return (SessionType[]) theList.toArray();
+ return theList.toArray(new SessionType[theList.size()]);
}
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java
index f0db617b3..8f68a1ebe 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCMessage.java
@@ -25,12 +25,16 @@ public class RPCMessage extends RPCStruct {
}
public RPCMessage(String functionName, String messageType) {
- function = new Hashtable<String, Object>();
- this.messageType = messageType;
- store.put(messageType, function);
+ function = new Hashtable<String, Object>();
parameters = new Hashtable<String, Object>();
+
+ this.messageType = messageType;
function.put(KEY_PARAMETERS, parameters);
- function.put(KEY_FUNCTION_NAME, functionName);
+
+ if (messageType != null)
+ store.put(messageType, function);
+ if (functionName != null)
+ function.put(KEY_FUNCTION_NAME, functionName);
}
@SuppressWarnings("unchecked")
@@ -57,7 +61,12 @@ public class RPCMessage extends RPCStruct {
}
public String getMessageType() {
- return messageType;
+ if (messageType.equals(KEY_REQUEST) ||
+ messageType.equals(KEY_RESPONSE) ||
+ messageType.equals(KEY_NOTIFICATION)) {
+ return messageType;
+ }
+ return null;
}
public void setParameters(String functionName, Object value) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCNotification.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCNotification.java
index 063cd7505..b9992e78b 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCNotification.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCNotification.java
@@ -8,7 +8,7 @@ import java.util.Hashtable;
public class RPCNotification extends RPCMessage {
public RPCNotification(String functionName) {
- super(functionName, "notification");
+ super(functionName, RPCMessage.KEY_NOTIFICATION);
}
public RPCNotification(Hashtable<String, Object> hash) {
@@ -16,6 +16,14 @@ public class RPCNotification extends RPCMessage {
}
public RPCNotification(RPCMessage rpcMsg) {
- super(rpcMsg);
+ super(preprocessMsg(rpcMsg));
}
-} // end-class \ No newline at end of file
+
+ static RPCMessage preprocessMsg (RPCMessage rpcMsg) {
+ if (rpcMsg.getMessageType() != RPCMessage.KEY_NOTIFICATION) {
+ rpcMsg.messageType = RPCMessage.KEY_NOTIFICATION;
+ }
+
+ return rpcMsg;
+ }
+} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java
index b2b8d0c7e..6a6b628a4 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCRequestFactory.java
@@ -77,6 +77,10 @@ public class RPCRequestFactory {
if(data == null) return null;
+ for (String item : data) {
+ if (item == null) return null;
+ }
+
SystemRequest msg = new SystemRequest(true);
msg.setCorrelationID(correlationID);
msg.setLegacyData(data);
@@ -90,7 +94,22 @@ public class RPCRequestFactory {
AddCommand msg = new AddCommand();
msg.setCorrelationID(correlationID);
msg.setCmdID(commandID);
- msg.setVrCommands(vrCommands);
+
+ if (vrCommands != null) {
+ boolean isValid = true;
+ for (String item : vrCommands) {
+ if (item == null) {
+ msg.setVrCommands(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setVrCommands(vrCommands);
+ }
+ } else {
+ msg.setVrCommands(null);
+ }
+
if (cmdIcon != null) msg.setCmdIcon(cmdIcon);
@@ -112,7 +131,20 @@ public class RPCRequestFactory {
msg.setCorrelationID(correlationID);
msg.setCmdID(commandID);
- if (vrCommands != null) msg.setVrCommands(vrCommands);
+ if (vrCommands != null) {
+ boolean isValid = true;
+ for (String item : vrCommands) {
+ if (item == null) {
+ msg.setVrCommands(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setVrCommands(vrCommands);
+ }
+ } else {
+ msg.setVrCommands(null);
+ }
Image cmdIcon = null;
@@ -143,7 +175,21 @@ public class RPCRequestFactory {
AddCommand msg = new AddCommand();
msg.setCorrelationID(correlationID);
msg.setCmdID(commandID);
- msg.setVrCommands(vrCommands);
+
+ if (vrCommands != null) {
+ boolean isValid = true;
+ for (String item : vrCommands) {
+ if (item == null) {
+ msg.setVrCommands(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setVrCommands(vrCommands);
+ }
+ } else {
+ msg.setVrCommands(null);
+ }
if(menuText != null || parentID != null || position != null) {
MenuParams menuParams = new MenuParams();
@@ -168,7 +214,21 @@ public class RPCRequestFactory {
AddCommand msg = new AddCommand();
msg.setCorrelationID(correlationID);
msg.setCmdID(commandID);
- msg.setVrCommands(vrCommands);
+
+ if (vrCommands != null) {
+ boolean isValid = true;
+ for (String item : vrCommands) {
+ if (item == null) {
+ msg.setVrCommands(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setVrCommands(vrCommands);
+ }
+ } else {
+ msg.setVrCommands(null);
+ }
return msg;
}
@@ -233,14 +293,40 @@ public class RPCRequestFactory {
msg.setAlertText3(alertText3);
msg.setDuration(duration);
msg.setPlayTone(playTone);
- msg.setTtsChunks(ttsChunks);
- msg.setSoftButtons(softButtons);
+
+ if (ttsChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : ttsChunks) {
+ if (item == null) {
+ msg.setTtsChunks(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setTtsChunks(ttsChunks);
+ }
+ } else {
+ msg.setTtsChunks(null);
+ }
+
+ if (softButtons != null) {
+ boolean isValid = true;
+ for (SoftButton item : softButtons) {
+ if (item == null) {
+ msg.setSoftButtons(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setTtsChunks(ttsChunks);
+ }
+ } else {
+ msg.setSoftButtons(null);
+ }
return msg;
}
-
-
public static Alert buildAlert(String ttsText, Boolean playTone,
Integer correlationID) {
Vector<TTSChunk> chunks = TTSChunkFactory
@@ -283,7 +369,21 @@ public class RPCRequestFactory {
msg.setAlertText2(alertText2);
msg.setDuration(duration);
msg.setPlayTone(playTone);
- msg.setTtsChunks(ttsChunks);
+
+ if (ttsChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : ttsChunks) {
+ if (item == null) {
+ msg.setTtsChunks(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setTtsChunks(ttsChunks);
+ }
+ } else {
+ msg.setTtsChunks(null);
+ }
return msg;
}
@@ -292,9 +392,24 @@ public class RPCRequestFactory {
Vector<Choice> choiceSet, Integer interactionChoiceSetID,
Integer correlationID) {
CreateInteractionChoiceSet msg = new CreateInteractionChoiceSet();
- msg.setChoiceSet(choiceSet);
msg.setInteractionChoiceSetID(interactionChoiceSetID);
msg.setCorrelationID(correlationID);
+
+ if (choiceSet != null) {
+ boolean isValid = true;
+ for (Choice item : choiceSet) {
+ if (item == null) {
+ msg.setChoiceSet(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setChoiceSet(choiceSet);
+ }
+ } else {
+ msg.setChoiceSet(null);
+ }
+
return msg;
}
@@ -346,16 +461,86 @@ public class RPCRequestFactory {
InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
Integer correlationID) {
PerformInteraction msg = new PerformInteraction();
- msg.setInitialPrompt(initChunks);
msg.setInitialText(displayText);
- msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
msg.setInteractionMode(interactionMode);
msg.setTimeout(timeout);
- msg.setHelpPrompt(helpChunks);
- msg.setTimeoutPrompt(timeoutChunks);
- msg.setVrHelp(vrHelp);
msg.setCorrelationID(correlationID);
+ if (interactionChoiceSetIDList != null) {
+ boolean isValid = true;
+ for (Integer item : interactionChoiceSetIDList) {
+ if (item == null) {
+ msg.setInteractionChoiceSetIDList(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
+ }
+ } else {
+ msg.setInteractionChoiceSetIDList(null);
+ }
+
+ if (vrHelp != null) {
+ boolean isValid = true;
+ for (VrHelpItem item : vrHelp) {
+ if (item == null) {
+ msg.setVrHelp(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setVrHelp(vrHelp);
+ }
+ } else {
+ msg.setVrHelp(null);
+ }
+
+ if (timeoutChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : timeoutChunks) {
+ if (item == null) {
+ msg.setTimeoutPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setTimeoutPrompt(timeoutChunks);
+ }
+ } else {
+ msg.setTimeoutPrompt(null);
+ }
+
+ if (initChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : initChunks) {
+ if (item == null) {
+ msg.setInitialPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setInitialPrompt(initChunks);
+ }
+ } else {
+ msg.setInitialPrompt(null);
+ }
+
+ if (helpChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : helpChunks) {
+ if (item == null) {
+ msg.setHelpPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setHelpPrompt(helpChunks);
+ }
+ } else {
+ msg.setHelpPrompt(null);
+ }
+
return msg;
}
@@ -408,15 +593,71 @@ public class RPCRequestFactory {
InteractionMode interactionMode, Integer timeout,
Integer correlationID) {
PerformInteraction msg = new PerformInteraction();
- msg.setInitialPrompt(initChunks);
msg.setInitialText(displayText);
- msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
msg.setInteractionMode(interactionMode);
msg.setTimeout(timeout);
- msg.setHelpPrompt(helpChunks);
- msg.setTimeoutPrompt(timeoutChunks);
msg.setCorrelationID(correlationID);
+ if (interactionChoiceSetIDList != null) {
+ boolean isValid = true;
+ for (Integer item : interactionChoiceSetIDList) {
+ if (item == null) {
+ msg.setInteractionChoiceSetIDList(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
+ }
+ } else {
+ msg.setInteractionChoiceSetIDList(null);
+ }
+
+ if (timeoutChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : timeoutChunks) {
+ if (item == null) {
+ msg.setTimeoutPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setTimeoutPrompt(timeoutChunks);
+ }
+ } else {
+ msg.setTimeoutPrompt(null);
+ }
+
+ if (initChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : initChunks) {
+ if (item == null) {
+ msg.setInitialPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setInitialPrompt(initChunks);
+ }
+ } else {
+ msg.setInitialPrompt(null);
+ }
+
+ if (helpChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : helpChunks) {
+ if (item == null) {
+ msg.setHelpPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setHelpPrompt(helpChunks);
+ }
+ } else {
+ msg.setHelpPrompt(null);
+ }
+
return msg;
}
@@ -475,6 +716,52 @@ public class RPCRequestFactory {
msg.setTimeout(timeout);
msg.setHelpPrompt(helpChunks);
msg.setCorrelationID(correlationID);
+
+ if (interactionChoiceSetIDList != null) {
+ boolean isValid = true;
+ for (Integer item : interactionChoiceSetIDList) {
+ if (item == null) {
+ msg.setInteractionChoiceSetIDList(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setInteractionChoiceSetIDList(interactionChoiceSetIDList);
+ }
+ } else {
+ msg.setInteractionChoiceSetIDList(null);
+ }
+
+ if (initChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : initChunks) {
+ if (item == null) {
+ msg.setInitialPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setInitialPrompt(initChunks);
+ }
+ } else {
+ msg.setInitialPrompt(null);
+ }
+
+ if (helpChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : helpChunks) {
+ if (item == null) {
+ msg.setHelpPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setHelpPrompt(helpChunks);
+ }
+ } else {
+ msg.setHelpPrompt(null);
+ }
+
return msg;
}
@@ -504,6 +791,7 @@ public class RPCRequestFactory {
return putFile;
}
+ @Deprecated
public static PutFile buildPutFile(String sdlFileName, Integer iOffset, Integer iLength) {
PutFile putFile = new PutFile();
putFile.setCorrelationID(10000);
@@ -513,8 +801,20 @@ public class RPCRequestFactory {
putFile.setOffset(iOffset);
putFile.setLength(iLength);
return putFile;
- }
+ }
+
+ public static PutFile buildPutFile(String sdlFileName, Long iOffset, Long iLength) {
+ PutFile putFile = new PutFile();
+ putFile.setCorrelationID(10000);
+ putFile.setSdlFileName(sdlFileName);
+ putFile.setFileType(FileType.BINARY);
+ putFile.setSystemFile(true);
+ putFile.setOffset(iOffset);
+ putFile.setLength(iLength);
+ return putFile;
+ }
+ @Deprecated
public static PutFile buildPutFile(String syncFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) {
PutFile putFile = new PutFile();
putFile.setCorrelationID(10000);
@@ -526,6 +826,43 @@ public class RPCRequestFactory {
putFile.setLength(iLength);
return putFile;
}
+
+ public static PutFile buildPutFile(String syncFileName, Long iOffset, Long iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) {
+ PutFile putFile = new PutFile();
+ putFile.setCorrelationID(10000);
+ putFile.setSdlFileName(syncFileName);
+ putFile.setFileType(fileType);
+ putFile.setPersistentFile(bPersistentFile);
+ putFile.setSystemFile(bSystemFile);
+ putFile.setOffset(iOffset);
+ putFile.setLength(iLength);
+ return putFile;
+ }
+
+ @Deprecated
+ public static PutFile buildPutFile(String sdlFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) {
+ PutFile putFile = new PutFile();
+ putFile.setCorrelationID(iCorrelationID);
+ putFile.setSdlFileName(sdlFileName);
+ putFile.setFileType(fileType);
+ putFile.setPersistentFile(bPersistentFile);
+ putFile.setSystemFile(bSystemFile);
+ putFile.setOffset(iOffset);
+ putFile.setLength(iLength);
+ return putFile;
+ }
+
+ public static PutFile buildPutFile(String sdlFileName, Long iOffset, Long iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) {
+ PutFile putFile = new PutFile();
+ putFile.setCorrelationID(iCorrelationID);
+ putFile.setSdlFileName(sdlFileName);
+ putFile.setFileType(fileType);
+ putFile.setPersistentFile(bPersistentFile);
+ putFile.setSystemFile(bSystemFile);
+ putFile.setOffset(iOffset);
+ putFile.setLength(iLength);
+ return putFile;
+ }
public static RegisterAppInterface buildRegisterAppInterface(String appName, String appID) {
return buildRegisterAppInterface(appName, false, appID);
@@ -559,7 +896,20 @@ public class RPCRequestFactory {
msg.setAppName(appName);
- msg.setTtsName(ttsName);
+ if (ttsName != null) {
+ boolean isValid = true;
+ for (TTSChunk item : ttsName) {
+ if (item == null) {
+ msg.setTtsName(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setTtsName(ttsName);
+ }
+ } else {
+ msg.setTtsName(null);
+ }
if (ngnMediaScreenAppName == null) {
ngnMediaScreenAppName = appName;
@@ -567,11 +917,20 @@ public class RPCRequestFactory {
msg.setNgnMediaScreenAppName(ngnMediaScreenAppName);
- if (vrSynonyms == null) {
- vrSynonyms = new Vector<String>();
- vrSynonyms.add(appName);
+ if (vrSynonyms != null) {
+ boolean isValid = true;
+ for (String item : vrSynonyms) {
+ if (item == null) {
+ msg.setVrSynonyms(new Vector<String>());
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setVrSynonyms(vrSynonyms);
+ }
+ } else {
+ msg.setVrSynonyms(new Vector<String>());
}
- msg.setVrSynonyms(vrSynonyms);
msg.setIsMediaApplication(isMediaApp);
@@ -586,7 +945,20 @@ public class RPCRequestFactory {
msg.setHmiDisplayLanguageDesired(hmiDisplayLanguageDesired);
- msg.setAppHMIType(appType);
+ if (appType != null) {
+ boolean isValid = true;
+ for (AppHMIType item : appType) {
+ if (item == null) {
+ msg.setAppHMIType(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setAppHMIType(appType);
+ }
+ } else {
+ msg.setAppHMIType(null);
+ }
msg.setAppID(appID);
@@ -613,9 +985,36 @@ public class RPCRequestFactory {
Integer correlationID) {
SetGlobalProperties req = new SetGlobalProperties();
req.setCorrelationID(correlationID);
-
- req.setHelpPrompt(helpChunks);
- req.setTimeoutPrompt(timeoutChunks);
+
+ if (helpChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : helpChunks) {
+ if (item == null) {
+ req.setHelpPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ req.setHelpPrompt(helpChunks);
+ }
+ } else {
+ req.setHelpPrompt(null);
+ }
+
+ if (timeoutChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : timeoutChunks) {
+ if (item == null) {
+ req.setTimeoutPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ req.setTimeoutPrompt(timeoutChunks);
+ }
+ } else {
+ req.setTimeoutPrompt(null);
+ }
return req;
}
@@ -637,11 +1036,53 @@ public class RPCRequestFactory {
SetGlobalProperties req = new SetGlobalProperties();
req.setCorrelationID(correlationID);
- req.setHelpPrompt(helpChunks);
- req.setTimeoutPrompt(timeoutChunks);
+ if (helpChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : helpChunks) {
+ if (item == null) {
+ req.setHelpPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ req.setHelpPrompt(helpChunks);
+ }
+ } else {
+ req.setHelpPrompt(null);
+ }
+
+ if (timeoutChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : timeoutChunks) {
+ if (item == null) {
+ req.setTimeoutPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ req.setTimeoutPrompt(timeoutChunks);
+ }
+ } else {
+ req.setTimeoutPrompt(null);
+ }
+
+ req.setVrHelpTitle(vrHelpTitle);
- req.setVrHelpTitle(vrHelpTitle);
req.setVrHelp(vrHelp);
+ if (vrHelp != null) {
+ boolean isValid = true;
+ for (VrHelpItem item : vrHelp) {
+ if (item == null) {
+ req.setVrHelp(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ req.setVrHelp(vrHelp);
+ }
+ } else {
+ req.setVrHelp(null);
+ }
return req;
}
@@ -693,9 +1134,23 @@ public class RPCRequestFactory {
msg.setAlignment(alignment);
msg.setMainField3(mainText3);
msg.setMainField4(mainText4);
- msg.setGraphic(graphic);
- msg.setSoftButtons(softButtons);
- msg.setCustomPresets(customPresets);
+ msg.setGraphic(graphic);
+ msg.setCustomPresets(customPresets);
+
+ if (softButtons != null) {
+ boolean isValid = true;
+ for (SoftButton item : softButtons) {
+ if (item == null) {
+ msg.setSoftButtons(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setSoftButtons(softButtons);
+ }
+ } else {
+ msg.setSoftButtons(null);
+ }
return msg;
}
@@ -742,7 +1197,20 @@ public class RPCRequestFactory {
Speak msg = new Speak();
msg.setCorrelationID(correlationID);
- msg.setTtsChunks(ttsChunks);
+ if (ttsChunks != null) {
+ boolean isValid = true;
+ for (TTSChunk item : ttsChunks) {
+ if (item == null) {
+ msg.setTtsChunks(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setTtsChunks(ttsChunks);
+ }
+ } else {
+ msg.setTtsChunks(null);
+ }
return msg;
}
@@ -861,7 +1329,21 @@ public class RPCRequestFactory {
msg.setCorrelationID(correlationID);
msg.setScrollableMessageBody(scrollableMessageBody);
msg.setTimeout(timeout);
- msg.setSoftButtons(softButtons);
+
+ if (softButtons != null) {
+ boolean isValid = true;
+ for (SoftButton item : softButtons) {
+ if (item == null) {
+ msg.setSoftButtons(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setSoftButtons(softButtons);
+ }
+ } else {
+ msg.setSoftButtons(null);
+ }
return msg;
}
@@ -873,9 +1355,23 @@ public class RPCRequestFactory {
msg.setNumTicks(numTicks);
msg.setPosition(position);
msg.setSliderHeader(sliderHeader);
- msg.setSliderFooter(sliderFooter);
msg.setTimeout(timeout);
+ if (sliderFooter != null) {
+ boolean isValid = true;
+ for (String item : sliderFooter) {
+ if (item == null) {
+ msg.setSliderFooter(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setSliderFooter(sliderFooter);
+ }
+ } else {
+ msg.setSliderFooter(null);
+ }
+
return msg;
}
@@ -917,7 +1413,6 @@ public class RPCRequestFactory {
{
PerformAudioPassThru msg = new PerformAudioPassThru();
msg.setCorrelationID(correlationID);
- msg.setInitialPrompt(initialPrompt);
msg.setAudioPassThruDisplayText1(audioPassThruDisplayText1);
msg.setAudioPassThruDisplayText2(audioPassThruDisplayText2);
msg.setSamplingRate(samplingRate);
@@ -925,6 +1420,21 @@ public class RPCRequestFactory {
msg.setBitsPerSample(bitsPerSample);
msg.setAudioType(audioType);
msg.setMuteAudio(muteAudio);
+
+ if (initialPrompt != null) {
+ boolean isValid = true;
+ for (TTSChunk item : initialPrompt) {
+ if (item == null) {
+ msg.setInitialPrompt(null);
+ isValid = false;
+ }
+ }
+ if (isValid) {
+ msg.setInitialPrompt(initialPrompt);
+ }
+ } else {
+ msg.setInitialPrompt(null);
+ }
return msg;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCResponse.java
index b37ef1f00..45349450d 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCResponse.java
@@ -4,8 +4,8 @@
package com.smartdevicelink.proxy;
import java.util.Hashtable;
+
import com.smartdevicelink.proxy.rpc.enums.Result;
-import com.smartdevicelink.util.LogTool;
/**
* Result sent by SDL after an RPC is processed, consists of four parts:
@@ -66,7 +66,15 @@ public class RPCResponse extends RPCMessage {
*@param rpcMsg The {@linkplain RPCMessage} to use
*/
public RPCResponse(RPCMessage rpcMsg) {
- super(rpcMsg);
+ super(preprocessMsg(rpcMsg));
+ }
+
+ static RPCMessage preprocessMsg (RPCMessage rpcMsg) {
+ if (rpcMsg.getMessageType() != RPCMessage.KEY_RESPONSE) {
+ rpcMsg.messageType = RPCMessage.KEY_RESPONSE;
+ }
+
+ return rpcMsg;
}
/**
@@ -129,14 +137,8 @@ public class RPCResponse extends RPCMessage {
Object obj = parameters.get(RPCResponse.KEY_RESULT_CODE);
if (obj instanceof Result) {
return (Result) obj;
- } else if (obj instanceof String) {
- Result theCode = null;
- try {
- theCode = Result.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + RPCResponse.KEY_RESULT_CODE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return Result.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/RPCStreamController.java b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCStreamController.java
new file mode 100644
index 000000000..0e2af0bc6
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/RPCStreamController.java
@@ -0,0 +1,32 @@
+package com.smartdevicelink.proxy;
+
+import com.smartdevicelink.streaming.StreamRPCPacketizer;
+
+public class RPCStreamController {
+ private StreamRPCPacketizer rpcPacketizer;
+ private Integer iCorrelationID;
+
+ public RPCStreamController(StreamRPCPacketizer rpcPacketizer, Integer iCorrelationID)
+ {
+ this.rpcPacketizer = rpcPacketizer;
+ this.iCorrelationID = iCorrelationID;
+ }
+
+ public Integer getCorrelationID()
+ {
+ return iCorrelationID;
+ }
+
+ public void pause()
+ {
+ rpcPacketizer.pause();
+ }
+ public void resume()
+ {
+ rpcPacketizer.resume();
+ }
+ public void stop()
+ {
+ rpcPacketizer.onPutFileStreamError(null, "Stop Putfile Stream Requested");
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
index e8f45b7e3..b4e919e19 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
@@ -27,7 +27,7 @@ import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.transport.BTTransportConfig;
import com.smartdevicelink.transport.BaseTransportConfig;
-import com.smartdevicelink.transport.TransportType;
+import com.smartdevicelink.transport.enums.TransportType;
public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
index 05d7c4b15..7e438bc1e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -1,4363 +1,4645 @@
-package com.smartdevicelink.proxy;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.ProtocolException;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Vector;
-
-import android.app.Service;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Environment;
-import android.os.Handler;
-import android.os.Looper;
-import android.telephony.TelephonyManager;
-import android.util.Log;
-
-import com.smartdevicelink.proxy.RPCRequestFactory;
-import com.smartdevicelink.proxy.rpc.PutFile;
-import com.smartdevicelink.Dispatcher.IDispatchingStrategy;
-import com.smartdevicelink.Dispatcher.IncomingProtocolMessageComparitor;
-import com.smartdevicelink.Dispatcher.InternalProxyMessageComparitor;
-import com.smartdevicelink.Dispatcher.OutgoingProtocolMessageComparitor;
-import com.smartdevicelink.Dispatcher.ProxyMessageDispatcher;
-import com.smartdevicelink.SdlConnection.ISdlConnectionListener;
-import com.smartdevicelink.SdlConnection.SdlConnection;
-import com.smartdevicelink.SdlConnection.SdlSession;
-import com.smartdevicelink.exception.SdlException;
-import com.smartdevicelink.exception.SdlExceptionCause;
-import com.smartdevicelink.marshal.JsonRPCMarshaller;
-import com.smartdevicelink.protocol.ProtocolMessage;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.protocol.enums.MessageType;
-import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.protocol.heartbeat.HeartbeatMonitor;
-import com.smartdevicelink.proxy.callbacks.InternalProxyMessage;
-import com.smartdevicelink.proxy.callbacks.OnError;
-import com.smartdevicelink.proxy.callbacks.OnProxyClosed;
-import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
-import com.smartdevicelink.proxy.interfaces.IProxyListenerBase;
-import com.smartdevicelink.proxy.rpc.*;
-import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
-import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState;
-import com.smartdevicelink.proxy.rpc.enums.AudioType;
-import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
-import com.smartdevicelink.proxy.rpc.enums.ButtonName;
-import com.smartdevicelink.proxy.rpc.enums.DriverDistractionState;
-import com.smartdevicelink.proxy.rpc.enums.FileType;
-import com.smartdevicelink.proxy.rpc.enums.GlobalProperty;
-import com.smartdevicelink.proxy.rpc.enums.HMILevel;
-import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities;
-import com.smartdevicelink.proxy.rpc.enums.ImageType;
-import com.smartdevicelink.proxy.rpc.enums.InteractionMode;
-import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
-import com.smartdevicelink.proxy.rpc.enums.RequestType;
-import com.smartdevicelink.proxy.rpc.enums.Result;
-import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
-import com.smartdevicelink.proxy.rpc.enums.SdlConnectionState;
-import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
-import com.smartdevicelink.proxy.rpc.enums.SdlInterfaceAvailability;
-import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
-import com.smartdevicelink.proxy.rpc.enums.SystemContext;
-import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
-import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
-import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
-import com.smartdevicelink.trace.SdlTrace;
-import com.smartdevicelink.trace.TraceDeviceInfo;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
-import com.smartdevicelink.transport.BaseTransportConfig;
-import com.smartdevicelink.transport.SiphonServer;
-import com.smartdevicelink.transport.TransportType;
-import com.smartdevicelink.util.LogTool;
-
-public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> {
- // Used for calls to Android Log class.
- public static final String TAG = "SdlProxy";
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
- private static final int PROX_PROT_VER_ONE = 1;
-
- private SdlSession sdlSession = null;
- private proxyListenerType _proxyListener = null;
-
- protected Service _appService = null;
- private String sPoliciesURL = ""; //for testing only
-
- // Protected Correlation IDs
- private final int REGISTER_APP_INTERFACE_CORRELATION_ID = 65529,
- UNREGISTER_APP_INTERFACE_CORRELATION_ID = 65530,
- POLICIES_CORRELATION_ID = 65535;
-
- // Sdlhronization Objects
- private static final Object CONNECTION_REFERENCE_LOCK = new Object(),
- INCOMING_MESSAGE_QUEUE_THREAD_LOCK = new Object(),
- OUTGOING_MESSAGE_QUEUE_THREAD_LOCK = new Object(),
- INTERNAL_MESSAGE_QUEUE_THREAD_LOCK = new Object();
-
- private Object APP_INTERFACE_REGISTERED_LOCK = new Object();
-
- private int iFileCount = 0;
-
- private boolean navServiceResponseReceived = false;
- private boolean navServiceResponse = false;
- @SuppressWarnings("unused")
- private boolean pcmServiceResponseReceived = false;
- @SuppressWarnings("unused")
- private boolean pcmServiceResponse = false;
-
- // Device Info for logging
- private TraceDeviceInfo _traceDeviceInterrogator = null;
-
- // Declare Queuing Threads
- private ProxyMessageDispatcher<ProtocolMessage> _incomingProxyMessageDispatcher;
- private ProxyMessageDispatcher<ProtocolMessage> _outgoingProxyMessageDispatcher;
- private ProxyMessageDispatcher<InternalProxyMessage> _internalProxyMessageDispatcher;
-
- // Flag indicating if callbacks should be called from UIThread
- private Boolean _callbackToUIThread = false;
- // UI Handler
- private Handler _mainUIHandler = null;
- final int HEARTBEAT_CORRELATION_ID = 65531;
-
- // SdlProxy Advanced Lifecycle Management
- protected Boolean _advancedLifecycleManagementEnabled = false;
- // Parameters passed to the constructor from the app to register an app interface
- private String _applicationName = null;
- private long instanceDateTime = System.currentTimeMillis();
- private String sConnectionDetails = "N/A";
- private Vector<TTSChunk> _ttsName = null;
- private String _ngnMediaScreenAppName = null;
- private Boolean _isMediaApp = null;
- private Language _sdlLanguageDesired = null;
- private Language _hmiDisplayLanguageDesired = null;
- private Vector<AppHMIType> _appType = null;
- private String _appID = null;
- private String _autoActivateIdDesired = null;
- private String _lastHashID = null;
- private SdlMsgVersion _sdlMsgVersionRequest = null;
- private Vector<String> _vrSynonyms = null;
- private boolean _bAppResumeEnabled = false;
-
- /**
- * Contains current configuration for the transport that was selected during
- * construction of this object
- */
- private BaseTransportConfig _transportConfig = null;
- // Proxy State Variables
- protected Boolean _appInterfaceRegisterd = false;
- protected Boolean _preRegisterd = false;
- @SuppressWarnings("unused")
- private Boolean _haveReceivedFirstNonNoneHMILevel = false;
- protected Boolean _haveReceivedFirstFocusLevel = false;
- protected Boolean _haveReceivedFirstFocusLevelFull = false;
- protected Boolean _proxyDisposed = false;
- protected SdlConnectionState _sdlConnectionState = null;
- protected SdlInterfaceAvailability _sdlIntefaceAvailablity = null;
- protected HMILevel _hmiLevel = null;
- private HMILevel _priorHmiLevel = null;
- protected AudioStreamingState _audioStreamingState = null;
- private AudioStreamingState _priorAudioStreamingState = null;
- protected SystemContext _systemContext = null;
- // Variables set by RegisterAppInterfaceResponse
- protected SdlMsgVersion _sdlMsgVersion = null;
- protected String _autoActivateIdReturned = null;
- protected Language _sdlLanguage = null;
- protected Language _hmiDisplayLanguage = null;
- protected DisplayCapabilities _displayCapabilities = null;
- protected List<ButtonCapabilities> _buttonCapabilities = null;
- protected List<SoftButtonCapabilities> _softButtonCapabilities = null;
- protected PresetBankCapabilities _presetBankCapabilities = null;
- protected List<HmiZoneCapabilities> _hmiZoneCapabilities = null;
- protected List<SpeechCapabilities> _speechCapabilities = null;
- protected List<PrerecordedSpeech> _prerecordedSpeech = null;
- protected List<VrCapabilities> _vrCapabilities = null;
- protected VehicleType _vehicleType = null;
- protected List<AudioPassThruCapabilities> _audioPassThruCapabilities = null;
- protected List<Integer> _diagModes = null;
- protected Boolean firstTimeFull = true;
- protected String _proxyVersionInfo = null;
- protected Boolean _bResumeSuccess = false;
-
- protected byte _wiproVersion = 1;
-
- // Interface broker
- private SdlInterfaceBroker _interfaceBroker = null;
-
- // Private Class to Interface with SdlConnection
- private class SdlInterfaceBroker implements ISdlConnectionListener {
-
- @Override
- public void onTransportDisconnected(String info) {
- // proxyOnTransportDisconnect is called to alert the proxy that a requested
- // disconnect has completed
-
- if (_advancedLifecycleManagementEnabled) {
- // If ALM, nothing is required to be done here
- } else {
- // If original model, notify app the proxy is closed so it will delete and reinstanciate
- notifyProxyClosed(info, new SdlException("Transport disconnected.", SdlExceptionCause.SDL_UNAVAILABLE), SdlDisconnectedReason.TRANSPORT_DISCONNECT);
- }
- }
-
- @Override
- public void onTransportError(String info, Exception e) {
- LogTool.logError("Transport failure: " + info, e);
-
- if (_advancedLifecycleManagementEnabled) {
- // Cycle the proxy
- cycleProxy(SdlDisconnectedReason.TRANSPORT_ERROR);
- } else {
- notifyProxyClosed(info, e, SdlDisconnectedReason.TRANSPORT_ERROR);
- }
- }
-
- @Override
- public void onProtocolMessageReceived(ProtocolMessage msg) {
-
- // AudioPathThrough is coming WITH BulkData but WITHOUT JSON Data
- // Policy Snapshot is coming WITH BulkData and WITH JSON Data
- if ((msg.getData() != null && msg.getData().length > 0) ||
- (msg.getBulkData() != null && msg.getBulkData().length > 0)) {
- queueIncomingMessage(msg);
- }
- }
-
- @Override
- public void onProtocolSessionStarted(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "onProtocolSessionStarted");
- updateBroadcastIntent(sendIntent, "COMMENT1", "SessionID: " + sessionID);
- updateBroadcastIntent(sendIntent, "COMMENT2", " SessionType: " + sessionType.getName());
- sendBroadcastIntent(sendIntent);
-
- setWiProVersion(version);
-
- if ( (_transportConfig.getHeartBeatTimeout() != Integer.MAX_VALUE) && (version > 2) )
- {
- HeartbeatMonitor heartbeatMonitor = new HeartbeatMonitor();
- heartbeatMonitor.setInterval(_transportConfig.getHeartBeatTimeout());
- sdlSession.setHeartbeatMonitor(heartbeatMonitor);
- }
-
- if (sessionType.eq(SessionType.RPC)) {
- startRPCProtocolSession(sessionID, correlationID);
- } else if (sessionType.eq(SessionType.NAV)) {
- NavServiceStarted();
- } else if (_wiproVersion > 1) {
- //If version is 2 or above then don't need to specify a Session Type
- startRPCProtocolSession(sessionID, correlationID);
- } else {
- // Handle other protocol session types here
- }
- }
-
- @Override
- public void onProtocolSessionNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
- if (sessionType.eq(SessionType.NAV)) {
- NavServiceEnded();
- }
- }
-
- @Override
- public void onProtocolSessionEnded(SessionType sessionType,
- byte sessionID, String correlationID) {
- // How to handle protocol session ended?
- // How should protocol session management occur?
- }
-
- @Override
- public void onProtocolError(String info, Exception e) {
- passErrorToProxyListener(info, e);
- }
-
- @Override
- public void onHeartbeatTimedOut(byte sessionID) {
- final String msg = "Heartbeat timeout";
- LogTool.logInfo(msg);
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "onHeartbeatTimedOut");
- updateBroadcastIntent(sendIntent, "COMMENT1", "Heartbeat timeout for SessionID: " + sessionID);
- sendBroadcastIntent(sendIntent);
-
- notifyProxyClosed(msg, new SdlException(msg, SdlExceptionCause.HEARTBEAT_PAST_DUE), SdlDisconnectedReason.HB_TIMEOUT);
-
- }
- }
-
- /**
- * Constructor.
- *
- * @param listener Type of listener for this proxy base.
- * @param sdlProxyConfigurationResources Configuration resources for this proxy.
- * @param enableAdvancedLifecycleManagement Flag that ALM should be enabled or not.
- * @param appName Client application name.
- * @param ttsName TTS name.
- * @param ngnMediaScreenAppName Media Screen Application name.
- * @param vrSynonyms List of synonyms.
- * @param isMediaApp Flag that indicates that client application if media application or not.
- * @param sdlMsgVersion Version of Sdl Message.
- * @param languageDesired Desired language.
- * @param hmiDisplayLanguageDesired Desired language for HMI.
- * @param appType Type of application.
- * @param appID Application identifier.
- * @param autoActivateID Auto activation identifier.
- * @param callbackToUIThread Flag that indicates that this proxy should send callback to UI thread or not.
- * @param transportConfig Configuration of transport to be used by underlying connection.
- * @throws SdlException
- */
- protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
- String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID,
- String autoActivateID, boolean callbackToUIThread, BaseTransportConfig transportConfig)
- throws SdlException {
-
- performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp,
- sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, callbackToUIThread, null, null, null, transportConfig);
- }
-
- private void performBaseCommon(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
- String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID,
- String autoActivateID, boolean callbackToUIThread, Boolean preRegister, String sHashID, Boolean bAppResumeEnab,
- BaseTransportConfig transportConfig) throws SdlException
- {
- setWiProVersion((byte)PROX_PROT_VER_ONE);
-
- if (preRegister != null && preRegister)
- {
- _appInterfaceRegisterd = preRegister;
- _preRegisterd = preRegister;
- }
-
- if (bAppResumeEnab != null && bAppResumeEnab)
- {
- _bAppResumeEnabled = true;
- _lastHashID = sHashID;
- }
- _interfaceBroker = new SdlInterfaceBroker();
-
- _callbackToUIThread = callbackToUIThread;
-
- if (_callbackToUIThread) {
- _mainUIHandler = new Handler(Looper.getMainLooper());
- }
-
- // Set variables for Advanced Lifecycle Management
- _advancedLifecycleManagementEnabled = enableAdvancedLifecycleManagement;
- _applicationName = appName;
- _ttsName = ttsName;
- _ngnMediaScreenAppName = ngnMediaScreenAppName;
- _isMediaApp = isMediaApp;
- _sdlMsgVersionRequest = sdlMsgVersion;
- _vrSynonyms = vrSynonyms;
- _sdlLanguageDesired = languageDesired;
- _hmiDisplayLanguageDesired = hmiDisplayLanguageDesired;
- _appType = appType;
- _appID = appID;
- _autoActivateIdDesired = autoActivateID;
- _transportConfig = transportConfig;
-
- // Test conditions to invalidate the proxy
- if (listener == null) {
- throw new IllegalArgumentException("IProxyListener listener must be provided to instantiate SdlProxy object.");
- }
- if (_advancedLifecycleManagementEnabled) {
- /* if (_applicationName == null ) {
- throw new IllegalArgumentException("To use SdlProxyALM, an application name, appName, must be provided");
- }
- if (_applicationName.length() < 1 || _applicationName.length() > 100) {
- throw new IllegalArgumentException("A provided application name, appName, must be between 1 and 100 characters in length.");
- }*/
- if (_isMediaApp == null) {
- throw new IllegalArgumentException("isMediaApp must not be null when using SdlProxyALM.");
- }
- }
-
- _proxyListener = listener;
-
- // Get information from sdlProxyConfigurationResources
- TelephonyManager telephonyManager = null;
- if (sdlProxyConfigurationResources != null) {
- telephonyManager = sdlProxyConfigurationResources.getTelephonyManager();
- }
-
- // Use the telephonyManager to get and log phone info
- if (telephonyManager != null) {
- // Following is not quite thread-safe (because m_traceLogger could test null twice),
- // so we need to fix this, but vulnerability (i.e. two instances of listener) is
- // likely harmless.
- if (_traceDeviceInterrogator == null) {
- _traceDeviceInterrogator = new TraceDeviceInfo(sdlProxyConfigurationResources.getTelephonyManager());
- } // end-if
- } // end-if
-
- // Setup Internal ProxyMessage Dispatcher
- synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) {
- // Ensure internalProxyMessageDispatcher is null
- if (_internalProxyMessageDispatcher != null) {
- _internalProxyMessageDispatcher.dispose();
- _internalProxyMessageDispatcher = null;
- }
-
- _internalProxyMessageDispatcher = new ProxyMessageDispatcher<InternalProxyMessage>("INTERNAL_MESSAGE_DISPATCHER",
- new InternalProxyMessageComparitor(),
- new IDispatchingStrategy<InternalProxyMessage>() {
-
- @Override
- public void dispatch(InternalProxyMessage message) {
- dispatchInternalMessage((InternalProxyMessage)message);
- }
-
- @Override
- public void handleDispatchingError(String info, Exception ex) {
- handleErrorsFromInternalMessageDispatcher(info, ex);
- }
-
- @Override
- public void handleQueueingError(String info, Exception ex) {
- handleErrorsFromInternalMessageDispatcher(info, ex);
- }
- });
- }
-
- // Setup Incoming ProxyMessage Dispatcher
- synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) {
- // Ensure incomingProxyMessageDispatcher is null
- if (_incomingProxyMessageDispatcher != null) {
- _incomingProxyMessageDispatcher.dispose();
- _incomingProxyMessageDispatcher = null;
- }
-
- _incomingProxyMessageDispatcher = new ProxyMessageDispatcher<ProtocolMessage>("INCOMING_MESSAGE_DISPATCHER",
- new IncomingProtocolMessageComparitor(),
- new IDispatchingStrategy<ProtocolMessage>() {
- @Override
- public void dispatch(ProtocolMessage message) {
- dispatchIncomingMessage((ProtocolMessage)message);
- }
-
- @Override
- public void handleDispatchingError(String info, Exception ex) {
- handleErrorsFromIncomingMessageDispatcher(info, ex);
- }
-
- @Override
- public void handleQueueingError(String info, Exception ex) {
- handleErrorsFromIncomingMessageDispatcher(info, ex);
- }
- });
- }
-
- // Setup Outgoing ProxyMessage Dispatcher
- synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) {
- // Ensure outgoingProxyMessageDispatcher is null
- if (_outgoingProxyMessageDispatcher != null) {
- _outgoingProxyMessageDispatcher.dispose();
- _outgoingProxyMessageDispatcher = null;
- }
-
- _outgoingProxyMessageDispatcher = new ProxyMessageDispatcher<ProtocolMessage>("OUTGOING_MESSAGE_DISPATCHER",
- new OutgoingProtocolMessageComparitor(),
- new IDispatchingStrategy<ProtocolMessage>() {
- @Override
- public void dispatch(ProtocolMessage message) {
- dispatchOutgoingMessage((ProtocolMessage)message);
- }
-
- @Override
- public void handleDispatchingError(String info, Exception ex) {
- handleErrorsFromOutgoingMessageDispatcher(info, ex);
- }
-
- @Override
- public void handleQueueingError(String info, Exception ex) {
- handleErrorsFromOutgoingMessageDispatcher(info, ex);
- }
- });
- }
-
- // Initialize the proxy
- try {
- initializeProxy();
- } catch (SdlException e) {
- // Couldn't initialize the proxy
- // Dispose threads and then rethrow exception
-
- if (_internalProxyMessageDispatcher != null) {
- _internalProxyMessageDispatcher.dispose();
- _internalProxyMessageDispatcher = null;
- }
- if (_incomingProxyMessageDispatcher != null) {
- _incomingProxyMessageDispatcher.dispose();
- _incomingProxyMessageDispatcher = null;
- }
- if (_outgoingProxyMessageDispatcher != null) {
- _outgoingProxyMessageDispatcher.dispose();
- _outgoingProxyMessageDispatcher = null;
- }
- throw e;
- }
-
- // Trace that ctor has fired
- SdlTrace.logProxyEvent("SdlProxy Created, instanceID=" + this.toString(), SDL_LIB_TRACE_KEY);
- }
-
- protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
- String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID,
- String autoActivateID, boolean callbackToUIThread, boolean preRegister, String sHashID, Boolean bEnableResume, BaseTransportConfig transportConfig)
- throws SdlException
- {
- performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp,
- sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, callbackToUIThread, preRegister, sHashID, bEnableResume, transportConfig);
- }
-
-
-
- /**
- * Constructor.
- *
- * @param listener Type of listener for this proxy base.
- * @param sdlProxyConfigurationResources Configuration resources for this proxy.
- * @param enableAdvancedLifecycleManagement Flag that ALM should be enabled or not.
- * @param appName Client application name.
- * @param ttsName TTS name.
- * @param ngnMediaScreenAppName Media Screen Application name.
- * @param vrSynonyms List of synonyms.
- * @param isMediaApp Flag that indicates that client application if media application or not.
- * @param sdlMsgVersion Version of Sdl Message.
- * @param languageDesired Desired language.
- * @param hmiDisplayLanguageDesired Desired language for HMI.
- * @param appType Type of application.
- * @param appID Application identifier.
- * @param autoActivateID Auto activation identifier.
- * @param callbackToUIThread Flag that indicates that this proxy should send callback to UI thread or not.
- * @param preRegister Flag that indicates that this proxy should be pre-registerd or not.
- * @param transportConfig Configuration of transport to be used by underlying connection.
- * @throws SdlException
- */
- protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
- String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID,
- String autoActivateID, boolean callbackToUIThread, boolean preRegister, BaseTransportConfig transportConfig)
- throws SdlException
- {
- performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp,
- sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, callbackToUIThread, preRegister, null, null, transportConfig);
- }
-
- private Intent createBroadcastIntent()
- {
- Intent sendIntent = new Intent();
- sendIntent.setAction("com.smartdevicelink.broadcast");
- sendIntent.putExtra("APP_NAME", this._applicationName);
- sendIntent.putExtra("APP_ID", this._appID);
- sendIntent.putExtra("RPC_NAME", "");
- sendIntent.putExtra("TYPE", "");
- sendIntent.putExtra("SUCCESS", true);
- sendIntent.putExtra("CORRID", 0);
- sendIntent.putExtra("FUNCTION_NAME", "");
- sendIntent.putExtra("COMMENT1", "");
- sendIntent.putExtra("COMMENT2", "");
- sendIntent.putExtra("COMMENT3", "");
- sendIntent.putExtra("COMMENT4", "");
- sendIntent.putExtra("COMMENT5", "");
- sendIntent.putExtra("COMMENT6", "");
- sendIntent.putExtra("COMMENT7", "");
- sendIntent.putExtra("COMMENT8", "");
- sendIntent.putExtra("COMMENT9", "");
- sendIntent.putExtra("COMMENT10", "");
- sendIntent.putExtra("DATA", "");
- sendIntent.putExtra("SHOW_ON_UI", true);
- return sendIntent;
- }
- private void updateBroadcastIntent(Intent sendIntent, String sKey, String sValue)
- {
- if (sValue == null) sValue = "";
- sendIntent.putExtra(sKey, sValue);
- }
- private void updateBroadcastIntent(Intent sendIntent, String sKey, boolean bValue)
- {
- sendIntent.putExtra(sKey, bValue);
- }
- private void updateBroadcastIntent(Intent sendIntent, String sKey, int iValue)
- {
- sendIntent.putExtra(sKey, iValue);
- }
-
- private void sendBroadcastIntent(Intent sendIntent)
- {
- Service myService = null;
- if (_proxyListener != null && _proxyListener instanceof Service)
- {
- myService = (Service) _proxyListener;
- }
- else if (_appService != null)
- {
- myService = _appService;
- }
- else
- {
- return;
- }
- try
- {
- Context myContext = myService.getApplicationContext();
- if (myContext != null) myContext.sendBroadcast(sendIntent);
- }
- catch(Exception ex)
- {
- //If the service or context has become unavailable unexpectedly, catch the exception and move on -- no broadcast log will occur.
- }
- }
-
- private void writeToFile(Object writeME, String fileName) {
- Intent sendIntent = createBroadcastIntent();
- try {
- updateBroadcastIntent(sendIntent,"FUNCTION_NAME", "writeToFile");
- updateBroadcastIntent(sendIntent, "SHOW_ON_UI", false);
-
- String sFileName = fileName + "_" + iFileCount + ".txt";
- String outFile = Environment.getExternalStorageDirectory().getPath() + "/" + sFileName;
- File out = new File(outFile);
- FileWriter writer = new FileWriter(out);
- writer.flush();
- writer.write(writeME.toString());
- writer.close();
- updateBroadcastIntent(sendIntent, "COMMENT1", outFile);
- } catch (FileNotFoundException e) {
- updateBroadcastIntent(sendIntent, "COMMENT2", "writeToFile FileNotFoundException " + e);
- Log.i("sdlp", "FileNotFoundException: " + e);
- e.printStackTrace();
- } catch (IOException e) {
- updateBroadcastIntent(sendIntent, "COMMENT2", "writeToFile IOException " + e);
- Log.i("sdlp", "IOException: " + e);
- e.printStackTrace();
- }
- finally
- {
- sendBroadcastIntent(sendIntent);
- }
- }
-
- private void LogHeader(String sType, final String myObject, String sFuncName)
- {
- Intent sendIntent = createBroadcastIntent();
-
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", sFuncName);
-
- updateBroadcastIntent(sendIntent, "COMMENT1", sType + "\r\n");
- updateBroadcastIntent(sendIntent, "DATA", myObject);
- sendBroadcastIntent(sendIntent);
- }
-
-
- private HttpURLConnection getURLConnection(Headers myHeader, String sURLString, int Timeout, int iContentLen)
- {
- String sContentType = "application/json";
- int CONNECTION_TIMEOUT = Timeout * 1000;
- int READ_TIMEOUT = Timeout * 1000;
- boolean bDoOutput = true;
- boolean bDoInput = true;
- boolean bUsesCaches = false;
- String sRequestMeth = "POST";
-
- boolean bInstFolRed = false;
- String sCharSet = "utf-8";
- int iContentLength = iContentLen;
-
- URL url = null;
- HttpURLConnection urlConnection = null;
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "getURLConnection");
- updateBroadcastIntent(sendIntent, "COMMENT1", "Actual Content Length: " + iContentLen);
-
- if (myHeader != null)
- {
- //if the header isn't null, use it and replace the hardcoded params
- int iTimeout;
- int iReadTimeout;
- sContentType = myHeader.getContentType();
- iTimeout = myHeader.getConnectTimeout();
- bDoOutput = myHeader.getDoOutput();
- bDoInput = myHeader.getDoInput();
- bUsesCaches = myHeader.getUseCaches();
- sRequestMeth = myHeader.getRequestMethod();
- iReadTimeout = myHeader.getReadTimeout();
- bInstFolRed = myHeader.getInstanceFollowRedirects();
- sCharSet = myHeader.getCharset();
- iContentLength = myHeader.getContentLength();
- CONNECTION_TIMEOUT = iTimeout*1000;
- READ_TIMEOUT = iReadTimeout*1000;
- updateBroadcastIntent(sendIntent, "COMMENT2", "\nHeader Defined Content Length: " + iContentLength);
- }
-
- try
- {
- url = new URL(sURLString);
- urlConnection = (HttpURLConnection) url.openConnection();
- urlConnection.setConnectTimeout(CONNECTION_TIMEOUT);
- urlConnection.setDoOutput(bDoOutput);
- urlConnection.setDoInput(bDoInput);
- urlConnection.setRequestMethod(sRequestMeth);
- urlConnection.setReadTimeout(READ_TIMEOUT);
- urlConnection.setInstanceFollowRedirects(bInstFolRed);
- urlConnection.setRequestProperty("Content-Type", sContentType);
- urlConnection.setRequestProperty("charset", sCharSet);
- urlConnection.setRequestProperty("Content-Length", "" + Integer.toString(iContentLength));
- urlConnection.setUseCaches(bUsesCaches);
- return urlConnection;
- }
- catch (Exception e)
- {
- return null;
- }
- finally
- {
- sendBroadcastIntent(sendIntent);
- }
- }
-
-
- private void sendOnSystemRequestToUrl(OnSystemRequest msg)
- {
- Intent sendIntent = createBroadcastIntent();
- Intent sendIntent2 = createBroadcastIntent();
-
- HttpURLConnection urlConnection = null;
- boolean bLegacy = false;
-
- String sURLString;
- if (!getPoliciesURL().equals(""))
- sURLString = sPoliciesURL;
- else
- sURLString = msg.getUrl();
-
- Integer iTimeout = msg.getTimeout();
-
- if (iTimeout == null)
- iTimeout = 2000;
-
- Headers myHeader = msg.getHeader();
- String sFunctionName = "SYSTEM_REQUEST";
-
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "sendOnSystemRequestToUrl");
- updateBroadcastIntent(sendIntent, "COMMENT5", "\r\nCloud URL: " + sURLString);
-
- try
- {
- if (myHeader == null)
- updateBroadcastIntent(sendIntent, "COMMENT7", "\r\nHTTPRequest Header is null");
-
- String sBodyString = msg.getBody();
-
- JSONObject jsonObjectToSendToServer;
- String valid_json;
-
- if (sBodyString == null)
- {
- List<String> legacyData = msg.getLegacyData();
- JSONArray jsonArrayOfSdlPPackets = new JSONArray(legacyData);
- jsonObjectToSendToServer = new JSONObject();
- jsonObjectToSendToServer.put("data", jsonArrayOfSdlPPackets);
- bLegacy = true;
- sFunctionName = "SYSTEM_REQUEST_LEGACY";
- updateBroadcastIntent(sendIntent, "COMMENT6", "\r\nLegacy SystemRequest: true");
- valid_json = jsonObjectToSendToServer.toString().replace("\\", "");
- }
- else
- {
- Intent sendIntent3 = createBroadcastIntent();
- updateBroadcastIntent(sendIntent3, "FUNCTION_NAME", "replace");
- updateBroadcastIntent(sendIntent3, "COMMENT1", "Valid Json length before replace: " + sBodyString.getBytes("UTF-8").length);
- sendBroadcastIntent(sendIntent3);
- valid_json = sBodyString.replace("\\", "");
- }
-
- writeToFile(valid_json, "requestToCloud");
- LogHeader("Cloud Request", valid_json, sFunctionName);
-
- urlConnection = getURLConnection(myHeader, sURLString, iTimeout, valid_json.getBytes("UTF-8").length);
-
- if (urlConnection == null)
- {
- Log.i(TAG, "urlConnection is null, check RPC input parameters");
- updateBroadcastIntent(sendIntent, "COMMENT2", "urlConnection is null, check RPC input parameters");
- return;
- }
-
- DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
- wr.writeBytes(valid_json);
- wr.flush();
- wr.close();
-
-
- long BeforeTime = System.currentTimeMillis();
- @SuppressWarnings("unused")
- String sResponseMsg = urlConnection.getResponseMessage();
- long AfterTime = System.currentTimeMillis();
- final long roundtriptime = AfterTime - BeforeTime;
-
- updateBroadcastIntent(sendIntent, "COMMENT4", " Round trip time: " + roundtriptime);
- updateBroadcastIntent(sendIntent, "COMMENT1", "Received response from cloud, response code=" + urlConnection.getResponseCode() + " ");
-
- int iResponseCode = urlConnection.getResponseCode();
-
- if (iResponseCode != HttpURLConnection.HTTP_OK)
- {
- Log.i(TAG, "Response code not HTTP_OK, returning from sendOnSystemRequestToUrl.");
- updateBroadcastIntent(sendIntent, "COMMENT2", "Response code not HTTP_OK, aborting request. ");
- return;
- }
-
- InputStream is = urlConnection.getInputStream();
- BufferedReader rd = new BufferedReader(new InputStreamReader(is));
- String line;
- StringBuffer response = new StringBuffer();
- while((line = rd.readLine()) != null)
- {
- response.append(line);
- response.append('\r');
- }
- rd.close();
- Log.i(TAG, "response: " + response.toString());
-
- writeToFile(response.toString(), "responseFromCloud");
-
- LogHeader("Cloud Response", response.toString(), sFunctionName);
-
- Vector<String> cloudDataReceived = new Vector<String>();
-
- // Convert the response to JSON
- JSONObject jsonResponse = new JSONObject(response.toString());
- if (jsonResponse.get("data") instanceof JSONArray)
- {
- JSONArray jsonArray = jsonResponse.getJSONArray("data");
- for (int i=0; i<jsonArray.length(); i++)
- {
- if (jsonArray.get(i) instanceof String)
- {
- cloudDataReceived.add(jsonArray.getString(i));
- //Log.i("sendOnSystemRequestToUrl", "jsonArray.getString(i): " + jsonArray.getString(i));
- }
- }
- }
- else if (jsonResponse.get("data") instanceof String)
- {
- cloudDataReceived.add(jsonResponse.getString("data"));
- //Log.i("sendOnSystemRequestToUrl", "jsonResponse.getString(data): " + jsonResponse.getString("data"));
- }
- else
- {
- LogTool.logError("sendOnSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
- //Log.i("sendOnSystemRequestToUrl", "sendOnSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
- return;
- }
-
- String sResponse = cloudDataReceived.toString();
-
- if (sResponse.length() > 512)
- {
- sResponse = sResponse.substring(0, 511);
- }
-
- updateBroadcastIntent(sendIntent, "DATA", "Data from cloud response: " + sResponse);
-
- // Send new SystemRequest to SDL
- SystemRequest mySystemRequest;
-
- if (bLegacy)
- mySystemRequest = RPCRequestFactory.buildSystemRequestLegacy(cloudDataReceived, getPoliciesReservedCorrelationID());
- else
- mySystemRequest = RPCRequestFactory.buildSystemRequest(response.toString(), getPoliciesReservedCorrelationID());
-
- if (getIsConnected())
- {
- sendRPCRequestPrivate(mySystemRequest);
- Log.i("sendOnSystemRequestToUrl", "sent to sdl");
-
- updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.SYSTEM_REQUEST);
- updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST);
- updateBroadcastIntent(sendIntent2, "CORRID", mySystemRequest.getCorrelationID());
- }
- }
- catch (SdlException e)
- {
- LogTool.logError("sendOnSystemRequestToUrl: Could not get data from JSONObject received.", e);
- updateBroadcastIntent(sendIntent, "COMMENT3", " SdlException encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: Could not get data from JSONObject received."+ e);
- }
- catch (JSONException e)
- {
- LogTool.logError("sendOnSystemRequestToUrl: JSONException: ", e);
- updateBroadcastIntent(sendIntent, "COMMENT3", " JSONException encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: JSONException: "+ e);
- }
- catch (UnsupportedEncodingException e)
- {
- LogTool.logError("sendOnSystemRequestToUrl: Could not encode string.", e);
- updateBroadcastIntent(sendIntent, "COMMENT3", " UnsupportedEncodingException encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: Could not encode string."+ e);
- }
- catch (ProtocolException e)
- {
- LogTool.logError("sendOnSystemRequestToUrl: Could not set request method to post.", e);
- updateBroadcastIntent(sendIntent, "COMMENT3", " ProtocolException encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: Could not set request method to post."+ e);
- }
- catch (MalformedURLException e)
- {
- LogTool.logError("sendOnSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e);
- updateBroadcastIntent(sendIntent, "COMMENT3", " MalformedURLException encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: URL Exception when sending SystemRequest to an external server."+ e);
- }
- catch (IOException e)
- {
- LogTool.logError("sendOnSystemRequestToUrl: IOException: ", e);
- updateBroadcastIntent(sendIntent, "COMMENT3", " IOException while sending to cloud: IOException: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: IOException: "+ e);
- }
- catch (Exception e)
- {
- LogTool.logError("sendOnSystemRequestToUrl: Unexpected Exception: ", e);
- updateBroadcastIntent(sendIntent, "COMMENT3", " Exception encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: Unexpected Exception: " + e);
- }
- finally
- {
- sendBroadcastIntent(sendIntent);
- sendBroadcastIntent(sendIntent2);
-
- if (iFileCount < 10)
- iFileCount++;
- else
- iFileCount = 0;
-
- if(urlConnection != null)
- {
- urlConnection.disconnect();
- }
- }
- }
-
- private int getPoliciesReservedCorrelationID() {
- return POLICIES_CORRELATION_ID;
- }
-
- // Test correlationID
- private boolean isCorrelationIDProtected(Integer correlationID) {
- if (correlationID != null &&
- (HEARTBEAT_CORRELATION_ID == correlationID
- || REGISTER_APP_INTERFACE_CORRELATION_ID == correlationID
- || UNREGISTER_APP_INTERFACE_CORRELATION_ID == correlationID
- || POLICIES_CORRELATION_ID == correlationID)) {
- return true;
- }
-
- return false;
- }
-
- // Protected isConnected method to allow legacy proxy to poll isConnected state
- public Boolean getIsConnected() {
- if (sdlSession == null) return false;
-
- return sdlSession.getIsConnected();
- }
-
- /**
- * Returns whether the application is registered in SDL. Note: for testing
- * purposes, it's possible that the connection is established, but the
- * application is not registered.
- *
- * @return true if the application is registered in SDL
- */
- public Boolean getAppInterfaceRegistered() {
- return _appInterfaceRegisterd;
- }
-
- // Function to initialize new proxy connection
- private void initializeProxy() throws SdlException {
- // Reset all of the flags and state variables
- _haveReceivedFirstNonNoneHMILevel = false;
- _haveReceivedFirstFocusLevel = false;
- _haveReceivedFirstFocusLevelFull = false;
- if (_preRegisterd)
- _appInterfaceRegisterd = true;
- else
- _appInterfaceRegisterd = false;
-
- _sdlIntefaceAvailablity = SdlInterfaceAvailability.SDL_INTERFACE_UNAVAILABLE;
-
- // Setup SdlConnection
- synchronized(CONNECTION_REFERENCE_LOCK) {
- this.sdlSession = SdlSession.createSession(_wiproVersion,_interfaceBroker, _transportConfig);
- }
-
- synchronized(CONNECTION_REFERENCE_LOCK) {
- this.sdlSession.startSession();
- sendTransportBroadcast();
- }
- }
-
- public void sendTransportBroadcast()
- {
- if (sdlSession == null || _transportConfig == null) return;
-
- String sTransComment = sdlSession.getBroadcastComment(_transportConfig);
-
- if (sTransComment == null || sTransComment.equals("")) return;
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "initializeProxy");
- updateBroadcastIntent(sendIntent, "COMMENT1", sTransComment);
- sendBroadcastIntent(sendIntent);
- }
-
-
- /**
- * Public method to enable the siphon transport
- */
- public void enableSiphonDebug() {
-
- short enabledPortNumber = SiphonServer.enableSiphonServer();
- String sSiphonPortNumber = "Enabled Siphon Port Number: " + enabledPortNumber;
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "enableSiphonDebug");
- updateBroadcastIntent(sendIntent, "COMMENT1", sSiphonPortNumber);
- sendBroadcastIntent(sendIntent);
- }
-
-
-
- /**
- * Public method to disable the Siphon Trace Server
- */
- public void disableSiphonDebug() {
-
- short disabledPortNumber = SiphonServer.disableSiphonServer();
- if (disabledPortNumber != -1) {
- String sSiphonPortNumber = "Disabled Siphon Port Number: " + disabledPortNumber;
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "disableSiphonDebug");
- updateBroadcastIntent(sendIntent, "COMMENT1", sSiphonPortNumber);
- sendBroadcastIntent(sendIntent);
- }
- }
-
-
-
- /**
- * Public method to enable the Debug Tool
- */
- public static void enableLogTool() {
- LogTool.setSiphonServerLoggingEnabled();
- }
-
- /**
- * Public method to disable the Debug Tool
- */
- public static void disableLogTool() {
- LogTool.setSiphonServerLoggingDisabled();
- }
-
- /**
- * Public method to determine Debug Tool enabled
- */
- public static boolean isDebugEnabled() {
- return LogTool.isSiphonServerLoggingEnabled();
- }
-
-
- @Deprecated
- public void close() throws SdlException {
- dispose();
- }
-
- private void cleanProxy(SdlDisconnectedReason disconnectedReason) throws SdlException {
- try {
-
- // ALM Specific Cleanup
- if (_advancedLifecycleManagementEnabled) {
- _sdlConnectionState = SdlConnectionState.SDL_DISCONNECTED;
-
- firstTimeFull = true;
-
- // Should we wait for the interface to be unregistered?
- Boolean waitForInterfaceUnregistered = false;
- // Unregister app interface
- synchronized(CONNECTION_REFERENCE_LOCK) {
- if (sdlSession != null && sdlSession.getIsConnected() && getAppInterfaceRegistered()) {
- waitForInterfaceUnregistered = true;
- unregisterAppInterfacePrivate(UNREGISTER_APP_INTERFACE_CORRELATION_ID);
- }
- }
-
- // Wait for the app interface to be unregistered
- if (waitForInterfaceUnregistered) {
- synchronized(APP_INTERFACE_REGISTERED_LOCK) {
- try {
- APP_INTERFACE_REGISTERED_LOCK.wait(3000);
- } catch (InterruptedException e) {
- // Do nothing
- }
- }
- }
- }
-
- // Clean up SDL Connection
- synchronized(CONNECTION_REFERENCE_LOCK) {
- if (sdlSession != null) sdlSession.close();
- }
- } catch (SdlException e) {
- throw e;
- } finally {
- SdlTrace.logProxyEvent("SdlProxy cleaned.", SDL_LIB_TRACE_KEY);
- }
- }
-
- /**
- * Terminates the App's Interface Registration, closes the transport connection, ends the protocol session, and frees any resources used by the proxy.
- */
- public void dispose() throws SdlException
- {
- if (_proxyDisposed) {
- throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
- }
-
- _proxyDisposed = true;
-
- SdlTrace.logProxyEvent("Application called dispose() method.", SDL_LIB_TRACE_KEY);
-
- try{
- // Clean the proxy
- cleanProxy(SdlDisconnectedReason.APPLICATION_REQUESTED_DISCONNECT);
-
- // Close IncomingProxyMessageDispatcher thread
- synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) {
- if (_incomingProxyMessageDispatcher != null) {
- _incomingProxyMessageDispatcher.dispose();
- _incomingProxyMessageDispatcher = null;
- }
- }
-
- // Close OutgoingProxyMessageDispatcher thread
- synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) {
- if (_outgoingProxyMessageDispatcher != null) {
- _outgoingProxyMessageDispatcher.dispose();
- _outgoingProxyMessageDispatcher = null;
- }
- }
-
- // Close InternalProxyMessageDispatcher thread
- synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) {
- if (_internalProxyMessageDispatcher != null) {
- _internalProxyMessageDispatcher.dispose();
- _internalProxyMessageDispatcher = null;
- }
- }
-
- _traceDeviceInterrogator = null;
- } catch (SdlException e) {
- throw e;
- } finally {
- SdlTrace.logProxyEvent("SdlProxy disposed.", SDL_LIB_TRACE_KEY);
- }
- } // end-method
-
-
- private static Object CYCLE_LOCK = new Object();
-
- private boolean _cycling = false;
-
- // Method to cycle the proxy, only called in ALM
- protected void cycleProxy(SdlDisconnectedReason disconnectedReason) {
- if (_cycling) return;
-
- synchronized(CYCLE_LOCK)
- {
- try{
- _cycling = true;
- cleanProxy(disconnectedReason);
- initializeProxy();
- notifyProxyClosed("Sdl Proxy Cycled", new SdlException("Sdl Proxy Cycled", SdlExceptionCause.SDL_PROXY_CYCLED), disconnectedReason);
- }
- catch (SdlException e) {
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "cycleProxy");
- updateBroadcastIntent(sendIntent, "COMMENT1", "Proxy cycled, exception cause: " + e.getSdlExceptionCause());
- sendBroadcastIntent(sendIntent);
-
- switch(e.getSdlExceptionCause()) {
- case BLUETOOTH_DISABLED:
- notifyProxyClosed("Bluetooth is disabled. Bluetooth must be enabled to connect to SDL. Reattempt a connection once Bluetooth is enabled.",
- new SdlException("Bluetooth is disabled. Bluetooth must be enabled to connect to SDL. Reattempt a connection once Bluetooth is enabled.", SdlExceptionCause.BLUETOOTH_DISABLED), SdlDisconnectedReason.BLUETOOTH_DISABLED);
- break;
- case BLUETOOTH_ADAPTER_NULL:
- notifyProxyClosed("Cannot locate a Bluetooth adapater. A SDL connection is impossible on this device until a Bluetooth adapter is added.",
- new SdlException("Cannot locate a Bluetooth adapater. A SDL connection is impossible on this device until a Bluetooth adapter is added.", SdlExceptionCause.BLUETOOTH_ADAPTER_NULL), SdlDisconnectedReason.BLUETOOTH_ADAPTER_ERROR);
- break;
- default :
- notifyProxyClosed("Cycling the proxy failed.", e, SdlDisconnectedReason.GENERIC_ERROR);
- break;
- }
- } catch (Exception e) {
- notifyProxyClosed("Cycling the proxy failed.", e, SdlDisconnectedReason.GENERIC_ERROR);
- }
- _cycling = false;
- }
- }
-
-
-
- /************* Functions used by the Message Dispatching Queues ****************/
- private void dispatchIncomingMessage(ProtocolMessage message) {
- try{
- // Dispatching logic
- if (message.getSessionType().equals(SessionType.RPC)) {
- try {
- if (_wiproVersion == 1) {
- if (message.getVersion() > 1) setWiProVersion(message.getVersion());
- }
-
- Hashtable<String, Object> hash = new Hashtable<String, Object>();
- if (_wiproVersion > 1) {
- Hashtable<String, Object> hashTemp = new Hashtable<String, Object>();
- hashTemp.put(RPCMessage.KEY_CORRELATION_ID, message.getCorrID());
- if (message.getJsonSize() > 0) {
- final Hashtable<String, Object> mhash = JsonRPCMarshaller.unmarshall(message.getData());
- //hashTemp.put(Names.parameters, mhash.get(Names.parameters));
- hashTemp.put(RPCMessage.KEY_PARAMETERS, mhash);
- }
-
- String functionName = FunctionID.getFunctionName(message.getFunctionID());
- if (functionName != null) {
- hashTemp.put(RPCMessage.KEY_FUNCTION_NAME, functionName);
- } else {
- LogTool.logWarning("Dispatch Incoming Message - function name is null unknown RPC. FunctionID: " + message.getFunctionID());
- return;
- }
- if (message.getRPCType() == 0x00) {
- hash.put(RPCMessage.KEY_REQUEST, hashTemp);
- } else if (message.getRPCType() == 0x01) {
- hash.put(RPCMessage.KEY_RESPONSE, hashTemp);
- } else if (message.getRPCType() == 0x02) {
- hash.put(RPCMessage.KEY_NOTIFICATION, hashTemp);
- }
- if (message.getBulkData() != null) hash.put(RPCStruct.KEY_BULK_DATA, message.getBulkData());
- } else {
- final Hashtable<String, Object> mhash = JsonRPCMarshaller.unmarshall(message.getData());
- hash = mhash;
- }
- handleRPCMessage(hash);
- } catch (final Exception excp) {
- LogTool.logError("Failure handling protocol message: " + excp.toString(), excp);
- passErrorToProxyListener("Error handing incoming protocol message.", excp);
- } // end-catch
- } else {
- // Handle other protocol message types here
- }
- } catch (final Exception e) {
- // Pass error to application through listener
- LogTool.logError("Error handing proxy event.", e);
- passErrorToProxyListener("Error handing incoming protocol message.", e);
- }
- }
-
- private byte getWiProVersion() {
- return this._wiproVersion;
- }
-
- private void setWiProVersion(byte version) {
- this._wiproVersion = version;
- }
-
- public String serializeJSON(RPCMessage msg)
- {
- String sReturn = null;
- try
- {
- sReturn = msg.serializeJSON(getWiProVersion()).toString(2);
- }
- catch (final Exception e)
- {
- LogTool.logError("Error handing proxy event.", e);
- passErrorToProxyListener("Error serializing message.", e);
- return null;
- }
- return sReturn;
- }
-
- private void handleErrorsFromIncomingMessageDispatcher(String info, Exception e) {
- passErrorToProxyListener(info, e);
- }
-
- private void dispatchOutgoingMessage(ProtocolMessage message) {
- synchronized(CONNECTION_REFERENCE_LOCK) {
- if (sdlSession != null) {
- sdlSession.sendMessage(message);
- }
- }
- SdlTrace.logProxyEvent("SdlProxy sending Protocol Message: " + message.toString(), SDL_LIB_TRACE_KEY);
- }
-
- private void handleErrorsFromOutgoingMessageDispatcher(String info, Exception e) {
- passErrorToProxyListener(info, e);
- }
-
- void dispatchInternalMessage(final InternalProxyMessage message) {
- try{
- if (message.getFunctionName().equals(InternalProxyMessage.OnProxyError)) {
- final OnError msg = (OnError)message;
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onError(msg.getInfo(), msg.getException());
- }
- });
- } else {
- _proxyListener.onError(msg.getInfo(), msg.getException());
- }
- /**************Start Legacy Specific Call-backs************/
- } else if (message.getFunctionName().equals(InternalProxyMessage.OnProxyOpened)) {
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- ((IProxyListener)_proxyListener).onProxyOpened();
- }
- });
- } else {
- ((IProxyListener)_proxyListener).onProxyOpened();
- }
- } else if (message.getFunctionName().equals(InternalProxyMessage.OnProxyClosed)) {
- final OnProxyClosed msg = (OnProxyClosed)message;
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onProxyClosed(msg.getInfo(), msg.getException(), msg.getReason());
- }
- });
- } else {
- _proxyListener.onProxyClosed(msg.getInfo(), msg.getException(), msg.getReason());
- }
- /****************End Legacy Specific Call-backs************/
- } else {
- // Diagnostics
- SdlTrace.logProxyEvent("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.", SDL_LIB_TRACE_KEY);
- LogTool.logError("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.");
- }
-
- SdlTrace.logProxyEvent("Proxy fired callback: " + message.getFunctionName(), SDL_LIB_TRACE_KEY);
- } catch(final Exception e) {
- // Pass error to application through listener
- LogTool.logError("Error handing proxy event.", e);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onError("Error handing proxy event.", e);
- }
- });
- } else {
- _proxyListener.onError("Error handing proxy event.", e);
- }
- }
- }
-
- private void handleErrorsFromInternalMessageDispatcher(String info, Exception e) {
- LogTool.logError(info, e);
- // This error cannot be passed to the user, as it indicates an error
- // in the communication between the proxy and the application.
-
- LogTool.logError("InternalMessageDispatcher failed.", e);
-
- // Note, this is the only place where the _proxyListener should be referenced asdlhronously,
- // with an error on the internalMessageDispatcher, we have no other reliable way of
- // communicating with the application.
- notifyProxyClosed("Proxy callback dispatcher is down. Proxy instance is invalid.", e, SdlDisconnectedReason.GENERIC_ERROR);
- _proxyListener.onError("Proxy callback dispatcher is down. Proxy instance is invalid.", e);
- }
- /************* END Functions used by the Message Dispatching Queues ****************/
-
- // Private sendPRCRequest method. All RPCRequests are funneled through this method after
- // error checking.
- private void sendRPCRequestPrivate(RPCRequest request) throws SdlException {
- try {
- SdlTrace.logRPCEvent(InterfaceActivityDirection.Transmit, request, SDL_LIB_TRACE_KEY);
-
- byte[] msgBytes = JsonRPCMarshaller.marshall(request, _wiproVersion);
-
- ProtocolMessage pm = new ProtocolMessage();
- pm.setData(msgBytes);
- if (sdlSession != null)
- pm.setSessionID(sdlSession.getSessionId());
- pm.setMessageType(MessageType.RPC);
- pm.setSessionType(SessionType.RPC);
- pm.setFunctionID(FunctionID.getFunctionID(request.getFunctionName()));
- if (request.getCorrelationID() == null)
- {
- //Log error here
- throw new SdlException("CorrelationID cannot be null. RPC: " + request.getFunctionName(), SdlExceptionCause.INVALID_ARGUMENT);
- }
- pm.setCorrID(request.getCorrelationID());
- if (request.getBulkData() != null)
- pm.setBulkData(request.getBulkData());
-
- // Queue this outgoing message
- synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) {
- if (_outgoingProxyMessageDispatcher != null) {
- _outgoingProxyMessageDispatcher.queueMessage(pm);
- }
- }
- } catch (OutOfMemoryError e) {
- SdlTrace.logProxyEvent("OutOfMemory exception while sending request " + request.getFunctionName(), SDL_LIB_TRACE_KEY);
- throw new SdlException("OutOfMemory exception while sending request " + request.getFunctionName(), e, SdlExceptionCause.INVALID_ARGUMENT);
- }
- }
-
- private void handleRPCMessage(Hashtable<String, Object> hash) {
- RPCMessage rpcMsg = new RPCMessage(hash);
- String functionName = rpcMsg.getFunctionName();
- String messageType = rpcMsg.getMessageType();
-
- if (messageType.equals(RPCMessage.KEY_RESPONSE)) {
- SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, new RPCResponse(rpcMsg), SDL_LIB_TRACE_KEY);
-
- // Check to ensure response is not from an internal message (reserved correlation ID)
- if (isCorrelationIDProtected((new RPCResponse(hash)).getCorrelationID())) {
- // This is a response generated from an internal message, it can be trapped here
- // The app should not receive a response for a request it did not send
- if ((new RPCResponse(hash)).getCorrelationID() == REGISTER_APP_INTERFACE_CORRELATION_ID
- && _advancedLifecycleManagementEnabled
- && functionName.equals(FunctionID.REGISTER_APP_INTERFACE)) {
- final RegisterAppInterfaceResponse msg = new RegisterAppInterfaceResponse(hash);
- if (msg.getSuccess()) {
- _appInterfaceRegisterd = true;
- }
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.REGISTER_APP_INTERFACE);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
- updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
- updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
- updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
- updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
- updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
- sendBroadcastIntent(sendIntent);
-
- //_autoActivateIdReturned = msg.getAutoActivateID();
- /*Place holder for legacy support*/ _autoActivateIdReturned = "8675309";
- _buttonCapabilities = msg.getButtonCapabilities();
- _displayCapabilities = msg.getDisplayCapabilities();
- _softButtonCapabilities = msg.getSoftButtonCapabilities();
- _presetBankCapabilities = msg.getPresetBankCapabilities();
- _hmiZoneCapabilities = msg.getHmiZoneCapabilities();
- _speechCapabilities = msg.getSpeechCapabilities();
- _prerecordedSpeech = msg.getPrerecordedSpeech();
- _sdlLanguage = msg.getLanguage();
- _hmiDisplayLanguage = msg.getHmiDisplayLanguage();
- _sdlMsgVersion = msg.getSdlMsgVersion();
- _vrCapabilities = msg.getVrCapabilities();
- _vehicleType = msg.getVehicleType();
- _audioPassThruCapabilities = msg.getAudioPassThruCapabilities();
- _proxyVersionInfo = msg.getProxyVersionInfo();
-
- if (_bAppResumeEnabled)
- {
- if ( (msg.getResultCode() == Result.RESUME_FAILED) || (msg.getResultCode() != Result.SUCCESS) )
- {
- _bResumeSuccess = false;
- _lastHashID = null;
- }
- else if ( (_sdlMsgVersion.getMajorVersion() > 2) && (_lastHashID != null) && (msg.getResultCode() == Result.SUCCESS) )
- _bResumeSuccess = true;
- }
- _diagModes = msg.getSupportedDiagModes();
-
- String sVersionInfo = "SDL Proxy Version: " + _proxyVersionInfo;
-
- if (!isDebugEnabled())
- {
- enableLogTool();
- LogTool.logInfo(sVersionInfo, false);
- disableLogTool();
- }
- else
- LogTool.logInfo(sVersionInfo, false);
-
- sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "RAI_RESPONSE");
- updateBroadcastIntent(sendIntent, "COMMENT1", sVersionInfo);
- sendBroadcastIntent(sendIntent);
-
- // Send onSdlConnected message in ALM
- _sdlConnectionState = SdlConnectionState.SDL_CONNECTED;
-
- // If registerAppInterface failed, exit with OnProxyUnusable
- if (!msg.getSuccess()) {
- notifyProxyClosed("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: ",
- new SdlException("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: " + msg.getResultCode(), SdlExceptionCause.SDL_REGISTRATION_ERROR), SdlDisconnectedReason.SDL_REGISTRATION_ERROR);
- }
-
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- if (_proxyListener instanceof IProxyListener) {
- ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
- }
- }
- });
- } else {
- if (_proxyListener instanceof IProxyListener) {
- ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
- }
- }
- } else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID
- && functionName.equals(FunctionID.ON_ENCODED_SYNC_P_DATA)) {
-
- Log.i("pt", "POLICIES_CORRELATION_ID SystemRequest Notification (Legacy)");
-
- final OnSystemRequest msg = new OnSystemRequest(hash);
-
- // If url is not null, then send to URL
- if ( (msg.getUrl() != null) )
- {
- // URL has data, attempt to post request to external server
- Thread handleOffboardTransmissionThread = new Thread() {
- @Override
- public void run() {
- sendOnSystemRequestToUrl(msg);
- }
- };
-
- handleOffboardTransmissionThread.start();
- }
- }
- else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID
- && functionName.equals(FunctionID.ENCODED_SYNC_P_DATA)) {
-
- Log.i("pt", "POLICIES_CORRELATION_ID SystemRequest Response (Legacy)");
- final SystemRequestResponse msg = new SystemRequestResponse(hash);
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
- updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
- updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
- updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
- updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
- sendBroadcastIntent(sendIntent);
- }
- else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID
- && functionName.equals(FunctionID.SYSTEM_REQUEST)) {
- final SystemRequestResponse msg = new SystemRequestResponse(hash);
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
- updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
- updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
- updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
- updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
- updateBroadcastIntent(sendIntent, "DATA", serializeJSON(msg));
- sendBroadcastIntent(sendIntent);
- }
- else if (functionName.equals(FunctionID.UNREGISTER_APP_INTERFACE)) {
- // UnregisterAppInterface
- _appInterfaceRegisterd = false;
- synchronized(APP_INTERFACE_REGISTERED_LOCK) {
- APP_INTERFACE_REGISTERED_LOCK.notify();
- }
- final UnregisterAppInterfaceResponse msg = new UnregisterAppInterfaceResponse(hash);
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
- updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
- updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
- updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
- updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
- updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
- sendBroadcastIntent(sendIntent);
- }
- return;
- }
-
- if (functionName.equals(FunctionID.REGISTER_APP_INTERFACE)) {
- final RegisterAppInterfaceResponse msg = new RegisterAppInterfaceResponse(hash);
- if (msg.getSuccess()) {
- _appInterfaceRegisterd = true;
- }
-
- //_autoActivateIdReturned = msg.getAutoActivateID();
- /*Place holder for legacy support*/ _autoActivateIdReturned = "8675309";
- _buttonCapabilities = msg.getButtonCapabilities();
- _displayCapabilities = msg.getDisplayCapabilities();
- _softButtonCapabilities = msg.getSoftButtonCapabilities();
- _presetBankCapabilities = msg.getPresetBankCapabilities();
- _hmiZoneCapabilities = msg.getHmiZoneCapabilities();
- _speechCapabilities = msg.getSpeechCapabilities();
- _prerecordedSpeech = msg.getPrerecordedSpeech();
- _sdlLanguage = msg.getLanguage();
- _hmiDisplayLanguage = msg.getHmiDisplayLanguage();
- _sdlMsgVersion = msg.getSdlMsgVersion();
- _vrCapabilities = msg.getVrCapabilities();
- _vehicleType = msg.getVehicleType();
- _audioPassThruCapabilities = msg.getAudioPassThruCapabilities();
- _proxyVersionInfo = msg.getProxyVersionInfo();
-
- if (_bAppResumeEnabled)
- {
- if ( (msg.getResultCode() == Result.RESUME_FAILED) || (msg.getResultCode() != Result.SUCCESS) )
- {
- _bResumeSuccess = false;
- _lastHashID = null;
- }
- else if ( (_sdlMsgVersion.getMajorVersion() > 2) && (_lastHashID != null) && (msg.getResultCode() == Result.SUCCESS) )
- _bResumeSuccess = true;
- }
-
- _diagModes = msg.getSupportedDiagModes();
-
- if (!isDebugEnabled())
- {
- enableLogTool();
- LogTool.logInfo("SDL Proxy Version: " + _proxyVersionInfo);
- disableLogTool();
- }
- else
- LogTool.logInfo("SDL Proxy Version: " + _proxyVersionInfo);
-
- // RegisterAppInterface
- if (_advancedLifecycleManagementEnabled) {
-
- // Send onSdlConnected message in ALM
- _sdlConnectionState = SdlConnectionState.SDL_CONNECTED;
-
- // If registerAppInterface failed, exit with OnProxyUnusable
- if (!msg.getSuccess()) {
- notifyProxyClosed("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: ",
- new SdlException("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: " + msg.getResultCode(), SdlExceptionCause.SDL_REGISTRATION_ERROR), SdlDisconnectedReason.SDL_REGISTRATION_ERROR);
- }
- } else {
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- if (_proxyListener instanceof IProxyListener) {
- ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
- }
- }
- });
- } else {
- if (_proxyListener instanceof IProxyListener) {
- ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
- }
- }
- }
- } else if (functionName.equals(FunctionID.SPEAK)) {
- // SpeakResponse
-
- final SpeakResponse msg = new SpeakResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSpeakResponse(msg);
- }
- });
- } else {
- _proxyListener.onSpeakResponse(msg);
- }
- } else if (functionName.equals(FunctionID.ALERT)) {
- // AlertResponse
-
- final AlertResponse msg = new AlertResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onAlertResponse(msg);
- }
- });
- } else {
- _proxyListener.onAlertResponse(msg);
- }
- } else if (functionName.equals(FunctionID.SHOW)) {
- // ShowResponse
-
- final ShowResponse msg = new ShowResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onShowResponse((ShowResponse)msg);
- }
- });
- } else {
- _proxyListener.onShowResponse((ShowResponse)msg);
- }
- } else if (functionName.equals(FunctionID.ADD_COMMAND)) {
- // AddCommand
-
- final AddCommandResponse msg = new AddCommandResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onAddCommandResponse((AddCommandResponse)msg);
- }
- });
- } else {
- _proxyListener.onAddCommandResponse((AddCommandResponse)msg);
- }
- } else if (functionName.equals(FunctionID.DELETE_COMMAND)) {
- // DeleteCommandResponse
-
- final DeleteCommandResponse msg = new DeleteCommandResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onDeleteCommandResponse((DeleteCommandResponse)msg);
- }
- });
- } else {
- _proxyListener.onDeleteCommandResponse((DeleteCommandResponse)msg);
- }
- } else if (functionName.equals(FunctionID.ADD_SUB_MENU)) {
- // AddSubMenu
-
- final AddSubMenuResponse msg = new AddSubMenuResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onAddSubMenuResponse((AddSubMenuResponse)msg);
- }
- });
- } else {
- _proxyListener.onAddSubMenuResponse((AddSubMenuResponse)msg);
- }
- } else if (functionName.equals(FunctionID.DELETE_SUB_MENU)) {
- // DeleteSubMenu
-
- final DeleteSubMenuResponse msg = new DeleteSubMenuResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onDeleteSubMenuResponse((DeleteSubMenuResponse)msg);
- }
- });
- } else {
- _proxyListener.onDeleteSubMenuResponse((DeleteSubMenuResponse)msg);
- }
- } else if (functionName.equals(FunctionID.SUBSCRIBE_BUTTON)) {
- // SubscribeButton
-
- final SubscribeButtonResponse msg = new SubscribeButtonResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSubscribeButtonResponse((SubscribeButtonResponse)msg);
- }
- });
- } else {
- _proxyListener.onSubscribeButtonResponse((SubscribeButtonResponse)msg);
- }
- } else if (functionName.equals(FunctionID.UNSUBSCRIBE_BUTTON)) {
- // UnsubscribeButton
-
- final UnsubscribeButtonResponse msg = new UnsubscribeButtonResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onUnsubscribeButtonResponse((UnsubscribeButtonResponse)msg);
- }
- });
- } else {
- _proxyListener.onUnsubscribeButtonResponse((UnsubscribeButtonResponse)msg);
- }
- } else if (functionName.equals(FunctionID.SET_MEDIA_CLOCK_TIMER)) {
- // SetMediaClockTimer
-
- final SetMediaClockTimerResponse msg = new SetMediaClockTimerResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSetMediaClockTimerResponse((SetMediaClockTimerResponse)msg);
- }
- });
- } else {
- _proxyListener.onSetMediaClockTimerResponse((SetMediaClockTimerResponse)msg);
- }
- } else if (functionName.equals(FunctionID.ENCODED_SYNC_P_DATA)) {
-
- final SystemRequestResponse msg = new SystemRequestResponse(hash);
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
- updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
- updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
- updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
- updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
- sendBroadcastIntent(sendIntent);
-
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSystemRequestResponse(msg);
- }
- });
- } else {
- _proxyListener.onSystemRequestResponse(msg);
- }
- } else if (functionName.equals(FunctionID.CREATE_INTERACTION_CHOICE_SET)) {
- // CreateInteractionChoiceSet
-
- final CreateInteractionChoiceSetResponse msg = new CreateInteractionChoiceSetResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onCreateInteractionChoiceSetResponse((CreateInteractionChoiceSetResponse)msg);
- }
- });
- } else {
- _proxyListener.onCreateInteractionChoiceSetResponse((CreateInteractionChoiceSetResponse)msg);
- }
- } else if (functionName.equals(FunctionID.DELETE_INTERACTION_CHOICE_SET)) {
- // DeleteInteractionChoiceSet
-
- final DeleteInteractionChoiceSetResponse msg = new DeleteInteractionChoiceSetResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onDeleteInteractionChoiceSetResponse((DeleteInteractionChoiceSetResponse)msg);
- }
- });
- } else {
- _proxyListener.onDeleteInteractionChoiceSetResponse((DeleteInteractionChoiceSetResponse)msg);
- }
- } else if (functionName.equals(FunctionID.PERFORM_INTERACTION)) {
- // PerformInteraction
-
- final PerformInteractionResponse msg = new PerformInteractionResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onPerformInteractionResponse((PerformInteractionResponse)msg);
- }
- });
- } else {
- _proxyListener.onPerformInteractionResponse((PerformInteractionResponse)msg);
- }
- } else if (functionName.equals(FunctionID.SET_GLOBAL_PROPERTIES)) {
- // SetGlobalPropertiesResponse
-
- final SetGlobalPropertiesResponse msg = new SetGlobalPropertiesResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSetGlobalPropertiesResponse((SetGlobalPropertiesResponse)msg);
- }
- });
- } else {
- _proxyListener.onSetGlobalPropertiesResponse((SetGlobalPropertiesResponse)msg);
- }
- } else if (functionName.equals(FunctionID.RESET_GLOBAL_PROPERTIES)) {
- // ResetGlobalProperties
-
- final ResetGlobalPropertiesResponse msg = new ResetGlobalPropertiesResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onResetGlobalPropertiesResponse((ResetGlobalPropertiesResponse)msg);
- }
- });
- } else {
- _proxyListener.onResetGlobalPropertiesResponse((ResetGlobalPropertiesResponse)msg);
- }
- } else if (functionName.equals(FunctionID.UNREGISTER_APP_INTERFACE)) {
- // UnregisterAppInterface
-
- _appInterfaceRegisterd = false;
- synchronized(APP_INTERFACE_REGISTERED_LOCK) {
- APP_INTERFACE_REGISTERED_LOCK.notify();
- }
-
- final UnregisterAppInterfaceResponse msg = new UnregisterAppInterfaceResponse(hash);
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
- updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
- updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
- updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
- updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
- updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
- sendBroadcastIntent(sendIntent);
-
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- if (_proxyListener instanceof IProxyListener) {
- ((IProxyListener)_proxyListener).onUnregisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onUnregisterAppInterfaceResponse(msg);
- }
- }
- });
- } else {
- if (_proxyListener instanceof IProxyListener) {
- ((IProxyListener)_proxyListener).onUnregisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onUnregisterAppInterfaceResponse(msg);
- }
- }
-
- notifyProxyClosed("UnregisterAppInterfaceResponse", null, SdlDisconnectedReason.APP_INTERFACE_UNREG);
- } else if (functionName.equals(FunctionID.GENERIC_RESPONSE)) {
- // GenericResponse (Usually and error)
- final GenericResponse msg = new GenericResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onGenericResponse((GenericResponse)msg);
- }
- });
- } else {
- _proxyListener.onGenericResponse((GenericResponse)msg);
- }
- } else if (functionName.equals(FunctionID.SLIDER)) {
- // Slider
- final SliderResponse msg = new SliderResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSliderResponse((SliderResponse)msg);
- }
- });
- } else {
- _proxyListener.onSliderResponse((SliderResponse)msg);
- }
- } else if (functionName.equals(FunctionID.PUT_FILE)) {
- // PutFile
- final PutFileResponse msg = new PutFileResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onPutFileResponse((PutFileResponse)msg);
- }
- });
- } else {
- _proxyListener.onPutFileResponse((PutFileResponse)msg);
- }
- } else if (functionName.equals(FunctionID.DELETE_FILE)) {
- // DeleteFile
- final DeleteFileResponse msg = new DeleteFileResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onDeleteFileResponse((DeleteFileResponse)msg);
- }
- });
- } else {
- _proxyListener.onDeleteFileResponse((DeleteFileResponse)msg);
- }
- } else if (functionName.equals(FunctionID.LIST_FILES)) {
- // ListFiles
- final ListFilesResponse msg = new ListFilesResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onListFilesResponse((ListFilesResponse)msg);
- }
- });
- } else {
- _proxyListener.onListFilesResponse((ListFilesResponse)msg);
- }
- } else if (functionName.equals(FunctionID.SET_APP_ICON)) {
- // SetAppIcon
- final SetAppIconResponse msg = new SetAppIconResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSetAppIconResponse((SetAppIconResponse)msg);
- }
- });
- } else {
- _proxyListener.onSetAppIconResponse((SetAppIconResponse)msg);
- }
- } else if (functionName.equals(FunctionID.SCROLLABLE_MESSAGE)) {
- // ScrollableMessage
- final ScrollableMessageResponse msg = new ScrollableMessageResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onScrollableMessageResponse((ScrollableMessageResponse)msg);
- }
- });
- } else {
- _proxyListener.onScrollableMessageResponse((ScrollableMessageResponse)msg);
- }
- } else if (functionName.equals(FunctionID.CHANGE_REGISTRATION)) {
- // ChangeLanguageRegistration
- final ChangeRegistrationResponse msg = new ChangeRegistrationResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onChangeRegistrationResponse((ChangeRegistrationResponse)msg);
- }
- });
- } else {
- _proxyListener.onChangeRegistrationResponse((ChangeRegistrationResponse)msg);
- }
- } else if (functionName.equals(FunctionID.SET_DISPLAY_LAYOUT)) {
- // SetDisplayLayout
- final SetDisplayLayoutResponse msg = new SetDisplayLayoutResponse(hash);
-
- // successfully changed display layout - update layout capabilities
- if(msg.getSuccess()){
- _displayCapabilities = msg.getDisplayCapabilities();
- _buttonCapabilities = msg.getButtonCapabilities();
- _presetBankCapabilities = msg.getPresetBankCapabilities();
- _softButtonCapabilities = msg.getSoftButtonCapabilities();
- }
-
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSetDisplayLayoutResponse((SetDisplayLayoutResponse)msg);
- }
- });
- } else {
- _proxyListener.onSetDisplayLayoutResponse((SetDisplayLayoutResponse)msg);
- }
- } else if (functionName.equals(FunctionID.PERFORM_AUDIO_PASS_THRU)) {
- // PerformAudioPassThru
- final PerformAudioPassThruResponse msg = new PerformAudioPassThruResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onPerformAudioPassThruResponse((PerformAudioPassThruResponse)msg);
- }
- });
- } else {
- _proxyListener.onPerformAudioPassThruResponse((PerformAudioPassThruResponse)msg);
- }
- } else if (functionName.equals(FunctionID.END_AUDIO_PASS_THRU)) {
- // EndAudioPassThru
- final EndAudioPassThruResponse msg = new EndAudioPassThruResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onEndAudioPassThruResponse((EndAudioPassThruResponse)msg);
- }
- });
- } else {
- _proxyListener.onEndAudioPassThruResponse((EndAudioPassThruResponse)msg);
- }
- } else if (functionName.equals(FunctionID.SUBSCRIBE_VEHICLE_DATA)) {
- // SubscribeVehicleData
- final SubscribeVehicleDataResponse msg = new SubscribeVehicleDataResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSubscribeVehicleDataResponse((SubscribeVehicleDataResponse)msg);
- }
- });
- } else {
- _proxyListener.onSubscribeVehicleDataResponse((SubscribeVehicleDataResponse)msg);
- }
- } else if (functionName.equals(FunctionID.UNSUBSCRIBE_VEHICLE_DATA)) {
- // UnsubscribeVehicleData
- final UnsubscribeVehicleDataResponse msg = new UnsubscribeVehicleDataResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onUnsubscribeVehicleDataResponse((UnsubscribeVehicleDataResponse)msg);
- }
- });
- } else {
- _proxyListener.onUnsubscribeVehicleDataResponse((UnsubscribeVehicleDataResponse)msg);
- }
- } else if (functionName.equals(FunctionID.GET_VEHICLE_DATA)) {
- // GetVehicleData
- final GetVehicleDataResponse msg = new GetVehicleDataResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onGetVehicleDataResponse((GetVehicleDataResponse)msg);
- }
- });
- } else {
- _proxyListener.onGetVehicleDataResponse((GetVehicleDataResponse)msg);
- }
- } else if (functionName.equals(FunctionID.READ_DID)) {
- final ReadDIDResponse msg = new ReadDIDResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onReadDIDResponse((ReadDIDResponse)msg);
- }
- });
- } else {
- _proxyListener.onReadDIDResponse((ReadDIDResponse)msg);
- }
- } else if (functionName.equals(FunctionID.GET_DTCS)) {
- final GetDTCsResponse msg = new GetDTCsResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onGetDTCsResponse((GetDTCsResponse)msg);
- }
- });
- } else {
- _proxyListener.onGetDTCsResponse((GetDTCsResponse)msg);
- }
- } else if (functionName.equals(FunctionID.DIAGNOSTIC_MESSAGE)) {
- final DiagnosticMessageResponse msg = new DiagnosticMessageResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onDiagnosticMessageResponse((DiagnosticMessageResponse)msg);
- }
- });
- } else {
- _proxyListener.onDiagnosticMessageResponse((DiagnosticMessageResponse)msg);
- }
- }
- else if (functionName.equals(FunctionID.SYSTEM_REQUEST)) {
-
- final SystemRequestResponse msg = new SystemRequestResponse(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onSystemRequestResponse((SystemRequestResponse)msg);
- }
- });
- } else {
- _proxyListener.onSystemRequestResponse((SystemRequestResponse)msg);
- }
- }
- else {
- if (_sdlMsgVersion != null) {
- LogTool.logError("Unrecognized response Message: " + functionName.toString() +
- "SDL Message Version = " + _sdlMsgVersion);
- } else {
- LogTool.logError("Unrecognized response Message: " + functionName.toString());
- }
- } // end-if
- } else if (messageType.equals(RPCMessage.KEY_NOTIFICATION)) {
- SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, new RPCNotification(rpcMsg), SDL_LIB_TRACE_KEY);
- if (functionName.equals(FunctionID.ON_HMI_STATUS)) {
- // OnHMIStatus
-
- final OnHMIStatus msg = new OnHMIStatus(hash);
-
- //setup lockscreeninfo
- if (sdlSession != null)
- {
- sdlSession.getLockScreenMan().setHMILevel(msg.getHmiLevel());
- }
-
- msg.setFirstRun(Boolean.valueOf(firstTimeFull));
- if (msg.getHmiLevel() == HMILevel.HMI_FULL) firstTimeFull = false;
-
- if (msg.getHmiLevel() != _priorHmiLevel && msg.getAudioStreamingState() != _priorAudioStreamingState) {
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnHMIStatus((OnHMIStatus)msg);
- _proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
- }
- });
- } else {
- _proxyListener.onOnHMIStatus((OnHMIStatus)msg);
- _proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
- }
- }
- } else if (functionName.equals(FunctionID.ON_COMMAND)) {
- // OnCommand
-
- final OnCommand msg = new OnCommand(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnCommand((OnCommand)msg);
- }
- });
- } else {
- _proxyListener.onOnCommand((OnCommand)msg);
- }
- } else if (functionName.equals(FunctionID.ON_DRIVER_DISTRACTION)) {
- // OnDriverDistration
-
- final OnDriverDistraction msg = new OnDriverDistraction(hash);
-
- //setup lockscreeninfo
- if (sdlSession != null)
- {
- DriverDistractionState drDist = msg.getState();
- boolean bVal = false;
- if (drDist == DriverDistractionState.DD_ON)
- bVal = true;
- else
- bVal = false;
- sdlSession.getLockScreenMan().setDriverDistStatus(bVal);
- }
-
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnDriverDistraction(msg);
- _proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
- }
- });
- } else {
- _proxyListener.onOnDriverDistraction(msg);
- _proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
- }
- } else if (functionName.equals(FunctionID.ON_ENCODED_SYNC_P_DATA)) {
-
- final OnSystemRequest msg = new OnSystemRequest(hash);
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.ON_SYSTEM_REQUEST);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_NOTIFICATION);
-
- // If url is null, then send notification to the app, otherwise, send to URL
- if (msg.getUrl() == null) {
- updateBroadcastIntent(sendIntent, "COMMENT1", "URL is a null value (received)");
- sendBroadcastIntent(sendIntent);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnSystemRequest(msg);
- }
- });
- } else {
- _proxyListener.onOnSystemRequest(msg);
- }
- } else {
- updateBroadcastIntent(sendIntent, "COMMENT1", "Sending to cloud: " + msg.getUrl());
- sendBroadcastIntent(sendIntent);
-
- Log.i("pt", "send to url");
-
- if ( (msg.getUrl() != null) )
- {
- Thread handleOffboardTransmissionThread = new Thread() {
- @Override
- public void run() {
- sendOnSystemRequestToUrl(msg);
- }
- };
-
- handleOffboardTransmissionThread.start();
- }
- }
- } else if (functionName.equals(FunctionID.ON_PERMISSIONS_CHANGE)) {
- //OnPermissionsChange
-
- final OnPermissionsChange msg = new OnPermissionsChange(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnPermissionsChange(msg);
- }
- });
- } else {
- _proxyListener.onOnPermissionsChange(msg);
- }
- } else if (functionName.equals(FunctionID.ON_TBT_CLIENT_STATE)) {
- // OnTBTClientState
-
- final OnTBTClientState msg = new OnTBTClientState(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnTBTClientState(msg);
- }
- });
- } else {
- _proxyListener.onOnTBTClientState(msg);
- }
- } else if (functionName.equals(FunctionID.ON_BUTTON_PRESS)) {
- // OnButtonPress
-
- final OnButtonPress msg = new OnButtonPress(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnButtonPress((OnButtonPress)msg);
- }
- });
- } else {
- _proxyListener.onOnButtonPress((OnButtonPress)msg);
- }
- } else if (functionName.equals(FunctionID.ON_BUTTON_EVENT)) {
- // OnButtonEvent
-
- final OnButtonEvent msg = new OnButtonEvent(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnButtonEvent((OnButtonEvent)msg);
- }
- });
- } else {
- _proxyListener.onOnButtonEvent((OnButtonEvent)msg);
- }
- } else if (functionName.equals(FunctionID.ON_LANGUAGE_CHANGE)) {
- // OnLanguageChange
-
- final OnLanguageChange msg = new OnLanguageChange(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnLanguageChange((OnLanguageChange)msg);
- }
- });
- } else {
- _proxyListener.onOnLanguageChange((OnLanguageChange)msg);
- }
- } else if (functionName.equals(FunctionID.ON_HASH_CHANGE)) {
- // OnLanguageChange
-
- final OnHashChange msg = new OnHashChange(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnHashChange((OnHashChange)msg);
- if (_bAppResumeEnabled)
- {
- _lastHashID = msg.getHashID();
- }
- }
- });
- } else {
- _proxyListener.onOnHashChange((OnHashChange)msg);
- if (_bAppResumeEnabled)
- {
- _lastHashID = msg.getHashID();
- }
- }
- } else if (functionName.equals(FunctionID.ON_SYSTEM_REQUEST)) {
- // OnSystemRequest
-
- final OnSystemRequest msg = new OnSystemRequest(hash);
-
- if ( (msg.getUrl() != null) &&
- (msg.getRequestType() == RequestType.PROPRIETARY) &&
- (msg.getFileType() == FileType.JSON) )
- {
- Thread handleOffboardTransmissionThread = new Thread() {
- @Override
- public void run() {
- sendOnSystemRequestToUrl(msg);
- }
- };
-
- handleOffboardTransmissionThread.start();
- }
-
-
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnSystemRequest((OnSystemRequest)msg);
- }
- });
- } else {
- _proxyListener.onOnSystemRequest((OnSystemRequest)msg);
- }
- } else if (functionName.equals(FunctionID.ON_AUDIO_PASS_THRU)) {
- // OnAudioPassThru
- final OnAudioPassThru msg = new OnAudioPassThru(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnAudioPassThru((OnAudioPassThru)msg);
- }
- });
- } else {
- _proxyListener.onOnAudioPassThru((OnAudioPassThru)msg);
- }
- } else if (functionName.equals(FunctionID.ON_VEHICLE_DATA)) {
- // OnVehicleData
- final OnVehicleData msg = new OnVehicleData(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnVehicleData((OnVehicleData)msg);
- }
- });
- } else {
- _proxyListener.onOnVehicleData((OnVehicleData)msg);
- }
- }
- else if (functionName.equals(FunctionID.ON_APP_INTERFACE_UNREGISTERED)) {
- // OnAppInterfaceUnregistered
-
- _appInterfaceRegisterd = false;
- synchronized(APP_INTERFACE_REGISTERED_LOCK) {
- APP_INTERFACE_REGISTERED_LOCK.notify();
- }
-
- final OnAppInterfaceUnregistered msg = new OnAppInterfaceUnregistered(hash);
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.ON_APP_INTERFACE_UNREGISTERED);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_NOTIFICATION);
- updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
- sendBroadcastIntent(sendIntent);
-
- if (_advancedLifecycleManagementEnabled) {
- // This requires the proxy to be cycled
- cycleProxy(SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(msg.getReason()));
- } else {
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- ((IProxyListener)_proxyListener).onOnAppInterfaceUnregistered(msg);
- }
- });
- } else {
- ((IProxyListener)_proxyListener).onOnAppInterfaceUnregistered(msg);
- }
- notifyProxyClosed("OnAppInterfaceUnregistered", null, SdlDisconnectedReason.APP_INTERFACE_UNREG);
- }
- }
- else if (functionName.equals(FunctionID.ON_KEYBOARD_INPUT)) {
- final OnKeyboardInput msg = new OnKeyboardInput(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnKeyboardInput((OnKeyboardInput)msg);
- }
- });
- } else {
- _proxyListener.onOnKeyboardInput((OnKeyboardInput)msg);
- }
- }
- else if (functionName.equals(FunctionID.ON_TOUCH_EVENT)) {
- final OnTouchEvent msg = new OnTouchEvent(hash);
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onOnTouchEvent((OnTouchEvent)msg);
- }
- });
- } else {
- _proxyListener.onOnTouchEvent((OnTouchEvent)msg);
- }
- }
- else {
- if (_sdlMsgVersion != null) {
- LogTool.logInfo("Unrecognized notification Message: " + functionName.toString() +
- " connected to SDL using message version: " + _sdlMsgVersion.getMajorVersion() + "." + _sdlMsgVersion.getMinorVersion());
- } else {
- LogTool.logInfo("Unrecognized notification Message: " + functionName.toString());
- }
- } // end-if
- } // end-if notification
-
- SdlTrace.logProxyEvent("Proxy received RPC Message: " + functionName, SDL_LIB_TRACE_KEY);
- }
-
- /**
- * Takes an RPCRequest and sends it to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param request
- * @throws SdlException
- */
- public void sendRPCRequest(RPCRequest request) throws SdlException {
- if (_proxyDisposed) {
- throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
- }
-
- // Test if request is null
- if (request == null) {
- SdlTrace.logProxyEvent("Application called sendRPCRequest method with a null RPCRequest.", SDL_LIB_TRACE_KEY);
- throw new IllegalArgumentException("sendRPCRequest cannot be called with a null request.");
- }
-
- SdlTrace.logProxyEvent("Application called sendRPCRequest method for RPCRequest: ." + request.getFunctionName(), SDL_LIB_TRACE_KEY);
-
- // Test if SdlConnection is null
- synchronized(CONNECTION_REFERENCE_LOCK) {
- if (sdlSession == null || !sdlSession.getIsConnected()) {
- SdlTrace.logProxyEvent("Application attempted to send and RPCRequest without a connected transport.", SDL_LIB_TRACE_KEY);
- throw new SdlException("There is no valid connection to SDL. sendRPCRequest cannot be called until SDL has been connected.", SdlExceptionCause.SDL_UNAVAILABLE);
- }
- }
-
- // Test for illegal correlation ID
- if (isCorrelationIDProtected(request.getCorrelationID())) {
-
- SdlTrace.logProxyEvent("Application attempted to use the reserved correlation ID, " + request.getCorrelationID(), SDL_LIB_TRACE_KEY);
- throw new SdlException("Invalid correlation ID. The correlation ID, " + request.getCorrelationID()
- + " , is a reserved correlation ID.", SdlExceptionCause.RESERVED_CORRELATION_ID);
- }
-
- // Throw exception if RPCRequest is sent when SDL is unavailable
- if (!_appInterfaceRegisterd && !request.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE)) {
-
- SdlTrace.logProxyEvent("Application attempted to send an RPCRequest (non-registerAppInterface), before the interface was registerd.", SDL_LIB_TRACE_KEY);
- throw new SdlException("SDL is currently unavailable. RPC Requests cannot be sent.", SdlExceptionCause.SDL_UNAVAILABLE);
- }
-
- if (_advancedLifecycleManagementEnabled) {
- if (request.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE)
- || request.getFunctionName().equals(FunctionID.UNREGISTER_APP_INTERFACE)) {
-
- SdlTrace.logProxyEvent("Application attempted to send a RegisterAppInterface or UnregisterAppInterface while using ALM.", SDL_LIB_TRACE_KEY);
- throw new SdlException("The RPCRequest, " + request.getFunctionName() +
- ", is unallowed using the Advanced Lifecycle Management Model.", SdlExceptionCause.INCORRECT_LIFECYCLE_MODEL);
- }
- }
-
- sendRPCRequestPrivate(request);
- } // end-method
-
- protected void notifyProxyClosed(final String info, final Exception e, final SdlDisconnectedReason reason) {
- SdlTrace.logProxyEvent("NotifyProxyClose", SDL_LIB_TRACE_KEY);
- OnProxyClosed message = new OnProxyClosed(info, e, reason);
- queueInternalMessage(message);
- }
-
- private void passErrorToProxyListener(final String info, final Exception e) {
-
- OnError message = new OnError(info, e);
- queueInternalMessage(message);
- }
-
- private void startRPCProtocolSession(byte sessionID, String correlationID) {
-
- // Set Proxy Lifecyclek Available
- if (_advancedLifecycleManagementEnabled) {
-
- try {
- registerAppInterfacePrivate(
- _sdlMsgVersionRequest,
- _applicationName,
- _ttsName,
- _ngnMediaScreenAppName,
- _vrSynonyms,
- _isMediaApp,
- _sdlLanguageDesired,
- _hmiDisplayLanguageDesired,
- _appType,
- _appID,
- _autoActivateIdDesired,
- REGISTER_APP_INTERFACE_CORRELATION_ID);
-
- } catch (Exception e) {
- notifyProxyClosed("Failed to register application interface with SDL. Check parameter values given to SdlProxy constructor.", e, SdlDisconnectedReason.SDL_REGISTRATION_ERROR);
- }
- } else {
- InternalProxyMessage message = new InternalProxyMessage(InternalProxyMessage.OnProxyOpened);
- queueInternalMessage(message);
- }
- }
-
- // Queue internal callback message
- private void queueInternalMessage(InternalProxyMessage message) {
- synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) {
- if (_internalProxyMessageDispatcher != null) {
- _internalProxyMessageDispatcher.queueMessage(message);
- }
- }
- }
-
- // Queue incoming ProtocolMessage
- private void queueIncomingMessage(ProtocolMessage message) {
- synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) {
- if (_incomingProxyMessageDispatcher != null) {
- _incomingProxyMessageDispatcher.queueMessage(message);
- }
- }
- }
-
- public boolean startRPCStream(InputStream is, RPCRequest msg) {
- if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
- sdlConn.startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
- return true;
- }
-
- public OutputStream startRPCStream(RPCRequest msg) {
- if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
- return sdlConn.startRPCStream(msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
- }
-
- public void endRPCStream() {
- if (sdlSession == null) return;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return;
- sdlConn.stopStream();
- }
-
-
- public boolean startH264(InputStream is) {
-
- if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
-
- navServiceResponseReceived = false;
- navServiceResponse = false;
- sdlConn.startService(SessionType.NAV, sdlSession.getSessionId());
- int infiniteLoopKiller = 0;
- while (!navServiceResponseReceived && infiniteLoopKiller<2147483647) {
- infiniteLoopKiller++;
- }
- if (navServiceResponse) {
- sdlConn.startStream(is, SessionType.NAV, sdlSession.getSessionId());
- return true;
- } else {
- return false;
- }
- }
-
- public OutputStream startH264() {
-
- if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
-
- navServiceResponseReceived = false;
- navServiceResponse = false;
- sdlConn.startService(SessionType.NAV, sdlSession.getSessionId());
- int infiniteLoopKiller = 0;
- while (!navServiceResponseReceived && infiniteLoopKiller<2147483647) {
- infiniteLoopKiller++;
- }
- if (navServiceResponse) {
- return sdlConn.startStream(SessionType.NAV, sdlSession.getSessionId());
- } else {
- return null;
- }
- }
-
- public void endH264() {
- if (sdlSession == null) return;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return;
- sdlConn.endService(SessionType.NAV, sdlSession.getSessionId());
- }
-
- public boolean startPCM(InputStream is) {
- if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
-
- navServiceResponseReceived = false;
- navServiceResponse = false;
-
- sdlConn.startService(SessionType.PCM, sdlSession.getSessionId());
- int infiniteLoopKiller = 0;
- while (!navServiceResponseReceived && infiniteLoopKiller<2147483647) {
- infiniteLoopKiller++;
- }
- if (navServiceResponse) {
- sdlConn.startStream(is, SessionType.PCM, sdlSession.getSessionId());
- return true;
- } else {
- return false;
- }
- }
-
- public OutputStream startPCM() {
- if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
-
- navServiceResponseReceived = false;
- navServiceResponse = false;
- sdlConn.startService(SessionType.PCM, sdlSession.getSessionId());
- int infiniteLoopKiller = 0;
- while (!navServiceResponseReceived && infiniteLoopKiller<2147483647) {
- infiniteLoopKiller++;
- }
- if (navServiceResponse) {
- return sdlConn.startStream(SessionType.PCM, sdlSession.getSessionId());
- } else {
- return null;
- }
- }
- public void endPCM() {
- if (sdlSession == null) return;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return;
-
- sdlConn.endService(SessionType.PCM, sdlSession.getSessionId());
- }
-
- private void NavServiceStarted() {
- navServiceResponseReceived = true;
- navServiceResponse = true;
- }
-
- private void NavServiceEnded() {
- navServiceResponseReceived = true;
- navServiceResponse = false;
- }
-
- @SuppressWarnings("unused")
- private void AudioServiceStarted() {
- pcmServiceResponseReceived = true;
- pcmServiceResponse = true;
- }
-
- @SuppressWarnings("unused")
- private void AudioServiceEnded() {
- pcmServiceResponseReceived = true;
- pcmServiceResponse = false;
- }
-
- public void setAppService(Service mService)
- {
- _appService = mService;
- }
-
- /******************** Public Helper Methods *************************/
-
- /*Begin V1 Enhanced helper*/
-
- /**
- *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param parentID -Menu parent ID for optional sub value containing menu parameters.
- *@param position -Menu position for optional sub value containing menu parameters.
- *@param vrCommands -VR synonyms for this AddCommand.
- *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
- *@param IconType -Describes whether the image is static or dynamic
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Integer parentID, Integer position,
- Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
- throws SdlException {
-
- AddCommand msg = RPCRequestFactory.buildAddCommand(commandID, menuText, parentID, position,
- vrCommands, IconValue, IconType, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param position -Menu position for optional sub value containing menu parameters.
- *@param vrCommands -VR synonyms for this AddCommand.
- *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
- *@param IconType -Describes whether the image is static or dynamic
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Integer position,
- Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, menuText, null, position, vrCommands, IconValue, IconType, correlationID);
- }
-
- /**
- *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param position -Menu position for optional sub value containing menu parameters.
- *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
- *@param IconType -Describes whether the image is static or dynamic
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Integer position, String IconValue, ImageType IconType,
- Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, menuText, null, position, null, IconValue, IconType, correlationID);
- }
-
- /**
- *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
- *@param IconType -Describes whether the image is static or dynamic
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, String IconValue, ImageType IconType, Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, menuText, null, null, null, IconValue, IconType, correlationID);
- }
-
- /**
- * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param commandID -Unique command ID of the command to add.
- * @param menuText -Menu text for optional sub value containing menu parameters.
- * @param vrCommands -VR synonyms for this AddCommand.
- * @param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
- * @param IconType -Describes whether the image is static or dynamic
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, menuText, null, null, vrCommands, IconValue, IconType, correlationID);
- }
-
- /**
- * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param commandID -Unique command ID of the command to add.
- * @param vrCommands -VR synonyms for this AddCommand.
- * @param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
- * @param IconType -Describes whether the image is static or dynamic
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void addCommand(Integer commandID,
- Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, null, null, null, vrCommands, IconValue, IconType, correlationID);
- }
-
- /*End V1 Enhanced helper*/
-
- /**
- *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param parentID -Menu parent ID for optional sub value containing menu parameters.
- *@param position -Menu position for optional sub value containing menu parameters.
- *@param vrCommands -VR synonyms for this AddCommand.
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Integer parentID, Integer position,
- Vector<String> vrCommands, Integer correlationID)
- throws SdlException {
-
- AddCommand msg = RPCRequestFactory.buildAddCommand(commandID, menuText, parentID, position,
- vrCommands, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param position -Menu position for optional sub value containing menu parameters.
- *@param vrCommands -VR synonyms for this AddCommand.
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Integer position,
- Vector<String> vrCommands, Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, menuText, null, position, vrCommands, correlationID);
- }
-
- /**
- *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param position -Menu position for optional sub value containing menu parameters.
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Integer position,
- Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, menuText, null, position, null, correlationID);
- }
-
- /**
- *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Integer correlationID)
- throws SdlException {
- Vector<String> vrCommands = null;
-
- addCommand(commandID, menuText, null, null, vrCommands, correlationID);
- }
-
- /**
- * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param menuText -Menu text for optional sub value containing menu parameters.
- *@param vrCommands -VR synonyms for this AddCommand.
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- String menuText, Vector<String> vrCommands, Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, menuText, null, null, vrCommands, correlationID);
- }
-
- /**
- * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- *@param commandID -Unique command ID of the command to add.
- *@param vrCommands -VR synonyms for this AddCommand.
- *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- *@throws SdlException
- */
- public void addCommand(Integer commandID,
- Vector<String> vrCommands, Integer correlationID)
- throws SdlException {
-
- addCommand(commandID, null, null, null, vrCommands, correlationID);
- }
-
-
- /**
- * Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param menuID -Unique ID of the sub menu to add.
- * @param menuName -Text to show in the menu for this sub menu.
- * @param position -Position within the items that are are at top level of the in application menu.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void addSubMenu(Integer menuID, String menuName,
- Integer position, Integer correlationID)
- throws SdlException {
-
- AddSubMenu msg = RPCRequestFactory.buildAddSubMenu(menuID, menuName,
- position, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param menuID -Unique ID of the sub menu to add.
- * @param menuName -Text to show in the menu for this sub menu.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void addSubMenu(Integer menuID, String menuName,
- Integer correlationID) throws SdlException {
-
- addSubMenu(menuID, menuName, null, correlationID);
- }
-
- /*Begin V1 Enhanced helper*/
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param ttsText -The text to speech message in the form of a string.
- * @param alertText1 -The first line of the alert text field.
- * @param alertText2 -The second line of the alert text field.
- * @param alertText3 -The optional third line of the alert text field.
- * @param playTone -Defines if tone should be played.
- * @param duration -Timeout in milliseconds.
- * @param softButtons -A list of App defined SoftButtons.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(String ttsText, String alertText1,
- String alertText2, String alertText3, Boolean playTone, Integer duration, Vector<SoftButton> softButtons,
- Integer correlationID) throws SdlException {
-
- Alert msg = RPCRequestFactory.buildAlert(ttsText, alertText1, alertText2, alertText3, playTone, duration, softButtons, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param ttsChunks -Text/phonemes to speak in the form of ttsChunks.
- * @param alertText1 -The first line of the alert text field.
- * @param alertText2 -The second line of the alert text field.
- * @param alertText3 -The optional third line of the alert text field.
- * @param playTone -Defines if tone should be played.
- * @param duration -Timeout in milliseconds.
- * @param softButtons -A list of App defined SoftButtons.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(Vector<TTSChunk> ttsChunks,
- String alertText1, String alertText2, String alertText3, Boolean playTone,
- Integer duration, Vector<SoftButton> softButtons, Integer correlationID) throws SdlException {
-
- Alert msg = RPCRequestFactory.buildAlert(ttsChunks, alertText1, alertText2, alertText3, playTone, duration, softButtons, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param ttsText -The text to speech message in the form of a string.
- * @param playTone -Defines if tone should be played.
- * @param softButtons -A list of App defined SoftButtons.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(String ttsText, Boolean playTone, Vector<SoftButton> softButtons,
- Integer correlationID) throws SdlException {
-
- alert(ttsText, null, null, null, playTone, null, softButtons, correlationID);
- }
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param chunks -A list of text/phonemes to speak in the form of ttsChunks.
- * @param playTone -Defines if tone should be played.
- * @param softButtons -A list of App defined SoftButtons.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(Vector<TTSChunk> chunks, Boolean playTone, Vector<SoftButton> softButtons,
- Integer correlationID) throws SdlException {
-
- alert(chunks, null, null, null, playTone, null, softButtons, correlationID);
- }
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param alertText1 -The first line of the alert text field.
- * @param alertText2 -The second line of the alert text field.
- * @param alertText3 -The optional third line of the alert text field.
- * @param playTone -Defines if tone should be played.
- * @param duration -Timeout in milliseconds.
- * @param softButtons -A list of App defined SoftButtons.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(String alertText1, String alertText2, String alertText3,
- Boolean playTone, Integer duration, Vector<SoftButton> softButtons, Integer correlationID)
- throws SdlException {
-
- alert((Vector<TTSChunk>)null, alertText1, alertText2, alertText3, playTone, duration, softButtons, correlationID);
- }
-
- /*End V1 Enhanced helper*/
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param ttsText -The text to speech message in the form of a string.
- * @param alertText1 -The first line of the alert text field.
- * @param alertText2 -The second line of the alert text field.
- * @param playTone -Defines if tone should be played.
- * @param duration -Timeout in milliseconds.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(String ttsText, String alertText1,
- String alertText2, Boolean playTone, Integer duration,
- Integer correlationID) throws SdlException {
-
- Alert msg = RPCRequestFactory.buildAlert(ttsText, alertText1, alertText2,
- playTone, duration, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param ttsChunks -A list of text/phonemes to speak in the form of ttsChunks.
- * @param alertText1 -The first line of the alert text field.
- * @param alertText2 -The second line of the alert text field.
- * @param playTone -Defines if tone should be played.
- * @param duration -Timeout in milliseconds.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(Vector<TTSChunk> ttsChunks,
- String alertText1, String alertText2, Boolean playTone,
- Integer duration, Integer correlationID) throws SdlException {
-
- Alert msg = RPCRequestFactory.buildAlert(ttsChunks, alertText1, alertText2, playTone,
- duration, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param ttsText -The text to speech message in the form of a string.
- * @param playTone -Defines if tone should be played.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(String ttsText, Boolean playTone,
- Integer correlationID) throws SdlException {
-
- alert(ttsText, null, null, playTone, null, correlationID);
- }
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param chunks -A list of text/phonemes to speak in the form of ttsChunks.
- * @param playTone -Defines if tone should be played.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(Vector<TTSChunk> chunks, Boolean playTone,
- Integer correlationID) throws SdlException {
-
- alert(chunks, null, null, playTone, null, correlationID);
- }
-
- /**
- * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param alertText1 -The first line of the alert text field.
- * @param alertText2 -The second line of the alert text field.
- * @param playTone -Defines if tone should be played.
- * @param duration -Timeout in milliseconds.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void alert(String alertText1, String alertText2,
- Boolean playTone, Integer duration, Integer correlationID)
- throws SdlException {
-
- alert((Vector<TTSChunk>)null, alertText1, alertText2, playTone, duration, correlationID);
- }
-
- /**
- * Sends a CreateInteractionChoiceSet RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param choiceSet
- * @param interactionChoiceSetID
- * @param correlationID
- * @throws SdlException
- */
- public void createInteractionChoiceSet(
- Vector<Choice> choiceSet, Integer interactionChoiceSetID,
- Integer correlationID) throws SdlException {
-
- CreateInteractionChoiceSet msg = RPCRequestFactory.buildCreateInteractionChoiceSet(
- choiceSet, interactionChoiceSetID, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a DeleteCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param commandID -ID of the command(s) to delete.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void deleteCommand(Integer commandID,
- Integer correlationID) throws SdlException {
-
- DeleteCommand msg = RPCRequestFactory.buildDeleteCommand(commandID, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a DeleteInteractionChoiceSet RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param interactionChoiceSetID -ID of the interaction choice set to delete.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void deleteInteractionChoiceSet(
- Integer interactionChoiceSetID, Integer correlationID)
- throws SdlException {
-
- DeleteInteractionChoiceSet msg = RPCRequestFactory.buildDeleteInteractionChoiceSet(
- interactionChoiceSetID, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a DeleteSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param menuID -The menuID of the submenu to delete.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
- */
- public void deleteSubMenu(Integer menuID,
- Integer correlationID) throws SdlException {
-
- DeleteSubMenu msg = RPCRequestFactory.buildDeleteSubMenu(menuID, correlationID);
-
- sendRPCRequest(msg);
- }
-
-
-
- /*Begin V1 Enhanced helper*/
-
- /**
- * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
- * @param displayText -Text to be displayed first.
- * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction.
- * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performInteraction(String initPrompt,
- String displayText, Integer interactionChoiceSetID, Vector<VrHelpItem> vrHelp,
- Integer correlationID) throws SdlException {
-
- PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
- displayText, interactionChoiceSetID, vrHelp, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
- * @param displayText -Text to be displayed first.
- * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction.
- * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction.
- * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out.
- * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
- * @param timeout -Timeout in milliseconds.
- * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performInteraction(String initPrompt,
- String displayText, Integer interactionChoiceSetID,
- String helpPrompt, String timeoutPrompt,
- InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
- Integer correlationID) throws SdlException {
-
- PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
- initPrompt, displayText, interactionChoiceSetID,
- helpPrompt, timeoutPrompt, interactionMode,
- timeout, vrHelp, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
- * @param displayText -Text to be displayed first.
- * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction.
- * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction.
- * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out.
- * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
- * @param timeout -Timeout in milliseconds.
- * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performInteraction(String initPrompt,
- String displayText, Vector<Integer> interactionChoiceSetIDList,
- String helpPrompt, String timeoutPrompt,
- InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
- Integer correlationID) throws SdlException {
-
- PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
- displayText, interactionChoiceSetIDList,
- helpPrompt, timeoutPrompt, interactionMode, timeout, vrHelp,
- correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param initChunks -A list of text/phonemes to speak for the initial prompt in the form of ttsChunks.
- * @param displayText -Text to be displayed first.
- * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction.
- * @param helpChunks -A list of text/phonemes to speak for the help text that is spoken when a user speaks "help" during the interaction.
- * @param timeoutChunks A list of text/phonems to speak for the timeout text that is spoken when a VR interaction times out.
- * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
- * @param timeout -Timeout in milliseconds.
- * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performInteraction(
- Vector<TTSChunk> initChunks, String displayText,
- Vector<Integer> interactionChoiceSetIDList,
- Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks,
- InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
- Integer correlationID) throws SdlException {
-
- PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
- initChunks, displayText, interactionChoiceSetIDList,
- helpChunks, timeoutChunks, interactionMode, timeout,vrHelp,
- correlationID);
-
- sendRPCRequest(msg);
- }
-
- /*End V1 Enhanced*/
-
- /**
- * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
- * @param displayText -Text to be displayed first.
- * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performInteraction(String initPrompt,
- String displayText, Integer interactionChoiceSetID,
- Integer correlationID) throws SdlException {
-
- PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
- displayText, interactionChoiceSetID, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
- * @param displayText -Text to be displayed first.
- * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction.
- * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction.
- * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out.
- * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
- * @param timeout -Timeout in milliseconds.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performInteraction(String initPrompt,
- String displayText, Integer interactionChoiceSetID,
- String helpPrompt, String timeoutPrompt,
- InteractionMode interactionMode, Integer timeout,
- Integer correlationID) throws SdlException {
-
- PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
- initPrompt, displayText, interactionChoiceSetID,
- helpPrompt, timeoutPrompt, interactionMode,
- timeout, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
- * @param displayText -Text to be displayed first.
- * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction.
- * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction.
- * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out.
- * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
- * @param timeout -Timeout in milliseconds.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performInteraction(String initPrompt,
- String displayText, Vector<Integer> interactionChoiceSetIDList,
- String helpPrompt, String timeoutPrompt,
- InteractionMode interactionMode, Integer timeout,
- Integer correlationID) throws SdlException {
-
- PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
- displayText, interactionChoiceSetIDList,
- helpPrompt, timeoutPrompt, interactionMode, timeout,
- correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param initChunks -A list of text/phonemes to speak for the initial prompt in the form of ttsChunks.
- * @param displayText -Text to be displayed first.
- * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction.
- * @param helpChunks -A list of text/phonemes to speak for the help text that is spoken when a user speaks "help" during the interaction.
- * @param timeoutChunks A list of text/phonems to speak for the timeout text that is spoken when a VR interaction times out.
- * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
- * @param timeout -Timeout in milliseconds.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performInteraction(
- Vector<TTSChunk> initChunks, String displayText,
- Vector<Integer> interactionChoiceSetIDList,
- Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks,
- InteractionMode interactionMode, Integer timeout,
- Integer correlationID) throws SdlException {
-
- PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
- initChunks, displayText, interactionChoiceSetIDList,
- helpChunks, timeoutChunks, interactionMode, timeout,
- correlationID);
-
- sendRPCRequest(msg);
- }
-
- // Protected registerAppInterface used to ensure only non-ALM applications call
- // reqisterAppInterface
- protected void registerAppInterfacePrivate(
- SdlMsgVersion sdlMsgVersion, String appName, Vector<TTSChunk> ttsName,
- String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType,
- String appID, String autoActivateID, Integer correlationID)
- throws SdlException {
-
- RegisterAppInterface msg = RPCRequestFactory.buildRegisterAppInterface(
- sdlMsgVersion, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp,
- languageDesired, hmiDisplayLanguageDesired, appType, appID, correlationID);
-
- if (_bAppResumeEnabled)
- {
- if (_lastHashID != null)
- msg.setHashID(_lastHashID);
- }
-
- Intent sendIntent = createBroadcastIntent();
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.REGISTER_APP_INTERFACE);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_REQUEST);
- updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
- updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
- sendBroadcastIntent(sendIntent);
-
- sendRPCRequestPrivate(msg);
- }
-
- /*Begin V1 Enhanced helper function*/
-
- /**
- * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param helpPrompt
- * @param timeoutPrompt
- * @param vrHelpTitle
- * @param vrHelp
- * @param correlationID
- * @throws SdlException
- */
- public void setGlobalProperties(
- String helpPrompt, String timeoutPrompt, String vrHelpTitle, Vector<VrHelpItem> vrHelp, Integer correlationID)
- throws SdlException {
-
- SetGlobalProperties req = RPCRequestFactory.buildSetGlobalProperties(helpPrompt,
- timeoutPrompt, vrHelpTitle, vrHelp, correlationID);
-
- sendRPCRequest(req);
- }
-
- /**
- * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param helpChunks
- * @param timeoutChunks
- * @param vrHelpTitle
- * @param vrHelp
- * @param correlationID
- * @throws SdlException
- */
- public void setGlobalProperties(
- Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks, String vrHelpTitle, Vector<VrHelpItem> vrHelp,
- Integer correlationID) throws SdlException {
-
- SetGlobalProperties req = RPCRequestFactory.buildSetGlobalProperties(
- helpChunks, timeoutChunks, vrHelpTitle, vrHelp, correlationID);
-
- sendRPCRequest(req);
- }
-
- /*End V1 Enhanced helper function*/
-
- /**
- * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param helpPrompt
- * @param timeoutPrompt
- * @param correlationID
- * @throws SdlException
- */
- public void setGlobalProperties(
- String helpPrompt, String timeoutPrompt, Integer correlationID)
- throws SdlException {
-
- SetGlobalProperties req = RPCRequestFactory.buildSetGlobalProperties(helpPrompt,
- timeoutPrompt, correlationID);
-
- sendRPCRequest(req);
- }
-
- /**
- * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param helpChunks
- * @param timeoutChunks
- * @param correlationID
- * @throws SdlException
- */
- public void setGlobalProperties(
- Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks,
- Integer correlationID) throws SdlException {
-
- SetGlobalProperties req = RPCRequestFactory.buildSetGlobalProperties(
- helpChunks, timeoutChunks, correlationID);
-
- sendRPCRequest(req);
- }
-
- public void resetGlobalProperties(Vector<GlobalProperty> properties,
- Integer correlationID) throws SdlException {
-
- ResetGlobalProperties req = new ResetGlobalProperties();
-
- req.setCorrelationID(correlationID);
- req.setProperties(properties);
-
- sendRPCRequest(req);
- }
-
-
- /**
- * Sends a SetMediaClockTimer RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param hours
- * @param minutes
- * @param seconds
- * @param updateMode
- * @param correlationID
- * @throws SdlException
- */
- public void setMediaClockTimer(Integer hours,
- Integer minutes, Integer seconds, UpdateMode updateMode,
- Integer correlationID) throws SdlException {
-
- SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(hours,
- minutes, seconds, updateMode, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Pauses the media clock. Responses are captured through callback on IProxyListener.
- *
- * @param correlationID
- * @throws SdlException
- */
- public void pauseMediaClockTimer(Integer correlationID)
- throws SdlException {
-
- SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
- 0, 0, UpdateMode.PAUSE, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Resumes the media clock. Responses are captured through callback on IProxyListener.
- *
- * @param correlationID
- * @throws SdlException
- */
- public void resumeMediaClockTimer(Integer correlationID)
- throws SdlException {
-
- SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
- 0, 0, UpdateMode.RESUME, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Clears the media clock. Responses are captured through callback on IProxyListener.
- *
- * @param correlationID
- * @throws SdlException
- */
- public void clearMediaClockTimer(Integer correlationID)
- throws SdlException {
-
- Show msg = RPCRequestFactory.buildShow(null, null, null, " ", null, null, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /*Begin V1 Enhanced helper*/
- /**
- * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param mainText1 -Text displayed in a single or upper display line.
- * @param mainText2 -Text displayed on the second display line.
- * @param mainText3 -Text displayed on the second "page" first display line.
- * @param mainText4 -Text displayed on the second "page" second display line.
- * @param statusBar
- * @param mediaClock -Text value for MediaClock field.
- * @param mediaTrack -Text displayed in the track field.
- * @param graphic -Image struct determining whether static or dynamic image to display in app.
- * @param softButtons -App defined SoftButtons.
- * @param customPresets -App labeled on-screen presets.
- * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void show(String mainText1, String mainText2, String mainText3, String mainText4,
- String statusBar, String mediaClock, String mediaTrack,
- Image graphic, Vector<SoftButton> softButtons, Vector <String> customPresets,
- TextAlignment alignment, Integer correlationID)
- throws SdlException {
-
- Show msg = RPCRequestFactory.buildShow(mainText1, mainText2, mainText3, mainText4,
- statusBar, mediaClock, mediaTrack, graphic, softButtons, customPresets,
- alignment, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param mainText1 -Text displayed in a single or upper display line.
- * @param mainText2 -Text displayed on the second display line.
- * @param mainText3 -Text displayed on the second "page" first display line.
- * @param mainText4 -Text displayed on the second "page" second display line.
- * @param graphic -Image struct determining whether static or dynamic image to display in app.
- * @param softButtons -App defined SoftButtons.
- * @param customPresets -App labeled on-screen presets.
- * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void show(String mainText1, String mainText2, String mainText3, String mainText4,
- Image graphic, Vector<SoftButton> softButtons, Vector <String> customPresets,
- TextAlignment alignment, Integer correlationID)
- throws SdlException {
-
- show(mainText1, mainText2, mainText3, mainText4, null, null, null, graphic, softButtons, customPresets, alignment, correlationID);
- }
- /*End V1 Enhanced helper*/
-
- /**
- * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param mainText1 -Text displayed in a single or upper display line.
- * @param mainText2 -Text displayed on the second display line.
- * @param statusBar
- * @param mediaClock -Text value for MediaClock field.
- * @param mediaTrack -Text displayed in the track field.
- * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void show(String mainText1, String mainText2,
- String statusBar, String mediaClock, String mediaTrack,
- TextAlignment alignment, Integer correlationID)
- throws SdlException {
-
- Show msg = RPCRequestFactory.buildShow(mainText1, mainText2,
- statusBar, mediaClock, mediaTrack,
- alignment, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param mainText1 -Text displayed in a single or upper display line.
- * @param mainText2 -Text displayed on the second display line.
- * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void show(String mainText1, String mainText2,
- TextAlignment alignment, Integer correlationID)
- throws SdlException {
-
- show(mainText1, mainText2, null, null, null, alignment, correlationID);
- }
-
- /**
- * Sends a Speak RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param ttsText -The text to speech message in the form of a string.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void speak(String ttsText, Integer correlationID)
- throws SdlException {
-
- Speak msg = RPCRequestFactory.buildSpeak(TTSChunkFactory.createSimpleTTSChunks(ttsText),
- correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a Speak RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param ttsChunks -Text/phonemes to speak in the form of ttsChunks.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void speak(Vector<TTSChunk> ttsChunks,
- Integer correlationID) throws SdlException {
-
- Speak msg = RPCRequestFactory.buildSpeak(ttsChunks, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Sends a SubscribeButton RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param buttonName -Name of the button to subscribe.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void subscribeButton(ButtonName buttonName,
- Integer correlationID) throws SdlException {
-
- SubscribeButton msg = RPCRequestFactory.buildSubscribeButton(buttonName,
- correlationID);
-
- sendRPCRequest(msg);
- }
-
- // Protected unregisterAppInterface used to ensure no non-ALM app calls
- // unregisterAppInterface.
- protected void unregisterAppInterfacePrivate(Integer correlationID)
- throws SdlException {
-
- UnregisterAppInterface msg =
- RPCRequestFactory.buildUnregisterAppInterface(correlationID);
- Intent sendIntent = createBroadcastIntent();
-
- updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE);
- updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_REQUEST);
- updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
- updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
- sendBroadcastIntent(sendIntent);
-
- sendRPCRequestPrivate(msg);
- }
-
- /**
- * Sends an UnsubscribeButton RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param buttonName -Name of the button to unsubscribe.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void unsubscribeButton(ButtonName buttonName,
- Integer correlationID) throws SdlException {
-
- UnsubscribeButton msg = RPCRequestFactory.buildUnsubscribeButton(
- buttonName, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Creates a choice to be added to a choiceset. Choice has both a voice and a visual menu component.
- *
- * @param choiceID -Unique ID used to identify this choice (returned in callback).
- * @param choiceMenuName -Text name displayed for this choice.
- * @param choiceVrCommands -Vector of vrCommands used to select this choice by voice. Must contain
- * at least one non-empty element.
- * @return Choice created.
- * @throws SdlException
- */
- public Choice createChoiceSetChoice(Integer choiceID, String choiceMenuName,
- Vector<String> choiceVrCommands) {
- Choice returnChoice = new Choice();
-
- returnChoice.setChoiceID(choiceID);
- returnChoice.setMenuName(choiceMenuName);
- returnChoice.setVrCommands(choiceVrCommands);
-
- return returnChoice;
- }
-
- /**
- * Starts audio pass thru session. Responses are captured through callback on IProxyListener.
- *
- * @param initialPrompt -SDL will speak this prompt before opening the audio pass thru session.
- * @param audioPassThruDisplayText1 -First line of text displayed during audio capture.
- * @param audioPassThruDisplayText2 -Second line of text displayed during audio capture.
- * @param samplingRate -Allowable values of 8 khz or 16 or 22 or 44 khz.
- * @param maxDuration -The maximum duration of audio recording in milliseconds.
- * @param bitsPerSample -Specifies the quality the audio is recorded. Currently 8 bit or 16 bit.
- * @param audioType -Specifies the type of audio data being requested.
- * @param muteAudio -Defines if the current audio source should be muted during the APT session.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void performaudiopassthru(String initialPrompt, String audioPassThruDisplayText1, String audioPassThruDisplayText2,
- SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample,
- AudioType audioType, Boolean muteAudio, Integer correlationID) throws SdlException {
-
- PerformAudioPassThru msg = RPCRequestFactory.BuildPerformAudioPassThru(initialPrompt, audioPassThruDisplayText1, audioPassThruDisplayText2,
- samplingRate, maxDuration, bitsPerSample, audioType, muteAudio, correlationID);
- sendRPCRequest(msg);
- }
-
- /**
- * Ends audio pass thru session. Responses are captured through callback on IProxyListener.
- *
- * @param correlationID
- * @throws SdlException
- */
- public void endaudiopassthru(Integer correlationID) throws SdlException
- {
- EndAudioPassThru msg = RPCRequestFactory.BuildEndAudioPassThru(correlationID);
- sendRPCRequest(msg);
- }
-
- /**
- * Subscribes for specific published data items. The data will be only sent if it has changed.
- * Responses are captured through callback on IProxyListener.
- *
- * @param gps -Subscribes to GPS data.
- * @param speed -Subscribes to vehicle speed data in kilometers per hour.
- * @param rpm -Subscribes to number of revolutions per minute of the engine.
- * @param fuelLevel -Subscribes to fuel level in the tank (percentage).
- * @param fuelLevel_State -Subscribes to fuel level state.
- * @param instantFuelConsumption -Subscribes to instantaneous fuel consumption in microlitres.
- * @param externalTemperature -Subscribes to the external temperature in degrees celsius.
- * @param prndl -Subscribes to PRNDL data that houses the selected gear.
- * @param tirePressure -Subscribes to the TireStatus data containing status and pressure of tires.
- * @param odometer -Subscribes to Odometer data in km.
- * @param beltStatus -Subscribes to status of the seat belts.
- * @param bodyInformation -Subscribes to body information including power modes.
- * @param deviceStatus -Subscribes to device status including signal and battery strength.
- * @param driverBraking -Subscribes to the status of the brake pedal.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void subscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State,
- boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure,
- boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus,
- boolean driverBraking, Integer correlationID) throws SdlException
- {
- SubscribeVehicleData msg = RPCRequestFactory.BuildSubscribeVehicleData(gps, speed, rpm, fuelLevel, fuelLevel_State, instantFuelConsumption, externalTemperature, prndl, tirePressure,
- odometer, beltStatus, bodyInformation, deviceStatus, driverBraking, correlationID);
-
- sendRPCRequest(msg);
- }
-
- /**
- * Unsubscribes for specific published data items.
- * Responses are captured through callback on IProxyListener.
- *
- * @param gps -Unsubscribes to GPS data.
- * @param speed -Unsubscribes to vehicle speed data in kilometers per hour.
- * @param rpm -Unsubscribes to number of revolutions per minute of the engine.
- * @param fuelLevel -Unsubscribes to fuel level in the tank (percentage).
- * @param fuelLevel_State -Unsubscribes to fuel level state.
- * @param instantFuelConsumption -Unsubscribes to instantaneous fuel consumption in microlitres.
- * @param externalTemperature -Unsubscribes to the external temperature in degrees celsius.
- * @param prndl -Unsubscribes to PRNDL data that houses the selected gear.
- * @param tirePressure -Unsubscribes to the TireStatus data containing status and pressure of tires.
- * @param odometer -Unsubscribes to Odometer data in km.
- * @param beltStatus -Unsubscribes to status of the seat belts.
- * @param bodyInformation -Unsubscribes to body information including power modes.
- * @param deviceStatus -Unsubscribes to device status including signal and battery strength.
- * @param driverBraking -Unsubscribes to the status of the brake pedal.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
-
- public void unsubscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State,
- boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure,
- boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus,
- boolean driverBraking, Integer correlationID) throws SdlException
- {
- UnsubscribeVehicleData msg = RPCRequestFactory.BuildUnsubscribeVehicleData(gps, speed, rpm, fuelLevel, fuelLevel_State, instantFuelConsumption, externalTemperature, prndl, tirePressure,
- odometer, beltStatus, bodyInformation, deviceStatus, driverBraking, correlationID);
- sendRPCRequest(msg);
- }
-
-
- /**
- * Performs a Non periodic vehicle data read request.
- * Responses are captured through callback on IProxyListener.
- *
- * @param gps -Performs an ad-hoc request for GPS data.
- * @param speed -Performs an ad-hoc request for vehicle speed data in kilometers per hour.
- * @param rpm -Performs an ad-hoc request for number of revolutions per minute of the engine.
- * @param fuelLevel -Performs an ad-hoc request for fuel level in the tank (percentage).
- * @param fuelLevel_State -Performs an ad-hoc request for fuel level state.
- * @param instantFuelConsumption -Performs an ad-hoc request for instantaneous fuel consumption in microlitres.
- * @param externalTemperature -Performs an ad-hoc request for the external temperature in degrees celsius.
- * @param vin -Performs an ad-hoc request for the Vehicle identification number
- * @param prndl -Performs an ad-hoc request for PRNDL data that houses the selected gear.
- * @param tirePressure -Performs an ad-hoc request for the TireStatus data containing status and pressure of tires.
- * @param odometer -Performs an ad-hoc request for Odometer data in km.
- * @param beltStatus -Performs an ad-hoc request for status of the seat belts.
- * @param bodyInformation -Performs an ad-hoc request for body information including power modes.
- * @param deviceStatus -Performs an ad-hoc request for device status including signal and battery strength.
- * @param driverBraking -Performs an ad-hoc request for the status of the brake pedal.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void getvehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State,
- boolean instantFuelConsumption, boolean externalTemperature, boolean vin, boolean prndl, boolean tirePressure,
- boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus,
- boolean driverBraking, Integer correlationID) throws SdlException
- {
-
- GetVehicleData msg = RPCRequestFactory.BuildGetVehicleData(gps, speed, rpm, fuelLevel, fuelLevel_State, instantFuelConsumption, externalTemperature, vin, prndl, tirePressure, odometer,
- beltStatus, bodyInformation, deviceStatus, driverBraking, correlationID);
- sendRPCRequest(msg);
- }
-
-
- /**
- * Creates a full screen overlay containing a large block of formatted text that can be scrolled with up to 8 SoftButtons defined.
- * Responses are captured through callback on IProxyListener.
- *
- * @param scrollableMessageBody -Body of text that can include newlines and tabs.
- * @param timeout -App defined timeout. Indicates how long of a timeout from the last action.
- * @param softButtons -App defined SoftButtons.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void scrollablemessage(String scrollableMessageBody, Integer timeout, Vector<SoftButton> softButtons, Integer correlationID) throws SdlException
- {
- ScrollableMessage msg = RPCRequestFactory.BuildScrollableMessage(scrollableMessageBody, timeout, softButtons, correlationID);
- sendRPCRequest(msg);
- }
-
-
- /**
- * Creates a full screen or pop-up overlay (depending on platform) with a single user controlled slider.
- * Responses are captured through callback on IProxyListener.
- *
- * @param numTicks -Number of selectable items on a horizontal axis.
- * @param position -Initial position of slider control (cannot exceed numTicks).
- * @param sliderHeader -Text header to display.
- * @param sliderFooter - Text footer to display (meant to display min/max threshold descriptors).
- * @param timeout -App defined timeout. Indicates how long of a timeout from the last action.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void slider(Integer numTicks, Integer position, String sliderHeader, Vector<String> sliderFooter, Integer timeout, Integer correlationID) throws SdlException
- {
- Slider msg = RPCRequestFactory.BuildSlider(numTicks, position, sliderHeader, sliderFooter, timeout, correlationID);
- sendRPCRequest(msg);
- }
-
- /**
- * Responses are captured through callback on IProxyListener.
- *
- * @param language
- * @param hmiDisplayLanguage
- * @param correlationID
- * @throws SdlException
- */
- public void changeregistration(Language language, Language hmiDisplayLanguage, Integer correlationID) throws SdlException
- {
- ChangeRegistration msg = RPCRequestFactory.BuildChangeRegistration(language, hmiDisplayLanguage, correlationID);
- sendRPCRequest(msg);
- }
-
- /**
- * Used to push a binary stream of file data onto the module from a mobile device.
- * Responses are captured through callback on IProxyListener.
- *
- * @param is - The input stream of byte data that PutFileStream will read from
- * @param sdlFileName - The file reference name used by the putFile RPC.
- * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of the file.
- * A value greater than zero is used for resuming partial data chunks.
- * @param iLength - The total length of the file being sent.
- * @throws SdlException
- */
- public void PutFileStream(InputStream is, String sdlFileName, Integer iOffset, Integer iLength) throws SdlException
- {
- PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
- startRPCStream(is, msg);
- }
-
- /**
- * Used to push a binary stream of file data onto the module from a mobile device.
- * Responses are captured through callback on IProxyListener.
- *
- * @param sdlFileName - The file reference name used by the putFile RPC.
- * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file.
- * A value greater than zero is used for resuming partial data chunks.
- * @param iLength - The total length of the file being sent.
- *
- * @return OutputStream - The output stream of byte data that is written to by the app developer
- * @throws SdlException
- */
- public OutputStream PutFileStream(String sdlFileName, Integer iOffset, Integer iLength) throws SdlException
- {
- PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
- return startRPCStream(msg);
- }
-
- /**
- * Used to push a binary stream of file data onto the module from a mobile device.
- * Responses are captured through callback on IProxyListener.
- *
- * @param is - The input stream of byte data that PutFileStream will read from
- * @param syncFileName - The file reference name used by the putFile RPC.
- * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of the file.
- * A value greater than zero is used for resuming partial data chunks.
- * @param iLength - The total length of the file being sent.
- * @param fileType - The selected file type -- see the FileType enumeration for details
- * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles.
- * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system.
- * @throws SyncException
- */
- public void PutFileStream(InputStream is, String syncFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) throws SdlException
- {
- PutFile msg = RPCRequestFactory.buildPutFile(syncFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile);
- startRPCStream(is, msg);
- }
-
- /**
- * Used to push a binary stream of file data onto the module from a mobile device.
- * Responses are captured through callback on IProxyListener.
- *
- * @param syncFileName - The file reference name used by the putFile RPC.
- * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file.
- * A value greater than zero is used for resuming partial data chunks.
- * @param iLength - The total length of the file being sent.
- * @param fileType - The selected file type -- see the FileType enumeration for details
- * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles.
- * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system.
- * @return OutputStream - The output stream of byte data that is written to by the app developer
- * @throws SyncException
- */
- public OutputStream PutFileStream(String syncFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) throws SdlException
- {
- PutFile msg = RPCRequestFactory.buildPutFile(syncFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile);
- return startRPCStream(msg);
- }
-
- /**
- *
- * Used to end an existing PutFileStream that was previously initiated with any PutFileStream method.
- *
- */
- public void endPutFileStream()
- {
- endRPCStream();
- }
-
-
- /**
- * Used to push a binary data onto the SDL module from a mobile device, such as icons and album art. Not supported on first generation SDL vehicles.
- * Responses are captured through callback on IProxyListener.
- *
- * @param sdlFileName -File reference name.
- * @param fileType -Selected file type.
- * @param persistentFile -Indicates if the file is meant to persist between sessions / ignition cycles.
- * @param fileData
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void putfile(String sdlFileName, FileType fileType, Boolean persistentFile, byte[] fileData, Integer correlationID) throws SdlException
- {
- PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, fileType, persistentFile, fileData, correlationID);
- sendRPCRequest(msg);
- }
-
- /**
- * Used to delete a file resident on the SDL module in the app's local cache. Not supported on first generation SDL vehicles.
- * Responses are captured through callback on IProxyListener.
- *
- * @param sdlFileName -File reference name.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void deletefile(String sdlFileName, Integer correlationID) throws SdlException
- {
- DeleteFile msg = RPCRequestFactory.buildDeleteFile(sdlFileName, correlationID);
- sendRPCRequest(msg);
- }
-
- /**
- * Requests the current list of resident filenames for the registered app. Not supported on first generation SDL vehicles.
- * Responses are captured through callback on IProxyListener.
- *
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void listfiles(Integer correlationID) throws SdlException
- {
- ListFiles msg = RPCRequestFactory.buildListFiles(correlationID);
- sendRPCRequest(msg);
- }
-
- /**
- * Used to set existing local file on SDL as the app's icon. Not supported on first generation SDL vehicles.
- * Responses are captured through callback on IProxyListener.
- *
- * @param sdlFileName -File reference name.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void setappicon(String sdlFileName, Integer correlationID) throws SdlException
- {
- SetAppIcon msg = RPCRequestFactory.buildSetAppIcon(sdlFileName, correlationID);
- sendRPCRequest(msg);
- }
-
- /**
- * Set an alternate display layout. If not sent, default screen for given platform will be shown.
- * Responses are captured through callback on IProxyListener.
- *
- * @param displayLayout -Predefined or dynamically created screen layout.
- * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
- */
- public void setdisplaylayout(String displayLayout, Integer correlationID) throws SdlException
- {
- SetDisplayLayout msg = RPCRequestFactory.BuildSetDisplayLayout(displayLayout, correlationID);
- sendRPCRequest(msg);
- }
-
- /******************** END Public Helper Methods *************************/
-
- /**
- * Gets type of transport currently used by this SdlProxy.
- *
- * @return One of TransportType enumeration values.
- *
- * @see TransportType
- */
- public TransportType getCurrentTransportType() throws IllegalStateException {
- if (sdlSession == null) {
- throw new IllegalStateException("Incorrect state of SdlProxyBase: Calling for getCurrentTransportType() while connection is not initialized");
- }
-
- return sdlSession.getCurrentTransportType();
- }
-
- public String getAppName()
- {
- return _applicationName;
- }
-
- public String getNgnAppName()
- {
- return _ngnMediaScreenAppName;
- }
-
- public String getAppID()
- {
- return _appID;
- }
-
- public long getInstanceDT()
- {
- return instanceDateTime;
- }
- public void setConnectionDetails(String sDetails)
- {
- sConnectionDetails = sDetails;
- }
- public String getConnectionDetails()
- {
- return sConnectionDetails;
- }
- //for testing only
- public void setPoliciesURL(String sText)
- {
- sPoliciesURL = sText;
- }
- //for testing only
- public String getPoliciesURL()
- {
- return sPoliciesURL;
- }
-
-} // end-class
+package com.smartdevicelink.proxy;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Environment;
+import android.os.Handler;
+import android.os.Looper;
+import android.telephony.TelephonyManager;
+
+import com.smartdevicelink.proxy.RPCRequestFactory;
+import com.smartdevicelink.proxy.rpc.PutFile;
+import com.smartdevicelink.Dispatcher.IDispatchingStrategy;
+import com.smartdevicelink.Dispatcher.IncomingProtocolMessageComparitor;
+import com.smartdevicelink.Dispatcher.InternalProxyMessageComparitor;
+import com.smartdevicelink.Dispatcher.OutgoingProtocolMessageComparitor;
+import com.smartdevicelink.Dispatcher.ProxyMessageDispatcher;
+import com.smartdevicelink.SdlConnection.ISdlConnectionListener;
+import com.smartdevicelink.SdlConnection.SdlConnection;
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.exception.SdlException;
+import com.smartdevicelink.exception.SdlExceptionCause;
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.ProtocolMessage;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.protocol.enums.MessageType;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.protocol.heartbeat.HeartbeatMonitor;
+import com.smartdevicelink.proxy.callbacks.InternalProxyMessage;
+import com.smartdevicelink.proxy.callbacks.OnError;
+import com.smartdevicelink.proxy.callbacks.OnProxyClosed;
+import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
+import com.smartdevicelink.proxy.interfaces.IProxyListenerBase;
+import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener;
+import com.smartdevicelink.proxy.rpc.*;
+import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
+import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState;
+import com.smartdevicelink.proxy.rpc.enums.AudioType;
+import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
+import com.smartdevicelink.proxy.rpc.enums.ButtonName;
+import com.smartdevicelink.proxy.rpc.enums.DriverDistractionState;
+import com.smartdevicelink.proxy.rpc.enums.FileType;
+import com.smartdevicelink.proxy.rpc.enums.GlobalProperty;
+import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.ImageType;
+import com.smartdevicelink.proxy.rpc.enums.InteractionMode;
+import com.smartdevicelink.proxy.rpc.enums.Language;
+import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
+import com.smartdevicelink.proxy.rpc.enums.RequestType;
+import com.smartdevicelink.proxy.rpc.enums.Result;
+import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
+import com.smartdevicelink.proxy.rpc.enums.SdlConnectionState;
+import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
+import com.smartdevicelink.proxy.rpc.enums.SdlInterfaceAvailability;
+import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.SystemContext;
+import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
+import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
+import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
+import com.smartdevicelink.streaming.StreamRPCPacketizer;
+import com.smartdevicelink.trace.SdlTrace;
+import com.smartdevicelink.trace.TraceDeviceInfo;
+import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
+import com.smartdevicelink.transport.BaseTransportConfig;
+import com.smartdevicelink.transport.enums.TransportType;
+import com.smartdevicelink.util.SdlLog;
+
+public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> {
+
+ private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
+ private static final int PROX_PROT_VER_ONE = 1;
+
+ private SdlSession sdlSession = null;
+ private proxyListenerType _proxyListener = null;
+
+ protected Service _appService = null;
+ private String sPoliciesURL = ""; //for testing only
+
+ // Protected Correlation IDs
+ private final int REGISTER_APP_INTERFACE_CORRELATION_ID = 65529,
+ UNREGISTER_APP_INTERFACE_CORRELATION_ID = 65530,
+ POLICIES_CORRELATION_ID = 65535;
+
+ // Sdlhronization Objects
+ private static final Object CONNECTION_REFERENCE_LOCK = new Object(),
+ INCOMING_MESSAGE_QUEUE_THREAD_LOCK = new Object(),
+ OUTGOING_MESSAGE_QUEUE_THREAD_LOCK = new Object(),
+ INTERNAL_MESSAGE_QUEUE_THREAD_LOCK = new Object();
+
+ private Object APP_INTERFACE_REGISTERED_LOCK = new Object();
+
+ private int iFileCount = 0;
+
+ private boolean navServiceResponseReceived = false;
+ private boolean navServiceResponse = false;
+ @SuppressWarnings("unused")
+ private boolean pcmServiceResponseReceived = false;
+ @SuppressWarnings("unused")
+ private boolean pcmServiceResponse = false;
+
+ // Device Info for logging
+ private TraceDeviceInfo _traceDeviceInterrogator = null;
+
+ // Declare Queuing Threads
+ private ProxyMessageDispatcher<ProtocolMessage> _incomingProxyMessageDispatcher;
+ private ProxyMessageDispatcher<ProtocolMessage> _outgoingProxyMessageDispatcher;
+ private ProxyMessageDispatcher<InternalProxyMessage> _internalProxyMessageDispatcher;
+
+ // Flag indicating if callbacks should be called from UIThread
+ private Boolean _callbackToUIThread = false;
+ // UI Handler
+ private Handler _mainUIHandler = null;
+ final int HEARTBEAT_CORRELATION_ID = 65531;
+
+ // SdlProxy Advanced Lifecycle Management
+ protected Boolean _advancedLifecycleManagementEnabled = false;
+ // Parameters passed to the constructor from the app to register an app interface
+ private String _applicationName = null;
+ private long instanceDateTime = System.currentTimeMillis();
+ private String sConnectionDetails = "N/A";
+ private Vector<TTSChunk> _ttsName = null;
+ private String _ngnMediaScreenAppName = null;
+ private Boolean _isMediaApp = null;
+ private Language _sdlLanguageDesired = null;
+ private Language _hmiDisplayLanguageDesired = null;
+ private Vector<AppHMIType> _appType = null;
+ private String _appID = null;
+ private String _autoActivateIdDesired = null;
+ private String _lastHashID = null;
+ private SdlMsgVersion _sdlMsgVersionRequest = null;
+ private Vector<String> _vrSynonyms = null;
+ private boolean _bAppResumeEnabled = false;
+
+ /**
+ * Contains current configuration for the transport that was selected during
+ * construction of this object
+ */
+ private BaseTransportConfig _transportConfig = null;
+ // Proxy State Variables
+ protected Boolean _appInterfaceRegisterd = false;
+ protected Boolean _preRegisterd = false;
+ @SuppressWarnings("unused")
+ private Boolean _haveReceivedFirstNonNoneHMILevel = false;
+ protected Boolean _haveReceivedFirstFocusLevel = false;
+ protected Boolean _haveReceivedFirstFocusLevelFull = false;
+ protected Boolean _proxyDisposed = false;
+ protected SdlConnectionState _sdlConnectionState = null;
+ protected SdlInterfaceAvailability _sdlIntefaceAvailablity = null;
+ protected HMILevel _hmiLevel = null;
+ private HMILevel _priorHmiLevel = null;
+ protected AudioStreamingState _audioStreamingState = null;
+ private AudioStreamingState _priorAudioStreamingState = null;
+ protected SystemContext _systemContext = null;
+ // Variables set by RegisterAppInterfaceResponse
+ protected SdlMsgVersion _sdlMsgVersion = null;
+ protected String _autoActivateIdReturned = null;
+ protected Language _sdlLanguage = null;
+ protected Language _hmiDisplayLanguage = null;
+ protected DisplayCapabilities _displayCapabilities = null;
+ protected List<ButtonCapabilities> _buttonCapabilities = null;
+ protected List<SoftButtonCapabilities> _softButtonCapabilities = null;
+ protected PresetBankCapabilities _presetBankCapabilities = null;
+ protected List<HmiZoneCapabilities> _hmiZoneCapabilities = null;
+ protected List<SpeechCapabilities> _speechCapabilities = null;
+ protected List<PrerecordedSpeech> _prerecordedSpeech = null;
+ protected List<VrCapabilities> _vrCapabilities = null;
+ protected VehicleType _vehicleType = null;
+ protected List<AudioPassThruCapabilities> _audioPassThruCapabilities = null;
+ protected List<Integer> _diagModes = null;
+ protected Boolean firstTimeFull = true;
+ protected String _proxyVersionInfo = null;
+ protected Boolean _bResumeSuccess = false;
+
+ private CopyOnWriteArrayList<IPutFileResponseListener> _putFileListenerList = new CopyOnWriteArrayList<IPutFileResponseListener>();
+
+ protected byte _wiproVersion = 1;
+
+ // Interface broker
+ private SdlInterfaceBroker _interfaceBroker = null;
+
+ private void notifyPutFileStreamError(Exception e, String info)
+ {
+ for (IPutFileResponseListener _putFileListener : _putFileListenerList) {
+ _putFileListener.onPutFileStreamError(e, info);
+ }
+ }
+
+ private void notifyPutFileStreamResponse(PutFileResponse msg)
+ {
+ for (IPutFileResponseListener _putFileListener : _putFileListenerList) {
+ _putFileListener.onPutFileResponse(msg);
+ }
+ }
+
+ public void addPutFileResponseListener(IPutFileResponseListener _putFileListener)
+ {
+ _putFileListenerList.addIfAbsent(_putFileListener);
+ }
+
+ public void remPutFileResponseListener(IPutFileResponseListener _putFileListener)
+ {
+ _putFileListenerList.remove(_putFileListener);
+ }
+
+ // Private Class to Interface with SdlConnection
+ private class SdlInterfaceBroker implements ISdlConnectionListener {
+
+ @Override
+ public void onTransportDisconnected(String info) {
+ // proxyOnTransportDisconnect is called to alert the proxy that a requested
+ // disconnect has completed
+ notifyPutFileStreamError(null, info);
+
+ if (_advancedLifecycleManagementEnabled) {
+ // If ALM, nothing is required to be done here
+ } else {
+ // If original model, notify app the proxy is closed so it will delete and reinstanciate
+ notifyProxyClosed(info, new SdlException("Transport disconnected.", SdlExceptionCause.SDL_UNAVAILABLE), SdlDisconnectedReason.TRANSPORT_DISCONNECT);
+ }
+ }
+
+ @Override
+ public void onTransportError(String info, Exception e) {
+ SdlLog.e("Transport failure: " + info, e);
+
+ notifyPutFileStreamError(e, info);
+
+ if (_advancedLifecycleManagementEnabled) {
+ // Cycle the proxy
+ cycleProxy(SdlDisconnectedReason.TRANSPORT_ERROR);
+ } else {
+ notifyProxyClosed(info, e, SdlDisconnectedReason.TRANSPORT_ERROR);
+ }
+ }
+
+ @Override
+ public void onProtocolMessageReceived(ProtocolMessage msg) {
+
+ // AudioPathThrough is coming WITH BulkData but WITHOUT JSON Data
+ // Policy Snapshot is coming WITH BulkData and WITH JSON Data
+ if ((msg.getData() != null && msg.getData().length > 0) ||
+ (msg.getBulkData() != null && msg.getBulkData().length > 0)) {
+ queueIncomingMessage(msg);
+ }
+ }
+
+ @Override
+ public void onProtocolSessionStarted(SessionType sessionType,
+ byte sessionID, byte version, String correlationID) {
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "onProtocolSessionStarted");
+ updateBroadcastIntent(sendIntent, "COMMENT1", "SessionID: " + sessionID);
+ updateBroadcastIntent(sendIntent, "COMMENT2", " SessionType: " + sessionType.getName());
+ sendBroadcastIntent(sendIntent);
+
+ setWiProVersion(version);
+
+ if ( (_transportConfig.getHeartBeatTimeout() != Integer.MAX_VALUE) && (version > 2) )
+ {
+ HeartbeatMonitor heartbeatMonitor = new HeartbeatMonitor();
+ heartbeatMonitor.setInterval(_transportConfig.getHeartBeatTimeout());
+ sdlSession.setHeartbeatMonitor(heartbeatMonitor);
+ }
+
+ if (sessionType.eq(SessionType.RPC)) {
+ startRPCProtocolSession(sessionID, correlationID);
+ } else if (sessionType.eq(SessionType.NAV)) {
+ NavServiceStarted();
+ } else if (_wiproVersion > 1) {
+ //If version is 2 or above then don't need to specify a Session Type
+ startRPCProtocolSession(sessionID, correlationID);
+ } else {
+ // Handle other protocol session types here
+ }
+ }
+
+ @Override
+ public void onProtocolSessionNACKed(SessionType sessionType,
+ byte sessionID, byte version, String correlationID) {
+ if (sessionType.eq(SessionType.NAV)) {
+ NavServiceEnded();
+ }
+ }
+
+ @Override
+ public void onProtocolSessionEnded(SessionType sessionType,
+ byte sessionID, String correlationID) {
+ // How to handle protocol session ended?
+ // How should protocol session management occur?
+ }
+
+ @Override
+ public void onProtocolError(String info, Exception e) {
+ notifyPutFileStreamError(e, info);
+ passErrorToProxyListener(info, e);
+ }
+
+ @Override
+ public void onHeartbeatTimedOut(byte sessionID) {
+ final String msg = "Heartbeat timeout";
+ SdlLog.i(msg);
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "onHeartbeatTimedOut");
+ updateBroadcastIntent(sendIntent, "COMMENT1", "Heartbeat timeout for SessionID: " + sessionID);
+ sendBroadcastIntent(sendIntent);
+
+ notifyProxyClosed(msg, new SdlException(msg, SdlExceptionCause.HEARTBEAT_PAST_DUE), SdlDisconnectedReason.HB_TIMEOUT);
+
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param listener Type of listener for this proxy base.
+ * @param sdlProxyConfigurationResources Configuration resources for this proxy.
+ * @param enableAdvancedLifecycleManagement Flag that ALM should be enabled or not.
+ * @param appName Client application name.
+ * @param ttsName TTS name.
+ * @param ngnMediaScreenAppName Media Screen Application name.
+ * @param vrSynonyms List of synonyms.
+ * @param isMediaApp Flag that indicates that client application if media application or not.
+ * @param sdlMsgVersion Version of Sdl Message.
+ * @param languageDesired Desired language.
+ * @param hmiDisplayLanguageDesired Desired language for HMI.
+ * @param appType Type of application.
+ * @param appID Application identifier.
+ * @param autoActivateID Auto activation identifier.
+ * @param callbackToUIThread Flag that indicates that this proxy should send callback to UI thread or not.
+ * @param transportConfig Configuration of transport to be used by underlying connection.
+ * @throws SdlException
+ */
+ protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
+ String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID,
+ String autoActivateID, boolean callbackToUIThread, BaseTransportConfig transportConfig)
+ throws SdlException {
+
+ performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp,
+ sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, callbackToUIThread, null, null, null, transportConfig);
+ }
+
+ private void performBaseCommon(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
+ String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID,
+ String autoActivateID, boolean callbackToUIThread, Boolean preRegister, String sHashID, Boolean bAppResumeEnab,
+ BaseTransportConfig transportConfig) throws SdlException
+ {
+ setWiProVersion((byte)PROX_PROT_VER_ONE);
+
+ if (preRegister != null && preRegister)
+ {
+ _appInterfaceRegisterd = preRegister;
+ _preRegisterd = preRegister;
+ }
+
+ if (bAppResumeEnab != null && bAppResumeEnab)
+ {
+ _bAppResumeEnabled = true;
+ _lastHashID = sHashID;
+ }
+ _interfaceBroker = new SdlInterfaceBroker();
+
+ _callbackToUIThread = callbackToUIThread;
+
+ if (_callbackToUIThread) {
+ _mainUIHandler = new Handler(Looper.getMainLooper());
+ }
+
+ // Set variables for Advanced Lifecycle Management
+ _advancedLifecycleManagementEnabled = enableAdvancedLifecycleManagement;
+ _applicationName = appName;
+ _ttsName = ttsName;
+ _ngnMediaScreenAppName = ngnMediaScreenAppName;
+ _isMediaApp = isMediaApp;
+ _sdlMsgVersionRequest = sdlMsgVersion;
+ _vrSynonyms = vrSynonyms;
+ _sdlLanguageDesired = languageDesired;
+ _hmiDisplayLanguageDesired = hmiDisplayLanguageDesired;
+ _appType = appType;
+ _appID = appID;
+ _autoActivateIdDesired = autoActivateID;
+ _transportConfig = transportConfig;
+
+ // Test conditions to invalidate the proxy
+ if (listener == null) {
+ throw new IllegalArgumentException("IProxyListener listener must be provided to instantiate SdlProxy object.");
+ }
+ if (_advancedLifecycleManagementEnabled) {
+ /* if (_applicationName == null ) {
+ throw new IllegalArgumentException("To use SdlProxyALM, an application name, appName, must be provided");
+ }
+ if (_applicationName.length() < 1 || _applicationName.length() > 100) {
+ throw new IllegalArgumentException("A provided application name, appName, must be between 1 and 100 characters in length.");
+ }*/
+ if (_isMediaApp == null) {
+ throw new IllegalArgumentException("isMediaApp must not be null when using SdlProxyALM.");
+ }
+ }
+
+ _proxyListener = listener;
+
+ // Get information from sdlProxyConfigurationResources
+ TelephonyManager telephonyManager = null;
+ if (sdlProxyConfigurationResources != null) {
+ telephonyManager = sdlProxyConfigurationResources.getTelephonyManager();
+ }
+
+ // Use the telephonyManager to get and log phone info
+ if (telephonyManager != null) {
+ // Following is not quite thread-safe (because m_traceLogger could test null twice),
+ // so we need to fix this, but vulnerability (i.e. two instances of listener) is
+ // likely harmless.
+ if (_traceDeviceInterrogator == null) {
+ _traceDeviceInterrogator = new TraceDeviceInfo(sdlProxyConfigurationResources.getTelephonyManager());
+ } // end-if
+ } // end-if
+
+ // Setup Internal ProxyMessage Dispatcher
+ synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) {
+ // Ensure internalProxyMessageDispatcher is null
+ if (_internalProxyMessageDispatcher != null) {
+ _internalProxyMessageDispatcher.dispose();
+ _internalProxyMessageDispatcher = null;
+ }
+
+ _internalProxyMessageDispatcher = new ProxyMessageDispatcher<InternalProxyMessage>("INTERNAL_MESSAGE_DISPATCHER",
+ new InternalProxyMessageComparitor(),
+ new IDispatchingStrategy<InternalProxyMessage>() {
+
+ @Override
+ public void dispatch(InternalProxyMessage message) {
+ dispatchInternalMessage((InternalProxyMessage)message);
+ }
+
+ @Override
+ public void handleDispatchingError(String info, Exception ex) {
+ handleErrorsFromInternalMessageDispatcher(info, ex);
+ }
+
+ @Override
+ public void handleQueueingError(String info, Exception ex) {
+ handleErrorsFromInternalMessageDispatcher(info, ex);
+ }
+ });
+ }
+
+ // Setup Incoming ProxyMessage Dispatcher
+ synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) {
+ // Ensure incomingProxyMessageDispatcher is null
+ if (_incomingProxyMessageDispatcher != null) {
+ _incomingProxyMessageDispatcher.dispose();
+ _incomingProxyMessageDispatcher = null;
+ }
+
+ _incomingProxyMessageDispatcher = new ProxyMessageDispatcher<ProtocolMessage>("INCOMING_MESSAGE_DISPATCHER",
+ new IncomingProtocolMessageComparitor(),
+ new IDispatchingStrategy<ProtocolMessage>() {
+ @Override
+ public void dispatch(ProtocolMessage message) {
+ dispatchIncomingMessage((ProtocolMessage)message);
+ }
+
+ @Override
+ public void handleDispatchingError(String info, Exception ex) {
+ handleErrorsFromIncomingMessageDispatcher(info, ex);
+ }
+
+ @Override
+ public void handleQueueingError(String info, Exception ex) {
+ handleErrorsFromIncomingMessageDispatcher(info, ex);
+ }
+ });
+ }
+
+ // Setup Outgoing ProxyMessage Dispatcher
+ synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) {
+ // Ensure outgoingProxyMessageDispatcher is null
+ if (_outgoingProxyMessageDispatcher != null) {
+ _outgoingProxyMessageDispatcher.dispose();
+ _outgoingProxyMessageDispatcher = null;
+ }
+
+ _outgoingProxyMessageDispatcher = new ProxyMessageDispatcher<ProtocolMessage>("OUTGOING_MESSAGE_DISPATCHER",
+ new OutgoingProtocolMessageComparitor(),
+ new IDispatchingStrategy<ProtocolMessage>() {
+ @Override
+ public void dispatch(ProtocolMessage message) {
+ dispatchOutgoingMessage((ProtocolMessage)message);
+ }
+
+ @Override
+ public void handleDispatchingError(String info, Exception ex) {
+ handleErrorsFromOutgoingMessageDispatcher(info, ex);
+ }
+
+ @Override
+ public void handleQueueingError(String info, Exception ex) {
+ handleErrorsFromOutgoingMessageDispatcher(info, ex);
+ }
+ });
+ }
+
+ // Initialize the proxy
+ try {
+ initializeProxy();
+ } catch (SdlException e) {
+ // Couldn't initialize the proxy
+ // Dispose threads and then rethrow exception
+
+ if (_internalProxyMessageDispatcher != null) {
+ _internalProxyMessageDispatcher.dispose();
+ _internalProxyMessageDispatcher = null;
+ }
+ if (_incomingProxyMessageDispatcher != null) {
+ _incomingProxyMessageDispatcher.dispose();
+ _incomingProxyMessageDispatcher = null;
+ }
+ if (_outgoingProxyMessageDispatcher != null) {
+ _outgoingProxyMessageDispatcher.dispose();
+ _outgoingProxyMessageDispatcher = null;
+ }
+ throw e;
+ }
+
+ // Trace that ctor has fired
+ SdlTrace.logProxyEvent("SdlProxy Created, instanceID=" + this.toString(), SDL_LIB_TRACE_KEY);
+ }
+
+ protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
+ String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID,
+ String autoActivateID, boolean callbackToUIThread, boolean preRegister, String sHashID, Boolean bEnableResume, BaseTransportConfig transportConfig)
+ throws SdlException
+ {
+ performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp,
+ sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, callbackToUIThread, preRegister, sHashID, bEnableResume, transportConfig);
+ }
+
+
+
+ /**
+ * Constructor.
+ *
+ * @param listener Type of listener for this proxy base.
+ * @param sdlProxyConfigurationResources Configuration resources for this proxy.
+ * @param enableAdvancedLifecycleManagement Flag that ALM should be enabled or not.
+ * @param appName Client application name.
+ * @param ttsName TTS name.
+ * @param ngnMediaScreenAppName Media Screen Application name.
+ * @param vrSynonyms List of synonyms.
+ * @param isMediaApp Flag that indicates that client application if media application or not.
+ * @param sdlMsgVersion Version of Sdl Message.
+ * @param languageDesired Desired language.
+ * @param hmiDisplayLanguageDesired Desired language for HMI.
+ * @param appType Type of application.
+ * @param appID Application identifier.
+ * @param autoActivateID Auto activation identifier.
+ * @param callbackToUIThread Flag that indicates that this proxy should send callback to UI thread or not.
+ * @param preRegister Flag that indicates that this proxy should be pre-registerd or not.
+ * @param transportConfig Configuration of transport to be used by underlying connection.
+ * @throws SdlException
+ */
+ protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
+ String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType, String appID,
+ String autoActivateID, boolean callbackToUIThread, boolean preRegister, BaseTransportConfig transportConfig)
+ throws SdlException
+ {
+ performBaseCommon(listener, sdlProxyConfigurationResources, enableAdvancedLifecycleManagement, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp,
+ sdlMsgVersion, languageDesired, hmiDisplayLanguageDesired, appType, appID, autoActivateID, callbackToUIThread, preRegister, null, null, transportConfig);
+ }
+
+ private Intent createBroadcastIntent()
+ {
+ Intent sendIntent = new Intent();
+ sendIntent.setAction("com.smartdevicelink.broadcast");
+ sendIntent.putExtra("APP_NAME", this._applicationName);
+ sendIntent.putExtra("APP_ID", this._appID);
+ sendIntent.putExtra("RPC_NAME", "");
+ sendIntent.putExtra("TYPE", "");
+ sendIntent.putExtra("SUCCESS", true);
+ sendIntent.putExtra("CORRID", 0);
+ sendIntent.putExtra("FUNCTION_NAME", "");
+ sendIntent.putExtra("COMMENT1", "");
+ sendIntent.putExtra("COMMENT2", "");
+ sendIntent.putExtra("COMMENT3", "");
+ sendIntent.putExtra("COMMENT4", "");
+ sendIntent.putExtra("COMMENT5", "");
+ sendIntent.putExtra("COMMENT6", "");
+ sendIntent.putExtra("COMMENT7", "");
+ sendIntent.putExtra("COMMENT8", "");
+ sendIntent.putExtra("COMMENT9", "");
+ sendIntent.putExtra("COMMENT10", "");
+ sendIntent.putExtra("DATA", "");
+ sendIntent.putExtra("SHOW_ON_UI", true);
+ return sendIntent;
+ }
+ private void updateBroadcastIntent(Intent sendIntent, String sKey, String sValue)
+ {
+ if (sValue == null) sValue = "";
+ sendIntent.putExtra(sKey, sValue);
+ }
+ private void updateBroadcastIntent(Intent sendIntent, String sKey, boolean bValue)
+ {
+ sendIntent.putExtra(sKey, bValue);
+ }
+ private void updateBroadcastIntent(Intent sendIntent, String sKey, int iValue)
+ {
+ sendIntent.putExtra(sKey, iValue);
+ }
+
+ private void sendBroadcastIntent(Intent sendIntent)
+ {
+ Service myService = null;
+ if (_proxyListener != null && _proxyListener instanceof Service)
+ {
+ myService = (Service) _proxyListener;
+ }
+ else if (_appService != null)
+ {
+ myService = _appService;
+ }
+ else
+ {
+ return;
+ }
+ try
+ {
+ Context myContext = myService.getApplicationContext();
+ if (myContext != null) myContext.sendBroadcast(sendIntent);
+ }
+ catch(Exception ex)
+ {
+ //If the service or context has become unavailable unexpectedly, catch the exception and move on -- no broadcast log will occur.
+ }
+ }
+
+ private void writeToFile(Object writeME, String fileName) {
+ Intent sendIntent = createBroadcastIntent();
+ try {
+ updateBroadcastIntent(sendIntent,"FUNCTION_NAME", "writeToFile");
+ updateBroadcastIntent(sendIntent, "SHOW_ON_UI", false);
+
+ String sFileName = fileName + "_" + iFileCount + ".txt";
+ String outFile = Environment.getExternalStorageDirectory().getPath() + "/" + sFileName;
+ File out = new File(outFile);
+ FileWriter writer = new FileWriter(out);
+ writer.flush();
+ writer.write(writeME.toString());
+ writer.close();
+ updateBroadcastIntent(sendIntent, "COMMENT1", outFile);
+ } catch (FileNotFoundException e) {
+ updateBroadcastIntent(sendIntent, "COMMENT2", "writeToFile FileNotFoundException " + e);
+ SdlLog.i("FileNotFoundException: " + e);
+ e.printStackTrace();
+ } catch (IOException e) {
+ updateBroadcastIntent(sendIntent, "COMMENT2", "writeToFile IOException " + e);
+ SdlLog.i("IOException: " + e);
+ e.printStackTrace();
+ }
+ finally
+ {
+ sendBroadcastIntent(sendIntent);
+ }
+ }
+
+ private void LogHeader(String sType, final String myObject, String sFuncName)
+ {
+ Intent sendIntent = createBroadcastIntent();
+
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", sFuncName);
+
+ updateBroadcastIntent(sendIntent, "COMMENT1", sType + "\r\n");
+ updateBroadcastIntent(sendIntent, "DATA", myObject);
+ sendBroadcastIntent(sendIntent);
+ }
+
+
+ private HttpURLConnection getURLConnection(Headers myHeader, String sURLString, int Timeout, int iContentLen)
+ {
+ String sContentType = "application/json";
+ int CONNECTION_TIMEOUT = Timeout * 1000;
+ int READ_TIMEOUT = Timeout * 1000;
+ boolean bDoOutput = true;
+ boolean bDoInput = true;
+ boolean bUsesCaches = false;
+ String sRequestMeth = "POST";
+
+ boolean bInstFolRed = false;
+ String sCharSet = "utf-8";
+ int iContentLength = iContentLen;
+
+ URL url = null;
+ HttpURLConnection urlConnection = null;
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "getURLConnection");
+ updateBroadcastIntent(sendIntent, "COMMENT1", "Actual Content Length: " + iContentLen);
+
+ if (myHeader != null)
+ {
+ //if the header isn't null, use it and replace the hardcoded params
+ int iTimeout;
+ int iReadTimeout;
+ sContentType = myHeader.getContentType();
+ iTimeout = myHeader.getConnectTimeout();
+ bDoOutput = myHeader.getDoOutput();
+ bDoInput = myHeader.getDoInput();
+ bUsesCaches = myHeader.getUseCaches();
+ sRequestMeth = myHeader.getRequestMethod();
+ iReadTimeout = myHeader.getReadTimeout();
+ bInstFolRed = myHeader.getInstanceFollowRedirects();
+ sCharSet = myHeader.getCharset();
+ iContentLength = myHeader.getContentLength();
+ CONNECTION_TIMEOUT = iTimeout*1000;
+ READ_TIMEOUT = iReadTimeout*1000;
+ updateBroadcastIntent(sendIntent, "COMMENT2", "\nHeader Defined Content Length: " + iContentLength);
+ }
+
+ try
+ {
+ url = new URL(sURLString);
+ urlConnection = (HttpURLConnection) url.openConnection();
+ urlConnection.setConnectTimeout(CONNECTION_TIMEOUT);
+ urlConnection.setDoOutput(bDoOutput);
+ urlConnection.setDoInput(bDoInput);
+ urlConnection.setRequestMethod(sRequestMeth);
+ urlConnection.setReadTimeout(READ_TIMEOUT);
+ urlConnection.setInstanceFollowRedirects(bInstFolRed);
+ urlConnection.setRequestProperty("Content-Type", sContentType);
+ urlConnection.setRequestProperty("charset", sCharSet);
+ urlConnection.setRequestProperty("Content-Length", "" + Integer.toString(iContentLength));
+ urlConnection.setUseCaches(bUsesCaches);
+ return urlConnection;
+ }
+ catch (Exception e)
+ {
+ return null;
+ }
+ finally
+ {
+ sendBroadcastIntent(sendIntent);
+ }
+ }
+
+
+ private void sendOnSystemRequestToUrl(OnSystemRequest msg)
+ {
+ Intent sendIntent = createBroadcastIntent();
+ Intent sendIntent2 = createBroadcastIntent();
+
+ HttpURLConnection urlConnection = null;
+ boolean bLegacy = false;
+
+ String sURLString;
+ if (!getPoliciesURL().equals(""))
+ sURLString = sPoliciesURL;
+ else
+ sURLString = msg.getUrl();
+
+ Integer iTimeout = msg.getTimeout();
+
+ if (iTimeout == null)
+ iTimeout = 2000;
+
+ Headers myHeader = msg.getHeader();
+ String sFunctionName = "SYSTEM_REQUEST";
+
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "sendOnSystemRequestToUrl");
+ updateBroadcastIntent(sendIntent, "COMMENT5", "\r\nCloud URL: " + sURLString);
+
+ try
+ {
+ if (myHeader == null)
+ updateBroadcastIntent(sendIntent, "COMMENT7", "\r\nHTTPRequest Header is null");
+
+ String sBodyString = msg.getBody();
+
+ JSONObject jsonObjectToSendToServer;
+ String valid_json;
+
+ if (sBodyString == null)
+ {
+ List<String> legacyData = msg.getLegacyData();
+ JSONArray jsonArrayOfSdlPPackets = new JSONArray(legacyData);
+ jsonObjectToSendToServer = new JSONObject();
+ jsonObjectToSendToServer.put("data", jsonArrayOfSdlPPackets);
+ bLegacy = true;
+ sFunctionName = "SYSTEM_REQUEST_LEGACY";
+ updateBroadcastIntent(sendIntent, "COMMENT6", "\r\nLegacy SystemRequest: true");
+ valid_json = jsonObjectToSendToServer.toString().replace("\\", "");
+ }
+ else
+ {
+ Intent sendIntent3 = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent3, "FUNCTION_NAME", "replace");
+ updateBroadcastIntent(sendIntent3, "COMMENT1", "Valid Json length before replace: " + sBodyString.getBytes("UTF-8").length);
+ sendBroadcastIntent(sendIntent3);
+ valid_json = sBodyString.replace("\\", "");
+ }
+
+ writeToFile(valid_json, "requestToCloud");
+ LogHeader("Cloud Request", valid_json, sFunctionName);
+
+ urlConnection = getURLConnection(myHeader, sURLString, iTimeout, valid_json.getBytes("UTF-8").length);
+
+ if (urlConnection == null)
+ {
+ SdlLog.i("urlConnection is null, check RPC input parameters");
+ updateBroadcastIntent(sendIntent, "COMMENT2", "urlConnection is null, check RPC input parameters");
+ return;
+ }
+
+ DataOutputStream wr = new DataOutputStream(urlConnection.getOutputStream());
+ wr.writeBytes(valid_json);
+ wr.flush();
+ wr.close();
+
+
+ long BeforeTime = System.currentTimeMillis();
+ @SuppressWarnings("unused")
+ String sResponseMsg = urlConnection.getResponseMessage();
+ long AfterTime = System.currentTimeMillis();
+ final long roundtriptime = AfterTime - BeforeTime;
+
+ updateBroadcastIntent(sendIntent, "COMMENT4", " Round trip time: " + roundtriptime);
+ updateBroadcastIntent(sendIntent, "COMMENT1", "Received response from cloud, response code=" + urlConnection.getResponseCode() + " ");
+
+ int iResponseCode = urlConnection.getResponseCode();
+
+ if (iResponseCode != HttpURLConnection.HTTP_OK)
+ {
+ SdlLog.i("Response code not HTTP_OK, returning from sendOnSystemRequestToUrl.");
+ updateBroadcastIntent(sendIntent, "COMMENT2", "Response code not HTTP_OK, aborting request. ");
+ return;
+ }
+
+ InputStream is = urlConnection.getInputStream();
+ BufferedReader rd = new BufferedReader(new InputStreamReader(is));
+ String line;
+ StringBuffer response = new StringBuffer();
+ while((line = rd.readLine()) != null)
+ {
+ response.append(line);
+ response.append('\r');
+ }
+ rd.close();
+ SdlLog.i("response: " + response.toString());
+
+ writeToFile(response.toString(), "responseFromCloud");
+
+ LogHeader("Cloud Response", response.toString(), sFunctionName);
+
+ Vector<String> cloudDataReceived = new Vector<String>();
+
+ // Convert the response to JSON
+ JSONObject jsonResponse = new JSONObject(response.toString());
+ if (jsonResponse.get("data") instanceof JSONArray)
+ {
+ JSONArray jsonArray = jsonResponse.getJSONArray("data");
+ for (int i=0; i<jsonArray.length(); i++)
+ {
+ if (jsonArray.get(i) instanceof String)
+ {
+ cloudDataReceived.add(jsonArray.getString(i));
+ }
+ }
+ }
+ else if (jsonResponse.get("data") instanceof String)
+ {
+ cloudDataReceived.add(jsonResponse.getString("data"));
+ }
+ else
+ {
+ SdlLog.e("sendOnSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
+ return;
+ }
+
+ String sResponse = cloudDataReceived.toString();
+
+ if (sResponse.length() > 512)
+ {
+ sResponse = sResponse.substring(0, 511);
+ }
+
+ updateBroadcastIntent(sendIntent, "DATA", "Data from cloud response: " + sResponse);
+
+ // Send new SystemRequest to SDL
+ SystemRequest mySystemRequest;
+
+ if (bLegacy)
+ mySystemRequest = RPCRequestFactory.buildSystemRequestLegacy(cloudDataReceived, getPoliciesReservedCorrelationID());
+ else
+ mySystemRequest = RPCRequestFactory.buildSystemRequest(response.toString(), getPoliciesReservedCorrelationID());
+
+ if (getIsConnected())
+ {
+ sendRPCRequestPrivate(mySystemRequest);
+ SdlLog.i("sendOnSystemRequestToUrl sent to sdl");
+
+ updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString());
+ updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST);
+ updateBroadcastIntent(sendIntent2, "CORRID", mySystemRequest.getCorrelationID());
+ }
+ }
+ catch (SdlException e)
+ {
+ SdlLog.e("sendOnSystemRequestToUrl: Could not get data from JSONObject received.", e);
+ updateBroadcastIntent(sendIntent, "COMMENT3", " SdlException encountered sendOnSystemRequestToUrl: "+ e);
+ }
+ catch (JSONException e)
+ {
+ SdlLog.e("sendOnSystemRequestToUrl: JSONException: ", e);
+ updateBroadcastIntent(sendIntent, "COMMENT3", " JSONException encountered sendOnSystemRequestToUrl: "+ e);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ SdlLog.e("sendOnSystemRequestToUrl: Could not encode string.", e);
+ updateBroadcastIntent(sendIntent, "COMMENT3", " UnsupportedEncodingException encountered sendOnSystemRequestToUrl: "+ e);
+ }
+ catch (ProtocolException e)
+ {
+ SdlLog.e("sendOnSystemRequestToUrl: Could not set request method to post.", e);
+ updateBroadcastIntent(sendIntent, "COMMENT3", " ProtocolException encountered sendOnSystemRequestToUrl: "+ e);
+ }
+ catch (MalformedURLException e)
+ {
+ SdlLog.e("sendOnSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e);
+ updateBroadcastIntent(sendIntent, "COMMENT3", " MalformedURLException encountered sendOnSystemRequestToUrl: "+ e);
+ }
+ catch (IOException e)
+ {
+ SdlLog.e("sendOnSystemRequestToUrl: IOException: ", e);
+ updateBroadcastIntent(sendIntent, "COMMENT3", " IOException while sending to cloud: IOException: "+ e);
+ }
+ catch (Exception e)
+ {
+ SdlLog.e("sendOnSystemRequestToUrl: Unexpected Exception: ", e);
+ updateBroadcastIntent(sendIntent, "COMMENT3", " Exception encountered sendOnSystemRequestToUrl: "+ e);
+ }
+ finally
+ {
+ sendBroadcastIntent(sendIntent);
+ sendBroadcastIntent(sendIntent2);
+
+ if (iFileCount < 10)
+ iFileCount++;
+ else
+ iFileCount = 0;
+
+ if(urlConnection != null)
+ {
+ urlConnection.disconnect();
+ }
+ }
+ }
+
+ private int getPoliciesReservedCorrelationID() {
+ return POLICIES_CORRELATION_ID;
+ }
+
+ // Test correlationID
+ private boolean isCorrelationIDProtected(Integer correlationID) {
+ if (correlationID != null &&
+ (HEARTBEAT_CORRELATION_ID == correlationID
+ || REGISTER_APP_INTERFACE_CORRELATION_ID == correlationID
+ || UNREGISTER_APP_INTERFACE_CORRELATION_ID == correlationID
+ || POLICIES_CORRELATION_ID == correlationID)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ // Protected isConnected method to allow legacy proxy to poll isConnected state
+ public Boolean getIsConnected() {
+ if (sdlSession == null) return false;
+
+ return sdlSession.getIsConnected();
+ }
+
+ /**
+ * Returns whether the application is registered in SDL. Note: for testing
+ * purposes, it's possible that the connection is established, but the
+ * application is not registered.
+ *
+ * @return true if the application is registered in SDL
+ */
+ public Boolean getAppInterfaceRegistered() {
+ return _appInterfaceRegisterd;
+ }
+
+ // Function to initialize new proxy connection
+ private void initializeProxy() throws SdlException {
+ // Reset all of the flags and state variables
+ _haveReceivedFirstNonNoneHMILevel = false;
+ _haveReceivedFirstFocusLevel = false;
+ _haveReceivedFirstFocusLevelFull = false;
+ if (_preRegisterd)
+ _appInterfaceRegisterd = true;
+ else
+ _appInterfaceRegisterd = false;
+
+ _putFileListenerList.clear();
+
+ _sdlIntefaceAvailablity = SdlInterfaceAvailability.SDL_INTERFACE_UNAVAILABLE;
+
+ // Setup SdlConnection
+ synchronized(CONNECTION_REFERENCE_LOCK) {
+ this.sdlSession = SdlSession.createSession(_wiproVersion,_interfaceBroker, _transportConfig);
+ }
+
+ synchronized(CONNECTION_REFERENCE_LOCK) {
+ this.sdlSession.startSession();
+ sendTransportBroadcast();
+ }
+ }
+
+ public void sendTransportBroadcast()
+ {
+ if (sdlSession == null || _transportConfig == null) return;
+
+ String sTransComment = sdlSession.getBroadcastComment(_transportConfig);
+
+ if (sTransComment == null || sTransComment.equals("")) return;
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "initializeProxy");
+ updateBroadcastIntent(sendIntent, "COMMENT1", sTransComment);
+ sendBroadcastIntent(sendIntent);
+ }
+
+ @Deprecated
+ public void close() throws SdlException {
+ dispose();
+ }
+
+ private void cleanProxy(SdlDisconnectedReason disconnectedReason) throws SdlException {
+ try {
+
+ // ALM Specific Cleanup
+ if (_advancedLifecycleManagementEnabled) {
+ _sdlConnectionState = SdlConnectionState.SDL_DISCONNECTED;
+
+ firstTimeFull = true;
+
+ // Should we wait for the interface to be unregistered?
+ Boolean waitForInterfaceUnregistered = false;
+ // Unregister app interface
+ synchronized(CONNECTION_REFERENCE_LOCK) {
+ if (sdlSession != null && sdlSession.getIsConnected() && getAppInterfaceRegistered()) {
+ waitForInterfaceUnregistered = true;
+ unregisterAppInterfacePrivate(UNREGISTER_APP_INTERFACE_CORRELATION_ID);
+ }
+ }
+
+ // Wait for the app interface to be unregistered
+ if (waitForInterfaceUnregistered) {
+ synchronized(APP_INTERFACE_REGISTERED_LOCK) {
+ try {
+ APP_INTERFACE_REGISTERED_LOCK.wait(3000);
+ } catch (InterruptedException e) {
+ // Do nothing
+ }
+ }
+ }
+ }
+
+ // Clean up SDL Connection
+ synchronized(CONNECTION_REFERENCE_LOCK) {
+ if (sdlSession != null) sdlSession.close();
+ }
+ } catch (SdlException e) {
+ throw e;
+ } finally {
+ SdlTrace.logProxyEvent("SdlProxy cleaned.", SDL_LIB_TRACE_KEY);
+ }
+ }
+
+ /**
+ * Terminates the App's Interface Registration, closes the transport connection, ends the protocol session, and frees any resources used by the proxy.
+ */
+ public void dispose() throws SdlException
+ {
+ if (_proxyDisposed) {
+ throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
+ }
+
+ _proxyDisposed = true;
+
+ SdlTrace.logProxyEvent("Application called dispose() method.", SDL_LIB_TRACE_KEY);
+
+ try{
+ // Clean the proxy
+ cleanProxy(SdlDisconnectedReason.APPLICATION_REQUESTED_DISCONNECT);
+
+ // Close IncomingProxyMessageDispatcher thread
+ synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) {
+ if (_incomingProxyMessageDispatcher != null) {
+ _incomingProxyMessageDispatcher.dispose();
+ _incomingProxyMessageDispatcher = null;
+ }
+ }
+
+ // Close OutgoingProxyMessageDispatcher thread
+ synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) {
+ if (_outgoingProxyMessageDispatcher != null) {
+ _outgoingProxyMessageDispatcher.dispose();
+ _outgoingProxyMessageDispatcher = null;
+ }
+ }
+
+ // Close InternalProxyMessageDispatcher thread
+ synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) {
+ if (_internalProxyMessageDispatcher != null) {
+ _internalProxyMessageDispatcher.dispose();
+ _internalProxyMessageDispatcher = null;
+ }
+ }
+
+ _traceDeviceInterrogator = null;
+ } catch (SdlException e) {
+ throw e;
+ } finally {
+ SdlTrace.logProxyEvent("SdlProxy disposed.", SDL_LIB_TRACE_KEY);
+ }
+ } // end-method
+
+
+ private static Object CYCLE_LOCK = new Object();
+
+ private boolean _cycling = false;
+
+ // Method to cycle the proxy, only called in ALM
+ protected void cycleProxy(SdlDisconnectedReason disconnectedReason) {
+ if (_cycling) return;
+
+ synchronized(CYCLE_LOCK)
+ {
+ try{
+ _cycling = true;
+ cleanProxy(disconnectedReason);
+ initializeProxy();
+ notifyProxyClosed("Sdl Proxy Cycled", new SdlException("Sdl Proxy Cycled", SdlExceptionCause.SDL_PROXY_CYCLED), disconnectedReason);
+ }
+ catch (SdlException e) {
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "cycleProxy");
+ updateBroadcastIntent(sendIntent, "COMMENT1", "Proxy cycled, exception cause: " + e.getSdlExceptionCause());
+ sendBroadcastIntent(sendIntent);
+
+ switch(e.getSdlExceptionCause()) {
+ case BLUETOOTH_DISABLED:
+ notifyProxyClosed("Bluetooth is disabled. Bluetooth must be enabled to connect to SDL. Reattempt a connection once Bluetooth is enabled.",
+ new SdlException("Bluetooth is disabled. Bluetooth must be enabled to connect to SDL. Reattempt a connection once Bluetooth is enabled.", SdlExceptionCause.BLUETOOTH_DISABLED), SdlDisconnectedReason.BLUETOOTH_DISABLED);
+ break;
+ case BLUETOOTH_ADAPTER_NULL:
+ notifyProxyClosed("Cannot locate a Bluetooth adapater. A SDL connection is impossible on this device until a Bluetooth adapter is added.",
+ new SdlException("Cannot locate a Bluetooth adapater. A SDL connection is impossible on this device until a Bluetooth adapter is added.", SdlExceptionCause.BLUETOOTH_ADAPTER_NULL), SdlDisconnectedReason.BLUETOOTH_ADAPTER_ERROR);
+ break;
+ default :
+ notifyProxyClosed("Cycling the proxy failed.", e, SdlDisconnectedReason.GENERIC_ERROR);
+ break;
+ }
+ } catch (Exception e) {
+ notifyProxyClosed("Cycling the proxy failed.", e, SdlDisconnectedReason.GENERIC_ERROR);
+ }
+ _cycling = false;
+ }
+ }
+
+
+
+ /************* Functions used by the Message Dispatching Queues ****************/
+ private void dispatchIncomingMessage(ProtocolMessage message) {
+ try{
+ // Dispatching logic
+ if (message.getSessionType().equals(SessionType.RPC)) {
+ try {
+ if (_wiproVersion == 1) {
+ if (message.getVersion() > 1) setWiProVersion(message.getVersion());
+ }
+
+ Hashtable<String, Object> hash = new Hashtable<String, Object>();
+ if (_wiproVersion > 1) {
+ Hashtable<String, Object> hashTemp = new Hashtable<String, Object>();
+ hashTemp.put(RPCMessage.KEY_CORRELATION_ID, message.getCorrID());
+ if (message.getJsonSize() > 0) {
+ final Hashtable<String, Object> mhash = JsonRPCMarshaller.unmarshall(message.getData());
+ //hashTemp.put(Names.parameters, mhash.get(Names.parameters));
+ hashTemp.put(RPCMessage.KEY_PARAMETERS, mhash);
+ }
+
+ String functionName = FunctionID.getFunctionName(message.getFunctionID());
+ if (functionName != null) {
+ hashTemp.put(RPCMessage.KEY_FUNCTION_NAME, functionName);
+ } else {
+ SdlLog.w("Dispatch Incoming Message - function name is null unknown RPC. FunctionID: " + message.getFunctionID());
+ return;
+ }
+ if (message.getRPCType() == 0x00) {
+ hash.put(RPCMessage.KEY_REQUEST, hashTemp);
+ } else if (message.getRPCType() == 0x01) {
+ hash.put(RPCMessage.KEY_RESPONSE, hashTemp);
+ } else if (message.getRPCType() == 0x02) {
+ hash.put(RPCMessage.KEY_NOTIFICATION, hashTemp);
+ }
+ if (message.getBulkData() != null) hash.put(RPCStruct.KEY_BULK_DATA, message.getBulkData());
+ } else {
+ final Hashtable<String, Object> mhash = JsonRPCMarshaller.unmarshall(message.getData());
+ hash = mhash;
+ }
+ handleRPCMessage(hash);
+ } catch (final Exception excp) {
+ SdlLog.e("Failure handling protocol message: " + excp.toString(), excp);
+ passErrorToProxyListener("Error handing incoming protocol message.", excp);
+ } // end-catch
+ } else {
+ // Handle other protocol message types here
+ }
+ } catch (final Exception e) {
+ // Pass error to application through listener
+ SdlLog.e("Error handing proxy event.", e);
+ passErrorToProxyListener("Error handing incoming protocol message.", e);
+ }
+ }
+
+ private byte getWiProVersion() {
+ return this._wiproVersion;
+ }
+
+ private void setWiProVersion(byte version) {
+ this._wiproVersion = version;
+ }
+
+ public String serializeJSON(RPCMessage msg)
+ {
+ String sReturn = null;
+ try
+ {
+ sReturn = msg.serializeJSON(getWiProVersion()).toString(2);
+ }
+ catch (final Exception e)
+ {
+ SdlLog.e("Error handing proxy event.", e);
+ passErrorToProxyListener("Error serializing message.", e);
+ return null;
+ }
+ return sReturn;
+ }
+
+ private void handleErrorsFromIncomingMessageDispatcher(String info, Exception e) {
+ passErrorToProxyListener(info, e);
+ }
+
+ private void dispatchOutgoingMessage(ProtocolMessage message) {
+ synchronized(CONNECTION_REFERENCE_LOCK) {
+ if (sdlSession != null) {
+ sdlSession.sendMessage(message);
+ }
+ }
+ SdlTrace.logProxyEvent("SdlProxy sending Protocol Message: " + message.toString(), SDL_LIB_TRACE_KEY);
+ }
+
+ private void handleErrorsFromOutgoingMessageDispatcher(String info, Exception e) {
+ passErrorToProxyListener(info, e);
+ }
+
+ void dispatchInternalMessage(final InternalProxyMessage message) {
+ try{
+ if (message.getFunctionName().equals(InternalProxyMessage.OnProxyError)) {
+ final OnError msg = (OnError)message;
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onError(msg.getInfo(), msg.getException());
+ }
+ });
+ } else {
+ _proxyListener.onError(msg.getInfo(), msg.getException());
+ }
+ /**************Start Legacy Specific Call-backs************/
+ } else if (message.getFunctionName().equals(InternalProxyMessage.OnProxyOpened)) {
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ ((IProxyListener)_proxyListener).onProxyOpened();
+ }
+ });
+ } else {
+ ((IProxyListener)_proxyListener).onProxyOpened();
+ }
+ } else if (message.getFunctionName().equals(InternalProxyMessage.OnProxyClosed)) {
+ final OnProxyClosed msg = (OnProxyClosed)message;
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onProxyClosed(msg.getInfo(), msg.getException(), msg.getReason());
+ }
+ });
+ } else {
+ _proxyListener.onProxyClosed(msg.getInfo(), msg.getException(), msg.getReason());
+ }
+ /****************End Legacy Specific Call-backs************/
+ } else {
+ // Diagnostics
+ SdlTrace.logProxyEvent("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.", SDL_LIB_TRACE_KEY);
+ SdlLog.e("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.");
+ }
+
+ SdlTrace.logProxyEvent("Proxy fired callback: " + message.getFunctionName(), SDL_LIB_TRACE_KEY);
+ } catch(final Exception e) {
+ // Pass error to application through listener
+ SdlLog.e("Error handing proxy event.", e);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onError("Error handing proxy event.", e);
+ }
+ });
+ } else {
+ _proxyListener.onError("Error handing proxy event.", e);
+ }
+ }
+ }
+
+ private void handleErrorsFromInternalMessageDispatcher(String info, Exception e) {
+ SdlLog.e(info, e);
+ // This error cannot be passed to the user, as it indicates an error
+ // in the communication between the proxy and the application.
+
+ SdlLog.e("InternalMessageDispatcher failed.", e);
+
+ // Note, this is the only place where the _proxyListener should be referenced asdlhronously,
+ // with an error on the internalMessageDispatcher, we have no other reliable way of
+ // communicating with the application.
+ notifyProxyClosed("Proxy callback dispatcher is down. Proxy instance is invalid.", e, SdlDisconnectedReason.GENERIC_ERROR);
+ _proxyListener.onError("Proxy callback dispatcher is down. Proxy instance is invalid.", e);
+ }
+ /************* END Functions used by the Message Dispatching Queues ****************/
+
+ // Private sendPRCRequest method. All RPCRequests are funneled through this method after
+ // error checking.
+ private void sendRPCRequestPrivate(RPCRequest request) throws SdlException {
+ try {
+ SdlTrace.logRPCEvent(InterfaceActivityDirection.Transmit, request, SDL_LIB_TRACE_KEY);
+
+ byte[] msgBytes = JsonRPCMarshaller.marshall(request, _wiproVersion);
+
+ ProtocolMessage pm = new ProtocolMessage();
+ pm.setData(msgBytes);
+ if (sdlSession != null)
+ pm.setSessionID(sdlSession.getSessionId());
+ pm.setMessageType(MessageType.RPC);
+ pm.setSessionType(SessionType.RPC);
+ pm.setFunctionID(FunctionID.getFunctionId(request.getFunctionName()));
+ if (request.getCorrelationID() == null)
+ {
+ //Log error here
+ throw new SdlException("CorrelationID cannot be null. RPC: " + request.getFunctionName(), SdlExceptionCause.INVALID_ARGUMENT);
+ }
+ pm.setCorrID(request.getCorrelationID());
+ if (request.getBulkData() != null)
+ pm.setBulkData(request.getBulkData());
+
+ // Queue this outgoing message
+ synchronized(OUTGOING_MESSAGE_QUEUE_THREAD_LOCK) {
+ if (_outgoingProxyMessageDispatcher != null) {
+ _outgoingProxyMessageDispatcher.queueMessage(pm);
+ }
+ }
+ } catch (OutOfMemoryError e) {
+ SdlTrace.logProxyEvent("OutOfMemory exception while sending request " + request.getFunctionName(), SDL_LIB_TRACE_KEY);
+ throw new SdlException("OutOfMemory exception while sending request " + request.getFunctionName(), e, SdlExceptionCause.INVALID_ARGUMENT);
+ }
+ }
+
+ private void handleRPCMessage(Hashtable<String, Object> hash) {
+ RPCMessage rpcMsg = new RPCMessage(hash);
+ String functionName = rpcMsg.getFunctionName();
+ String messageType = rpcMsg.getMessageType();
+
+ if (messageType.equals(RPCMessage.KEY_RESPONSE)) {
+ SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, new RPCResponse(rpcMsg), SDL_LIB_TRACE_KEY);
+
+ // Check to ensure response is not from an internal message (reserved correlation ID)
+ if (isCorrelationIDProtected((new RPCResponse(hash)).getCorrelationID())) {
+ // This is a response generated from an internal message, it can be trapped here
+ // The app should not receive a response for a request it did not send
+ if ((new RPCResponse(hash)).getCorrelationID() == REGISTER_APP_INTERFACE_CORRELATION_ID
+ && _advancedLifecycleManagementEnabled
+ && functionName.equals(FunctionID.REGISTER_APP_INTERFACE.toString())) {
+ final RegisterAppInterfaceResponse msg = new RegisterAppInterfaceResponse(hash);
+ if (msg.getSuccess()) {
+ _appInterfaceRegisterd = true;
+ }
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.REGISTER_APP_INTERFACE.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
+ updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
+ updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
+ updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
+ updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
+ updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
+ sendBroadcastIntent(sendIntent);
+
+ //_autoActivateIdReturned = msg.getAutoActivateID();
+ /*Place holder for legacy support*/ _autoActivateIdReturned = "8675309";
+ _buttonCapabilities = msg.getButtonCapabilities();
+ _displayCapabilities = msg.getDisplayCapabilities();
+ _softButtonCapabilities = msg.getSoftButtonCapabilities();
+ _presetBankCapabilities = msg.getPresetBankCapabilities();
+ _hmiZoneCapabilities = msg.getHmiZoneCapabilities();
+ _speechCapabilities = msg.getSpeechCapabilities();
+ _prerecordedSpeech = msg.getPrerecordedSpeech();
+ _sdlLanguage = msg.getLanguage();
+ _hmiDisplayLanguage = msg.getHmiDisplayLanguage();
+ _sdlMsgVersion = msg.getSdlMsgVersion();
+ _vrCapabilities = msg.getVrCapabilities();
+ _vehicleType = msg.getVehicleType();
+ _audioPassThruCapabilities = msg.getAudioPassThruCapabilities();
+ _proxyVersionInfo = msg.getProxyVersionInfo();
+
+ if (_bAppResumeEnabled)
+ {
+ if ( (msg.getResultCode() == Result.RESUME_FAILED) || (msg.getResultCode() != Result.SUCCESS) )
+ {
+ _bResumeSuccess = false;
+ _lastHashID = null;
+ }
+ else if ( (_sdlMsgVersion.getMajorVersion() > 2) && (_lastHashID != null) && (msg.getResultCode() == Result.SUCCESS) )
+ _bResumeSuccess = true;
+ }
+ _diagModes = msg.getSupportedDiagModes();
+
+ String sVersionInfo = "SDL Proxy Version: " + _proxyVersionInfo;
+ SdlLog.i(sVersionInfo);
+
+ sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "RAI_RESPONSE");
+ updateBroadcastIntent(sendIntent, "COMMENT1", sVersionInfo);
+ sendBroadcastIntent(sendIntent);
+
+ // Send onSdlConnected message in ALM
+ _sdlConnectionState = SdlConnectionState.SDL_CONNECTED;
+
+ // If registerAppInterface failed, exit with OnProxyUnusable
+ if (!msg.getSuccess()) {
+ notifyProxyClosed("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: ",
+ new SdlException("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: " + msg.getResultCode(), SdlExceptionCause.SDL_REGISTRATION_ERROR), SdlDisconnectedReason.SDL_REGISTRATION_ERROR);
+ }
+
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (_proxyListener instanceof IProxyListener) {
+ ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
+ } else if (_proxyListener instanceof IProxyListenerALM) {
+ //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
+ }
+ }
+ });
+ } else {
+ if (_proxyListener instanceof IProxyListener) {
+ ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
+ } else if (_proxyListener instanceof IProxyListenerALM) {
+ //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
+ }
+ }
+ } else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID
+ && functionName.equals(FunctionID.ON_ENCODED_SYNC_P_DATA.toString())) {
+
+ SdlLog.i("Policy Table: POLICIES_CORRELATION_ID SystemRequest Notification (Legacy)");
+
+ final OnSystemRequest msg = new OnSystemRequest(hash);
+
+ // If url is not null, then send to URL
+ if ( (msg.getUrl() != null) )
+ {
+ // URL has data, attempt to post request to external server
+ Thread handleOffboardTransmissionThread = new Thread() {
+ @Override
+ public void run() {
+ sendOnSystemRequestToUrl(msg);
+ }
+ };
+
+ handleOffboardTransmissionThread.start();
+ }
+ }
+ else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID
+ && functionName.equals(FunctionID.ENCODED_SYNC_P_DATA.toString())) {
+
+ SdlLog.i("Policy Table: POLICIES_CORRELATION_ID SystemRequest Response (Legacy)");
+ final SystemRequestResponse msg = new SystemRequestResponse(hash);
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
+ updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
+ updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
+ updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
+ updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
+ sendBroadcastIntent(sendIntent);
+ }
+ else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID
+ && functionName.equals(FunctionID.SYSTEM_REQUEST.toString())) {
+ final SystemRequestResponse msg = new SystemRequestResponse(hash);
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
+ updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
+ updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
+ updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
+ updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
+ updateBroadcastIntent(sendIntent, "DATA", serializeJSON(msg));
+ sendBroadcastIntent(sendIntent);
+ }
+ else if (functionName.equals(FunctionID.UNREGISTER_APP_INTERFACE.toString())) {
+ // UnregisterAppInterface
+ _appInterfaceRegisterd = false;
+ synchronized(APP_INTERFACE_REGISTERED_LOCK) {
+ APP_INTERFACE_REGISTERED_LOCK.notify();
+ }
+ final UnregisterAppInterfaceResponse msg = new UnregisterAppInterfaceResponse(hash);
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
+ updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
+ updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
+ updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
+ updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
+ updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
+ sendBroadcastIntent(sendIntent);
+ }
+ return;
+ }
+
+ if (functionName.equals(FunctionID.REGISTER_APP_INTERFACE.toString())) {
+ final RegisterAppInterfaceResponse msg = new RegisterAppInterfaceResponse(hash);
+ if (msg.getSuccess()) {
+ _appInterfaceRegisterd = true;
+ }
+
+ //_autoActivateIdReturned = msg.getAutoActivateID();
+ /*Place holder for legacy support*/ _autoActivateIdReturned = "8675309";
+ _buttonCapabilities = msg.getButtonCapabilities();
+ _displayCapabilities = msg.getDisplayCapabilities();
+ _softButtonCapabilities = msg.getSoftButtonCapabilities();
+ _presetBankCapabilities = msg.getPresetBankCapabilities();
+ _hmiZoneCapabilities = msg.getHmiZoneCapabilities();
+ _speechCapabilities = msg.getSpeechCapabilities();
+ _prerecordedSpeech = msg.getPrerecordedSpeech();
+ _sdlLanguage = msg.getLanguage();
+ _hmiDisplayLanguage = msg.getHmiDisplayLanguage();
+ _sdlMsgVersion = msg.getSdlMsgVersion();
+ _vrCapabilities = msg.getVrCapabilities();
+ _vehicleType = msg.getVehicleType();
+ _audioPassThruCapabilities = msg.getAudioPassThruCapabilities();
+ _proxyVersionInfo = msg.getProxyVersionInfo();
+
+ if (_bAppResumeEnabled)
+ {
+ if ( (msg.getResultCode() == Result.RESUME_FAILED) || (msg.getResultCode() != Result.SUCCESS) )
+ {
+ _bResumeSuccess = false;
+ _lastHashID = null;
+ }
+ else if ( (_sdlMsgVersion.getMajorVersion() > 2) && (_lastHashID != null) && (msg.getResultCode() == Result.SUCCESS) )
+ _bResumeSuccess = true;
+ }
+
+ _diagModes = msg.getSupportedDiagModes();
+
+ SdlLog.i("SDL Proxy Version: " + _proxyVersionInfo);
+
+ // RegisterAppInterface
+ if (_advancedLifecycleManagementEnabled) {
+
+ // Send onSdlConnected message in ALM
+ _sdlConnectionState = SdlConnectionState.SDL_CONNECTED;
+
+ // If registerAppInterface failed, exit with OnProxyUnusable
+ if (!msg.getSuccess()) {
+ notifyProxyClosed("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: ",
+ new SdlException("Unable to register app interface. Review values passed to the SdlProxy constructor. RegisterAppInterface result code: " + msg.getResultCode(), SdlExceptionCause.SDL_REGISTRATION_ERROR), SdlDisconnectedReason.SDL_REGISTRATION_ERROR);
+ }
+ } else {
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (_proxyListener instanceof IProxyListener) {
+ ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
+ } else if (_proxyListener instanceof IProxyListenerALM) {
+ //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
+ }
+ }
+ });
+ } else {
+ if (_proxyListener instanceof IProxyListener) {
+ ((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
+ } else if (_proxyListener instanceof IProxyListenerALM) {
+ //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
+ }
+ }
+ }
+ } else if (functionName.equals(FunctionID.SPEAK.toString())) {
+ // SpeakResponse
+
+ final SpeakResponse msg = new SpeakResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSpeakResponse(msg);
+ }
+ });
+ } else {
+ _proxyListener.onSpeakResponse(msg);
+ }
+ } else if (functionName.equals(FunctionID.ALERT.toString())) {
+ // AlertResponse
+
+ final AlertResponse msg = new AlertResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onAlertResponse(msg);
+ }
+ });
+ } else {
+ _proxyListener.onAlertResponse(msg);
+ }
+ } else if (functionName.equals(FunctionID.SHOW.toString())) {
+ // ShowResponse
+
+ final ShowResponse msg = new ShowResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onShowResponse((ShowResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onShowResponse((ShowResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.ADD_COMMAND.toString())) {
+ // AddCommand
+
+ final AddCommandResponse msg = new AddCommandResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onAddCommandResponse((AddCommandResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onAddCommandResponse((AddCommandResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.DELETE_COMMAND.toString())) {
+ // DeleteCommandResponse
+
+ final DeleteCommandResponse msg = new DeleteCommandResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onDeleteCommandResponse((DeleteCommandResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onDeleteCommandResponse((DeleteCommandResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.ADD_SUB_MENU.toString())) {
+ // AddSubMenu
+
+ final AddSubMenuResponse msg = new AddSubMenuResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onAddSubMenuResponse((AddSubMenuResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onAddSubMenuResponse((AddSubMenuResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.DELETE_SUB_MENU.toString())) {
+ // DeleteSubMenu
+
+ final DeleteSubMenuResponse msg = new DeleteSubMenuResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onDeleteSubMenuResponse((DeleteSubMenuResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onDeleteSubMenuResponse((DeleteSubMenuResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.SUBSCRIBE_BUTTON.toString())) {
+ // SubscribeButton
+
+ final SubscribeButtonResponse msg = new SubscribeButtonResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSubscribeButtonResponse((SubscribeButtonResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onSubscribeButtonResponse((SubscribeButtonResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.UNSUBSCRIBE_BUTTON.toString())) {
+ // UnsubscribeButton
+
+ final UnsubscribeButtonResponse msg = new UnsubscribeButtonResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onUnsubscribeButtonResponse((UnsubscribeButtonResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onUnsubscribeButtonResponse((UnsubscribeButtonResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.SET_MEDIA_CLOCK_TIMER.toString())) {
+ // SetMediaClockTimer
+
+ final SetMediaClockTimerResponse msg = new SetMediaClockTimerResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSetMediaClockTimerResponse((SetMediaClockTimerResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onSetMediaClockTimerResponse((SetMediaClockTimerResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.ENCODED_SYNC_P_DATA.toString())) {
+
+ final SystemRequestResponse msg = new SystemRequestResponse(hash);
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
+ updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
+ updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
+ updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
+ updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
+ sendBroadcastIntent(sendIntent);
+
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSystemRequestResponse(msg);
+ }
+ });
+ } else {
+ _proxyListener.onSystemRequestResponse(msg);
+ }
+ } else if (functionName.equals(FunctionID.CREATE_INTERACTION_CHOICE_SET.toString())) {
+ // CreateInteractionChoiceSet
+
+ final CreateInteractionChoiceSetResponse msg = new CreateInteractionChoiceSetResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onCreateInteractionChoiceSetResponse((CreateInteractionChoiceSetResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onCreateInteractionChoiceSetResponse((CreateInteractionChoiceSetResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.DELETE_INTERACTION_CHOICE_SET.toString())) {
+ // DeleteInteractionChoiceSet
+
+ final DeleteInteractionChoiceSetResponse msg = new DeleteInteractionChoiceSetResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onDeleteInteractionChoiceSetResponse((DeleteInteractionChoiceSetResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onDeleteInteractionChoiceSetResponse((DeleteInteractionChoiceSetResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.PERFORM_INTERACTION.toString())) {
+ // PerformInteraction
+
+ final PerformInteractionResponse msg = new PerformInteractionResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onPerformInteractionResponse((PerformInteractionResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onPerformInteractionResponse((PerformInteractionResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.SET_GLOBAL_PROPERTIES.toString())) {
+ // SetGlobalPropertiesResponse
+
+ final SetGlobalPropertiesResponse msg = new SetGlobalPropertiesResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSetGlobalPropertiesResponse((SetGlobalPropertiesResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onSetGlobalPropertiesResponse((SetGlobalPropertiesResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.RESET_GLOBAL_PROPERTIES.toString())) {
+ // ResetGlobalProperties
+
+ final ResetGlobalPropertiesResponse msg = new ResetGlobalPropertiesResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onResetGlobalPropertiesResponse((ResetGlobalPropertiesResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onResetGlobalPropertiesResponse((ResetGlobalPropertiesResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.UNREGISTER_APP_INTERFACE.toString())) {
+ // UnregisterAppInterface
+
+ _appInterfaceRegisterd = false;
+ synchronized(APP_INTERFACE_REGISTERED_LOCK) {
+ APP_INTERFACE_REGISTERED_LOCK.notify();
+ }
+
+ final UnregisterAppInterfaceResponse msg = new UnregisterAppInterfaceResponse(hash);
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_RESPONSE);
+ updateBroadcastIntent(sendIntent, "SUCCESS", msg.getSuccess());
+ updateBroadcastIntent(sendIntent, "COMMENT1", msg.getInfo());
+ updateBroadcastIntent(sendIntent, "COMMENT2", msg.getResultCode().toString());
+ updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
+ updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
+ sendBroadcastIntent(sendIntent);
+
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (_proxyListener instanceof IProxyListener) {
+ ((IProxyListener)_proxyListener).onUnregisterAppInterfaceResponse(msg);
+ } else if (_proxyListener instanceof IProxyListenerALM) {
+ //((IProxyListenerALM)_proxyListener).onUnregisterAppInterfaceResponse(msg);
+ }
+ }
+ });
+ } else {
+ if (_proxyListener instanceof IProxyListener) {
+ ((IProxyListener)_proxyListener).onUnregisterAppInterfaceResponse(msg);
+ } else if (_proxyListener instanceof IProxyListenerALM) {
+ //((IProxyListenerALM)_proxyListener).onUnregisterAppInterfaceResponse(msg);
+ }
+ }
+
+ notifyProxyClosed("UnregisterAppInterfaceResponse", null, SdlDisconnectedReason.APP_INTERFACE_UNREG);
+ } else if (functionName.equals(FunctionID.GENERIC_RESPONSE.toString())) {
+ // GenericResponse (Usually and error)
+ final GenericResponse msg = new GenericResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onGenericResponse((GenericResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onGenericResponse((GenericResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.SLIDER.toString())) {
+ // Slider
+ final SliderResponse msg = new SliderResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSliderResponse((SliderResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onSliderResponse((SliderResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.PUT_FILE.toString())) {
+ // PutFile
+ final PutFileResponse msg = new PutFileResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onPutFileResponse((PutFileResponse)msg);
+ notifyPutFileStreamResponse(msg);
+ }
+ });
+ } else {
+ _proxyListener.onPutFileResponse((PutFileResponse)msg);
+ notifyPutFileStreamResponse(msg);
+ }
+ } else if (functionName.equals(FunctionID.DELETE_FILE.toString())) {
+ // DeleteFile
+ final DeleteFileResponse msg = new DeleteFileResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onDeleteFileResponse((DeleteFileResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onDeleteFileResponse((DeleteFileResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.LIST_FILES.toString())) {
+ // ListFiles
+ final ListFilesResponse msg = new ListFilesResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onListFilesResponse((ListFilesResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onListFilesResponse((ListFilesResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.SET_APP_ICON.toString())) {
+ // SetAppIcon
+ final SetAppIconResponse msg = new SetAppIconResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSetAppIconResponse((SetAppIconResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onSetAppIconResponse((SetAppIconResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.SCROLLABLE_MESSAGE.toString())) {
+ // ScrollableMessage
+ final ScrollableMessageResponse msg = new ScrollableMessageResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onScrollableMessageResponse((ScrollableMessageResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onScrollableMessageResponse((ScrollableMessageResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.CHANGE_REGISTRATION.toString())) {
+ // ChangeLanguageRegistration
+ final ChangeRegistrationResponse msg = new ChangeRegistrationResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onChangeRegistrationResponse((ChangeRegistrationResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onChangeRegistrationResponse((ChangeRegistrationResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.SET_DISPLAY_LAYOUT.toString())) {
+ // SetDisplayLayout
+ final SetDisplayLayoutResponse msg = new SetDisplayLayoutResponse(hash);
+
+ // successfully changed display layout - update layout capabilities
+ if(msg.getSuccess()){
+ _displayCapabilities = msg.getDisplayCapabilities();
+ _buttonCapabilities = msg.getButtonCapabilities();
+ _presetBankCapabilities = msg.getPresetBankCapabilities();
+ _softButtonCapabilities = msg.getSoftButtonCapabilities();
+ }
+
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSetDisplayLayoutResponse((SetDisplayLayoutResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onSetDisplayLayoutResponse((SetDisplayLayoutResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.PERFORM_AUDIO_PASS_THRU.toString())) {
+ // PerformAudioPassThru
+ final PerformAudioPassThruResponse msg = new PerformAudioPassThruResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onPerformAudioPassThruResponse((PerformAudioPassThruResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onPerformAudioPassThruResponse((PerformAudioPassThruResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.END_AUDIO_PASS_THRU.toString())) {
+ // EndAudioPassThru
+ final EndAudioPassThruResponse msg = new EndAudioPassThruResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onEndAudioPassThruResponse((EndAudioPassThruResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onEndAudioPassThruResponse((EndAudioPassThruResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.SUBSCRIBE_VEHICLE_DATA.toString())) {
+ // SubscribeVehicleData
+ final SubscribeVehicleDataResponse msg = new SubscribeVehicleDataResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSubscribeVehicleDataResponse((SubscribeVehicleDataResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onSubscribeVehicleDataResponse((SubscribeVehicleDataResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.UNSUBSCRIBE_VEHICLE_DATA.toString())) {
+ // UnsubscribeVehicleData
+ final UnsubscribeVehicleDataResponse msg = new UnsubscribeVehicleDataResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onUnsubscribeVehicleDataResponse((UnsubscribeVehicleDataResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onUnsubscribeVehicleDataResponse((UnsubscribeVehicleDataResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.GET_VEHICLE_DATA.toString())) {
+ // GetVehicleData
+ final GetVehicleDataResponse msg = new GetVehicleDataResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onGetVehicleDataResponse((GetVehicleDataResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onGetVehicleDataResponse((GetVehicleDataResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.READ_DID.toString())) {
+ final ReadDIDResponse msg = new ReadDIDResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onReadDIDResponse((ReadDIDResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onReadDIDResponse((ReadDIDResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.GET_DTCS.toString())) {
+ final GetDTCsResponse msg = new GetDTCsResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onGetDTCsResponse((GetDTCsResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onGetDTCsResponse((GetDTCsResponse)msg);
+ }
+ } else if (functionName.equals(FunctionID.DIAGNOSTIC_MESSAGE.toString())) {
+ final DiagnosticMessageResponse msg = new DiagnosticMessageResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onDiagnosticMessageResponse((DiagnosticMessageResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onDiagnosticMessageResponse((DiagnosticMessageResponse)msg);
+ }
+ }
+ else if (functionName.equals(FunctionID.SYSTEM_REQUEST.toString())) {
+
+ final SystemRequestResponse msg = new SystemRequestResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSystemRequestResponse((SystemRequestResponse)msg);
+ }
+ });
+ } else {
+ _proxyListener.onSystemRequestResponse((SystemRequestResponse)msg);
+ }
+ }
+ else if (functionName.equals(FunctionID.SEND_LOCATION.toString())) {
+
+ final SendLocationResponse msg = new SendLocationResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSendLocationResponse(msg);
+ }
+ });
+ } else {
+ _proxyListener.onSendLocationResponse(msg);
+ }
+ }
+ else if (functionName.equals(FunctionID.DIAL_NUMBER.toString())) {
+
+ final DialNumberResponse msg = new DialNumberResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onDialNumberResponse(msg);
+ }
+ });
+ } else {
+ _proxyListener.onDialNumberResponse(msg);
+ }
+ }
+ else {
+ if (_sdlMsgVersion != null) {
+ SdlLog.e("Unrecognized response Message: " + functionName.toString() +
+ "SDL Message Version = " + _sdlMsgVersion);
+ } else {
+ SdlLog.e("Unrecognized response Message: " + functionName.toString());
+ }
+ } // end-if
+ } else if (messageType.equals(RPCMessage.KEY_NOTIFICATION)) {
+ SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, new RPCNotification(rpcMsg), SDL_LIB_TRACE_KEY);
+ if (functionName.equals(FunctionID.ON_HMI_STATUS.toString())) {
+ // OnHMIStatus
+
+ final OnHMIStatus msg = new OnHMIStatus(hash);
+
+ //setup lockscreeninfo
+ if (sdlSession != null)
+ {
+ sdlSession.getLockScreenMan().setHMILevel(msg.getHmiLevel());
+ }
+
+ msg.setFirstRun(Boolean.valueOf(firstTimeFull));
+ if (msg.getHmiLevel() == HMILevel.HMI_FULL) firstTimeFull = false;
+
+ if (msg.getHmiLevel() != _priorHmiLevel && msg.getAudioStreamingState() != _priorAudioStreamingState) {
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnHMIStatus((OnHMIStatus)msg);
+ _proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
+ }
+ });
+ } else {
+ _proxyListener.onOnHMIStatus((OnHMIStatus)msg);
+ _proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
+ }
+ }
+ } else if (functionName.equals(FunctionID.ON_COMMAND.toString())) {
+ // OnCommand
+
+ final OnCommand msg = new OnCommand(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnCommand((OnCommand)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnCommand((OnCommand)msg);
+ }
+ } else if (functionName.equals(FunctionID.ON_DRIVER_DISTRACTION.toString())) {
+ // OnDriverDistration
+
+ final OnDriverDistraction msg = new OnDriverDistraction(hash);
+
+ //setup lockscreeninfo
+ if (sdlSession != null)
+ {
+ DriverDistractionState drDist = msg.getState();
+ boolean bVal = false;
+ if (drDist == DriverDistractionState.DD_ON)
+ bVal = true;
+ else
+ bVal = false;
+ sdlSession.getLockScreenMan().setDriverDistStatus(bVal);
+ }
+
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnDriverDistraction(msg);
+ _proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
+ }
+ });
+ } else {
+ _proxyListener.onOnDriverDistraction(msg);
+ _proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
+ }
+ } else if (functionName.equals(FunctionID.ON_ENCODED_SYNC_P_DATA.toString())) {
+
+ final OnSystemRequest msg = new OnSystemRequest(hash);
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.ON_SYSTEM_REQUEST.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_NOTIFICATION);
+
+ // If url is null, then send notification to the app, otherwise, send to URL
+ if (msg.getUrl() == null) {
+ updateBroadcastIntent(sendIntent, "COMMENT1", "URL is a null value (received)");
+ sendBroadcastIntent(sendIntent);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnSystemRequest(msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnSystemRequest(msg);
+ }
+ } else {
+ updateBroadcastIntent(sendIntent, "COMMENT1", "Sending to cloud: " + msg.getUrl());
+ sendBroadcastIntent(sendIntent);
+
+ SdlLog.i("Policy Table: send to url");
+
+ if ( (msg.getUrl() != null) )
+ {
+ Thread handleOffboardTransmissionThread = new Thread() {
+ @Override
+ public void run() {
+ sendOnSystemRequestToUrl(msg);
+ }
+ };
+
+ handleOffboardTransmissionThread.start();
+ }
+ }
+ } else if (functionName.equals(FunctionID.ON_PERMISSIONS_CHANGE.toString())) {
+ //OnPermissionsChange
+
+ final OnPermissionsChange msg = new OnPermissionsChange(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnPermissionsChange(msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnPermissionsChange(msg);
+ }
+ } else if (functionName.equals(FunctionID.ON_TBT_CLIENT_STATE.toString())) {
+ // OnTBTClientState
+
+ final OnTBTClientState msg = new OnTBTClientState(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnTBTClientState(msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnTBTClientState(msg);
+ }
+ } else if (functionName.equals(FunctionID.ON_BUTTON_PRESS.toString())) {
+ // OnButtonPress
+
+ final OnButtonPress msg = new OnButtonPress(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnButtonPress((OnButtonPress)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnButtonPress((OnButtonPress)msg);
+ }
+ } else if (functionName.equals(FunctionID.ON_BUTTON_EVENT.toString())) {
+ // OnButtonEvent
+
+ final OnButtonEvent msg = new OnButtonEvent(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnButtonEvent((OnButtonEvent)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnButtonEvent((OnButtonEvent)msg);
+ }
+ } else if (functionName.equals(FunctionID.ON_LANGUAGE_CHANGE.toString())) {
+ // OnLanguageChange
+
+ final OnLanguageChange msg = new OnLanguageChange(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnLanguageChange((OnLanguageChange)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnLanguageChange((OnLanguageChange)msg);
+ }
+ } else if (functionName.equals(FunctionID.ON_HASH_CHANGE.toString())) {
+ // OnLanguageChange
+
+ final OnHashChange msg = new OnHashChange(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnHashChange((OnHashChange)msg);
+ if (_bAppResumeEnabled)
+ {
+ _lastHashID = msg.getHashID();
+ }
+ }
+ });
+ } else {
+ _proxyListener.onOnHashChange((OnHashChange)msg);
+ if (_bAppResumeEnabled)
+ {
+ _lastHashID = msg.getHashID();
+ }
+ }
+ } else if (functionName.equals(FunctionID.ON_SYSTEM_REQUEST.toString())) {
+ // OnSystemRequest
+
+ final OnSystemRequest msg = new OnSystemRequest(hash);
+
+ if ( (msg.getUrl() != null) &&
+ (msg.getRequestType() == RequestType.PROPRIETARY) &&
+ (msg.getFileType() == FileType.JSON) )
+ {
+ Thread handleOffboardTransmissionThread = new Thread() {
+ @Override
+ public void run() {
+ sendOnSystemRequestToUrl(msg);
+ }
+ };
+
+ handleOffboardTransmissionThread.start();
+ }
+
+
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnSystemRequest((OnSystemRequest)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnSystemRequest((OnSystemRequest)msg);
+ }
+ } else if (functionName.equals(FunctionID.ON_AUDIO_PASS_THRU.toString())) {
+ // OnAudioPassThru
+ final OnAudioPassThru msg = new OnAudioPassThru(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnAudioPassThru((OnAudioPassThru)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnAudioPassThru((OnAudioPassThru)msg);
+ }
+ } else if (functionName.equals(FunctionID.ON_VEHICLE_DATA.toString())) {
+ // OnVehicleData
+ final OnVehicleData msg = new OnVehicleData(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnVehicleData((OnVehicleData)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnVehicleData((OnVehicleData)msg);
+ }
+ }
+ else if (functionName.equals(FunctionID.ON_APP_INTERFACE_UNREGISTERED.toString())) {
+ // OnAppInterfaceUnregistered
+
+ _appInterfaceRegisterd = false;
+ synchronized(APP_INTERFACE_REGISTERED_LOCK) {
+ APP_INTERFACE_REGISTERED_LOCK.notify();
+ }
+
+ final OnAppInterfaceUnregistered msg = new OnAppInterfaceUnregistered(hash);
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.ON_APP_INTERFACE_UNREGISTERED.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_NOTIFICATION);
+ updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
+ sendBroadcastIntent(sendIntent);
+
+ if (_advancedLifecycleManagementEnabled) {
+ // This requires the proxy to be cycled
+ cycleProxy(SdlDisconnectedReason.convertAppInterfaceUnregisteredReason(msg.getReason()));
+ } else {
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ ((IProxyListener)_proxyListener).onOnAppInterfaceUnregistered(msg);
+ }
+ });
+ } else {
+ ((IProxyListener)_proxyListener).onOnAppInterfaceUnregistered(msg);
+ }
+ notifyProxyClosed("OnAppInterfaceUnregistered", null, SdlDisconnectedReason.APP_INTERFACE_UNREG);
+ }
+ }
+ else if (functionName.equals(FunctionID.ON_KEYBOARD_INPUT.toString())) {
+ final OnKeyboardInput msg = new OnKeyboardInput(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnKeyboardInput((OnKeyboardInput)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnKeyboardInput((OnKeyboardInput)msg);
+ }
+ }
+ else if (functionName.equals(FunctionID.ON_TOUCH_EVENT.toString())) {
+ final OnTouchEvent msg = new OnTouchEvent(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnTouchEvent((OnTouchEvent)msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnTouchEvent((OnTouchEvent)msg);
+ }
+ }
+ else {
+ if (_sdlMsgVersion != null) {
+ SdlLog.i("Unrecognized notification Message: " + functionName.toString() +
+ " connected to SDL using message version: " + _sdlMsgVersion.getMajorVersion() + "." + _sdlMsgVersion.getMinorVersion());
+ } else {
+ SdlLog.i("Unrecognized notification Message: " + functionName.toString());
+ }
+ } // end-if
+ } // end-if notification
+
+ SdlTrace.logProxyEvent("Proxy received RPC Message: " + functionName, SDL_LIB_TRACE_KEY);
+ }
+
+ /**
+ * Takes an RPCRequest and sends it to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param request
+ * @throws SdlException
+ */
+ public void sendRPCRequest(RPCRequest request) throws SdlException {
+ if (_proxyDisposed) {
+ throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
+ }
+
+ // Test if request is null
+ if (request == null) {
+ SdlTrace.logProxyEvent("Application called sendRPCRequest method with a null RPCRequest.", SDL_LIB_TRACE_KEY);
+ throw new IllegalArgumentException("sendRPCRequest cannot be called with a null request.");
+ }
+
+ SdlTrace.logProxyEvent("Application called sendRPCRequest method for RPCRequest: ." + request.getFunctionName(), SDL_LIB_TRACE_KEY);
+
+ // Test if SdlConnection is null
+ synchronized(CONNECTION_REFERENCE_LOCK) {
+ if (sdlSession == null || !sdlSession.getIsConnected()) {
+ SdlTrace.logProxyEvent("Application attempted to send and RPCRequest without a connected transport.", SDL_LIB_TRACE_KEY);
+ throw new SdlException("There is no valid connection to SDL. sendRPCRequest cannot be called until SDL has been connected.", SdlExceptionCause.SDL_UNAVAILABLE);
+ }
+ }
+
+ // Test for illegal correlation ID
+ if (isCorrelationIDProtected(request.getCorrelationID())) {
+
+ SdlTrace.logProxyEvent("Application attempted to use the reserved correlation ID, " + request.getCorrelationID(), SDL_LIB_TRACE_KEY);
+ throw new SdlException("Invalid correlation ID. The correlation ID, " + request.getCorrelationID()
+ + " , is a reserved correlation ID.", SdlExceptionCause.RESERVED_CORRELATION_ID);
+ }
+
+ // Throw exception if RPCRequest is sent when SDL is unavailable
+ if (!_appInterfaceRegisterd && !request.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE.toString())) {
+
+ SdlTrace.logProxyEvent("Application attempted to send an RPCRequest (non-registerAppInterface), before the interface was registerd.", SDL_LIB_TRACE_KEY);
+ throw new SdlException("SDL is currently unavailable. RPC Requests cannot be sent.", SdlExceptionCause.SDL_UNAVAILABLE);
+ }
+
+ if (_advancedLifecycleManagementEnabled) {
+ if (request.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE.toString())
+ || request.getFunctionName().equals(FunctionID.UNREGISTER_APP_INTERFACE.toString())) {
+
+ SdlTrace.logProxyEvent("Application attempted to send a RegisterAppInterface or UnregisterAppInterface while using ALM.", SDL_LIB_TRACE_KEY);
+ throw new SdlException("The RPCRequest, " + request.getFunctionName() +
+ ", is unallowed using the Advanced Lifecycle Management Model.", SdlExceptionCause.INCORRECT_LIFECYCLE_MODEL);
+ }
+ }
+
+ sendRPCRequestPrivate(request);
+ } // end-method
+
+ protected void notifyProxyClosed(final String info, final Exception e, final SdlDisconnectedReason reason) {
+ SdlTrace.logProxyEvent("NotifyProxyClose", SDL_LIB_TRACE_KEY);
+ OnProxyClosed message = new OnProxyClosed(info, e, reason);
+ queueInternalMessage(message);
+ }
+
+ private void passErrorToProxyListener(final String info, final Exception e) {
+
+ OnError message = new OnError(info, e);
+ queueInternalMessage(message);
+ }
+
+ private void startRPCProtocolSession(byte sessionID, String correlationID) {
+
+ // Set Proxy Lifecyclek Available
+ if (_advancedLifecycleManagementEnabled) {
+
+ try {
+ registerAppInterfacePrivate(
+ _sdlMsgVersionRequest,
+ _applicationName,
+ _ttsName,
+ _ngnMediaScreenAppName,
+ _vrSynonyms,
+ _isMediaApp,
+ _sdlLanguageDesired,
+ _hmiDisplayLanguageDesired,
+ _appType,
+ _appID,
+ _autoActivateIdDesired,
+ REGISTER_APP_INTERFACE_CORRELATION_ID);
+
+ } catch (Exception e) {
+ notifyProxyClosed("Failed to register application interface with SDL. Check parameter values given to SdlProxy constructor.", e, SdlDisconnectedReason.SDL_REGISTRATION_ERROR);
+ }
+ } else {
+ InternalProxyMessage message = new InternalProxyMessage(InternalProxyMessage.OnProxyOpened);
+ queueInternalMessage(message);
+ }
+ }
+
+ // Queue internal callback message
+ private void queueInternalMessage(InternalProxyMessage message) {
+ synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) {
+ if (_internalProxyMessageDispatcher != null) {
+ _internalProxyMessageDispatcher.queueMessage(message);
+ }
+ }
+ }
+
+ // Queue incoming ProtocolMessage
+ private void queueIncomingMessage(ProtocolMessage message) {
+ synchronized(INCOMING_MESSAGE_QUEUE_THREAD_LOCK) {
+ if (_incomingProxyMessageDispatcher != null) {
+ _incomingProxyMessageDispatcher.queueMessage(message);
+ }
+ }
+ }
+
+ private FileInputStream getFileInputStream(String sLocalFile)
+ {
+ FileInputStream is = null;
+ try
+ {
+ is = new FileInputStream(sLocalFile);
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ return is;
+ }
+
+ private Long getFileInputStreamSize(FileInputStream is)
+ {
+ Long lSize = null;
+
+ try
+ {
+ lSize = is.getChannel().size();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ return lSize;
+ }
+
+ private void closeFileInputStream(FileInputStream is)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private RPCStreamController startRPCStream(String sLocalFile, PutFile request, SessionType sType, byte rpcSessionID, byte wiproVersion)
+ {
+ if (sdlSession == null) return null;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return null;
+
+ FileInputStream is = getFileInputStream(sLocalFile);
+ if (is == null) return null;
+
+ Integer iSize = Integer.valueOf(getFileInputStreamSize(is).intValue());
+ if (iSize == null)
+ {
+ closeFileInputStream(is);
+ return null;
+ }
+
+ try {
+ StreamRPCPacketizer rpcPacketizer = new StreamRPCPacketizer((SdlProxyBase<IProxyListenerBase>) this, sdlConn, is, request, sType, rpcSessionID, wiproVersion, iSize);
+ rpcPacketizer.start();
+ RPCStreamController streamController = new RPCStreamController(rpcPacketizer, request.getCorrelationID());
+ return streamController;
+ } catch (Exception e) {
+ SdlLog.e("SyncConnection: Unable to start streaming:" + e.toString());
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private RPCStreamController startRPCStream(InputStream is, PutFile request, SessionType sType, byte rpcSessionID, byte wiproVersion)
+ {
+ if (sdlSession == null) return null;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return null;
+ Long iSize = request.getLength();
+
+ if (request.getLength() == null)
+ {
+ return null;
+ }
+
+ try {
+ StreamRPCPacketizer rpcPacketizer = new StreamRPCPacketizer((SdlProxyBase<IProxyListenerBase>) this, sdlConn, is, request, sType, rpcSessionID, wiproVersion, iSize);
+ rpcPacketizer.start();
+ RPCStreamController streamController = new RPCStreamController(rpcPacketizer, request.getCorrelationID());
+ return streamController;
+ } catch (Exception e) {
+ SdlLog.e("SyncConnection: Unable to start streaming:" + e.toString());
+ return null;
+ }
+ }
+
+ private RPCStreamController startPutFileStream(String sPath, PutFile msg) {
+ if (sdlSession == null) return null;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return null;
+ return startRPCStream(sPath, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
+ }
+
+ private RPCStreamController startPutFileStream(InputStream is, PutFile msg) {
+ if (sdlSession == null) return null;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return null;
+ if (is == null) return null;
+ startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
+ return null;
+ }
+
+ public boolean startRPCStream(InputStream is, RPCRequest msg) {
+ if (sdlSession == null) return false;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return false;
+ sdlConn.startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
+ return true;
+ }
+
+ public OutputStream startRPCStream(RPCRequest msg) {
+ if (sdlSession == null) return null;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return null;
+ return sdlConn.startRPCStream(msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
+ }
+
+ public void endRPCStream() {
+ if (sdlSession == null) return;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return;
+ sdlConn.stopRPCStream();
+ }
+
+ public boolean startH264(InputStream is) {
+
+ if (sdlSession == null) return false;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return false;
+
+ navServiceResponseReceived = false;
+ navServiceResponse = false;
+ sdlConn.startService(SessionType.NAV, sdlSession.getSessionId());
+ int infiniteLoopKiller = 0;
+ while (!navServiceResponseReceived && infiniteLoopKiller<2147483647) {
+ infiniteLoopKiller++;
+ }
+ if (navServiceResponse) {
+ sdlConn.startStream(is, SessionType.NAV, sdlSession.getSessionId());
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public OutputStream startH264() {
+
+ if (sdlSession == null) return null;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return null;
+
+ navServiceResponseReceived = false;
+ navServiceResponse = false;
+ sdlConn.startService(SessionType.NAV, sdlSession.getSessionId());
+ int infiniteLoopKiller = 0;
+ while (!navServiceResponseReceived && infiniteLoopKiller<2147483647) {
+ infiniteLoopKiller++;
+ }
+ if (navServiceResponse) {
+ return sdlConn.startStream(SessionType.NAV, sdlSession.getSessionId());
+ } else {
+ return null;
+ }
+ }
+
+ public void endH264() {
+ if (sdlSession == null) return;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return;
+ sdlConn.endService(SessionType.NAV, sdlSession.getSessionId());
+ }
+
+ public boolean startPCM(InputStream is) {
+ if (sdlSession == null) return false;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return false;
+
+ navServiceResponseReceived = false;
+ navServiceResponse = false;
+
+ sdlConn.startService(SessionType.PCM, sdlSession.getSessionId());
+ int infiniteLoopKiller = 0;
+ while (!navServiceResponseReceived && infiniteLoopKiller<2147483647) {
+ infiniteLoopKiller++;
+ }
+ if (navServiceResponse) {
+ sdlConn.startStream(is, SessionType.PCM, sdlSession.getSessionId());
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public OutputStream startPCM() {
+ if (sdlSession == null) return null;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return null;
+
+ navServiceResponseReceived = false;
+ navServiceResponse = false;
+ sdlConn.startService(SessionType.PCM, sdlSession.getSessionId());
+ int infiniteLoopKiller = 0;
+ while (!navServiceResponseReceived && infiniteLoopKiller<2147483647) {
+ infiniteLoopKiller++;
+ }
+ if (navServiceResponse) {
+ return sdlConn.startStream(SessionType.PCM, sdlSession.getSessionId());
+ } else {
+ return null;
+ }
+ }
+ public void endPCM() {
+ if (sdlSession == null) return;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return;
+
+ sdlConn.endService(SessionType.PCM, sdlSession.getSessionId());
+ }
+
+ private void NavServiceStarted() {
+ navServiceResponseReceived = true;
+ navServiceResponse = true;
+ }
+
+ private void NavServiceEnded() {
+ navServiceResponseReceived = true;
+ navServiceResponse = false;
+ }
+
+ @SuppressWarnings("unused")
+ private void AudioServiceStarted() {
+ pcmServiceResponseReceived = true;
+ pcmServiceResponse = true;
+ }
+
+ @SuppressWarnings("unused")
+ private void AudioServiceEnded() {
+ pcmServiceResponseReceived = true;
+ pcmServiceResponse = false;
+ }
+
+ public void setAppService(Service mService)
+ {
+ _appService = mService;
+ }
+
+ /******************** Public Helper Methods *************************/
+
+ /*Begin V1 Enhanced helper*/
+
+ /**
+ *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param parentID -Menu parent ID for optional sub value containing menu parameters.
+ *@param position -Menu position for optional sub value containing menu parameters.
+ *@param vrCommands -VR synonyms for this AddCommand.
+ *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
+ *@param IconType -Describes whether the image is static or dynamic
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Integer parentID, Integer position,
+ Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
+ throws SdlException {
+
+ AddCommand msg = RPCRequestFactory.buildAddCommand(commandID, menuText, parentID, position,
+ vrCommands, IconValue, IconType, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param position -Menu position for optional sub value containing menu parameters.
+ *@param vrCommands -VR synonyms for this AddCommand.
+ *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
+ *@param IconType -Describes whether the image is static or dynamic
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Integer position,
+ Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, menuText, null, position, vrCommands, IconValue, IconType, correlationID);
+ }
+
+ /**
+ *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param position -Menu position for optional sub value containing menu parameters.
+ *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
+ *@param IconType -Describes whether the image is static or dynamic
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Integer position, String IconValue, ImageType IconType,
+ Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, menuText, null, position, null, IconValue, IconType, correlationID);
+ }
+
+ /**
+ *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
+ *@param IconType -Describes whether the image is static or dynamic
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, String IconValue, ImageType IconType, Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, menuText, null, null, null, IconValue, IconType, correlationID);
+ }
+
+ /**
+ * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param commandID -Unique command ID of the command to add.
+ * @param menuText -Menu text for optional sub value containing menu parameters.
+ * @param vrCommands -VR synonyms for this AddCommand.
+ * @param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
+ * @param IconType -Describes whether the image is static or dynamic
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, menuText, null, null, vrCommands, IconValue, IconType, correlationID);
+ }
+
+ /**
+ * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param commandID -Unique command ID of the command to add.
+ * @param vrCommands -VR synonyms for this AddCommand.
+ * @param IconValue -A static hex icon value or the binary image file name identifier (sent by the PutFile RPC).
+ * @param IconType -Describes whether the image is static or dynamic
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, null, null, null, vrCommands, IconValue, IconType, correlationID);
+ }
+
+ /*End V1 Enhanced helper*/
+
+ /**
+ *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param parentID -Menu parent ID for optional sub value containing menu parameters.
+ *@param position -Menu position for optional sub value containing menu parameters.
+ *@param vrCommands -VR synonyms for this AddCommand.
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Integer parentID, Integer position,
+ Vector<String> vrCommands, Integer correlationID)
+ throws SdlException {
+
+ AddCommand msg = RPCRequestFactory.buildAddCommand(commandID, menuText, parentID, position,
+ vrCommands, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param position -Menu position for optional sub value containing menu parameters.
+ *@param vrCommands -VR synonyms for this AddCommand.
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Integer position,
+ Vector<String> vrCommands, Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, menuText, null, position, vrCommands, correlationID);
+ }
+
+ /**
+ *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param position -Menu position for optional sub value containing menu parameters.
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Integer position,
+ Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, menuText, null, position, null, correlationID);
+ }
+
+ /**
+ *Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Integer correlationID)
+ throws SdlException {
+ Vector<String> vrCommands = null;
+
+ addCommand(commandID, menuText, null, null, vrCommands, correlationID);
+ }
+
+ /**
+ * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param menuText -Menu text for optional sub value containing menu parameters.
+ *@param vrCommands -VR synonyms for this AddCommand.
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ String menuText, Vector<String> vrCommands, Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, menuText, null, null, vrCommands, correlationID);
+ }
+
+ /**
+ * Sends an AddCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ *@param commandID -Unique command ID of the command to add.
+ *@param vrCommands -VR synonyms for this AddCommand.
+ *@param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ *@throws SdlException
+ */
+ public void addCommand(Integer commandID,
+ Vector<String> vrCommands, Integer correlationID)
+ throws SdlException {
+
+ addCommand(commandID, null, null, null, vrCommands, correlationID);
+ }
+
+
+ /**
+ * Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param menuID -Unique ID of the sub menu to add.
+ * @param menuName -Text to show in the menu for this sub menu.
+ * @param position -Position within the items that are are at top level of the in application menu.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void addSubMenu(Integer menuID, String menuName,
+ Integer position, Integer correlationID)
+ throws SdlException {
+
+ AddSubMenu msg = RPCRequestFactory.buildAddSubMenu(menuID, menuName,
+ position, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends an AddSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param menuID -Unique ID of the sub menu to add.
+ * @param menuName -Text to show in the menu for this sub menu.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void addSubMenu(Integer menuID, String menuName,
+ Integer correlationID) throws SdlException {
+
+ addSubMenu(menuID, menuName, null, correlationID);
+ }
+
+ /*Begin V1 Enhanced helper*/
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param ttsText -The text to speech message in the form of a string.
+ * @param alertText1 -The first line of the alert text field.
+ * @param alertText2 -The second line of the alert text field.
+ * @param alertText3 -The optional third line of the alert text field.
+ * @param playTone -Defines if tone should be played.
+ * @param duration -Timeout in milliseconds.
+ * @param softButtons -A list of App defined SoftButtons.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(String ttsText, String alertText1,
+ String alertText2, String alertText3, Boolean playTone, Integer duration, Vector<SoftButton> softButtons,
+ Integer correlationID) throws SdlException {
+
+ Alert msg = RPCRequestFactory.buildAlert(ttsText, alertText1, alertText2, alertText3, playTone, duration, softButtons, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param ttsChunks -Text/phonemes to speak in the form of ttsChunks.
+ * @param alertText1 -The first line of the alert text field.
+ * @param alertText2 -The second line of the alert text field.
+ * @param alertText3 -The optional third line of the alert text field.
+ * @param playTone -Defines if tone should be played.
+ * @param duration -Timeout in milliseconds.
+ * @param softButtons -A list of App defined SoftButtons.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(Vector<TTSChunk> ttsChunks,
+ String alertText1, String alertText2, String alertText3, Boolean playTone,
+ Integer duration, Vector<SoftButton> softButtons, Integer correlationID) throws SdlException {
+
+ Alert msg = RPCRequestFactory.buildAlert(ttsChunks, alertText1, alertText2, alertText3, playTone, duration, softButtons, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param ttsText -The text to speech message in the form of a string.
+ * @param playTone -Defines if tone should be played.
+ * @param softButtons -A list of App defined SoftButtons.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(String ttsText, Boolean playTone, Vector<SoftButton> softButtons,
+ Integer correlationID) throws SdlException {
+
+ alert(ttsText, null, null, null, playTone, null, softButtons, correlationID);
+ }
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param chunks -A list of text/phonemes to speak in the form of ttsChunks.
+ * @param playTone -Defines if tone should be played.
+ * @param softButtons -A list of App defined SoftButtons.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(Vector<TTSChunk> chunks, Boolean playTone, Vector<SoftButton> softButtons,
+ Integer correlationID) throws SdlException {
+
+ alert(chunks, null, null, null, playTone, null, softButtons, correlationID);
+ }
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param alertText1 -The first line of the alert text field.
+ * @param alertText2 -The second line of the alert text field.
+ * @param alertText3 -The optional third line of the alert text field.
+ * @param playTone -Defines if tone should be played.
+ * @param duration -Timeout in milliseconds.
+ * @param softButtons -A list of App defined SoftButtons.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(String alertText1, String alertText2, String alertText3,
+ Boolean playTone, Integer duration, Vector<SoftButton> softButtons, Integer correlationID)
+ throws SdlException {
+
+ alert((Vector<TTSChunk>)null, alertText1, alertText2, alertText3, playTone, duration, softButtons, correlationID);
+ }
+
+ /*End V1 Enhanced helper*/
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param ttsText -The text to speech message in the form of a string.
+ * @param alertText1 -The first line of the alert text field.
+ * @param alertText2 -The second line of the alert text field.
+ * @param playTone -Defines if tone should be played.
+ * @param duration -Timeout in milliseconds.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(String ttsText, String alertText1,
+ String alertText2, Boolean playTone, Integer duration,
+ Integer correlationID) throws SdlException {
+
+ Alert msg = RPCRequestFactory.buildAlert(ttsText, alertText1, alertText2,
+ playTone, duration, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param ttsChunks -A list of text/phonemes to speak in the form of ttsChunks.
+ * @param alertText1 -The first line of the alert text field.
+ * @param alertText2 -The second line of the alert text field.
+ * @param playTone -Defines if tone should be played.
+ * @param duration -Timeout in milliseconds.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(Vector<TTSChunk> ttsChunks,
+ String alertText1, String alertText2, Boolean playTone,
+ Integer duration, Integer correlationID) throws SdlException {
+
+ Alert msg = RPCRequestFactory.buildAlert(ttsChunks, alertText1, alertText2, playTone,
+ duration, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param ttsText -The text to speech message in the form of a string.
+ * @param playTone -Defines if tone should be played.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(String ttsText, Boolean playTone,
+ Integer correlationID) throws SdlException {
+
+ alert(ttsText, null, null, playTone, null, correlationID);
+ }
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param chunks -A list of text/phonemes to speak in the form of ttsChunks.
+ * @param playTone -Defines if tone should be played.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(Vector<TTSChunk> chunks, Boolean playTone,
+ Integer correlationID) throws SdlException {
+
+ alert(chunks, null, null, playTone, null, correlationID);
+ }
+
+ /**
+ * Sends an Alert RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param alertText1 -The first line of the alert text field.
+ * @param alertText2 -The second line of the alert text field.
+ * @param playTone -Defines if tone should be played.
+ * @param duration -Timeout in milliseconds.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void alert(String alertText1, String alertText2,
+ Boolean playTone, Integer duration, Integer correlationID)
+ throws SdlException {
+
+ alert((Vector<TTSChunk>)null, alertText1, alertText2, playTone, duration, correlationID);
+ }
+
+ /**
+ * Sends a CreateInteractionChoiceSet RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param choiceSet
+ * @param interactionChoiceSetID
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void createInteractionChoiceSet(
+ Vector<Choice> choiceSet, Integer interactionChoiceSetID,
+ Integer correlationID) throws SdlException {
+
+ CreateInteractionChoiceSet msg = RPCRequestFactory.buildCreateInteractionChoiceSet(
+ choiceSet, interactionChoiceSetID, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a DeleteCommand RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param commandID -ID of the command(s) to delete.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void deleteCommand(Integer commandID,
+ Integer correlationID) throws SdlException {
+
+ DeleteCommand msg = RPCRequestFactory.buildDeleteCommand(commandID, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a DeleteInteractionChoiceSet RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param interactionChoiceSetID -ID of the interaction choice set to delete.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void deleteInteractionChoiceSet(
+ Integer interactionChoiceSetID, Integer correlationID)
+ throws SdlException {
+
+ DeleteInteractionChoiceSet msg = RPCRequestFactory.buildDeleteInteractionChoiceSet(
+ interactionChoiceSetID, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a DeleteSubMenu RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param menuID -The menuID of the submenu to delete.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
+ * @throws SdlException
+ */
+ public void deleteSubMenu(Integer menuID,
+ Integer correlationID) throws SdlException {
+
+ DeleteSubMenu msg = RPCRequestFactory.buildDeleteSubMenu(menuID, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+
+
+ /*Begin V1 Enhanced helper*/
+
+ /**
+ * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
+ * @param displayText -Text to be displayed first.
+ * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction.
+ * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performInteraction(String initPrompt,
+ String displayText, Integer interactionChoiceSetID, Vector<VrHelpItem> vrHelp,
+ Integer correlationID) throws SdlException {
+
+ PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
+ displayText, interactionChoiceSetID, vrHelp, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
+ * @param displayText -Text to be displayed first.
+ * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction.
+ * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction.
+ * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out.
+ * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
+ * @param timeout -Timeout in milliseconds.
+ * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performInteraction(String initPrompt,
+ String displayText, Integer interactionChoiceSetID,
+ String helpPrompt, String timeoutPrompt,
+ InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
+ Integer correlationID) throws SdlException {
+
+ PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
+ initPrompt, displayText, interactionChoiceSetID,
+ helpPrompt, timeoutPrompt, interactionMode,
+ timeout, vrHelp, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
+ * @param displayText -Text to be displayed first.
+ * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction.
+ * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction.
+ * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out.
+ * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
+ * @param timeout -Timeout in milliseconds.
+ * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performInteraction(String initPrompt,
+ String displayText, Vector<Integer> interactionChoiceSetIDList,
+ String helpPrompt, String timeoutPrompt,
+ InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
+ Integer correlationID) throws SdlException {
+
+ PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
+ displayText, interactionChoiceSetIDList,
+ helpPrompt, timeoutPrompt, interactionMode, timeout, vrHelp,
+ correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param initChunks -A list of text/phonemes to speak for the initial prompt in the form of ttsChunks.
+ * @param displayText -Text to be displayed first.
+ * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction.
+ * @param helpChunks -A list of text/phonemes to speak for the help text that is spoken when a user speaks "help" during the interaction.
+ * @param timeoutChunks A list of text/phonems to speak for the timeout text that is spoken when a VR interaction times out.
+ * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
+ * @param timeout -Timeout in milliseconds.
+ * @param vrHelp -Suggested VR Help Items to display on-screen during Perform Interaction.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performInteraction(
+ Vector<TTSChunk> initChunks, String displayText,
+ Vector<Integer> interactionChoiceSetIDList,
+ Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks,
+ InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
+ Integer correlationID) throws SdlException {
+
+ PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
+ initChunks, displayText, interactionChoiceSetIDList,
+ helpChunks, timeoutChunks, interactionMode, timeout,vrHelp,
+ correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /*End V1 Enhanced*/
+
+ /**
+ * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
+ * @param displayText -Text to be displayed first.
+ * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performInteraction(String initPrompt,
+ String displayText, Integer interactionChoiceSetID,
+ Integer correlationID) throws SdlException {
+
+ PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
+ displayText, interactionChoiceSetID, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
+ * @param displayText -Text to be displayed first.
+ * @param interactionChoiceSetID -Interaction choice set IDs to use with an interaction.
+ * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction.
+ * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out.
+ * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
+ * @param timeout -Timeout in milliseconds.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performInteraction(String initPrompt,
+ String displayText, Integer interactionChoiceSetID,
+ String helpPrompt, String timeoutPrompt,
+ InteractionMode interactionMode, Integer timeout,
+ Integer correlationID) throws SdlException {
+
+ PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
+ initPrompt, displayText, interactionChoiceSetID,
+ helpPrompt, timeoutPrompt, interactionMode,
+ timeout, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param initPrompt -Intial prompt spoken to the user at the start of an interaction.
+ * @param displayText -Text to be displayed first.
+ * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction.
+ * @param helpPrompt -Help text that is spoken when a user speaks "help" during the interaction.
+ * @param timeoutPrompt -Timeout text that is spoken when a VR interaction times out.
+ * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
+ * @param timeout -Timeout in milliseconds.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performInteraction(String initPrompt,
+ String displayText, Vector<Integer> interactionChoiceSetIDList,
+ String helpPrompt, String timeoutPrompt,
+ InteractionMode interactionMode, Integer timeout,
+ Integer correlationID) throws SdlException {
+
+ PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
+ displayText, interactionChoiceSetIDList,
+ helpPrompt, timeoutPrompt, interactionMode, timeout,
+ correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a PerformInteraction RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param initChunks -A list of text/phonemes to speak for the initial prompt in the form of ttsChunks.
+ * @param displayText -Text to be displayed first.
+ * @param interactionChoiceSetIDList -A list of interaction choice set IDs to use with an interaction.
+ * @param helpChunks -A list of text/phonemes to speak for the help text that is spoken when a user speaks "help" during the interaction.
+ * @param timeoutChunks A list of text/phonems to speak for the timeout text that is spoken when a VR interaction times out.
+ * @param interactionMode - The method in which the user is notified and uses the interaction (Manual,VR,Both).
+ * @param timeout -Timeout in milliseconds.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performInteraction(
+ Vector<TTSChunk> initChunks, String displayText,
+ Vector<Integer> interactionChoiceSetIDList,
+ Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks,
+ InteractionMode interactionMode, Integer timeout,
+ Integer correlationID) throws SdlException {
+
+ PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
+ initChunks, displayText, interactionChoiceSetIDList,
+ helpChunks, timeoutChunks, interactionMode, timeout,
+ correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ // Protected registerAppInterface used to ensure only non-ALM applications call
+ // reqisterAppInterface
+ protected void registerAppInterfacePrivate(
+ SdlMsgVersion sdlMsgVersion, String appName, Vector<TTSChunk> ttsName,
+ String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ Language languageDesired, Language hmiDisplayLanguageDesired, Vector<AppHMIType> appType,
+ String appID, String autoActivateID, Integer correlationID)
+ throws SdlException {
+
+ RegisterAppInterface msg = RPCRequestFactory.buildRegisterAppInterface(
+ sdlMsgVersion, appName, ttsName, ngnMediaScreenAppName, vrSynonyms, isMediaApp,
+ languageDesired, hmiDisplayLanguageDesired, appType, appID, correlationID);
+
+ if (_bAppResumeEnabled)
+ {
+ if (_lastHashID != null)
+ msg.setHashID(_lastHashID);
+ }
+
+ Intent sendIntent = createBroadcastIntent();
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.REGISTER_APP_INTERFACE.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_REQUEST);
+ updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
+ updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
+ sendBroadcastIntent(sendIntent);
+
+ sendRPCRequestPrivate(msg);
+ }
+
+ /*Begin V1 Enhanced helper function*/
+
+ /**
+ * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param helpPrompt
+ * @param timeoutPrompt
+ * @param vrHelpTitle
+ * @param vrHelp
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void setGlobalProperties(
+ String helpPrompt, String timeoutPrompt, String vrHelpTitle, Vector<VrHelpItem> vrHelp, Integer correlationID)
+ throws SdlException {
+
+ SetGlobalProperties req = RPCRequestFactory.buildSetGlobalProperties(helpPrompt,
+ timeoutPrompt, vrHelpTitle, vrHelp, correlationID);
+
+ sendRPCRequest(req);
+ }
+
+ /**
+ * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param helpChunks
+ * @param timeoutChunks
+ * @param vrHelpTitle
+ * @param vrHelp
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void setGlobalProperties(
+ Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks, String vrHelpTitle, Vector<VrHelpItem> vrHelp,
+ Integer correlationID) throws SdlException {
+
+ SetGlobalProperties req = RPCRequestFactory.buildSetGlobalProperties(
+ helpChunks, timeoutChunks, vrHelpTitle, vrHelp, correlationID);
+
+ sendRPCRequest(req);
+ }
+
+ /*End V1 Enhanced helper function*/
+
+ /**
+ * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param helpPrompt
+ * @param timeoutPrompt
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void setGlobalProperties(
+ String helpPrompt, String timeoutPrompt, Integer correlationID)
+ throws SdlException {
+
+ SetGlobalProperties req = RPCRequestFactory.buildSetGlobalProperties(helpPrompt,
+ timeoutPrompt, correlationID);
+
+ sendRPCRequest(req);
+ }
+
+ /**
+ * Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param helpChunks
+ * @param timeoutChunks
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void setGlobalProperties(
+ Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks,
+ Integer correlationID) throws SdlException {
+
+ SetGlobalProperties req = RPCRequestFactory.buildSetGlobalProperties(
+ helpChunks, timeoutChunks, correlationID);
+
+ sendRPCRequest(req);
+ }
+
+ public void resetGlobalProperties(Vector<GlobalProperty> properties,
+ Integer correlationID) throws SdlException {
+
+ ResetGlobalProperties req = new ResetGlobalProperties();
+
+ req.setCorrelationID(correlationID);
+ req.setProperties(properties);
+
+ sendRPCRequest(req);
+ }
+
+
+ /**
+ * Sends a SetMediaClockTimer RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param hours
+ * @param minutes
+ * @param seconds
+ * @param updateMode
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void setMediaClockTimer(Integer hours,
+ Integer minutes, Integer seconds, UpdateMode updateMode,
+ Integer correlationID) throws SdlException {
+
+ SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(hours,
+ minutes, seconds, updateMode, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Pauses the media clock. Responses are captured through callback on IProxyListener.
+ *
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void pauseMediaClockTimer(Integer correlationID)
+ throws SdlException {
+
+ SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
+ 0, 0, UpdateMode.PAUSE, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Resumes the media clock. Responses are captured through callback on IProxyListener.
+ *
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void resumeMediaClockTimer(Integer correlationID)
+ throws SdlException {
+
+ SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
+ 0, 0, UpdateMode.RESUME, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Clears the media clock. Responses are captured through callback on IProxyListener.
+ *
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void clearMediaClockTimer(Integer correlationID)
+ throws SdlException {
+
+ Show msg = RPCRequestFactory.buildShow(null, null, null, " ", null, null, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /*Begin V1 Enhanced helper*/
+ /**
+ * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param mainText1 -Text displayed in a single or upper display line.
+ * @param mainText2 -Text displayed on the second display line.
+ * @param mainText3 -Text displayed on the second "page" first display line.
+ * @param mainText4 -Text displayed on the second "page" second display line.
+ * @param statusBar
+ * @param mediaClock -Text value for MediaClock field.
+ * @param mediaTrack -Text displayed in the track field.
+ * @param graphic -Image struct determining whether static or dynamic image to display in app.
+ * @param softButtons -App defined SoftButtons.
+ * @param customPresets -App labeled on-screen presets.
+ * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void show(String mainText1, String mainText2, String mainText3, String mainText4,
+ String statusBar, String mediaClock, String mediaTrack,
+ Image graphic, Vector<SoftButton> softButtons, Vector <String> customPresets,
+ TextAlignment alignment, Integer correlationID)
+ throws SdlException {
+
+ Show msg = RPCRequestFactory.buildShow(mainText1, mainText2, mainText3, mainText4,
+ statusBar, mediaClock, mediaTrack, graphic, softButtons, customPresets,
+ alignment, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param mainText1 -Text displayed in a single or upper display line.
+ * @param mainText2 -Text displayed on the second display line.
+ * @param mainText3 -Text displayed on the second "page" first display line.
+ * @param mainText4 -Text displayed on the second "page" second display line.
+ * @param graphic -Image struct determining whether static or dynamic image to display in app.
+ * @param softButtons -App defined SoftButtons.
+ * @param customPresets -App labeled on-screen presets.
+ * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void show(String mainText1, String mainText2, String mainText3, String mainText4,
+ Image graphic, Vector<SoftButton> softButtons, Vector <String> customPresets,
+ TextAlignment alignment, Integer correlationID)
+ throws SdlException {
+
+ show(mainText1, mainText2, mainText3, mainText4, null, null, null, graphic, softButtons, customPresets, alignment, correlationID);
+ }
+ /*End V1 Enhanced helper*/
+
+ /**
+ * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param mainText1 -Text displayed in a single or upper display line.
+ * @param mainText2 -Text displayed on the second display line.
+ * @param statusBar
+ * @param mediaClock -Text value for MediaClock field.
+ * @param mediaTrack -Text displayed in the track field.
+ * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void show(String mainText1, String mainText2,
+ String statusBar, String mediaClock, String mediaTrack,
+ TextAlignment alignment, Integer correlationID)
+ throws SdlException {
+
+ Show msg = RPCRequestFactory.buildShow(mainText1, mainText2,
+ statusBar, mediaClock, mediaTrack,
+ alignment, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a Show RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param mainText1 -Text displayed in a single or upper display line.
+ * @param mainText2 -Text displayed on the second display line.
+ * @param alignment -Specifies how mainText1 and mainText2s texts should be aligned on display.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void show(String mainText1, String mainText2,
+ TextAlignment alignment, Integer correlationID)
+ throws SdlException {
+
+ show(mainText1, mainText2, null, null, null, alignment, correlationID);
+ }
+
+ /**
+ * Sends a Speak RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param ttsText -The text to speech message in the form of a string.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void speak(String ttsText, Integer correlationID)
+ throws SdlException {
+
+ Speak msg = RPCRequestFactory.buildSpeak(TTSChunkFactory.createSimpleTTSChunks(ttsText),
+ correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a Speak RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param ttsChunks -Text/phonemes to speak in the form of ttsChunks.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void speak(Vector<TTSChunk> ttsChunks,
+ Integer correlationID) throws SdlException {
+
+ Speak msg = RPCRequestFactory.buildSpeak(ttsChunks, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Sends a SubscribeButton RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param buttonName -Name of the button to subscribe.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void subscribeButton(ButtonName buttonName,
+ Integer correlationID) throws SdlException {
+
+ SubscribeButton msg = RPCRequestFactory.buildSubscribeButton(buttonName,
+ correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ // Protected unregisterAppInterface used to ensure no non-ALM app calls
+ // unregisterAppInterface.
+ protected void unregisterAppInterfacePrivate(Integer correlationID)
+ throws SdlException {
+
+ UnregisterAppInterface msg =
+ RPCRequestFactory.buildUnregisterAppInterface(correlationID);
+ Intent sendIntent = createBroadcastIntent();
+
+ updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.UNREGISTER_APP_INTERFACE.toString());
+ updateBroadcastIntent(sendIntent, "TYPE", RPCMessage.KEY_REQUEST);
+ updateBroadcastIntent(sendIntent, "CORRID", msg.getCorrelationID());
+ updateBroadcastIntent(sendIntent, "DATA",serializeJSON(msg));
+ sendBroadcastIntent(sendIntent);
+
+ sendRPCRequestPrivate(msg);
+ }
+
+ /**
+ * Sends an UnsubscribeButton RPCRequest to SDL. Responses are captured through callback on IProxyListener.
+ *
+ * @param buttonName -Name of the button to unsubscribe.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void unsubscribeButton(ButtonName buttonName,
+ Integer correlationID) throws SdlException {
+
+ UnsubscribeButton msg = RPCRequestFactory.buildUnsubscribeButton(
+ buttonName, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Creates a choice to be added to a choiceset. Choice has both a voice and a visual menu component.
+ *
+ * @param choiceID -Unique ID used to identify this choice (returned in callback).
+ * @param choiceMenuName -Text name displayed for this choice.
+ * @param choiceVrCommands -Vector of vrCommands used to select this choice by voice. Must contain
+ * at least one non-empty element.
+ * @return Choice created.
+ * @throws SdlException
+ */
+ public Choice createChoiceSetChoice(Integer choiceID, String choiceMenuName,
+ Vector<String> choiceVrCommands) {
+ Choice returnChoice = new Choice();
+
+ returnChoice.setChoiceID(choiceID);
+ returnChoice.setMenuName(choiceMenuName);
+ returnChoice.setVrCommands(choiceVrCommands);
+
+ return returnChoice;
+ }
+
+ /**
+ * Starts audio pass thru session. Responses are captured through callback on IProxyListener.
+ *
+ * @param initialPrompt -SDL will speak this prompt before opening the audio pass thru session.
+ * @param audioPassThruDisplayText1 -First line of text displayed during audio capture.
+ * @param audioPassThruDisplayText2 -Second line of text displayed during audio capture.
+ * @param samplingRate -Allowable values of 8 khz or 16 or 22 or 44 khz.
+ * @param maxDuration -The maximum duration of audio recording in milliseconds.
+ * @param bitsPerSample -Specifies the quality the audio is recorded. Currently 8 bit or 16 bit.
+ * @param audioType -Specifies the type of audio data being requested.
+ * @param muteAudio -Defines if the current audio source should be muted during the APT session.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void performaudiopassthru(String initialPrompt, String audioPassThruDisplayText1, String audioPassThruDisplayText2,
+ SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample,
+ AudioType audioType, Boolean muteAudio, Integer correlationID) throws SdlException {
+
+ PerformAudioPassThru msg = RPCRequestFactory.BuildPerformAudioPassThru(initialPrompt, audioPassThruDisplayText1, audioPassThruDisplayText2,
+ samplingRate, maxDuration, bitsPerSample, audioType, muteAudio, correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Ends audio pass thru session. Responses are captured through callback on IProxyListener.
+ *
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void endaudiopassthru(Integer correlationID) throws SdlException
+ {
+ EndAudioPassThru msg = RPCRequestFactory.BuildEndAudioPassThru(correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Subscribes for specific published data items. The data will be only sent if it has changed.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param gps -Subscribes to GPS data.
+ * @param speed -Subscribes to vehicle speed data in kilometers per hour.
+ * @param rpm -Subscribes to number of revolutions per minute of the engine.
+ * @param fuelLevel -Subscribes to fuel level in the tank (percentage).
+ * @param fuelLevel_State -Subscribes to fuel level state.
+ * @param instantFuelConsumption -Subscribes to instantaneous fuel consumption in microlitres.
+ * @param externalTemperature -Subscribes to the external temperature in degrees celsius.
+ * @param prndl -Subscribes to PRNDL data that houses the selected gear.
+ * @param tirePressure -Subscribes to the TireStatus data containing status and pressure of tires.
+ * @param odometer -Subscribes to Odometer data in km.
+ * @param beltStatus -Subscribes to status of the seat belts.
+ * @param bodyInformation -Subscribes to body information including power modes.
+ * @param deviceStatus -Subscribes to device status including signal and battery strength.
+ * @param driverBraking -Subscribes to the status of the brake pedal.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void subscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State,
+ boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure,
+ boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus,
+ boolean driverBraking, Integer correlationID) throws SdlException
+ {
+ SubscribeVehicleData msg = RPCRequestFactory.BuildSubscribeVehicleData(gps, speed, rpm, fuelLevel, fuelLevel_State, instantFuelConsumption, externalTemperature, prndl, tirePressure,
+ odometer, beltStatus, bodyInformation, deviceStatus, driverBraking, correlationID);
+
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Unsubscribes for specific published data items.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param gps -Unsubscribes to GPS data.
+ * @param speed -Unsubscribes to vehicle speed data in kilometers per hour.
+ * @param rpm -Unsubscribes to number of revolutions per minute of the engine.
+ * @param fuelLevel -Unsubscribes to fuel level in the tank (percentage).
+ * @param fuelLevel_State -Unsubscribes to fuel level state.
+ * @param instantFuelConsumption -Unsubscribes to instantaneous fuel consumption in microlitres.
+ * @param externalTemperature -Unsubscribes to the external temperature in degrees celsius.
+ * @param prndl -Unsubscribes to PRNDL data that houses the selected gear.
+ * @param tirePressure -Unsubscribes to the TireStatus data containing status and pressure of tires.
+ * @param odometer -Unsubscribes to Odometer data in km.
+ * @param beltStatus -Unsubscribes to status of the seat belts.
+ * @param bodyInformation -Unsubscribes to body information including power modes.
+ * @param deviceStatus -Unsubscribes to device status including signal and battery strength.
+ * @param driverBraking -Unsubscribes to the status of the brake pedal.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+
+ public void unsubscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State,
+ boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure,
+ boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus,
+ boolean driverBraking, Integer correlationID) throws SdlException
+ {
+ UnsubscribeVehicleData msg = RPCRequestFactory.BuildUnsubscribeVehicleData(gps, speed, rpm, fuelLevel, fuelLevel_State, instantFuelConsumption, externalTemperature, prndl, tirePressure,
+ odometer, beltStatus, bodyInformation, deviceStatus, driverBraking, correlationID);
+ sendRPCRequest(msg);
+ }
+
+
+ /**
+ * Performs a Non periodic vehicle data read request.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param gps -Performs an ad-hoc request for GPS data.
+ * @param speed -Performs an ad-hoc request for vehicle speed data in kilometers per hour.
+ * @param rpm -Performs an ad-hoc request for number of revolutions per minute of the engine.
+ * @param fuelLevel -Performs an ad-hoc request for fuel level in the tank (percentage).
+ * @param fuelLevel_State -Performs an ad-hoc request for fuel level state.
+ * @param instantFuelConsumption -Performs an ad-hoc request for instantaneous fuel consumption in microlitres.
+ * @param externalTemperature -Performs an ad-hoc request for the external temperature in degrees celsius.
+ * @param vin -Performs an ad-hoc request for the Vehicle identification number
+ * @param prndl -Performs an ad-hoc request for PRNDL data that houses the selected gear.
+ * @param tirePressure -Performs an ad-hoc request for the TireStatus data containing status and pressure of tires.
+ * @param odometer -Performs an ad-hoc request for Odometer data in km.
+ * @param beltStatus -Performs an ad-hoc request for status of the seat belts.
+ * @param bodyInformation -Performs an ad-hoc request for body information including power modes.
+ * @param deviceStatus -Performs an ad-hoc request for device status including signal and battery strength.
+ * @param driverBraking -Performs an ad-hoc request for the status of the brake pedal.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void getvehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State,
+ boolean instantFuelConsumption, boolean externalTemperature, boolean vin, boolean prndl, boolean tirePressure,
+ boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus,
+ boolean driverBraking, Integer correlationID) throws SdlException
+ {
+
+ GetVehicleData msg = RPCRequestFactory.BuildGetVehicleData(gps, speed, rpm, fuelLevel, fuelLevel_State, instantFuelConsumption, externalTemperature, vin, prndl, tirePressure, odometer,
+ beltStatus, bodyInformation, deviceStatus, driverBraking, correlationID);
+ sendRPCRequest(msg);
+ }
+
+
+ /**
+ * Creates a full screen overlay containing a large block of formatted text that can be scrolled with up to 8 SoftButtons defined.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param scrollableMessageBody -Body of text that can include newlines and tabs.
+ * @param timeout -App defined timeout. Indicates how long of a timeout from the last action.
+ * @param softButtons -App defined SoftButtons.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void scrollablemessage(String scrollableMessageBody, Integer timeout, Vector<SoftButton> softButtons, Integer correlationID) throws SdlException
+ {
+ ScrollableMessage msg = RPCRequestFactory.BuildScrollableMessage(scrollableMessageBody, timeout, softButtons, correlationID);
+ sendRPCRequest(msg);
+ }
+
+
+ /**
+ * Creates a full screen or pop-up overlay (depending on platform) with a single user controlled slider.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param numTicks -Number of selectable items on a horizontal axis.
+ * @param position -Initial position of slider control (cannot exceed numTicks).
+ * @param sliderHeader -Text header to display.
+ * @param sliderFooter - Text footer to display (meant to display min/max threshold descriptors).
+ * @param timeout -App defined timeout. Indicates how long of a timeout from the last action.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void slider(Integer numTicks, Integer position, String sliderHeader, Vector<String> sliderFooter, Integer timeout, Integer correlationID) throws SdlException
+ {
+ Slider msg = RPCRequestFactory.BuildSlider(numTicks, position, sliderHeader, sliderFooter, timeout, correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param language
+ * @param hmiDisplayLanguage
+ * @param correlationID
+ * @throws SdlException
+ */
+ public void changeregistration(Language language, Language hmiDisplayLanguage, Integer correlationID) throws SdlException
+ {
+ ChangeRegistration msg = RPCRequestFactory.BuildChangeRegistration(language, hmiDisplayLanguage, correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile device.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param is - The input stream of byte data that putFileStream will read from
+ * @param sdlFileName - The file reference name used by the putFile RPC.
+ * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of the file.
+ * A value greater than zero is used for resuming partial data chunks.
+ * @param iLength - The total length of the file being sent.
+ * @throws SdlException
+ * @see {@link#putFileStream(InputStream, String, Long, Long)}
+ */
+ @Deprecated
+ public void putFileStream(InputStream is, String sdlFileName, Integer iOffset, Integer iLength) throws SdlException
+ {
+ PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
+ startRPCStream(is, msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile
+ * device. Responses are captured through callback on IProxyListener.
+ *
+ * @param inputStream The input stream of byte data that will be read from.
+ * @param fileName The SDL file reference name used by the RPC.
+ * @param offset The data offset in bytes. A value of zero is used to
+ * indicate data starting from the beginning of the file and a value greater
+ * than zero is used for resuming partial data chunks.
+ * @param length The total length of the file being sent.
+ * @throws SdlException
+ */
+ public void putFileStream(InputStream inputStream, String fileName, Long offset, Long length) throws SdlException {
+ PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length);
+ startRPCStream(inputStream, msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile device.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param sdlFileName - The file reference name used by the putFile RPC.
+ * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file.
+ * A value greater than zero is used for resuming partial data chunks.
+ * @param iLength - The total length of the file being sent.
+ *
+ * @return OutputStream - The output stream of byte data that is written to by the app developer
+ * @throws SdlException
+ * @see {@link#putFileStream(String, Long, Long)}
+ */
+ @Deprecated
+ public OutputStream putFileStream(String sdlFileName, Integer iOffset, Integer iLength) throws SdlException
+ {
+ PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
+ return startRPCStream(msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile
+ * device. Responses are captured through callback on IProxyListener.
+ *
+ * @param fileName The SDL file reference name used by the RPC.
+ * @param offset The data offset in bytes. A value of zero is used to
+ * indicate data starting from the beginning of the file and a value greater
+ * than zero is used for resuming partial data chunks.
+ * @param length The total length of the file being sent.
+ * @throws SdlException
+ */
+ public void putFileStream(String fileName, Long offset, Long length) throws SdlException {
+ PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length);
+ startRPCStream(msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile device.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param is - The input stream of byte data that PutFileStream will read from
+ * @param sdlFileName - The file reference name used by the putFile RPC.
+ * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of the file.
+ * A value greater than zero is used for resuming partial data chunks.
+ * @param iLength - The total length of the file being sent.
+ * @param fileType - The selected file type -- see the FileType enumeration for details
+ * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles.
+ * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system.
+ * @throws SdlException
+ * @see {@link#putFileStream(InputStream, String, Long, Long, FileType, Boolean, Boolean)}
+ */
+ @Deprecated
+ public void putFileStream(InputStream is, String sdlFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) throws SdlException
+ {
+ PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile);
+ startRPCStream(is, msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile
+ * device. Responses are captured through callback on IProxyListener.
+ *
+ * @param inputStream The input stream of byte data that will be read from.
+ * @param fileName The SDL file reference name used by the RPC.
+ * @param offset The data offset in bytes. A value of zero is used to
+ * indicate data starting from the beginning of the file and a value greater
+ * than zero is used for resuming partial data chunks.
+ * @param length The total length of the file being sent.
+ * @param fileType The selected file type. See the {@link FileType} enum for
+ * details.
+ * @param isPersistentFile Indicates if the file is meant to persist between
+ * sessions / ignition cycles.
+ * @param isSystemFile Indicates if the file is meant to be passed through
+ * core to elsewhere in the system.
+ * @throws SdlException
+ */
+ public void putFileStream(InputStream inputStream, String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile) throws SdlException {
+ PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length);
+ startRPCStream(inputStream, msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile device.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param sdlFileName - The file reference name used by the putFile RPC.
+ * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file.
+ * A value greater than zero is used for resuming partial data chunks.
+ * @param iLength - The total length of the file being sent.
+ * @param fileType - The selected file type -- see the FileType enumeration for details
+ * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles.
+ * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system.
+ * @return OutputStream - The output stream of byte data that is written to by the app developer
+ * @throws SdlException
+ * @see {@link#putFileStream(String, Long, Long, FileType, Boolean, Boolean)}
+ */
+ @Deprecated
+ public OutputStream putFileStream(String sdlFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile) throws SdlException
+ {
+ PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile);
+ return startRPCStream(msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile
+ * device. Responses are captured through callback on IProxyListener.
+ *
+ * @param fileName The SDL file reference name used by the RPC.
+ * @param offset The data offset in bytes. A value of zero is used to
+ * indicate data starting from the beginning of the file and a value greater
+ * than zero is used for resuming partial data chunks.
+ * @param length The total length of the file being sent.
+ * @param fileType The selected file type. See the {@link FileType} enum for
+ * details.
+ * @param isPersistentFile Indicates if the file is meant to persist between
+ * sessions / ignition cycles.
+ * @param isSystemFile Indicates if the file is meant to be passed through
+ * core to elsewhere in the system.
+ * @throws SdlException
+ */
+ public void putFileStream(String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile) throws SdlException {
+ PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length);
+ startRPCStream(msg);
+ }
+
+ /**
+ * Used to push a stream of putfile RPC's containing binary data from a mobile device to the module.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param sPath - The physical file path on the mobile device.
+ * @param sdlFileName - The file reference name used by the putFile RPC.
+ * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file.
+ * A value greater than zero is used for resuming partial data chunks.
+ * @param fileType - The selected file type -- see the FileType enumeration for details
+ * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles.
+ * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system.
+ * @param correlationID - A unique ID that correlates each RPCRequest and RPCResponse.
+ * @return RPCStreamController - If the putFileStream was not started successfully null is returned, otherwise a valid object reference is returned
+ * @throws SdlException
+ * @see {@link#putFileStream(String, String, Long, FileType, Boolean, Boolean, Integer)}
+ */
+ @Deprecated
+ public RPCStreamController putFileStream(String sPath, String sdlFileName, Integer iOffset, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) throws SdlException
+ {
+ PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, 0, fileType, bPersistentFile, bSystemFile, iCorrelationID);
+ return startPutFileStream(sPath, msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile
+ * device. Responses are captured through callback on IProxyListener.
+ *
+ * @param path The physical file path on the mobile device.
+ * @param fileName The SDL file reference name used by the RPC.
+ * @param offset The data offset in bytes. A value of zero is used to
+ * indicate data starting from the beginning of the file and a value greater
+ * than zero is used for resuming partial data chunks.
+ * @param fileType The selected file type. See the {@link FileType} enum for
+ * details.
+ * @param isPersistentFile Indicates if the file is meant to persist between
+ * sessions / ignition cycles.
+ * @param isSystemFile Indicates if the file is meant to be passed through
+ * core to elsewhere in the system.
+ * @param correlationId A unique id that correlates each RPCRequest and
+ * RPCResponse.
+ * @return RPCStreamController If the putFileStream was not started
+ * successfully null is returned, otherwise a valid object reference is
+ * returned .
+ * @throws SdlException
+ */
+ public void putFileStream(String path, String fileName, Long offset, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Integer correlationId) throws SdlException {
+ PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, 0L, fileType, isPersistentFile, isSystemFile, correlationId);
+ startRPCStream(msg);
+ }
+
+ /**
+ * Used to push a stream of putfile RPC's containing binary data from a mobile device to the module.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param is - The input stream of byte data that putFileStream will read from.
+ * @param sdlFileName - The file reference name used by the putFile RPC.
+ * @param iOffset - The data offset in bytes, a value of zero is used to indicate data starting from the beginging of a file.
+ * A value greater than zero is used for resuming partial data chunks.
+ * @param fileType - The selected file type -- see the FileType enumeration for details
+ * @param bPersistentFile - Indicates if the file is meant to persist between sessions / ignition cycles.
+ * @param bSystemFile - Indicates if the file is meant to be passed thru core to elsewhere on the system.
+ * @param correlationID - A unique ID that correlates each RPCRequest and RPCResponse.
+ * @return RPCStreamController - If the putFileStream was not started successfully null is returned, otherwise a valid object reference is returned
+ * @throws SdlException
+ * @see {@link#putFileStream(InputStream, String, Long, Long, FileType, Boolean, Boolean, Integer)}
+ */
+ @Deprecated
+ public RPCStreamController putFileStream(InputStream is, String sdlFileName, Integer iOffset, Integer iLength, FileType fileType, Boolean bPersistentFile, Boolean bSystemFile, Integer iCorrelationID) throws SdlException
+ {
+ PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile, iCorrelationID);
+ return startPutFileStream(is, msg);
+ }
+
+ /**
+ * Used to push a binary stream of file data onto the module from a mobile
+ * device. Responses are captured through callback on IProxyListener.
+ *
+ * @param inputStream The input stream of byte data that will be read from.
+ * @param fileName The SDL file reference name used by the RPC.
+ * @param offset The data offset in bytes. A value of zero is used to
+ * indicate data starting from the beginning of the file and a value greater
+ * than zero is used for resuming partial data chunks.
+ * @param length The total length of the file being sent.
+ * @param fileType The selected file type. See the {@link FileType} enum for
+ * details.
+ * @param isPersistentFile Indicates if the file is meant to persist between
+ * sessions / ignition cycles.
+ * @param isSystemFile Indicates if the file is meant to be passed through
+ * core to elsewhere in the system.
+ * @param correlationId A unique id that correlates each RPCRequest and
+ * RPCResponse.
+ * @throws SdlException
+ */
+ public void putFileStream(InputStream inputStream, String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Integer correlationId) throws SdlException {
+ PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length, fileType, isPersistentFile, isSystemFile, correlationId);
+ startRPCStream(msg);
+ }
+
+ /**
+ *
+ * Used to end an existing putFileStream that was previously initiated with any putFileStream method.
+ *
+ */
+ public void endPutFileStream()
+ {
+ endRPCStream();
+ }
+
+
+ /**
+ * Used to push a binary data onto the SDL module from a mobile device, such as icons and album art. Not supported on first generation SDL vehicles.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param sdlFileName -File reference name.
+ * @param fileType -Selected file type.
+ * @param persistentFile -Indicates if the file is meant to persist between sessions / ignition cycles.
+ * @param fileData
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void putfile(String sdlFileName, FileType fileType, Boolean persistentFile, byte[] fileData, Integer correlationID) throws SdlException
+ {
+ PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, fileType, persistentFile, fileData, correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Used to delete a file resident on the SDL module in the app's local cache. Not supported on first generation SDL vehicles.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param sdlFileName -File reference name.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void deletefile(String sdlFileName, Integer correlationID) throws SdlException
+ {
+ DeleteFile msg = RPCRequestFactory.buildDeleteFile(sdlFileName, correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Requests the current list of resident filenames for the registered app. Not supported on first generation SDL vehicles.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void listfiles(Integer correlationID) throws SdlException
+ {
+ ListFiles msg = RPCRequestFactory.buildListFiles(correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Used to set existing local file on SDL as the app's icon. Not supported on first generation SDL vehicles.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param sdlFileName -File reference name.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void setappicon(String sdlFileName, Integer correlationID) throws SdlException
+ {
+ SetAppIcon msg = RPCRequestFactory.buildSetAppIcon(sdlFileName, correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /**
+ * Set an alternate display layout. If not sent, default screen for given platform will be shown.
+ * Responses are captured through callback on IProxyListener.
+ *
+ * @param displayLayout -Predefined or dynamically created screen layout.
+ * @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException
+ */
+ public void setdisplaylayout(String displayLayout, Integer correlationID) throws SdlException
+ {
+ SetDisplayLayout msg = RPCRequestFactory.BuildSetDisplayLayout(displayLayout, correlationID);
+ sendRPCRequest(msg);
+ }
+
+ /******************** END Public Helper Methods *************************/
+
+ /**
+ * Gets type of transport currently used by this SdlProxy.
+ *
+ * @return One of TransportType enumeration values.
+ *
+ * @see TransportType
+ */
+ public TransportType getCurrentTransportType() throws IllegalStateException {
+ if (sdlSession == null) {
+ throw new IllegalStateException("Incorrect state of SdlProxyBase: Calling for getCurrentTransportType() while connection is not initialized");
+ }
+
+ return sdlSession.getCurrentTransportType();
+ }
+
+ public IProxyListenerBase getProxyListener()
+ {
+ return _proxyListener;
+ }
+
+ public String getAppName()
+ {
+ return _applicationName;
+ }
+
+ public String getNgnAppName()
+ {
+ return _ngnMediaScreenAppName;
+ }
+
+ public String getAppID()
+ {
+ return _appID;
+ }
+
+ public long getInstanceDT()
+ {
+ return instanceDateTime;
+ }
+ public void setConnectionDetails(String sDetails)
+ {
+ sConnectionDetails = sDetails;
+ }
+ public String getConnectionDetails()
+ {
+ return sConnectionDetails;
+ }
+ //for testing only
+ public void setPoliciesURL(String sText)
+ {
+ sPoliciesURL = sText;
+ }
+ //for testing only
+ public String getPoliciesURL()
+ {
+ return sPoliciesURL;
+ }
+
+} // end-class
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java b/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
index aaacf1665..7d112fc14 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
@@ -10,6 +10,7 @@ import com.smartdevicelink.proxy.rpc.DeleteFileResponse;
import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSetResponse;
import com.smartdevicelink.proxy.rpc.DeleteSubMenuResponse;
import com.smartdevicelink.proxy.rpc.DiagnosticMessageResponse;
+import com.smartdevicelink.proxy.rpc.DialNumberResponse;
import com.smartdevicelink.proxy.rpc.EndAudioPassThruResponse;
import com.smartdevicelink.proxy.rpc.GenericResponse;
import com.smartdevicelink.proxy.rpc.GetDTCsResponse;
@@ -28,6 +29,7 @@ import com.smartdevicelink.proxy.rpc.OnLockScreenStatus;
import com.smartdevicelink.proxy.rpc.OnPermissionsChange;
import com.smartdevicelink.proxy.rpc.OnSystemRequest;
import com.smartdevicelink.proxy.rpc.OnTBTClientState;
+import com.smartdevicelink.proxy.rpc.OnStreamRPC;
import com.smartdevicelink.proxy.rpc.OnTouchEvent;
import com.smartdevicelink.proxy.rpc.OnVehicleData;
import com.smartdevicelink.proxy.rpc.PerformAudioPassThruResponse;
@@ -36,6 +38,7 @@ import com.smartdevicelink.proxy.rpc.PutFileResponse;
import com.smartdevicelink.proxy.rpc.ReadDIDResponse;
import com.smartdevicelink.proxy.rpc.ResetGlobalPropertiesResponse;
import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse;
+import com.smartdevicelink.proxy.rpc.SendLocationResponse;
import com.smartdevicelink.proxy.rpc.SetAppIconResponse;
import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse;
@@ -43,6 +46,7 @@ import com.smartdevicelink.proxy.rpc.SetMediaClockTimerResponse;
import com.smartdevicelink.proxy.rpc.ShowResponse;
import com.smartdevicelink.proxy.rpc.SliderResponse;
import com.smartdevicelink.proxy.rpc.SpeakResponse;
+import com.smartdevicelink.proxy.rpc.StreamRPCResponse;
import com.smartdevicelink.proxy.rpc.SubscribeButtonResponse;
import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse;
import com.smartdevicelink.proxy.rpc.SystemRequestResponse;
@@ -75,6 +79,9 @@ public interface IProxyListenerBase {
*/
public void onProxyClosed(String info, Exception e, SdlDisconnectedReason reason);
+ public void onOnStreamRPC(OnStreamRPC notification);
+
+ public void onStreamRPCResponse(StreamRPCResponse response);
/**
* onProxyError() being called indicates that the SDL Proxy experenced an error.
*
@@ -297,4 +304,8 @@ public interface IProxyListenerBase {
public void onGetDTCsResponse(GetDTCsResponse response);
public void onOnLockScreenNotification(OnLockScreenStatus notification);
+
+ public void onDialNumberResponse(DialNumberResponse response);
+
+ public void onSendLocationResponse(SendLocationResponse response);
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IPutFileResponseListener.java b/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IPutFileResponseListener.java
new file mode 100644
index 000000000..7929e86e6
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/interfaces/IPutFileResponseListener.java
@@ -0,0 +1,9 @@
+package com.smartdevicelink.proxy.interfaces;
+
+import com.smartdevicelink.proxy.rpc.PutFileResponse;
+
+public interface IPutFileResponseListener {
+ public void onPutFileResponse(PutFileResponse response);
+
+ public void onPutFileStreamError(Exception e, String info);
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java
index e9bfd6f71..35c726289 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommand.java
@@ -5,7 +5,7 @@ import java.util.List;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
/**
* <p>
@@ -53,7 +53,7 @@ public class AddCommand extends RPCRequest {
* Constructs a new AddCommand object
*/
public AddCommand() {
- super(FunctionID.ADD_COMMAND);
+ super(FunctionID.ADD_COMMAND.toString());
}
/**
@@ -114,7 +114,7 @@ public class AddCommand extends RPCRequest {
try {
return new MenuParams((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MENU_PARAMS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_MENU_PARAMS, e);
}
}
return null;
@@ -149,10 +149,12 @@ public class AddCommand extends RPCRequest {
if (parameters.get(KEY_VR_COMMANDS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_VR_COMMANDS);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>)list;
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
}
+ return (List<String>) list;
}
}
return null;
@@ -175,7 +177,16 @@ public class AddCommand extends RPCRequest {
* not zero-length, not whitespace only) element
*/
public void setVrCommands( List<String> vrCommands ) {
- if (vrCommands != null) {
+
+ boolean valid = true;
+
+ for ( String item : vrCommands ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (vrCommands != null) && (vrCommands.size() > 0) && valid) {
parameters.put(KEY_VR_COMMANDS, vrCommands );
} else {
parameters.remove(KEY_VR_COMMANDS);
@@ -197,7 +208,7 @@ public class AddCommand extends RPCRequest {
try {
return new Image((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CMD_ICON, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_CMD_ICON, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommandResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommandResponse.java
index 26011f2e2..5d64cf6c8 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommandResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddCommandResponse.java
@@ -13,7 +13,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class AddCommandResponse extends RPCResponse {
public AddCommandResponse() {
- super(FunctionID.ADD_COMMAND);
+ super(FunctionID.ADD_COMMAND.toString());
}
public AddCommandResponse(Hashtable<String, Object> hash) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenu.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenu.java
index 469ae5223..9985fab61 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenu.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenu.java
@@ -29,7 +29,7 @@ public class AddSubMenu extends RPCRequest {
* Constructs a new AddSubMenu object
*/
public AddSubMenu() {
- super(FunctionID.ADD_SUB_MENU);
+ super(FunctionID.ADD_SUB_MENU.toString());
}
/**
* Constructs a new AddSubMenu object indicated by the Hashtable parameter
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenuResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenuResponse.java
index c021ed20f..c43317628 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenuResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AddSubMenuResponse.java
@@ -12,7 +12,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class AddSubMenuResponse extends RPCResponse {
public AddSubMenuResponse() {
- super(FunctionID.ADD_SUB_MENU);
+ super(FunctionID.ADD_SUB_MENU.toString());
}
public AddSubMenuResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AirbagStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AirbagStatus.java
index b9688a47e..1d790d3cc 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AirbagStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AirbagStatus.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
public class AirbagStatus extends RPCStruct {
public static final String KEY_DRIVER_AIRBAG_DEPLOYED = "driverAirbagDeployed";
@@ -32,14 +31,8 @@ public class AirbagStatus extends RPCStruct {
Object obj = store.get(KEY_DRIVER_AIRBAG_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_AIRBAG_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -54,14 +47,8 @@ public class AirbagStatus extends RPCStruct {
Object obj = store.get(KEY_DRIVER_SIDE_AIRBAG_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_SIDE_AIRBAG_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -76,14 +63,8 @@ public class AirbagStatus extends RPCStruct {
Object obj = store.get(KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -98,14 +79,8 @@ public class AirbagStatus extends RPCStruct {
Object obj = store.get(KEY_PASSENGER_AIRBAG_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_AIRBAG_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -120,14 +95,8 @@ public class AirbagStatus extends RPCStruct {
Object obj = store.get(KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -142,14 +111,8 @@ public class AirbagStatus extends RPCStruct {
Object obj = store.get(KEY_DRIVER_KNEE_AIRBAG_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_KNEE_AIRBAG_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -164,14 +127,8 @@ public class AirbagStatus extends RPCStruct {
Object obj = store.get(KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -186,15 +143,9 @@ public class AirbagStatus extends RPCStruct {
Object obj = store.get(KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
-}
+} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java
index d65c83084..1f1805dd7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Alert.java
@@ -52,7 +52,7 @@ public class Alert extends RPCRequest {
* Constructs a new Alert object
*/
public Alert() {
- super(FunctionID.ALERT);
+ super(FunctionID.ALERT.toString());
}
/**
* Constructs a new Alert object indicated by the Hashtable parameter
@@ -180,16 +180,43 @@ public class Alert extends RPCRequest {
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<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -203,7 +230,16 @@ public class Alert extends RPCRequest {
* <b>Notes: </b>Array must have a least one element
*/
public void setTtsChunks(List<TTSChunk> ttsChunks) {
- if (ttsChunks != null) {
+
+ boolean valid = true;
+
+ for ( TTSChunk item : ttsChunks ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (ttsChunks != null) && (ttsChunks.size() > 0) && valid) {
parameters.put(KEY_TTS_CHUNKS, ttsChunks);
} else {
parameters.remove(KEY_TTS_CHUNKS);
@@ -281,16 +317,43 @@ public class Alert extends RPCRequest {
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<SoftButton>) list;
- } else if (obj instanceof Hashtable) {
- List<SoftButton> newList = new ArrayList<SoftButton>();
- for (Object hashObj : list) {
- newList.add(new SoftButton((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<SoftButton> softButtonList = new ArrayList<SoftButton>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButton and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButton) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SoftButton>) list;
+ } else if (flagHash) {
+ return softButtonList;
+ }
}
}
return null;
@@ -313,7 +376,16 @@ public class Alert extends RPCRequest {
*/
public void setSoftButtons(List<SoftButton> softButtons) {
- if (softButtons != null) {
+
+ boolean valid = true;
+
+ for ( SoftButton item : softButtons ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
parameters.put(KEY_SOFT_BUTTONS, softButtons);
} else {
parameters.remove(KEY_SOFT_BUTTONS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java
index 791c89a1b..6bc897ae7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuver.java
@@ -28,7 +28,7 @@ public class AlertManeuver extends RPCRequest{
* Constructs a new AlertManeuver object
*/
public AlertManeuver(){
- super(FunctionID.ALERT_MANEUVER);
+ super(FunctionID.ALERT_MANEUVER.toString());
}
/**
@@ -54,17 +54,43 @@ public class AlertManeuver extends RPCRequest{
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<SoftButton>) list;
- }
- else if(obj instanceof Hashtable){
- List<SoftButton> newList = new ArrayList<SoftButton>();
- for(Object hashObj : list){
- newList.add(new SoftButton((Hashtable<String, Object>) hashObj));
- }
- return newList;
- }
+
+ List<SoftButton> softButtonList = new ArrayList<SoftButton>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButton and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButton) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SoftButton>) list;
+ } else if (flagHash) {
+ return softButtonList;
+ }
}
}
return null;
@@ -86,7 +112,16 @@ public class AlertManeuver extends RPCRequest{
*/
public void setSoftButtons(List<SoftButton> softButtons){
- if(softButtons != null){
+
+ boolean valid = true;
+
+ for ( SoftButton item : softButtons ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
parameters.put(KEY_SOFT_BUTTONS, softButtons);
}
else{
@@ -104,17 +139,43 @@ public class AlertManeuver extends RPCRequest{
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<TTSChunk>) list;
- }
- else if(obj instanceof Hashtable){
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for(Object hashObj : list){
- newList.add(new TTSChunk((Hashtable<String, Object>) hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -128,7 +189,16 @@ public class AlertManeuver extends RPCRequest{
* <b>Notes: </b>Array must have a least one element
*/
public void setTtsChunks(List<TTSChunk> ttsChunks){
- if(ttsChunks != null){
+
+ boolean valid = true;
+
+ for ( TTSChunk item : ttsChunks ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (ttsChunks != null) && (ttsChunks.size() > 0) && valid) {
parameters.put(KEY_TTS_CHUNKS, ttsChunks);
}
else{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java
index 24d5dc710..6ed8ca1a4 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertManeuverResponse.java
@@ -16,7 +16,7 @@ public class AlertManeuverResponse extends RPCResponse{
* Constructs a new AlertManeuverResponse object
*/
public AlertManeuverResponse() {
- super(FunctionID.ALERT_MANEUVER);
+ super(FunctionID.ALERT_MANEUVER.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertResponse.java
index 221ae43ca..fc01fbe63 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AlertResponse.java
@@ -17,7 +17,7 @@ public class AlertResponse extends RPCResponse {
* Constructs a new AlertResponse object
*/
public AlertResponse() {
- super(FunctionID.ALERT);
+ super(FunctionID.ALERT.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java
index ff20515a8..fcb9302a5 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java
@@ -5,8 +5,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.AudioType;
import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
-import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
/**
* Describes different audio type configurations for PerformAudioPassThru, e.g. {8kHz,8-bit,PCM}
@@ -80,14 +79,8 @@ public class AudioPassThruCapabilities extends RPCStruct {
Object obj = store.get(KEY_SAMPLING_RATE);
if (obj instanceof SamplingRate) {
return (SamplingRate) obj;
- } else if (obj instanceof String) {
- SamplingRate theCode = null;
- try {
- theCode = SamplingRate.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SAMPLING_RATE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return SamplingRate.valueForString((String) obj);
}
return null;
}
@@ -112,14 +105,8 @@ public class AudioPassThruCapabilities extends RPCStruct {
Object obj = store.get(KEY_BITS_PER_SAMPLE);
if (obj instanceof BitsPerSample) {
return (BitsPerSample) obj;
- } else if (obj instanceof String) {
- BitsPerSample theCode = null;
- try {
- theCode = BitsPerSample.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BITS_PER_SAMPLE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return BitsPerSample.valueForString((String) obj);
}
return null;
}
@@ -144,14 +131,8 @@ public class AudioPassThruCapabilities extends RPCStruct {
Object obj = store.get(KEY_AUDIO_TYPE);
if (obj instanceof AudioType) {
return (AudioType) obj;
- } else if (obj instanceof String) {
- AudioType theCode = null;
- try {
- theCode = AudioType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AUDIO_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return AudioType.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BeltStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BeltStatus.java
index 8e8086b95..e77a8c5bf 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BeltStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BeltStatus.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
public class BeltStatus extends RPCStruct {
public static final String KEY_DRIVER_BELT_DEPLOYED = "driverBeltDeployed";
@@ -39,14 +38,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_DRIVER_BELT_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BELT_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -61,14 +54,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_PASSENGER_BELT_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_BELT_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -83,14 +70,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_PASSENGER_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -105,14 +86,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_DRIVER_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -127,14 +102,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_LEFT_ROW_2_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LEFT_ROW_2_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -149,14 +118,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_PASSENGER_CHILD_DETECTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PASSENGER_CHILD_DETECTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -171,14 +134,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_RIGHT_ROW_2_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_ROW_2_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -193,14 +150,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_MIDDLE_ROW_2_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MIDDLE_ROW_2_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -215,14 +166,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_MIDDLE_ROW_3_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MIDDLE_ROW_3_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -237,14 +182,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_LEFT_ROW_3_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LEFT_ROW_3_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -259,14 +198,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_RIGHT_ROW_3_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_ROW_3_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -281,14 +214,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_REAR_INFLATABLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_REAR_INFLATABLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -303,14 +230,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_RIGHT_REAR_INFLATABLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_REAR_INFLATABLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -325,14 +246,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_MIDDLE_ROW_1_BELT_DEPLOYED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MIDDLE_ROW_1_BELT_DEPLOYED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -347,14 +262,8 @@ public class BeltStatus extends RPCStruct {
Object obj = store.get(KEY_MIDDLE_ROW_1_BUCKLE_BELTED);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MIDDLE_ROW_1_BUCKLE_BELTED, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BodyInformation.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BodyInformation.java
index 908c215e7..94ddc6de7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BodyInformation.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/BodyInformation.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.IgnitionStableStatus;
-import com.smartdevicelink.proxy.rpc.enums.IgnitionStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.IgnitionStatus;
public class BodyInformation extends RPCStruct {
public static final String KEY_PARK_BRAKE_ACTIVE = "parkBrakeActive";
@@ -42,14 +41,8 @@ public class BodyInformation extends RPCStruct {
Object obj = store.get(KEY_IGNITION_STABLE_STATUS);
if (obj instanceof IgnitionStableStatus) {
return (IgnitionStableStatus) obj;
- } else if (obj instanceof String) {
- IgnitionStableStatus theCode = null;
- try {
- theCode = IgnitionStableStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IGNITION_STABLE_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return IgnitionStableStatus.valueForString((String) obj);
}
return null;
}
@@ -64,14 +57,8 @@ public class BodyInformation extends RPCStruct {
Object obj = store.get(KEY_IGNITION_STATUS);
if (obj instanceof IgnitionStatus) {
return (IgnitionStatus) obj;
- } else if (obj instanceof String) {
- IgnitionStatus theCode = null;
- try {
- theCode = IgnitionStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IGNITION_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return IgnitionStatus.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java
index 823242a56..36b1783ef 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.ButtonName;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.ButtonName;
/**
* Provides information about the capabilities of a SDL HMI button.
@@ -68,14 +67,8 @@ public class ButtonCapabilities extends RPCStruct {
Object obj = store.get(KEY_NAME);
if (obj instanceof ButtonName) {
return (ButtonName) obj;
- } else if (obj instanceof String) {
- ButtonName theCode = null;
- try {
- theCode = ButtonName.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_NAME, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ButtonName.valueForString((String) obj);
}
return null;
}
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 09aee2072..095ee74d4 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistration.java
@@ -6,8 +6,7 @@ import java.util.List;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.Language;
/**
* If the app recognizes during the app registration that the Sdl HMI language
@@ -35,7 +34,7 @@ public class ChangeRegistration extends RPCRequest {
* Constructs a new ChangeRegistration object
*/
public ChangeRegistration() {
- super(FunctionID.CHANGE_REGISTRATION);
+ super(FunctionID.CHANGE_REGISTRATION.toString());
}
/**
@@ -73,14 +72,8 @@ public class ChangeRegistration extends RPCRequest {
Object obj = parameters.get(KEY_LANGUAGE);
if (obj instanceof Language) {
return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LANGUAGE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
}
return null;
}
@@ -108,14 +101,8 @@ public class ChangeRegistration extends RPCRequest {
Object obj = parameters.get(KEY_HMI_DISPLAY_LANGUAGE);
if (obj instanceof Language) {
return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_DISPLAY_LANGUAGE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
}
return null;
}
@@ -172,7 +159,16 @@ public class ChangeRegistration extends RPCRequest {
* @param ttsName The TTS name to set
*/
public void setTtsName(List<TTSChunk> ttsName){
- if(ttsName != null){
+
+ boolean valid = true;
+
+ for ( TTSChunk item : ttsName ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (ttsName != null) && (ttsName.size() > 0) && valid) {
parameters.put(KEY_TTS_NAME, ttsName);
}
else{
@@ -190,16 +186,43 @@ public class ChangeRegistration extends RPCRequest {
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<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -216,12 +239,14 @@ public class ChangeRegistration extends RPCRequest {
@SuppressWarnings("unchecked")
public List<String> 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<String>) list;
- }
+ List<?> list = (List<?>) parameters.get(KEY_VR_SYNONYMS);
+ if (list != null && list.size() > 0) {
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
+ }
+ return (List<String>) list;
}
}
return null;
@@ -245,7 +270,16 @@ public class ChangeRegistration extends RPCRequest {
* </ul>
*/
public void setVrSynonyms(List<String> vrSynonyms) {
- if (vrSynonyms != null) {
+
+ boolean valid = true;
+
+ for ( String item : vrSynonyms ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (vrSynonyms != null) && (vrSynonyms.size() > 0) && valid) {
parameters.put(KEY_VR_SYNONYMS, vrSynonyms);
} else {
parameters.remove(KEY_VR_SYNONYMS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistrationResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistrationResponse.java
index ad71f6561..0ab62ba49 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistrationResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ChangeRegistrationResponse.java
@@ -16,7 +16,7 @@ public class ChangeRegistrationResponse extends RPCResponse {
* Constructs a new ChangeRegistrationResponse object
*/
public ChangeRegistrationResponse() {
- super(FunctionID.CHANGE_REGISTRATION);
+ super(FunctionID.CHANGE_REGISTRATION.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java
index 1d5a1e888..07f982322 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Choice.java
@@ -4,7 +4,7 @@ import java.util.Hashtable;
import java.util.List;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
/**
* A choice is an option which a user can select either via the menu or via voice recognition (VR) during an application initiated interaction.
@@ -119,10 +119,12 @@ public class Choice extends RPCStruct {
if (store.get(KEY_VR_COMMANDS) instanceof List<?>) {
List<?> list = (List<?>)store.get( KEY_VR_COMMANDS);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
}
+ return (List<String>) list;
}
}
return null;
@@ -133,7 +135,16 @@ public class Choice extends RPCStruct {
* @since SmartDeviceLink 2.0
*/
public void setVrCommands(List<String> vrCommands) {
- if (vrCommands != null) {
+
+ boolean valid = true;
+
+ for ( String item : vrCommands ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (vrCommands != null) && (vrCommands.size() > 0) && valid) {
store.put(KEY_VR_COMMANDS, vrCommands);
} else {
store.remove(KEY_VR_COMMANDS);
@@ -163,7 +174,7 @@ public class Choice extends RPCStruct {
try {
return new Image((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
}
}
return null;
@@ -212,7 +223,7 @@ public class Choice extends RPCStruct {
try {
return new Image((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SECONDARY_IMAGE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_SECONDARY_IMAGE, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java
index 33a7a61be..8bc55e2e7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java
@@ -5,8 +5,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.CarModeStatus;
import com.smartdevicelink.proxy.rpc.enums.PowerModeQualificationStatus;
-import com.smartdevicelink.proxy.rpc.enums.PowerModeStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.PowerModeStatus;
public class ClusterModeStatus extends RPCStruct {
public static final String KEY_POWER_MODE_ACTIVE = "powerModeActive";
@@ -40,14 +39,8 @@ public class ClusterModeStatus extends RPCStruct {
Object obj = store.get(KEY_POWER_MODE_QUALIFICATION_STATUS);
if (obj instanceof PowerModeQualificationStatus) {
return (PowerModeQualificationStatus) obj;
- } else if (obj instanceof String) {
- PowerModeQualificationStatus theCode = null;
- try {
- theCode = PowerModeQualificationStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_POWER_MODE_QUALIFICATION_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return PowerModeQualificationStatus.valueForString((String) obj);
}
return null;
}
@@ -62,14 +55,8 @@ public class ClusterModeStatus extends RPCStruct {
Object obj = store.get(KEY_CAR_MODE_STATUS);
if (obj instanceof CarModeStatus) {
return (CarModeStatus) obj;
- } else if (obj instanceof String) {
- CarModeStatus theCode = null;
- try {
- theCode = CarModeStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CAR_MODE_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return CarModeStatus.valueForString((String) obj);
}
return null;
}
@@ -84,14 +71,8 @@ public class ClusterModeStatus extends RPCStruct {
Object obj = store.get(KEY_POWER_MODE_STATUS);
if (obj instanceof PowerModeStatus) {
return (PowerModeStatus) obj;
- } else if (obj instanceof String) {
- PowerModeStatus theCode = null;
- try {
- theCode = PowerModeStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_POWER_MODE_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return PowerModeStatus.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java
index 53fee6201..bd4a3aca0 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java
@@ -28,7 +28,7 @@ public class CreateInteractionChoiceSet extends RPCRequest {
* Constructs a new CreateInteractionChoiceSet object
*/
public CreateInteractionChoiceSet() {
- super(FunctionID.CREATE_INTERACTION_CHOICE_SET);
+ super(FunctionID.CREATE_INTERACTION_CHOICE_SET.toString());
}
/**
* Constructs a new CreateInteractionChoiceSet object indicated by the
@@ -75,16 +75,43 @@ public class CreateInteractionChoiceSet extends RPCRequest {
if (parameters.get(KEY_CHOICE_SET) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_CHOICE_SET);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof Choice) {
- return (List<Choice>) list;
- } else if (obj instanceof Hashtable) {
- List<Choice> newList = new ArrayList<Choice>();
- for (Object hashObj : list) {
- newList.add(new Choice((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<Choice> choiceList = new ArrayList<Choice>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButton and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof Choice) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ choiceList.add(new Choice((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<Choice>) list;
+ } else if (flagHash) {
+ return choiceList;
+ }
}
}
return null;
@@ -99,7 +126,16 @@ public class CreateInteractionChoiceSet extends RPCRequest {
* <b>Notes: </b>Min Value: 1; Max Value: 100
*/
public void setChoiceSet( List<Choice> choiceSet ) {
- if (choiceSet != null) {
+
+ boolean valid = true;
+
+ for ( Choice item : choiceSet ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (choiceSet != null) && (choiceSet.size() > 0) && valid) {
parameters.put(KEY_CHOICE_SET, choiceSet );
} else {
parameters.remove(KEY_CHOICE_SET);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSetResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSetResponse.java
index 7edc84294..d5a417090 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSetResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSetResponse.java
@@ -14,7 +14,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class CreateInteractionChoiceSetResponse extends RPCResponse {
public CreateInteractionChoiceSetResponse() {
- super(FunctionID.CREATE_INTERACTION_CHOICE_SET);
+ super(FunctionID.CREATE_INTERACTION_CHOICE_SET.toString());
}
public CreateInteractionChoiceSetResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DIDResult.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DIDResult.java
index 98056f85d..3ac63fbb6 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DIDResult.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DIDResult.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode;
public class DIDResult extends RPCStruct {
public static final String KEY_RESULT_CODE = "resultCode";
@@ -26,14 +25,8 @@ public class DIDResult extends RPCStruct {
Object obj = store.get(KEY_RESULT_CODE);
if (obj instanceof VehicleDataResultCode) {
return (VehicleDataResultCode) obj;
- } else if (obj instanceof String) {
- VehicleDataResultCode theCode = null;
- try {
- theCode = VehicleDataResultCode.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RESULT_CODE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataResultCode.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommand.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommand.java
index 2aa701afe..bf32d6996 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommand.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommand.java
@@ -26,7 +26,7 @@ public class DeleteCommand extends RPCRequest {
* Constructs a new DeleteCommand object
*/
public DeleteCommand() {
- super(FunctionID.DELETE_COMMAND);
+ super(FunctionID.DELETE_COMMAND.toString());
}
/**
* Constructs a new DeleteCommand object indicated by the Hashtable
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommandResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommandResponse.java
index ace0f8beb..b6bcc9e7d 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommandResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteCommandResponse.java
@@ -13,7 +13,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class DeleteCommandResponse extends RPCResponse {
public DeleteCommandResponse() {
- super(FunctionID.DELETE_COMMAND);
+ super(FunctionID.DELETE_COMMAND.toString());
}
public DeleteCommandResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFile.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFile.java
index ebb134a7a..b2bc91a99 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFile.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFile.java
@@ -21,7 +21,7 @@ public class DeleteFile extends RPCRequest {
* Constructs a new DeleteFile object
*/
public DeleteFile() {
- super(FunctionID.DELETE_FILE);
+ super(FunctionID.DELETE_FILE.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java
index 5d09572b0..ad54b2a14 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java
@@ -14,7 +14,7 @@ public class DeleteFileResponse extends RPCResponse {
public static final String KEY_SPACE_AVAILABLE = "spaceAvailable";
public DeleteFileResponse() {
- super(FunctionID.DELETE_FILE);
+ super(FunctionID.DELETE_FILE.toString());
}
public DeleteFileResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java
index df80e02c2..0d7d610d7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java
@@ -27,7 +27,7 @@ public class DeleteInteractionChoiceSet extends RPCRequest {
* Constructs a new DeleteInteractionChoiceSet object
*/
public DeleteInteractionChoiceSet() {
- super(FunctionID.DELETE_INTERACTION_CHOICE_SET);
+ super(FunctionID.DELETE_INTERACTION_CHOICE_SET.toString());
}
/**
* Constructs a new DeleteInteractionChoiceSet object indicated by the
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSetResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSetResponse.java
index 6c41b23ef..5f29ed567 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSetResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSetResponse.java
@@ -13,7 +13,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class DeleteInteractionChoiceSetResponse extends RPCResponse {
public DeleteInteractionChoiceSetResponse() {
- super(FunctionID.DELETE_INTERACTION_CHOICE_SET);
+ super(FunctionID.DELETE_INTERACTION_CHOICE_SET.toString());
}
public DeleteInteractionChoiceSetResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java
index 154ba6668..bd7fc216b 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java
@@ -25,7 +25,7 @@ public class DeleteSubMenu extends RPCRequest {
* Constructs a new DeleteSubMenu object
*/
public DeleteSubMenu() {
- super(FunctionID.DELETE_SUB_MENU);
+ super(FunctionID.DELETE_SUB_MENU.toString());
}
/**
* Constructs a new DeleteSubMenu object indicated by the Hashtable parameter<p>
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenuResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenuResponse.java
index cf24f0e16..c13e37131 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenuResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeleteSubMenuResponse.java
@@ -13,7 +13,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class DeleteSubMenuResponse extends RPCResponse {
public DeleteSubMenuResponse() {
- super(FunctionID.DELETE_SUB_MENU);
+ super(FunctionID.DELETE_SUB_MENU.toString());
}
public DeleteSubMenuResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeviceStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeviceStatus.java
index e5a1eeb53..19d6d037e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeviceStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DeviceStatus.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.DeviceLevelStatus;
-import com.smartdevicelink.proxy.rpc.enums.PrimaryAudioSource;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.PrimaryAudioSource;
/**
* Describes the status related to a connected mobile device or SDL and if or how it is represented in the vehicle.
@@ -238,14 +237,8 @@ public class DeviceStatus extends RPCStruct {
Object obj = store.get(KEY_BATT_LEVEL_STATUS);
if (obj instanceof DeviceLevelStatus) {
return (DeviceLevelStatus) obj;
- } else if (obj instanceof String) {
- DeviceLevelStatus theCode = null;
- try {
- theCode = DeviceLevelStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BATT_LEVEL_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return DeviceLevelStatus.valueForString((String) obj);
}
return null;
}
@@ -310,14 +303,8 @@ public class DeviceStatus extends RPCStruct {
Object obj = store.get(KEY_SIGNAL_LEVEL_STATUS);
if (obj instanceof DeviceLevelStatus) {
return (DeviceLevelStatus) obj;
- } else if (obj instanceof String) {
- DeviceLevelStatus theCode = null;
- try {
- theCode = DeviceLevelStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SIGNAL_LEVEL_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return DeviceLevelStatus.valueForString((String) obj);
}
return null;
}
@@ -342,14 +329,8 @@ public class DeviceStatus extends RPCStruct {
Object obj = store.get(KEY_PRIMARY_AUDIO_SOURCE);
if (obj instanceof PrimaryAudioSource) {
return (PrimaryAudioSource) obj;
- } else if (obj instanceof String) {
- PrimaryAudioSource theCode = null;
- try {
- theCode = PrimaryAudioSource.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRIMARY_AUDIO_SOURCE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return PrimaryAudioSource.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java
index 2aa37445b..df067b49e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java
@@ -12,7 +12,7 @@ public class DiagnosticMessage extends RPCRequest {
public static final String KEY_MESSAGE_DATA = "messageData";
public DiagnosticMessage() {
- super(FunctionID.DIAGNOSTIC_MESSAGE);
+ super(FunctionID.DIAGNOSTIC_MESSAGE.toString());
}
public DiagnosticMessage(Hashtable<String, Object> hash) {
@@ -45,18 +45,29 @@ public class DiagnosticMessage extends RPCRequest {
public List<Integer> getMessageData() {
if(parameters.get(KEY_MESSAGE_DATA) instanceof List<?>){
List<?> list = (List<?>)parameters.get(KEY_MESSAGE_DATA);
- if(list != null && list.size()>0){
- Object obj = list.get(0);
- if(obj instanceof Integer){
- return (List<Integer>) list;
+ if(list != null && list.size() > 0){
+ for( Object obj : list ) {
+ if (!(obj instanceof Integer)) {
+ return null;
+ }
}
+ return (List<Integer>) list;
}
}
return null;
}
public void setMessageData(List<Integer> messageData) {
- if (messageData != null) {
+
+ boolean valid = true;
+
+ for ( Integer item : messageData ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (messageData != null) && (messageData.size() > 0) && valid) {
parameters.put(KEY_MESSAGE_DATA, messageData);
} else {
parameters.remove(KEY_MESSAGE_DATA);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
index 742270845..35dcc49de 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
@@ -10,7 +10,7 @@ public class DiagnosticMessageResponse extends RPCResponse {
public static final String KEY_MESSAGE_DATA_RESULT = "messageDataResult";
public DiagnosticMessageResponse() {
- super(FunctionID.DIAGNOSTIC_MESSAGE);
+ super(FunctionID.DIAGNOSTIC_MESSAGE.toString());
}
public DiagnosticMessageResponse(Hashtable<String, Object> hash) {
super(hash);
@@ -20,17 +20,28 @@ public class DiagnosticMessageResponse extends RPCResponse {
if(parameters.get(KEY_MESSAGE_DATA_RESULT) instanceof List<?>){
List<?> list = (List<?>)parameters.get(KEY_MESSAGE_DATA_RESULT);
if(list != null && list.size()>0){
- Object obj = list.get(0);
- if(obj instanceof Integer){
- return (List<Integer>) list;
+ for( Object obj : list ) {
+ if (!(obj instanceof Integer)) {
+ return null;
+ }
}
+ return (List<Integer>) list;
}
}
return null;
}
public void setMessageDataResult(List<Integer> messageDataResult) {
- if (messageDataResult != null) {
+
+ boolean valid = true;
+
+ for ( Integer item : messageDataResult ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (messageDataResult != null) && (messageDataResult.size() > 0) && valid) {
parameters.put(KEY_MESSAGE_DATA_RESULT, messageDataResult);
} else {
parameters.remove(KEY_MESSAGE_DATA_RESULT);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DialNumber.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DialNumber.java
new file mode 100644
index 000000000..76fbc02d1
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DialNumber.java
@@ -0,0 +1,51 @@
+package com.smartdevicelink.proxy.rpc;
+
+import java.util.Hashtable;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+
+/**
+ * Dials a phone number and switches to phone application.
+ *
+ * @since SmartDeviceLink 4.0
+ */
+public class DialNumber extends RPCRequest {
+ public static final String KEY_NUMBER = "number";
+
+
+ public DialNumber(){
+ super(FunctionID.DIAL_NUMBER.toString());
+ }
+
+ public DialNumber(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets a number to dial
+ *
+ * @param number
+ * a phone number is a string, which can be up to 40 chars.
+ * <p>
+ * <b>Notes: </b>Maxlength=40<p>
+ * All characters shall be stripped from string except digits 0-9 and * # , ; +
+ */
+ public void setNumber(String number) {
+ if (number != null) {
+ number = number.replaceAll("[^0-9*#,;+]", ""); //This will sanitize the input
+ parameters.put(KEY_NUMBER, number);
+ } else {
+ parameters.remove(KEY_NUMBER);
+ }
+ }
+
+ /**
+ * Gets a number to dial
+ *
+ * @return String - a String value representing a number to dial
+ */
+ public String getNumber() {
+ return (String) parameters.get(KEY_NUMBER);
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DialNumberResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DialNumberResponse.java
new file mode 100644
index 000000000..613755442
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DialNumberResponse.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;
+
+/**
+ * Dial Number Response is sent, when DialNumber has been called
+ *
+ * @since SmartDeviceLink 4.0
+ */
+public class DialNumberResponse extends RPCResponse {
+
+ public DialNumberResponse() {
+ super(FunctionID.DIAL_NUMBER.toString());
+ }
+
+ public DialNumberResponse(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
index 2617b533a..bd66ee78b 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
@@ -1,296 +1,409 @@
-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.DisplayType;
-import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
-import com.smartdevicelink.util.LogTool;
-/**
- * Contains information about the display for the SDL system to which the application is currently connected.
- * <p><b> Parameter List
- * <table border="1" rules="all">
- * <tr>
- * <th>Name</th>
- * <th>Type</th>
- * <th>Description</th>
- * <th>SmartDeviceLink Ver. Available</th>
- * </tr>
- * <tr>
- * <td>displayType</td>
- * <td>DisplayType</td>
- * <td>The type of display
- * </td>
- * <td>SmartDeviceLink 1.0</td>
- * </tr>
- * <tr>
- * <td>textField</td>
- * <td>TextField[]</td>
- * <td>An array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as <i>{@linkplain Show}</i>, <i>{@linkplain SetMediaClockTimer}</i>, etc.
- * This array of TextField structures identify all the text fields to which the application can write on the current display (identified by DisplayType ).
- * </td>
- * <td>SmartDeviceLink 1.0</td>
- * </tr>
- * <tr>
- * <td>mediaClockFormats</td>
- * <td>MediaClockFormat[]</td>
- * <td>An array of MediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field</td>
- * <td>SmartDeviceLink 1.0</td>
- * </tr>
- * <tr>
- * <td>graphicSupported</td>
- * <td>Boolean</td>
- * <td>The display's persistent screen supports referencing a static or dynamic image.</td>
- * <td>SmartDeviceLink 2.0</td>
- * </tr>
- * </table>
- * @since SmartDeviceLink 1.0
- */
-public class DisplayCapabilities extends RPCStruct {
- public static final String KEY_DISPLAY_TYPE = "displayType";
- public static final String KEY_MEDIA_CLOCK_FORMATS = "mediaClockFormats";
- public static final String KEY_TEXT_FIELDS = "textFields";
- public static final String KEY_IMAGE_FIELDS = "imageFields";
- public static final String KEY_GRAPHIC_SUPPORTED = "graphicSupported";
- public static final String KEY_SCREEN_PARAMS = "screenParams";
- public static final String KEY_TEMPLATES_AVAILABLE = "templatesAvailable";
- public static final String KEY_NUM_CUSTOM_PRESETS_AVAILABLE = "numCustomPresetsAvailable";
- /**
- * Constructs a newly allocated DisplayCapabilities object
- */
- public DisplayCapabilities() { }
- /**
- * Constructs a newly allocated DisplayCapabilities object indicated by the Hashtable parameter
- * @param hash The Hashtable to use
- */
- public DisplayCapabilities(Hashtable<String, Object> hash) {
- super(hash);
- }
- /**
- * Get the type of display
- * @return the type of display
- */
- public DisplayType getDisplayType() {
- Object obj = store.get(KEY_DISPLAY_TYPE);
- if (obj instanceof DisplayType) {
- return (DisplayType) obj;
- } else if (obj instanceof String) {
- DisplayType theCode = null;
- try {
- theCode = DisplayType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DISPLAY_TYPE, e);
- }
- return theCode;
- }
- return null;
- }
- /**
- * Set the type of display
- * @param displayType the display type
- */
- public void setDisplayType( DisplayType displayType ) {
- if (displayType != null) {
- store.put(KEY_DISPLAY_TYPE, displayType );
- } else {
- store.remove(KEY_DISPLAY_TYPE);
- }
- }
- /**
- *Get an array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as <i>{@linkplain Show}</i>, <i>{@linkplain SetMediaClockTimer}</i>, etc.
- * This array of TextField structures identify all the text fields to which the application can write on the current display (identified by DisplayType ).
- * @return the List of textFields
- */
- @SuppressWarnings("unchecked")
- public List<TextField> getTextFields() {
- if (store.get(KEY_TEXT_FIELDS) instanceof List<?>) {
- List<?> list = (List<?>)store.get(KEY_TEXT_FIELDS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TextField) {
- return (List<TextField>) list;
- } else if (obj instanceof Hashtable) {
- List<TextField> newList = new ArrayList<TextField>();
- for (Object hashObj : list) {
- newList.add(new TextField((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Set an array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as <i>{@linkplain Show}</i>, <i>{@linkplain SetMediaClockTimer}</i>, etc.
- * This array of TextField structures identify all the text fields to which the application can write on the current display (identified by DisplayType ).
- * @param textFields the List of textFields
- */
- public void setTextFields( List<TextField> textFields ) {
- if (textFields != null) {
- store.put(KEY_TEXT_FIELDS, textFields );
- } else {
- store.remove(KEY_TEXT_FIELDS);
- }
- }
-
-
-
- @SuppressWarnings("unchecked")
- public List<ImageField> getImageFields() {
- if (store.get(KEY_IMAGE_FIELDS) instanceof List<?>) {
- List<?> list = (List<?>)store.get(KEY_IMAGE_FIELDS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof ImageField) {
- return (List<ImageField>) list;
- } else if (obj instanceof Hashtable) {
- List<ImageField> newList = new ArrayList<ImageField>();
- for (Object hashObj : list) {
- newList.add(new ImageField((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
- }
- }
- return null;
- }
-
- public void setImageFields( List<ImageField> imageFields ) {
- if (imageFields != null) {
- store.put(KEY_IMAGE_FIELDS, imageFields );
- }
- else
- {
- store.remove(KEY_IMAGE_FIELDS);
- }
- }
-
- public Integer getNumCustomPresetsAvailable() {
- return (Integer) store.get(KEY_NUM_CUSTOM_PRESETS_AVAILABLE);
- }
-
- public void setNumCustomPresetsAvailable(Integer numCustomPresetsAvailable) {
- if (numCustomPresetsAvailable != null) {
- store.put(KEY_NUM_CUSTOM_PRESETS_AVAILABLE, numCustomPresetsAvailable);
- }
- else
- {
- store.remove(KEY_NUM_CUSTOM_PRESETS_AVAILABLE);
- }
- }
-
- /**
- * Get an array of MediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field
- * @return the Veotor of mediaClockFormat
- */
- @SuppressWarnings("unchecked")
- public List<MediaClockFormat> getMediaClockFormats() {
- if (store.get(KEY_MEDIA_CLOCK_FORMATS) instanceof List<?>) {
- List<?> list = (List<?>)store.get(KEY_MEDIA_CLOCK_FORMATS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof MediaClockFormat) {
- return (List<MediaClockFormat>) list;
- } else if (obj instanceof String) {
- List<MediaClockFormat> newList = new ArrayList<MediaClockFormat>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- MediaClockFormat toAdd = null;
- try {
- toAdd = MediaClockFormat.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse MediaClockFormat from " + getClass().getSimpleName() + "." + KEY_MEDIA_CLOCK_FORMATS, e);
- }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Set an array of MediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field
- * @param mediaClockFormats the List of MediaClockFormat
- */
- public void setMediaClockFormats( List<MediaClockFormat> mediaClockFormats ) {
- if (mediaClockFormats != null) {
- store.put(KEY_MEDIA_CLOCK_FORMATS, mediaClockFormats );
- } else {
- store.remove(KEY_MEDIA_CLOCK_FORMATS);
- }
- }
-
- /**
- * set the display's persistent screen supports.
- * @param graphicSupported
- * @since SmartDeviceLink 2.0
- */
- public void setGraphicSupported(Boolean graphicSupported) {
- if (graphicSupported != null) {
- store.put(KEY_GRAPHIC_SUPPORTED, graphicSupported);
- } else {
- store.remove(KEY_GRAPHIC_SUPPORTED);
- }
- }
-
- /**
- * Get the display's persistent screen supports.
- * @return Boolean get the value of graphicSupported
- * @since SmartDeviceLink 2.0
- */
- public Boolean getGraphicSupported() {
- return (Boolean) store.get(KEY_GRAPHIC_SUPPORTED);
- }
-
- @SuppressWarnings("unchecked")
- public List<String> getTemplatesAvailable() {
- if (store.get(KEY_TEMPLATES_AVAILABLE) instanceof List<?>) {
- List<?> list = (List<?>)store.get( KEY_TEMPLATES_AVAILABLE);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
- }
- }
- }
- return null;
- }
-
- public void setTemplatesAvailable(List<String> templatesAvailable) {
- if (templatesAvailable != null) {
- store.put(KEY_TEMPLATES_AVAILABLE, templatesAvailable);
- }
- else
- {
- store.remove(KEY_TEMPLATES_AVAILABLE);
- }
- }
-
- public void setScreenParams(ScreenParams screenParams) {
- if (screenParams != null) {
- store.put(KEY_SCREEN_PARAMS, screenParams);
- } else {
- store.remove(KEY_SCREEN_PARAMS);
- }
- }
-
- @SuppressWarnings("unchecked")
- public ScreenParams getScreenParams() {
- Object obj = store.get(KEY_SCREEN_PARAMS);
- if (obj instanceof ScreenParams) {
- return (ScreenParams) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new ScreenParams((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SCREEN_PARAMS, e);
- }
- }
- return null;
- }
-}
+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.DisplayType;
+import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
+import com.smartdevicelink.util.SdlLog;
+/**
+ * Contains information about the display for the SDL system to which the application is currently connected.
+ * <p><b> Parameter List
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Name</th>
+ * <th>Type</th>
+ * <th>Description</th>
+ * <th>SmartDeviceLink Ver. Available</th>
+ * </tr>
+ * <tr>
+ * <td>displayType</td>
+ * <td>DisplayType</td>
+ * <td>The type of display
+ * </td>
+ * <td>SmartDeviceLink 1.0</td>
+ * </tr>
+ * <tr>
+ * <td>textField</td>
+ * <td>TextField[]</td>
+ * <td>An array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as <i>{@linkplain Show}</i>, <i>{@linkplain SetMediaClockTimer}</i>, etc.
+ * This array of TextField structures identify all the text fields to which the application can write on the current display (identified by DisplayType ).
+ * </td>
+ * <td>SmartDeviceLink 1.0</td>
+ * </tr>
+ * <tr>
+ * <td>mediaClockFormats</td>
+ * <td>MediaClockFormat[]</td>
+ * <td>An array of MediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field</td>
+ * <td>SmartDeviceLink 1.0</td>
+ * </tr>
+ * <tr>
+ * <td>graphicSupported</td>
+ * <td>Boolean</td>
+ * <td>The display's persistent screen supports referencing a static or dynamic image.</td>
+ * <td>SmartDeviceLink 2.0</td>
+ * </tr>
+ * </table>
+ * @since SmartDeviceLink 1.0
+ */
+public class DisplayCapabilities extends RPCStruct {
+ public static final String KEY_DISPLAY_TYPE = "displayType";
+ public static final String KEY_MEDIA_CLOCK_FORMATS = "mediaClockFormats";
+ public static final String KEY_TEXT_FIELDS = "textFields";
+ public static final String KEY_IMAGE_FIELDS = "imageFields";
+ public static final String KEY_GRAPHIC_SUPPORTED = "graphicSupported";
+ public static final String KEY_SCREEN_PARAMS = "screenParams";
+ public static final String KEY_TEMPLATES_AVAILABLE = "templatesAvailable";
+ public static final String KEY_NUM_CUSTOM_PRESETS_AVAILABLE = "numCustomPresetsAvailable";
+ /**
+ * Constructs a newly allocated DisplayCapabilities object
+ */
+ public DisplayCapabilities() { }
+ /**
+ * Constructs a newly allocated DisplayCapabilities object indicated by the Hashtable parameter
+ * @param hash The Hashtable to use
+ */
+ public DisplayCapabilities(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+ /**
+ * Get the type of display
+ * @return the type of display
+ */
+ public DisplayType getDisplayType() {
+ Object obj = store.get(KEY_DISPLAY_TYPE);
+ if (obj instanceof DisplayType) {
+ return (DisplayType) obj;
+ } else if (obj instanceof String) {
+ return DisplayType.valueForString((String) obj);
+ }
+ return null;
+ }
+ /**
+ * Set the type of display
+ * @param displayType the display type
+ */
+ public void setDisplayType( DisplayType displayType ) {
+ if (displayType != null) {
+ store.put(KEY_DISPLAY_TYPE, displayType );
+ } else {
+ store.remove(KEY_DISPLAY_TYPE);
+ }
+ }
+ /**
+ *Get an array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as <i>{@linkplain Show}</i>, <i>{@linkplain SetMediaClockTimer}</i>, etc.
+ * This array of TextField structures identify all the text fields to which the application can write on the current display (identified by DisplayType ).
+ * @return the List of textFields
+ */
+ @SuppressWarnings("unchecked")
+ public List<TextField> getTextFields() {
+ if (store.get(KEY_TEXT_FIELDS) instanceof List<?>) {
+ List<?> list = (List<?>)store.get(KEY_TEXT_FIELDS);
+ if (list != null && list.size() > 0) {
+
+ List<TextField> textFieldList = new ArrayList<TextField>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TextField and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TextField) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ textFieldList.add(new TextField((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TextField>) list;
+ } else if (flagHash) {
+ return textFieldList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Set an array of TextField structures, each of which describes a field in the HMI which the application can write to using operations such as <i>{@linkplain Show}</i>, <i>{@linkplain SetMediaClockTimer}</i>, etc.
+ * This array of TextField structures identify all the text fields to which the application can write on the current display (identified by DisplayType ).
+ * @param textFields the List of textFields
+ */
+ public void setTextFields( List<TextField> textFields ) {
+
+ boolean valid = true;
+
+ for ( TextField item : textFields ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (textFields != null) && (textFields.size() > 0) && valid) {
+ store.put(KEY_TEXT_FIELDS, textFields );
+ } else {
+ store.remove(KEY_TEXT_FIELDS);
+ }
+ }
+
+
+
+ @SuppressWarnings("unchecked")
+ public List<ImageField> getImageFields() {
+ if (store.get(KEY_IMAGE_FIELDS) instanceof List<?>) {
+ List<?> list = (List<?>)store.get(KEY_IMAGE_FIELDS);
+ if (list != null && list.size() > 0) {
+
+ List<ImageField> imageFieldList = new ArrayList<ImageField>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw ImageField and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof ImageField) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ imageFieldList.add(new ImageField((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<ImageField>) list;
+ } else if (flagHash) {
+ return imageFieldList;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setImageFields( List<ImageField> imageFields ) {
+
+ boolean valid = true;
+
+ for ( ImageField item : imageFields ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (imageFields != null) && (imageFields.size() > 0) && valid) {
+ store.put(KEY_IMAGE_FIELDS, imageFields );
+ }
+ else
+ {
+ store.remove(KEY_IMAGE_FIELDS);
+ }
+ }
+
+ public Integer getNumCustomPresetsAvailable() {
+ return (Integer) store.get(KEY_NUM_CUSTOM_PRESETS_AVAILABLE);
+ }
+
+ public void setNumCustomPresetsAvailable(Integer numCustomPresetsAvailable) {
+ if (numCustomPresetsAvailable != null) {
+ store.put(KEY_NUM_CUSTOM_PRESETS_AVAILABLE, numCustomPresetsAvailable);
+ }
+ else
+ {
+ store.remove(KEY_NUM_CUSTOM_PRESETS_AVAILABLE);
+ }
+ }
+
+ /**
+ * Get an array of MediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field
+ * @return the Veotor of mediaClockFormat
+ */
+ @SuppressWarnings("unchecked")
+ public List<MediaClockFormat> getMediaClockFormats() {
+ if (store.get(KEY_MEDIA_CLOCK_FORMATS) instanceof List<?>) {
+ List<?> list = (List<?>)store.get(KEY_MEDIA_CLOCK_FORMATS);
+ if (list != null && list.size() > 0) {
+
+ List<MediaClockFormat> mediaClockFormatList = new ArrayList<MediaClockFormat>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw MediaClockFormat and a String value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof MediaClockFormat) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof String) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ String strFormat = (String) obj;
+ MediaClockFormat toAdd = null;
+ try {
+ toAdd = MediaClockFormat.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse MediaClockFormat from " + getClass().getSimpleName() + "." + KEY_MEDIA_CLOCK_FORMATS, e);
+ }
+ if (toAdd != null) {
+ mediaClockFormatList.add(toAdd);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<MediaClockFormat>) list;
+ } else if (flagHash) {
+ return mediaClockFormatList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Set an array of MediaClockFormat elements, defining the valid string formats used in specifying the contents of the media clock field
+ * @param mediaClockFormats the List of MediaClockFormat
+ */
+ public void setMediaClockFormats( List<MediaClockFormat> mediaClockFormats ) {
+
+ boolean valid = true;
+
+ for ( MediaClockFormat item : mediaClockFormats ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (mediaClockFormats != null) && (mediaClockFormats.size() > 0) && valid) {
+ store.put(KEY_MEDIA_CLOCK_FORMATS, mediaClockFormats );
+ } else {
+ store.remove(KEY_MEDIA_CLOCK_FORMATS);
+ }
+ }
+
+ /**
+ * set the display's persistent screen supports.
+ * @param graphicSupported
+ * @since SmartDeviceLink 2.0
+ */
+ public void setGraphicSupported(Boolean graphicSupported) {
+ if (graphicSupported != null) {
+ store.put(KEY_GRAPHIC_SUPPORTED, graphicSupported);
+ } else {
+ store.remove(KEY_GRAPHIC_SUPPORTED);
+ }
+ }
+
+ /**
+ * Get the display's persistent screen supports.
+ * @return Boolean get the value of graphicSupported
+ * @since SmartDeviceLink 2.0
+ */
+ public Boolean getGraphicSupported() {
+ return (Boolean) store.get(KEY_GRAPHIC_SUPPORTED);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<String> getTemplatesAvailable() {
+ if (store.get(KEY_TEMPLATES_AVAILABLE) instanceof List<?>) {
+ List<?> list = (List<?>)store.get( KEY_TEMPLATES_AVAILABLE);
+ if (list != null && list.size() > 0) {
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
+ }
+ return (List<String>) list;
+ }
+ }
+ return null;
+ }
+
+ public void setTemplatesAvailable(List<String> templatesAvailable) {
+
+ boolean valid = true;
+
+ for ( String item : templatesAvailable ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (templatesAvailable != null) && (templatesAvailable.size() > 0) && valid) {
+ store.put(KEY_TEMPLATES_AVAILABLE, templatesAvailable);
+ }
+ else
+ {
+ store.remove(KEY_TEMPLATES_AVAILABLE);
+ }
+ }
+
+ public void setScreenParams(ScreenParams screenParams) {
+ if (screenParams != null) {
+ store.put(KEY_SCREEN_PARAMS, screenParams);
+ } else {
+ store.remove(KEY_SCREEN_PARAMS);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public ScreenParams getScreenParams() {
+ Object obj = store.get(KEY_SCREEN_PARAMS);
+ if (obj instanceof ScreenParams) {
+ return (ScreenParams) obj;
+ } else if (obj instanceof Hashtable) {
+ try {
+ return new ScreenParams((Hashtable<String, Object>) obj);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_SCREEN_PARAMS, e);
+ }
+ }
+ return null;
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ECallInfo.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ECallInfo.java
index f6872ebf7..5b106d5ad 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ECallInfo.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ECallInfo.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.ECallConfirmationStatus;
-import com.smartdevicelink.proxy.rpc.enums.VehicleDataNotificationStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataNotificationStatus;
public class ECallInfo extends RPCStruct {
public static final String KEY_E_CALL_NOTIFICATION_STATUS = "eCallNotificationStatus";
@@ -28,14 +27,8 @@ public class ECallInfo extends RPCStruct {
Object obj = store.get(KEY_E_CALL_NOTIFICATION_STATUS);
if (obj instanceof VehicleDataNotificationStatus) {
return (VehicleDataNotificationStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataNotificationStatus theCode = null;
- try {
- theCode = VehicleDataNotificationStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_NOTIFICATION_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataNotificationStatus.valueForString((String) obj);
}
return null;
}
@@ -50,14 +43,8 @@ public class ECallInfo extends RPCStruct {
Object obj = store.get(KEY_AUX_E_CALL_NOTIFICATION_STATUS);
if (obj instanceof VehicleDataNotificationStatus) {
return (VehicleDataNotificationStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataNotificationStatus theCode = null;
- try {
- theCode = VehicleDataNotificationStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AUX_E_CALL_NOTIFICATION_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataNotificationStatus.valueForString((String) obj);
}
return null;
}
@@ -72,14 +59,8 @@ public class ECallInfo extends RPCStruct {
Object obj = store.get(KEY_E_CALL_CONFIRMATION_STATUS);
if (obj instanceof ECallConfirmationStatus) {
return (ECallConfirmationStatus) obj;
- } else if (obj instanceof String) {
- ECallConfirmationStatus theCode = null;
- try {
- theCode = ECallConfirmationStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_CONFIRMATION_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ECallConfirmationStatus.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EmergencyEvent.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EmergencyEvent.java
index 8670c0c48..ddd609c31 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EmergencyEvent.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EmergencyEvent.java
@@ -5,8 +5,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.EmergencyEventType;
import com.smartdevicelink.proxy.rpc.enums.FuelCutoffStatus;
-import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
public class EmergencyEvent extends RPCStruct {
public static final String KEY_EMERGENCY_EVENT_TYPE = "emergencyEventType";
@@ -31,14 +30,8 @@ public class EmergencyEvent extends RPCStruct {
Object obj = store.get(KEY_EMERGENCY_EVENT_TYPE);
if (obj instanceof EmergencyEventType) {
return (EmergencyEventType) obj;
- } else if (obj instanceof String) {
- EmergencyEventType theCode = null;
- try {
- theCode = EmergencyEventType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return EmergencyEventType.valueForString((String) obj);
}
return null;
}
@@ -53,14 +46,8 @@ public class EmergencyEvent extends RPCStruct {
Object obj = store.get(KEY_FUEL_CUTOFF_STATUS);
if (obj instanceof FuelCutoffStatus) {
return (FuelCutoffStatus) obj;
- } else if (obj instanceof String) {
- FuelCutoffStatus theCode = null;
- try {
- theCode = FuelCutoffStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_CUTOFF_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return FuelCutoffStatus.valueForString((String) obj);
}
return null;
}
@@ -75,14 +62,8 @@ public class EmergencyEvent extends RPCStruct {
Object obj = store.get(KEY_ROLLOVER_EVENT);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ROLLOVER_EVENT, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -107,14 +88,8 @@ public class EmergencyEvent extends RPCStruct {
Object obj = store.get(KEY_MULTIPLE_EVENTS);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MULTIPLE_EVENTS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThru.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThru.java
index 1020a4281..8a6793691 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThru.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThru.java
@@ -21,7 +21,7 @@ public class EndAudioPassThru extends RPCRequest {
* Constructs a new EndAudioPassThru object
*/
public EndAudioPassThru() {
- super(FunctionID.END_AUDIO_PASS_THRU);
+ super(FunctionID.END_AUDIO_PASS_THRU.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThruResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThruResponse.java
index d29cbccfa..4f7a09f7b 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThruResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/EndAudioPassThruResponse.java
@@ -16,7 +16,7 @@ public class EndAudioPassThruResponse extends RPCResponse {
* Constructs a new EndAudioPassThruResponse object
*/
public EndAudioPassThruResponse() {
- super(FunctionID.END_AUDIO_PASS_THRU);
+ super(FunctionID.END_AUDIO_PASS_THRU.toString());
}
public EndAudioPassThruResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GPSData.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GPSData.java
index 695aff248..8c9f6591e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GPSData.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GPSData.java
@@ -5,9 +5,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.CompassDirection;
import com.smartdevicelink.proxy.rpc.enums.Dimension;
-import com.smartdevicelink.util.LogTool;
-import com.smartdevicelink.util.SdlDataTypeConverter;
-
+import com.smartdevicelink.util.SdlDataTypeConverter;
/**
* Describes the GPS data. Not all data will be available on all carlines.
* <p><b>Parameter List
@@ -349,14 +347,8 @@ public class GPSData extends RPCStruct {
Object obj = store.get(KEY_COMPASS_DIRECTION);
if (obj instanceof CompassDirection) {
return (CompassDirection) obj;
- } else if (obj instanceof String) {
- CompassDirection theCode = null;
- try {
- theCode = CompassDirection.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_COMPASS_DIRECTION, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return CompassDirection.valueForString((String) obj);
}
return null;
}
@@ -473,14 +465,8 @@ public class GPSData extends RPCStruct {
Object obj = store.get(KEY_DIMENSION);
if (obj instanceof Dimension) {
return (Dimension) obj;
- } else if (obj instanceof String) {
- Dimension theCode = null;
- try {
- theCode = Dimension.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DIMENSION, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return Dimension.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GenericResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GenericResponse.java
index 4c2b1238e..e231dd04d 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GenericResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GenericResponse.java
@@ -13,7 +13,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class GenericResponse extends RPCResponse {
public GenericResponse() {
- super(FunctionID.GENERIC_RESPONSE);
+ super(FunctionID.GENERIC_RESPONSE.toString());
}
public GenericResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCs.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCs.java
index 65deeaaa0..967c62cbb 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCs.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCs.java
@@ -22,7 +22,7 @@ public class GetDTCs extends RPCRequest {
* Constructs a new GetDTCs object
*/
public GetDTCs() {
- super(FunctionID.GET_DTCS);
+ super(FunctionID.GET_DTCS.toString());
}
/**
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 8d19df40d..fcca3c606 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java
@@ -17,7 +17,7 @@ public class GetDTCsResponse extends RPCResponse{
public static final String KEY_DTC = "dtc";
public GetDTCsResponse(){
- super(FunctionID.GET_DTCS);
+ super(FunctionID.GET_DTCS.toString());
}
public GetDTCsResponse(Hashtable<String, Object> hash){
@@ -29,17 +29,28 @@ public class GetDTCsResponse extends RPCResponse{
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<String>) list;
- }
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
+ }
+ return (List<String>) list;
}
}
return null;
}
public void setDtc(List<String> dtc){
- if(dtc != null){
+
+ boolean valid = true;
+
+ for ( String item : dtc ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (dtc != null) && (dtc.size() > 0) && valid) {
parameters.put(KEY_DTC, dtc);
}
else{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleData.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleData.java
index 42840de97..b3d2e6189 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleData.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleData.java
@@ -33,7 +33,7 @@ public class GetVehicleData extends RPCRequest {
public static final String KEY_MY_KEY = "myKey";
public GetVehicleData() {
- super(FunctionID.GET_VEHICLE_DATA);
+ super(FunctionID.GET_VEHICLE_DATA.toString());
}
public GetVehicleData(Hashtable<String, Object> hash) {
super(hash);
@@ -80,15 +80,11 @@ public class GetVehicleData extends RPCRequest {
}
@Deprecated
public void setFuelLevel_State(Boolean fuelLevel_State) {
- if (fuelLevel_State != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevel_State);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setFuelLevelState(fuelLevel_State);
}
@Deprecated
public Boolean getFuelLevel_State() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL_STATE);
+ return getFuelLevelState();
}
public void setFuelLevelState(Boolean fuelLevelState) {
if (fuelLevelState != null) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java
index 8a8222040..05d5ba9e9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java
@@ -9,8 +9,8 @@ import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
import com.smartdevicelink.proxy.rpc.enums.PRNDL;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
import com.smartdevicelink.proxy.rpc.enums.WiperStatus;
-import com.smartdevicelink.util.LogTool;
import com.smartdevicelink.util.SdlDataTypeConverter;
+import com.smartdevicelink.util.SdlLog;
public class GetVehicleDataResponse extends RPCResponse {
public static final String KEY_SPEED = "speed";
@@ -41,7 +41,7 @@ public class GetVehicleDataResponse extends RPCResponse {
public GetVehicleDataResponse() {
- super(FunctionID.GET_VEHICLE_DATA);
+ super(FunctionID.GET_VEHICLE_DATA.toString());
}
public GetVehicleDataResponse(Hashtable<String, Object> hash) {
super(hash);
@@ -63,7 +63,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
theCode = new GPSData((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
}
return theCode;
}
@@ -103,27 +103,11 @@ public class GetVehicleDataResponse extends RPCResponse {
}
@Deprecated
public void setFuelLevel_State(ComponentVolumeStatus fuelLevel_State) {
- if (fuelLevel_State != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevel_State);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setFuelLevelState(fuelLevel_State);
}
@Deprecated
- public ComponentVolumeStatus getFuelLevel_State() {
- Object obj = parameters.get(KEY_FUEL_LEVEL_STATE);
- if (obj instanceof ComponentVolumeStatus) {
- return (ComponentVolumeStatus) obj;
- } else if (obj instanceof String) {
- ComponentVolumeStatus theCode = null;
- try {
- theCode = ComponentVolumeStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
- }
- return theCode;
- }
- return null;
+ public ComponentVolumeStatus getFuelLevel_State() {
+ return getFuelLevelState();
}
public void setFuelLevelState(ComponentVolumeStatus fuelLevelState) {
if (fuelLevelState != null) {
@@ -141,7 +125,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
theCode = ComponentVolumeStatus.valueForString((String) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
}
return theCode;
}
@@ -190,14 +174,8 @@ public class GetVehicleDataResponse extends RPCResponse {
Object obj = parameters.get(KEY_PRNDL);
if (obj instanceof PRNDL) {
return (PRNDL) obj;
- } else if (obj instanceof String) {
- PRNDL theCode = null;
- try {
- theCode = PRNDL.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRNDL, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return PRNDL.valueForString((String) obj);
}
return null;
}
@@ -217,7 +195,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new TireStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
}
}
return null;
@@ -248,7 +226,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new BeltStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
}
}
return null;
@@ -269,7 +247,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new BodyInformation((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
}
}
return null;
@@ -290,7 +268,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new DeviceStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
}
}
return null;
@@ -306,14 +284,8 @@ public class GetVehicleDataResponse extends RPCResponse {
Object obj = parameters.get(KEY_DRIVER_BRAKING);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BRAKING, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -328,14 +300,8 @@ public class GetVehicleDataResponse extends RPCResponse {
Object obj = parameters.get(KEY_WIPER_STATUS);
if (obj instanceof WiperStatus) {
return (WiperStatus) obj;
- } else if (obj instanceof String) {
- WiperStatus theCode = null;
- try {
- theCode = WiperStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_WIPER_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return WiperStatus.valueForString((String) obj);
}
return null;
}
@@ -356,7 +322,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new HeadLampStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
}
}
return null;
@@ -413,7 +379,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new ECallInfo((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
}
}
return null;
@@ -435,7 +401,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new AirbagStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
}
}
return null;
@@ -457,7 +423,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new EmergencyEvent((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
}
}
return null;
@@ -478,7 +444,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new ClusterModeStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
}
}
return null;
@@ -499,7 +465,7 @@ public class GetVehicleDataResponse extends RPCResponse {
try {
return new MyKey((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMICapabilities.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMICapabilities.java
new file mode 100644
index 000000000..efc94f57c
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMICapabilities.java
@@ -0,0 +1,49 @@
+package com.smartdevicelink.proxy.rpc;
+
+import java.util.Hashtable;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+public class HMICapabilities extends RPCStruct{
+ public static final String KEY_NAVIGATION = "navigation";
+ public static final String KEY_PHONE_CALL = "phoneCall";
+
+ public HMICapabilities() { }
+
+ public HMICapabilities(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ public boolean isNavigationAvailable(){
+ Object available = store.get(KEY_NAVIGATION);
+ if(available == null){
+ return false;
+ }
+ return (Boolean)available;
+ }
+
+ public void setNavigationAvilable(Boolean available){
+ if (available) {
+ store.put(KEY_NAVIGATION, available);
+ } else {
+ store.remove(KEY_NAVIGATION);
+ }
+ }
+
+ public boolean isPhoneCallAvailable(){
+ Object available = store.get(KEY_PHONE_CALL);
+ if(available == null){
+ return false;
+ }
+ return (Boolean)available;
+ }
+
+ public void setPhoneCallAvilable(Boolean available){
+ if (available) {
+ store.put(KEY_PHONE_CALL, available);
+ } else {
+ store.remove(KEY_PHONE_CALL);
+ }
+ }
+
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java
index 9f8729b9b..c9dff4baa 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HMIPermissions.java
@@ -1,150 +1,183 @@
-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.HMILevel;
-import com.smartdevicelink.util.LogTool;
-/**
- * Defining sets of HMI levels, which are permitted or prohibited for a given RPC.
- * <p><b>Parameter List
- * <table border="1" rules="all">
- * <tr>
- * <th>Name</th>
- * <th>Type</th>
- * <th>Description</th>
- * <th>SmartDeviceLink Ver. Available</th>
- * </tr>
- * <tr>
- * <td>allowed</td>
- * <td>HMILevel</td>
- * <td>A set of all HMI levels that are permitted for this given RPC.
- * <ul>
- * <li>Min: 0</li>
- * <li>Max: 100</li>
- * </ul>
- * </td>
- * <td>SmartDeviceLink 2.0</td>
- * </tr>
- * <tr>
- * <td>userDisallowed</td>
- * <td>HMILevel</td>
- * <td>A set of all HMI levels that are prohibated for this given RPC.
- * <ul>
- * <li>Min: 0</li>
- * <li>Max: 100</li>
- * </ul>
- * </td>
- * <td>SmartDeviceLink 2.0</td>
- * </tr>
- * </table>
- * @since SmartDeviceLink 2.0
- */
-public class HMIPermissions extends RPCStruct {
- public static final String KEY_ALLOWED = "allowed";
- public static final String KEY_USER_DISALLOWED = "userDisallowed";
- /**
- * Constructs a newly allocated HMIPermissions object
- */
- public HMIPermissions() { }
-
- /**
- * Constructs a newly allocated HMIPermissions object indicated by the Hashtable parameter
- * @param hash The Hashtable to use
- */
- public HMIPermissions(Hashtable<String, Object> hash) {
- super(hash);
- }
-
- /**
- * get a set of all HMI levels that are permitted for this given RPC.
- * @return a set of all HMI levels that are permitted for this given RPC
- */
- @SuppressWarnings("unchecked")
- public List<HMILevel> getAllowed() {
- if (store.get(KEY_ALLOWED) instanceof List<?>) {
- List<?> list = (List<?>)store.get(KEY_ALLOWED);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof HMILevel) {
- return (List<HMILevel>) list;
- } else if (obj instanceof String) {
- List<HMILevel> newList = new ArrayList<HMILevel>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- HMILevel toAdd = null;
- try {
- toAdd = HMILevel.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ALLOWED, e);
- }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
-
- /**
- * set HMI level that is permitted for this given RPC.
- * @param allowed HMI level that is permitted for this given RPC
- */
- public void setAllowed(List<HMILevel> allowed) {
- if (allowed != null) {
- store.put(KEY_ALLOWED, allowed);
- } else {
- store.remove(KEY_ALLOWED);
- }
- }
-
- /**
- * get a set of all HMI levels that are prohibited for this given RPC
- * @return a set of all HMI levels that are prohibited for this given RPC
- */
- @SuppressWarnings("unchecked")
- public List<HMILevel> getUserDisallowed() {
- if (store.get(KEY_USER_DISALLOWED) instanceof List<?>) {
- List<?> list = (List<?>)store.get(KEY_USER_DISALLOWED);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof HMILevel) {
- return (List<HMILevel>) list;
- } else if (obj instanceof String) {
- List<HMILevel> newList = new ArrayList<HMILevel>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- HMILevel toAdd = null;
- try {
- toAdd = HMILevel.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_USER_DISALLOWED, e);
- }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
-
- /**
- * set a set of all HMI levels that are prohibited for this given RPC
- * @param userDisallowed HMI level that is prohibited for this given RPC
- */
- public void setUserDisallowed(List<HMILevel> userDisallowed) {
- if (userDisallowed != null) {
- store.put(KEY_USER_DISALLOWED, userDisallowed);
- } else {
- store.remove(KEY_USER_DISALLOWED);
- }
- }
-}
+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.HMILevel;
+import com.smartdevicelink.util.SdlLog;
+/**
+ * Defining sets of HMI levels, which are permitted or prohibited for a given RPC.
+ * <p><b>Parameter List
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Name</th>
+ * <th>Type</th>
+ * <th>Description</th>
+ * <th>SmartDeviceLink Ver. Available</th>
+ * </tr>
+ * <tr>
+ * <td>allowed</td>
+ * <td>HMILevel</td>
+ * <td>A set of all HMI levels that are permitted for this given RPC.
+ * <ul>
+ * <li>Min: 0</li>
+ * <li>Max: 100</li>
+ * </ul>
+ * </td>
+ * <td>SmartDeviceLink 2.0</td>
+ * </tr>
+ * <tr>
+ * <td>userDisallowed</td>
+ * <td>HMILevel</td>
+ * <td>A set of all HMI levels that are prohibated for this given RPC.
+ * <ul>
+ * <li>Min: 0</li>
+ * <li>Max: 100</li>
+ * </ul>
+ * </td>
+ * <td>SmartDeviceLink 2.0</td>
+ * </tr>
+ * </table>
+ * @since SmartDeviceLink 2.0
+ */
+public class HMIPermissions extends RPCStruct {
+ public static final String KEY_ALLOWED = "allowed";
+ public static final String KEY_USER_DISALLOWED = "userDisallowed";
+ /**
+ * Constructs a newly allocated HMIPermissions object
+ */
+ public HMIPermissions() { }
+
+ /**
+ * Constructs a newly allocated HMIPermissions object indicated by the Hashtable parameter
+ * @param hash The Hashtable to use
+ */
+ public HMIPermissions(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * get a set of all HMI levels that are permitted for this given RPC.
+ * @return a set of all HMI levels that are permitted for this given RPC
+ */
+ @SuppressWarnings("unchecked")
+ public List<HMILevel> getAllowed() {
+ if (store.get(KEY_ALLOWED) instanceof List<?>) {
+ List<?> list = (List<?>)store.get(KEY_ALLOWED);
+ if (list != null && list.size() > 0) {
+
+ List<HMILevel> hmiLevelList = new ArrayList<HMILevel>();
+
+ boolean flagRaw = false;
+ boolean flagStr = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw HMILevel and a String value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof HMILevel) {
+ if (flagStr) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof String) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagStr = true;
+
+ String strFormat = (String) obj;
+ HMILevel toAdd = null;
+ try {
+ toAdd = HMILevel.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_ALLOWED, e);
+ }
+
+ if (toAdd != null) {
+ hmiLevelList.add(toAdd);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<HMILevel>) list;
+ } else if (flagStr) {
+ return hmiLevelList;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * set HMI level that is permitted for this given RPC.
+ * @param allowed HMI level that is permitted for this given RPC
+ */
+ public void setAllowed(List<HMILevel> allowed) {
+
+ boolean valid = true;
+
+ for ( HMILevel item : allowed ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (allowed != null) && (allowed.size() > 0) && valid) {
+ store.put(KEY_ALLOWED, allowed);
+ } else {
+ store.remove(KEY_ALLOWED);
+ }
+ }
+
+ /**
+ * get a set of all HMI levels that are prohibited for this given RPC
+ * @return a set of all HMI levels that are prohibited for this given RPC
+ */
+ @SuppressWarnings("unchecked")
+ public List<HMILevel> getUserDisallowed() {
+ if (store.get(KEY_USER_DISALLOWED) instanceof List<?>) {
+ List<?> list = (List<?>)store.get(KEY_USER_DISALLOWED);
+ if (list != null && list.size() > 0) {
+ Object obj = list.get(0);
+ if (obj instanceof HMILevel) {
+ return (List<HMILevel>) list;
+ } else if (obj instanceof String) {
+ List<HMILevel> newList = new ArrayList<HMILevel>();
+ for (Object hashObj : list) {
+ String strFormat = (String)hashObj;
+ HMILevel toAdd = HMILevel.valueForString(strFormat);
+ if (toAdd != null) {
+ newList.add(toAdd);
+ }
+ }
+ return newList;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * set a set of all HMI levels that are prohibited for this given RPC
+ * @param userDisallowed HMI level that is prohibited for this given RPC
+ */
+ public void setUserDisallowed(List<HMILevel> userDisallowed) {
+ if (userDisallowed != null) {
+ store.put(KEY_USER_DISALLOWED, userDisallowed);
+ } else {
+ store.remove(KEY_USER_DISALLOWED);
+ }
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HeadLampStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HeadLampStatus.java
index 5c24790bd..6ad049867 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HeadLampStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/HeadLampStatus.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus;
public class HeadLampStatus extends RPCStruct {
public static final String KEY_AMBIENT_LIGHT_SENSOR_STATUS = "ambientLightSensorStatus";
@@ -26,14 +25,8 @@ public class HeadLampStatus extends RPCStruct {
Object obj = store.get(KEY_AMBIENT_LIGHT_SENSOR_STATUS);
if (obj instanceof AmbientLightStatus) {
return (AmbientLightStatus) obj;
- } else if (obj instanceof String) {
- AmbientLightStatus theCode = null;
- try {
- theCode = AmbientLightStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AMBIENT_LIGHT_SENSOR_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return AmbientLightStatus.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Image.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Image.java
index 71bbaf1fc..655b16938 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Image.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Image.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.ImageType;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.ImageType;
/**
*Specifies, which image shall be used, e.g. in Alerts or on Softbuttons provided the display supports it.
@@ -93,14 +92,8 @@ public class Image extends RPCStruct {
Object obj = store.get(KEY_IMAGE_TYPE);
if (obj instanceof ImageType) {
return (ImageType) obj;
- } else if (obj instanceof String) {
- ImageType theCode = null;
- try {
- theCode = ImageType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ImageType.valueForString((String) obj);
}
return null;
}
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 1686fe2f5..e2407a8db 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ImageField.java
@@ -1,104 +1,136 @@
-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;
-import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
-import com.smartdevicelink.util.LogTool;
-
-public class ImageField extends RPCStruct {
- public static final String KEY_IMAGE_TYPE_SUPPORTED = "imageTypeSupported";
- public static final String KEY_IMAGE_RESOLUTION = "imageResolution";
- public static final String KEY_NAME = "name";
-
-
- public ImageField() { }
-
- public ImageField(Hashtable<String, Object> hash) {
- super(hash);
- }
- public ImageFieldName getName() {
- Object obj = store.get(KEY_NAME);
- if (obj instanceof ImageFieldName) {
- return (ImageFieldName) obj;
- } else if (obj instanceof String) {
- ImageFieldName theCode = null;
- try {
- theCode = ImageFieldName.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_NAME, e);
- }
- return theCode;
- }
- return null;
- }
- public void setName( ImageFieldName name ) {
- if (name != null) {
- store.put(KEY_NAME, name );
- }
- else {
- store.remove(KEY_NAME);
- }
- }
- @SuppressWarnings("unchecked")
- public List<FileType> 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<FileType>) list;
- } else if (obj instanceof String) {
- List<FileType> newList = new ArrayList<FileType>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- FileType theCode = null;
- try {
- theCode = FileType.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_TYPE_SUPPORTED, e);
- }
- if (theCode != null) {
- newList.add(theCode);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
- public void setImageTypeSupported( List<FileType> imageTypeSupported ) {
- if (imageTypeSupported != null) {
- store.put(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported );
- }
- else {
- store.remove(KEY_IMAGE_TYPE_SUPPORTED);
- }
- }
- @SuppressWarnings("unchecked")
- public ImageResolution getImageResolution() {
- Object obj = store.get(KEY_IMAGE_RESOLUTION);
- if (obj instanceof ImageResolution) {
- return (ImageResolution) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new ImageResolution((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_RESOLUTION, e);
- }
- }
- return null;
- }
- public void setImageResolution( ImageResolution imageResolution ) {
- if (imageResolution != null) {
- store.put(KEY_IMAGE_RESOLUTION, imageResolution );
- }
- else {
- store.remove(KEY_IMAGE_RESOLUTION);
- }
- }
-}
+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;
+import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
+import com.smartdevicelink.util.SdlLog;
+
+public class ImageField extends RPCStruct {
+ public static final String KEY_IMAGE_TYPE_SUPPORTED = "imageTypeSupported";
+ public static final String KEY_IMAGE_RESOLUTION = "imageResolution";
+ public static final String KEY_NAME = "name";
+
+
+ public ImageField() { }
+
+ public ImageField(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+ public ImageFieldName getName() {
+ Object obj = store.get(KEY_NAME);
+ if (obj instanceof ImageFieldName) {
+ return (ImageFieldName) obj;
+ } else if (obj instanceof String) {
+ return ImageFieldName.valueForString((String) obj);
+ }
+ return null;
+ }
+ public void setName( ImageFieldName name ) {
+ if (name != null) {
+ store.put(KEY_NAME, name );
+ }
+ else {
+ store.remove(KEY_NAME);
+ }
+ }
+ @SuppressWarnings("unchecked")
+ public List<FileType> 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) {
+
+ List<FileType> fileTypeList = new ArrayList<FileType>();
+
+ boolean flagRaw = false;
+ boolean flagStr = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw FileType and a String value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof FileType) {
+ if (flagStr) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof String) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagStr = true;
+
+ String strFormat = (String) obj;
+ FileType theCode = null;
+ try {
+ theCode = FileType.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_TYPE_SUPPORTED, e);
+ }
+ if (theCode != null) {
+ fileTypeList.add(theCode);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<FileType>) list;
+ } else if (flagStr) {
+ return fileTypeList;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setImageTypeSupported( List<FileType> imageTypeSupported ) {
+
+ boolean valid = true;
+
+ for ( FileType item : imageTypeSupported ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (imageTypeSupported != null) && (imageTypeSupported.size() > 0) && valid) {
+ store.put(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported );
+ }
+ else {
+ store.remove(KEY_IMAGE_TYPE_SUPPORTED);
+ }
+ }
+ @SuppressWarnings("unchecked")
+ public ImageResolution getImageResolution() {
+ Object obj = store.get(KEY_IMAGE_RESOLUTION);
+ if (obj instanceof ImageResolution) {
+ return (ImageResolution) obj;
+ } else if (obj instanceof Hashtable) {
+ try {
+ return new ImageResolution((Hashtable<String, Object>) obj);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_RESOLUTION, e);
+ }
+ }
+ return null;
+ }
+ public void setImageResolution( ImageResolution imageResolution ) {
+ if (imageResolution != null) {
+ store.put(KEY_IMAGE_RESOLUTION, imageResolution );
+ }
+ else {
+ store.remove(KEY_IMAGE_RESOLUTION);
+ }
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java
index 951de3a51..2151d9721 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/KeyboardProperties.java
@@ -6,8 +6,7 @@ import java.util.List;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.KeyboardLayout;
import com.smartdevicelink.proxy.rpc.enums.KeypressMode;
-import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.Language;
public class KeyboardProperties extends RPCStruct {
public static final String KEY_KEYPRESS_MODE = "keypressMode";
@@ -33,16 +32,8 @@ public class KeyboardProperties extends RPCStruct {
Object obj = store.get(KEY_LANGUAGE);
if (obj instanceof Language) {
return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError(
- "Failed to parse " + getClass().getSimpleName() + "." +
- KEY_LANGUAGE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
}
return null;
}
@@ -59,16 +50,8 @@ public class KeyboardProperties extends RPCStruct {
Object obj = store.get(KEY_KEYBOARD_LAYOUT);
if (obj instanceof KeyboardLayout) {
return (KeyboardLayout) obj;
- } else if (obj instanceof String) {
- KeyboardLayout theCode = null;
- try {
- theCode = KeyboardLayout.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError(
- "Failed to parse " + getClass().getSimpleName() + "." +
- KEY_KEYBOARD_LAYOUT, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return KeyboardLayout.valueForString((String) obj);
}
return null;
}
@@ -85,16 +68,8 @@ public class KeyboardProperties extends RPCStruct {
Object obj = store.get(KEY_KEYPRESS_MODE);
if (obj instanceof KeypressMode) {
return (KeypressMode) obj;
- } else if (obj instanceof String) {
- KeypressMode theCode = null;
- try {
- theCode = KeypressMode.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError(
- "Failed to parse " + getClass().getSimpleName() + "." +
- KEY_KEYPRESS_MODE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return KeypressMode.valueForString((String) obj);
}
return KEYPRESS_MODE_DEFAULT;
}
@@ -113,17 +88,28 @@ public class KeyboardProperties extends RPCStruct {
if (listObj instanceof List<?>) {
List<?> list = (List<?>) listObj;
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
- }
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
+ }
+ return (List<String>) list;
}
}
return null;
}
public void setLimitedCharacterList(List<String> limitedCharacterList) {
- if (limitedCharacterList != null) {
+
+ boolean valid = true;
+
+ for ( String item : limitedCharacterList ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (limitedCharacterList != null) && (limitedCharacterList.size() > 0) && valid) {
store.put(KEY_LIMITED_CHARACTER_LIST, limitedCharacterList);
} else {
store.remove(KEY_LIMITED_CHARACTER_LIST);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFiles.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFiles.java
index dba3f973e..f135eaa9e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFiles.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFiles.java
@@ -18,7 +18,7 @@ public class ListFiles extends RPCRequest {
* Constructs a new ListFiles object
*/
public ListFiles() {
- super(FunctionID.LIST_FILES);
+ super(FunctionID.LIST_FILES.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java
index 1284f1cbf..18c4ecd3b 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ListFilesResponse.java
@@ -19,27 +19,40 @@ public class ListFilesResponse extends RPCResponse {
* Constructs a new ListFilesResponse object
*/
public ListFilesResponse() {
- super(FunctionID.LIST_FILES);
+ super(FunctionID.LIST_FILES.toString());
}
public ListFilesResponse(Hashtable<String, Object> hash) {
super(hash);
}
+
public void setFilenames(List<String> filenames) {
- if (filenames != null) {
+
+ boolean valid = true;
+
+ for ( String item : filenames ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (filenames != null) && (filenames.size() > 0) && valid) {
parameters.put(KEY_FILENAMES, filenames);
} else {
parameters.remove(KEY_FILENAMES);
}
}
+
@SuppressWarnings("unchecked")
public List<String> getFilenames() {
if (parameters.get(KEY_FILENAMES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_FILENAMES);
- if (list != null && list.size()>0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
+ if (list != null && list.size() > 0) {
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
}
+ return (List<String>) list;
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/MyKey.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/MyKey.java
index ce18e730a..4f474835c 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/MyKey.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/MyKey.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus;
public class MyKey extends RPCStruct {
public static final String KEY_E_911_OVERRIDE = "e911Override";
@@ -25,14 +24,8 @@ public class MyKey extends RPCStruct {
Object obj = store.get(KEY_E_911_OVERRIDE);
if (obj instanceof VehicleDataStatus) {
return (VehicleDataStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataStatus theCode = null;
- try {
- theCode = VehicleDataStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_911_OVERRIDE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataStatus.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java
index 96db9bab4..5206a6feb 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.rpc.enums.AppInterfaceUnregisteredReason;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.AppInterfaceUnregisteredReason;
/**
* <p>Notifies an application that its interface registration has been terminated. This means that all SDL resources
@@ -47,7 +46,7 @@ public class OnAppInterfaceUnregistered extends RPCNotification {
*Constructs a newly allocated OnAppInterfaceUnregistered object
*/
public OnAppInterfaceUnregistered() {
- super(FunctionID.ON_APP_INTERFACE_UNREGISTERED);
+ super(FunctionID.ON_APP_INTERFACE_UNREGISTERED.toString());
}
/**
*<p>Constructs a newly allocated OnAppInterfaceUnregistered object indicated by the Hashtable parameter</p>
@@ -64,14 +63,8 @@ public class OnAppInterfaceUnregistered extends RPCNotification {
Object obj = parameters.get(KEY_REASON);
if (obj instanceof AppInterfaceUnregisteredReason) {
return (AppInterfaceUnregisteredReason) obj;
- } else if (obj instanceof String) {
- AppInterfaceUnregisteredReason theCode = null;
- try {
- theCode = AppInterfaceUnregisteredReason.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_REASON, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return AppInterfaceUnregisteredReason.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java
index 3369c4020..421bbd933 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnAudioPassThru.java
@@ -45,7 +45,7 @@ public class OnAudioPassThru extends RPCNotification {
*Constructs a newly allocated OnCommand object
*/
public OnAudioPassThru() {
- super(FunctionID.ON_AUDIO_PASS_THRU);
+ super(FunctionID.ON_AUDIO_PASS_THRU.toString());
}
/**
*<p>Constructs a newly allocated OnAudioPassThru object indicated by the Hashtable parameter</p>
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonEvent.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonEvent.java
index 2d7b9b3de..66746b27c 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonEvent.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonEvent.java
@@ -5,8 +5,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.rpc.enums.ButtonEventMode;
-import com.smartdevicelink.proxy.rpc.enums.ButtonName;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.ButtonName;
/**
* Notifies application that user has depressed or released a button to which
@@ -91,7 +90,7 @@ public class OnButtonEvent extends RPCNotification {
*Constructs a newly allocated OnButtonEvent object
*/
public OnButtonEvent() {
- super(FunctionID.ON_BUTTON_EVENT);
+ super(FunctionID.ON_BUTTON_EVENT.toString());
}
/**
* <p>
@@ -113,14 +112,8 @@ public class OnButtonEvent extends RPCNotification {
Object obj = parameters.get(KEY_BUTTON_NAME);
if (obj instanceof ButtonName) {
return (ButtonName) obj;
- } else if (obj instanceof String) {
- ButtonName theCode = null;
- try {
- theCode = ButtonName.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BUTTON_NAME, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ButtonName.valueForString((String) obj);
}
return null;
}
@@ -143,14 +136,8 @@ public class OnButtonEvent extends RPCNotification {
Object obj = parameters.get(KEY_BUTTON_EVENT_MODE);
if (obj instanceof ButtonEventMode) {
return (ButtonEventMode) obj;
- } else if (obj instanceof String) {
- ButtonEventMode theCode = null;
- try {
- theCode = ButtonEventMode.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BUTTON_EVENT_MODE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ButtonEventMode.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonPress.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonPress.java
index aab92af3c..496afd52f 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonPress.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnButtonPress.java
@@ -5,8 +5,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
-import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode;
/**
* <p>
@@ -96,7 +95,7 @@ public class OnButtonPress extends RPCNotification {
*Constructs a newly allocated OnButtonPress object
*/
public OnButtonPress() {
- super(FunctionID.ON_BUTTON_PRESS);
+ super(FunctionID.ON_BUTTON_PRESS.toString());
}
/**
* <p>
@@ -118,14 +117,8 @@ public class OnButtonPress extends RPCNotification {
Object obj = parameters.get(KEY_BUTTON_NAME);
if (obj instanceof ButtonName) {
return (ButtonName) obj;
- } else if (obj instanceof String) {
- ButtonName theCode = null;
- try {
- theCode = ButtonName.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BUTTON_NAME, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ButtonName.valueForString((String) obj);
}
return null;
}
@@ -147,14 +140,8 @@ public class OnButtonPress extends RPCNotification {
Object obj = parameters.get(KEY_BUTTON_PRESS_MODE);
if (obj instanceof ButtonPressMode) {
return (ButtonPressMode) obj;
- } else if (obj instanceof String) {
- ButtonPressMode theCode = null;
- try {
- theCode = ButtonPressMode.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BUTTON_PRESS_MODE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ButtonPressMode.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnCommand.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnCommand.java
index 5d1dd50de..59e9cbbee 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnCommand.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnCommand.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
/**
* This is called when a command was selected via VR after pressing the PTT button, or selected from the menu after
@@ -59,7 +58,7 @@ public class OnCommand extends RPCNotification {
*Constructs a newly allocated OnCommand object
*/
public OnCommand() {
- super(FunctionID.ON_COMMAND);
+ super(FunctionID.ON_COMMAND.toString());
}
/**
*<p>Constructs a newly allocated OnCommand object indicated by the Hashtable parameter</p>
@@ -94,14 +93,8 @@ public class OnCommand extends RPCNotification {
Object obj = parameters.get(KEY_TRIGGER_SOURCE);
if (obj instanceof TriggerSource) {
return (TriggerSource) obj;
- } else if (obj instanceof String) {
- TriggerSource theCode = null;
- try {
- theCode = TriggerSource.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TRIGGER_SOURCE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return TriggerSource.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java
index 41400173c..2cfeb5ba6 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java
@@ -2,13 +2,9 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
-
-
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.rpc.enums.DriverDistractionState;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.DriverDistractionState;
/**
* <p>Notifies the application of the current driver distraction state (whether driver distraction rules are in effect, or
@@ -48,7 +44,7 @@ public class OnDriverDistraction extends RPCNotification {
*Constructs a newly allocated OnDriverDistraction object
*/
public OnDriverDistraction() {
- super(FunctionID.ON_DRIVER_DISTRACTION);
+ super(FunctionID.ON_DRIVER_DISTRACTION.toString());
}
/**
*<p>Constructs a newly allocated OnDriverDistraction object indicated by the Hashtable parameter</p>
@@ -65,14 +61,8 @@ public class OnDriverDistraction extends RPCNotification {
Object obj = parameters.get(KEY_STATE);
if (obj instanceof DriverDistractionState) {
return (DriverDistractionState)obj;
- } else if(obj instanceof String) {
- DriverDistractionState theCode = null;
- try {
- theCode = DriverDistractionState.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_STATE, e);
- }
- return theCode;
+ } else if(obj instanceof String) {
+ return DriverDistractionState.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHMIStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHMIStatus.java
index c6e1c0e67..ba1756953 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHMIStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHMIStatus.java
@@ -6,8 +6,7 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
-import com.smartdevicelink.proxy.rpc.enums.SystemContext;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.SystemContext;
/**
* <p>Notifies an application that HMI conditions have changed for the application. This indicates whether the application
* can speak phrases, display text, perform interactions, receive button presses and events, stream audio, etc. This
@@ -73,7 +72,7 @@ public class OnHMIStatus extends RPCNotification {
*Constructs a newly allocated OnHMIStatus object
*/
public OnHMIStatus() {
- super(FunctionID.ON_HMI_STATUS);
+ super(FunctionID.ON_HMI_STATUS.toString());
}
/**
*<p>Constructs a newly allocated OnHMIStatus object indicated by the Hashtable parameter</p>
@@ -90,14 +89,8 @@ public class OnHMIStatus extends RPCNotification {
Object obj = parameters.get(KEY_HMI_LEVEL);
if (obj instanceof HMILevel) {
return (HMILevel) obj;
- } else if (obj instanceof String) {
- HMILevel theCode = null;
- try {
- theCode = HMILevel.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_LEVEL, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return HMILevel.valueForString((String) obj);
}
return null;
}
@@ -120,14 +113,8 @@ public class OnHMIStatus extends RPCNotification {
Object obj = parameters.get(KEY_AUDIO_STREAMING_STATE);
if (obj instanceof AudioStreamingState) {
return (AudioStreamingState) obj;
- } else if (obj instanceof String) {
- AudioStreamingState theCode = null;
- try {
- theCode = AudioStreamingState.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AUDIO_STREAMING_STATE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return AudioStreamingState.valueForString((String) obj);
}
return null;
}
@@ -150,14 +137,8 @@ public class OnHMIStatus extends RPCNotification {
Object obj = parameters.get(KEY_SYSTEM_CONTEXT);
if (obj instanceof SystemContext) {
return (SystemContext) obj;
- } else if (obj instanceof String) {
- SystemContext theCode = null;
- try {
- theCode = SystemContext.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SYSTEM_CONTEXT, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return SystemContext.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHashChange.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHashChange.java
index 363fb8ee5..e806e5225 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHashChange.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnHashChange.java
@@ -9,7 +9,7 @@ public class OnHashChange extends RPCNotification {
public static final String KEY_HASH_ID = "hashID";
public OnHashChange() {
- super(FunctionID.ON_HASH_CHANGE);
+ super(FunctionID.ON_HASH_CHANGE.toString());
}
public OnHashChange(Hashtable<String, Object> hash) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java
index 7455a2fa3..25b2ec83e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java
@@ -1,19 +1,17 @@
package com.smartdevicelink.proxy.rpc;
+import java.util.Hashtable;
+
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.rpc.enums.KeyboardEvent;
-import com.smartdevicelink.util.LogTool;
-
-import java.util.Hashtable;
-
public class OnKeyboardInput extends RPCNotification {
public static final String KEY_DATA = "data";
public static final String KEY_EVENT = "event";
public OnKeyboardInput() {
- super(FunctionID.ON_KEYBOARD_INPUT);
+ super(FunctionID.ON_KEYBOARD_INPUT.toString());
}
public OnKeyboardInput(Hashtable<String, Object> hash) {
@@ -24,14 +22,8 @@ public class OnKeyboardInput extends RPCNotification {
Object obj = parameters.get(KEY_EVENT);
if (obj instanceof KeyboardEvent) {
return (KeyboardEvent) obj;
- } else if (obj instanceof String) {
- KeyboardEvent theCode = null;
- try {
- theCode = KeyboardEvent.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EVENT, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return KeyboardEvent.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLanguageChange.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLanguageChange.java
index df793c168..796fcebda 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLanguageChange.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLanguageChange.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.Language;
/**
* Provides information to what language the Sdl HMI language was changed
@@ -64,7 +63,7 @@ public class OnLanguageChange extends RPCNotification {
*Constructs a newly allocated OnCommand object
*/
public OnLanguageChange() {
- super(FunctionID.ON_LANGUAGE_CHANGE);
+ super(FunctionID.ON_LANGUAGE_CHANGE.toString());
}
/**
*<p>Constructs a newly allocated OnLanguageChange object indicated by the Hashtable parameter</p>
@@ -92,14 +91,8 @@ public class OnLanguageChange extends RPCNotification {
Object obj = parameters.get(KEY_LANGUAGE);
if (obj instanceof Language) {
return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LANGUAGE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
}
return null;
}
@@ -122,14 +115,8 @@ public class OnLanguageChange extends RPCNotification {
Object obj = parameters.get(KEY_HMI_DISPLAY_LANGUAGE);
if (obj instanceof Language) {
return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_DISPLAY_LANGUAGE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java
index 02c6d1cf2..1ad23994c 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java
@@ -4,7 +4,6 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
import com.smartdevicelink.proxy.rpc.enums.LockScreenStatus;
-import com.smartdevicelink.proxy.rpc.OnHMIStatus;
public class OnLockScreenStatus extends RPCNotification {
public static final String KEY_DRIVER_DISTRACTION = "driverDistraction";
@@ -12,7 +11,7 @@ public class OnLockScreenStatus extends RPCNotification {
public static final String KEY_USER_SELECTED = "userSelected";
public OnLockScreenStatus() {
- super(FunctionID.ON_LOCK_SCREEN_STATUS);
+ super(FunctionID.ON_LOCK_SCREEN_STATUS.toString());
}
public Boolean getDriverDistractionStatus() {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
index e4ae9d46e..bb1ca7ca5 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
@@ -54,7 +54,7 @@ public class OnPermissionsChange extends RPCNotification {
*Constructs a newly allocated OnCommand object
*/
public OnPermissionsChange() {
- super(FunctionID.ON_PERMISSIONS_CHANGE);
+ super(FunctionID.ON_PERMISSIONS_CHANGE.toString());
}
/**
*<p>Constructs a newly allocated OnPermissionsChange object indicated by the Hashtable parameter</p>
@@ -71,16 +71,43 @@ public class OnPermissionsChange extends RPCNotification {
public List<PermissionItem> getPermissionItem() {
List<?> list = (List<?>)parameters.get(KEY_PERMISSION_ITEM);
if (list != null && list.size()>0) {
- Object obj = list.get(0);
- if(obj instanceof PermissionItem){
- return (List<PermissionItem>) list;
- } else if(obj instanceof Hashtable) {
- List<PermissionItem> newList = new ArrayList<PermissionItem>();
- for (Object hash:list) {
- newList.add(new PermissionItem((Hashtable<String, Object>)hash));
- }
- return newList;
- }
+
+ List<PermissionItem> permissionItemList = new ArrayList<PermissionItem>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw PermissionItem and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof PermissionItem) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ permissionItemList.add(new PermissionItem((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<PermissionItem>) list;
+ } else if (flagHash) {
+ return permissionItemList;
+ }
}
return null;
}
@@ -89,7 +116,16 @@ public class OnPermissionsChange extends RPCNotification {
* @param permissionItem an List of PermissionItem describing change in permissions for a given set of RPCs
*/
public void setPermissionItem(List<PermissionItem> permissionItem) {
- if (permissionItem != null) {
+
+ boolean valid = true;
+
+ for ( PermissionItem item : permissionItem ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (permissionItem != null) && (permissionItem.size() > 0) && valid) {
parameters.put(KEY_PERMISSION_ITEM, permissionItem);
} else {
parameters.remove(KEY_PERMISSION_ITEM);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java
index b3e046fdb..1f20447d9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java
@@ -5,8 +5,7 @@ import java.util.List;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
public class OnSdlChoiceChosen extends RPCNotification {
public static final String KEY_SDL_CHOICE = "sdlChoice";
@@ -139,7 +138,7 @@ public class OnSdlChoiceChosen extends RPCNotification {
public OnSdlChoiceChosen() {
- super(FunctionID.ON_SDL_CHOICE_CHOSEN);
+ super(FunctionID.ON_SDL_CHOICE_CHOSEN.toString());
}
public OnSdlChoiceChosen(Hashtable<String, Object> hash){
super(hash);
@@ -158,14 +157,8 @@ public class OnSdlChoiceChosen extends RPCNotification {
Object obj = parameters.get(KEY_TRIGGER_SOURCE);
if (obj instanceof TriggerSource) {
return (TriggerSource) obj;
- } else if (obj instanceof String) {
- TriggerSource theCode = null;
- try {
- theCode = TriggerSource.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TRIGGER_SOURCE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return TriggerSource.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnStreamRPC.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnStreamRPC.java
new file mode 100644
index 000000000..bb4bcc324
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnStreamRPC.java
@@ -0,0 +1,47 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCNotification;
+
+public class OnStreamRPC extends RPCNotification {
+ public static final String KEY_FILENAME = "fileName";
+ public static final String KEY_BYTESCOMPLETE = "bytesComplete";
+ public static final String KEY_FILESIZE = "fileSize";
+
+ public OnStreamRPC() {
+ super(FunctionID.ON_STREAM_RPC.toString());
+ }
+
+ public void setFileName(String fileName) {
+ if (fileName != null) {
+ parameters.put(KEY_FILENAME, fileName);
+ } else {
+ parameters.remove(KEY_FILENAME);
+ }
+ }
+ public String getFileName() {
+ return (String) parameters.get(KEY_FILENAME);
+ }
+
+ public void setBytesComplete(Long bytesComplete) {
+ if (bytesComplete != null) {
+ parameters.put(KEY_BYTESCOMPLETE, bytesComplete);
+ } else {
+ parameters.remove(KEY_BYTESCOMPLETE);
+ }
+ }
+ public Long getBytesComplete() {
+ return (Long) parameters.get(KEY_BYTESCOMPLETE);
+ }
+
+ public void setFileSize(Long fileSize) {
+ if (fileSize != null) {
+ parameters.put(KEY_FILESIZE, fileSize);
+ } else {
+ parameters.remove(KEY_FILESIZE);
+ }
+ }
+ public Long getFileSize() {
+ return (Long) parameters.get(KEY_FILESIZE);
+ }
+} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java
index b9c433f97..13ca397b1 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnSystemRequest.java
@@ -13,8 +13,7 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.FileType;
-import com.smartdevicelink.proxy.rpc.enums.RequestType;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.RequestType;
public class OnSystemRequest extends RPCNotification {
public static final String KEY_URL_V1 = "URL";
@@ -33,7 +32,7 @@ public class OnSystemRequest extends RPCNotification {
private Headers headers;
public OnSystemRequest() {
- super(FunctionID.ON_SYSTEM_REQUEST);
+ super(FunctionID.ON_SYSTEM_REQUEST.toString());
}
public OnSystemRequest(Hashtable<String, Object> hash) {
@@ -121,10 +120,12 @@ public class OnSystemRequest extends RPCNotification {
if (parameters.get(KEY_DATA) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_DATA);
if (list != null && list.size()>0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>)list;
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
}
+ return (List<String>) list;
}
}
return null;
@@ -151,16 +152,8 @@ public class OnSystemRequest extends RPCNotification {
if (obj == null) return null;
if (obj instanceof RequestType) {
return (RequestType) obj;
- } else if (obj instanceof String) {
- RequestType theCode = null;
- try {
- theCode = RequestType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError(
- "Failed to parse " + getClass().getSimpleName() + "." +
- KEY_REQUEST_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return RequestType.valueForString((String) obj);
}
return null;
}
@@ -202,16 +195,8 @@ public class OnSystemRequest extends RPCNotification {
if (obj == null) return null;
if (obj instanceof FileType) {
return (FileType) obj;
- } else if (obj instanceof String) {
- FileType theCode = null;
- try {
- theCode = FileType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError(
- "Failed to parse " + getClass().getSimpleName() + "." +
- KEY_FILE_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return FileType.valueForString((String) obj);
}
return null;
}
@@ -224,18 +209,34 @@ public class OnSystemRequest extends RPCNotification {
}
}
- public Integer getOffset() {
+ /**
+ * @deprecated as of SmartDeviceLink 4.0
+ * @param offset
+ */
+ public void setOffset(Integer offset) {
+ if(offset == null){
+ setOffset((Long)null);
+ }else{
+ setOffset(offset.longValue());
+ }
+ }
+
+ public Long getOffset() {
final Object o = parameters.get(KEY_OFFSET);
- if (o == null) return null;
+ if (o == null){
+ return null;
+ }
if (o instanceof Integer) {
- return (Integer) o;
+ return ((Integer) o).longValue();
+ }else if(o instanceof Long){
+ return (Long) o;
}
return null;
}
- public void setOffset(Integer offset) {
+ public void setOffset(Long offset) {
if (offset != null) {
parameters.put(KEY_OFFSET, offset);
} else {
@@ -264,18 +265,34 @@ public class OnSystemRequest extends RPCNotification {
parameters.remove(KEY_TIMEOUT);
}
}
-
- public Integer getLength() {
+
+ public Long getLength() {
final Object o = parameters.get(KEY_LENGTH);
- if (o == null) return null;
+ if (o == null){
+ return null;
+ }
if (o instanceof Integer) {
- return (Integer) o;
+ return ((Integer) o).longValue();
+ }else if(o instanceof Long){
+ return (Long) o;
}
return null;
}
+ /**
+ * @deprecated as of SmartDeviceLink 4.0
+ * @param length
+ */
public void setLength(Integer length) {
+ if(length == null){
+ setLength((Long)null);
+ }else{
+ setLength(length.longValue());
+ }
+ }
+
+ public void setLength(Long length) {
if (length != null) {
parameters.put(KEY_LENGTH, length);
} else {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTBTClientState.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTBTClientState.java
index 5337d8168..4ce905a99 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTBTClientState.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTBTClientState.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.rpc.enums.TBTState;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.TBTState;
/**
* <p>Notifies the application of the current TBT client status on the module.</p>
@@ -45,7 +44,7 @@ public class OnTBTClientState extends RPCNotification {
*Constructs a newly allocated OnTBTClientState object
*/
public OnTBTClientState() {
- super(FunctionID.ON_TBT_CLIENT_STATE);
+ super(FunctionID.ON_TBT_CLIENT_STATE.toString());
}
/**
*<p>Constructs a newly allocated OnTBTClientState object indicated by the Hashtable parameter</p>
@@ -62,14 +61,8 @@ public class OnTBTClientState extends RPCNotification {
Object obj = parameters.get(KEY_STATE);
if (obj instanceof TBTState) {
return (TBTState)obj;
- } else if(obj instanceof String) {
- TBTState theCode = null;
- try{
- theCode = TBTState.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_STATE, e);
- }
- return theCode;
+ } else if(obj instanceof String) {
+ return TBTState.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java
index 938bc1196..a5de40b91 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnTouchEvent.java
@@ -1,20 +1,19 @@
package com.smartdevicelink.proxy.rpc;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.RPCNotification;
-import com.smartdevicelink.proxy.rpc.enums.TouchType;
-import com.smartdevicelink.util.LogTool;
-
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCNotification;
+import com.smartdevicelink.proxy.rpc.enums.TouchType;
+
public class OnTouchEvent extends RPCNotification {
public static final String KEY_EVENT = "event";
public static final String KEY_TYPE = "type";
public OnTouchEvent() {
- super(FunctionID.ON_TOUCH_EVENT);
+ super(FunctionID.ON_TOUCH_EVENT.toString());
}
public OnTouchEvent(Hashtable<String, Object> hash) {
super(hash);
@@ -32,20 +31,23 @@ public class OnTouchEvent extends RPCNotification {
Object obj = parameters.get(KEY_TYPE);
if (obj instanceof TouchType) {
return (TouchType) obj;
- } else if (obj instanceof String) {
- TouchType theCode = null;
- try {
- theCode = TouchType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return TouchType.valueForString((String) obj);
}
return null;
}
public void setEvent(List<TouchEvent> event) {
- if (event != null) {
+
+ boolean valid = true;
+
+ for ( TouchEvent item : event ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (event != null) && (event.size() > 0) && valid) {
parameters.put(KEY_EVENT, event);
} else {
parameters.remove(KEY_EVENT);
@@ -57,16 +59,43 @@ public class OnTouchEvent extends RPCNotification {
if (parameters.get(KEY_EVENT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_EVENT);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TouchEvent) {
- return (List<TouchEvent>) list;
- } else if (obj instanceof Hashtable) {
- List<TouchEvent> newList = new ArrayList<TouchEvent>();
- for (Object hashObj : list) {
- newList.add(new TouchEvent((Hashtable<String, Object>) hashObj));
- }
- return newList;
- }
+
+ List<TouchEvent> touchEventList = new ArrayList<TouchEvent>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TouchEvent and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TouchEvent) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ touchEventList.add(new TouchEvent((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TouchEvent>) list;
+ } else if (flagHash) {
+ return touchEventList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnVehicleData.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnVehicleData.java
index 6b4ab9bb8..d3fdd498c 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnVehicleData.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/OnVehicleData.java
@@ -8,8 +8,8 @@ import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
import com.smartdevicelink.proxy.rpc.enums.PRNDL;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
import com.smartdevicelink.proxy.rpc.enums.WiperStatus;
-import com.smartdevicelink.util.LogTool;
import com.smartdevicelink.util.SdlDataTypeConverter;
+import com.smartdevicelink.util.SdlLog;
public class OnVehicleData extends RPCNotification {
public static final String KEY_SPEED = "speed";
@@ -39,7 +39,7 @@ public class OnVehicleData extends RPCNotification {
public static final String KEY_MY_KEY = "myKey";
public OnVehicleData() {
- super(FunctionID.ON_VEHICLE_DATA);
+ super(FunctionID.ON_VEHICLE_DATA.toString());
}
public OnVehicleData(Hashtable<String, Object> hash) {
super(hash);
@@ -61,7 +61,7 @@ public class OnVehicleData extends RPCNotification {
try {
theCode = new GPSData((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
}
return theCode;
}
@@ -101,27 +101,11 @@ public class OnVehicleData extends RPCNotification {
}
@Deprecated
public void setFuelLevel_State(ComponentVolumeStatus fuelLevel_State) {
- if (fuelLevel_State != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevel_State);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setFuelLevelState(fuelLevel_State);
}
@Deprecated
- public ComponentVolumeStatus getFuelLevel_State() {
- Object obj = parameters.get(KEY_FUEL_LEVEL_STATE);
- if (obj instanceof ComponentVolumeStatus) {
- return (ComponentVolumeStatus) obj;
- } else if (obj instanceof String) {
- ComponentVolumeStatus theCode = null;
- try {
- theCode = ComponentVolumeStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
- }
- return theCode;
- }
- return null;
+ public ComponentVolumeStatus getFuelLevel_State() {
+ return getFuelLevelState();
}
public void setFuelLevelState(ComponentVolumeStatus fuelLevelState) {
if (fuelLevelState != null) {
@@ -139,7 +123,7 @@ public class OnVehicleData extends RPCNotification {
try {
theCode = ComponentVolumeStatus.valueForString((String) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
}
return theCode;
}
@@ -188,14 +172,8 @@ public class OnVehicleData extends RPCNotification {
Object obj = parameters.get(KEY_PRNDL);
if (obj instanceof PRNDL) {
return (PRNDL) obj;
- } else if (obj instanceof String) {
- PRNDL theCode = null;
- try {
- theCode = PRNDL.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRNDL, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return PRNDL.valueForString((String) obj);
}
return null;
}
@@ -215,7 +193,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new TireStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
}
}
return null;
@@ -246,7 +224,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new BeltStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
}
}
return null;
@@ -267,7 +245,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new BodyInformation((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
}
}
return null;
@@ -288,7 +266,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new DeviceStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
}
}
return null;
@@ -304,14 +282,8 @@ public class OnVehicleData extends RPCNotification {
Object obj = parameters.get(KEY_DRIVER_BRAKING);
if (obj instanceof VehicleDataEventStatus) {
return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- VehicleDataEventStatus theCode = null;
- try {
- theCode = VehicleDataEventStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BRAKING, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataEventStatus.valueForString((String) obj);
}
return null;
}
@@ -326,14 +298,8 @@ public class OnVehicleData extends RPCNotification {
Object obj = parameters.get(KEY_WIPER_STATUS);
if (obj instanceof WiperStatus) {
return (WiperStatus) obj;
- } else if (obj instanceof String) {
- WiperStatus theCode = null;
- try {
- theCode = WiperStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_WIPER_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return WiperStatus.valueForString((String) obj);
}
return null;
}
@@ -353,7 +319,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new HeadLampStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
}
}
return null;
@@ -407,7 +373,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new ECallInfo((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
}
}
return null;
@@ -428,7 +394,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new AirbagStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
}
}
return null;
@@ -449,7 +415,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new EmergencyEvent((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
}
}
return null;
@@ -470,7 +436,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new ClusterModeStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
}
}
return null;
@@ -491,7 +457,7 @@ public class OnVehicleData extends RPCNotification {
try {
return new MyKey((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java
index ef8eddc16..1209629a5 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ParameterPermissions.java
@@ -68,10 +68,12 @@ public class ParameterPermissions extends RPCStruct {
if (store.get(KEY_ALLOWED) instanceof List<?>) {
List<?> list = (List<?>)store.get( KEY_ALLOWED);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
}
+ return (List<String>) list;
}
}
return null;
@@ -82,7 +84,16 @@ public class ParameterPermissions extends RPCStruct {
* @param allowed parameter that is permitted for this given RPC
*/
public void setAllowed(List<String> allowed) {
- if (allowed != null) {
+
+ boolean valid = true;
+
+ for ( String item : allowed ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (allowed != null) && (allowed.size() > 0) && valid) {
store.put(KEY_ALLOWED, allowed);
} else {
store.remove(KEY_ALLOWED);
@@ -98,10 +109,12 @@ public class ParameterPermissions extends RPCStruct {
if (store.get(KEY_USER_DISALLOWED) instanceof List<?>) {
List<?> list = (List<?>)store.get( KEY_USER_DISALLOWED);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
}
+ return (List<String>) list;
}
}
return null;
@@ -112,7 +125,16 @@ public class ParameterPermissions extends RPCStruct {
* @param userDisallowed paramter that is prohibited for this given RPC
*/
public void setUserDisallowed(List<String> userDisallowed) {
- if (userDisallowed != null) {
+
+ boolean valid = true;
+
+ for ( String item : userDisallowed ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (userDisallowed != null) && (userDisallowed.size() > 0) && valid) {
store.put(KEY_USER_DISALLOWED, userDisallowed);
} else {
store.remove(KEY_USER_DISALLOWED);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java
index 4680127e2..eff5f1fbf 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java
@@ -8,8 +8,7 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.AudioType;
import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
-import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
/**
* This will open an audio pass thru session. By doing so the app can receive
@@ -37,7 +36,7 @@ public class PerformAudioPassThru extends RPCRequest {
* Constructs a new PerformAudioPassThru object
*/
public PerformAudioPassThru() {
- super(FunctionID.PERFORM_AUDIO_PASS_THRU);
+ super(FunctionID.PERFORM_AUDIO_PASS_THRU.toString());
}
/**
@@ -71,7 +70,16 @@ public class PerformAudioPassThru extends RPCRequest {
* </ul>
*/
public void setInitialPrompt(List<TTSChunk> initialPrompt) {
- if (initialPrompt != null) {
+
+ boolean valid = true;
+
+ for ( TTSChunk item : initialPrompt ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (initialPrompt != null) && (initialPrompt.size() > 0) && valid) {
parameters.put(KEY_INITIAL_PROMPT, initialPrompt);
} else {
parameters.remove(KEY_INITIAL_PROMPT);
@@ -91,16 +99,43 @@ public class PerformAudioPassThru extends RPCRequest {
if (parameters.get(KEY_INITIAL_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_INITIAL_PROMPT);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TTSChunk) {
- return (List<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -183,14 +218,8 @@ public class PerformAudioPassThru extends RPCRequest {
Object obj = parameters.get(KEY_SAMPLING_RATE);
if (obj instanceof SamplingRate) {
return (SamplingRate) obj;
- } else if (obj instanceof String) {
- SamplingRate theCode = null;
- try {
- theCode = SamplingRate.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SAMPLING_RATE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return SamplingRate.valueForString((String) obj);
}
return null;
}
@@ -245,14 +274,8 @@ public class PerformAudioPassThru extends RPCRequest {
Object obj = parameters.get(KEY_BITS_PER_SAMPLE);
if (obj instanceof BitsPerSample) {
return (BitsPerSample) obj;
- } else if (obj instanceof String) {
- BitsPerSample theCode = null;
- try {
- theCode = BitsPerSample.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BITS_PER_SAMPLE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return BitsPerSample.valueForString((String) obj);
}
return null;
}
@@ -280,14 +303,8 @@ public class PerformAudioPassThru extends RPCRequest {
Object obj = parameters.get(KEY_AUDIO_TYPE);
if (obj instanceof AudioType) {
return (AudioType) obj;
- } else if (obj instanceof String) {
- AudioType theCode = null;
- try {
- theCode = AudioType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AUDIO_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return AudioType.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThruResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThruResponse.java
index f23513994..7ba905f96 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThruResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformAudioPassThruResponse.java
@@ -16,7 +16,7 @@ public class PerformAudioPassThruResponse extends RPCResponse {
* Constructs a new PerformAudioPassThruResponse object
*/
public PerformAudioPassThruResponse() {
- super(FunctionID.PERFORM_AUDIO_PASS_THRU);
+ super(FunctionID.PERFORM_AUDIO_PASS_THRU.toString());
}
/**
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 1debddf3c..ebf8c16f1 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteraction.java
@@ -7,8 +7,7 @@ import java.util.List;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.InteractionMode;
-import com.smartdevicelink.proxy.rpc.enums.LayoutMode;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.LayoutMode;
/**
* Performs an application-initiated interaction in which the user can select a
* {@linkplain Choice} from among the specified Choice Sets. For instance, an
@@ -39,7 +38,7 @@ public class PerformInteraction extends RPCRequest {
* Constructs a new PerformInteraction object
*/
public PerformInteraction() {
- super(FunctionID.PERFORM_INTERACTION);
+ super(FunctionID.PERFORM_INTERACTION.toString());
}
/**
* Constructs a new PerformInteraction object indicated by the Hashtable
@@ -91,16 +90,43 @@ public class PerformInteraction extends RPCRequest {
if (parameters.get(KEY_INITIAL_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_INITIAL_PROMPT);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TTSChunk) {
- return (List<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -114,7 +140,16 @@ public class PerformInteraction extends RPCRequest {
* user at the start of an interaction
*/
public void setInitialPrompt(List<TTSChunk> initialPrompt) {
- if (initialPrompt != null) {
+
+ boolean valid = true;
+
+ for ( TTSChunk item : initialPrompt ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (initialPrompt != null) && (initialPrompt.size() > 0) && valid) {
parameters.put(KEY_INITIAL_PROMPT, initialPrompt);
} else {
parameters.remove(KEY_INITIAL_PROMPT);
@@ -132,14 +167,8 @@ public class PerformInteraction extends RPCRequest {
Object obj = parameters.get(KEY_INTERACTION_MODE);
if (obj instanceof InteractionMode) {
return (InteractionMode) obj;
- } else if (obj instanceof String) {
- InteractionMode theCode = null;
- try {
- theCode = InteractionMode.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INTERACTION_MODE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return InteractionMode.valueForString((String) obj);
}
return null;
}
@@ -172,10 +201,12 @@ public class PerformInteraction extends RPCRequest {
if(parameters.get(KEY_INTERACTION_CHOICE_SET_ID_LIST) instanceof List<?>){
List<?> list = (List<?>)parameters.get(KEY_INTERACTION_CHOICE_SET_ID_LIST);
if(list != null && list.size()>0){
- Object obj = list.get(0);
- if(obj instanceof Integer){
- return (List<Integer>) list;
+ for( Object obj : list ) {
+ if (!(obj instanceof Integer)) {
+ return null;
+ }
}
+ return (List<Integer>) list;
}
}
return null;
@@ -192,7 +223,16 @@ public class PerformInteraction extends RPCRequest {
* <b>Notes: </b>Min Value: 0; Max Vlaue: 2000000000
*/
public void setInteractionChoiceSetIDList(List<Integer> interactionChoiceSetIDList) {
- if (interactionChoiceSetIDList != null) {
+
+ boolean valid = true;
+
+ for ( Integer item : interactionChoiceSetIDList ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (interactionChoiceSetIDList != null) && (interactionChoiceSetIDList.size() > 0) && valid) {
parameters.put(KEY_INTERACTION_CHOICE_SET_ID_LIST, interactionChoiceSetIDList);
} else {
parameters.remove(KEY_INTERACTION_CHOICE_SET_ID_LIST);
@@ -211,16 +251,43 @@ public class PerformInteraction extends RPCRequest {
if(parameters.get(KEY_HELP_PROMPT) instanceof List<?>){
List<?> list = (List<?>)parameters.get(KEY_HELP_PROMPT);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TTSChunk) {
- return (List<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -242,7 +309,16 @@ public class PerformInteraction extends RPCRequest {
* session
*/
public void setHelpPrompt(List<TTSChunk> helpPrompt) {
- if (helpPrompt != null) {
+
+ boolean valid = true;
+
+ for ( TTSChunk item : helpPrompt ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (helpPrompt != null) && (helpPrompt.size() > 0) && valid) {
parameters.put(KEY_HELP_PROMPT, helpPrompt);
} else {
parameters.remove(KEY_HELP_PROMPT);
@@ -260,16 +336,43 @@ public class PerformInteraction extends RPCRequest {
if (parameters.get(KEY_TIMEOUT_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_TIMEOUT_PROMPT);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TTSChunk) {
- return (List<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -286,7 +389,16 @@ public class PerformInteraction extends RPCRequest {
* listen times out during the VR session
*/
public void setTimeoutPrompt(List<TTSChunk> timeoutPrompt) {
- if (timeoutPrompt != null) {
+
+ boolean valid = true;
+
+ for ( TTSChunk item : timeoutPrompt ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (timeoutPrompt != null) && (timeoutPrompt.size() > 0) && valid) {
parameters.put(KEY_TIMEOUT_PROMPT, timeoutPrompt);
} else {
parameters.remove(KEY_TIMEOUT_PROMPT);
@@ -340,16 +452,43 @@ public class PerformInteraction extends RPCRequest {
if (parameters.get(KEY_VR_HELP) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_VR_HELP);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof VrHelpItem) {
- return (List<VrHelpItem>) list;
- } else if (obj instanceof Hashtable) {
- List<VrHelpItem> newList = new ArrayList<VrHelpItem>();
- for (Object hashObj : list) {
- newList.add(new VrHelpItem((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<VrHelpItem> vrHelpItemList = new ArrayList<VrHelpItem>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw VrHelpItem and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof VrHelpItem) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ vrHelpItemList.add(new VrHelpItem((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<VrHelpItem>) list;
+ } else if (flagHash) {
+ return vrHelpItemList;
+ }
}
}
return null;
@@ -367,7 +506,16 @@ public class PerformInteraction extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setVrHelp(List<VrHelpItem> vrHelp) {
- if (vrHelp != null) {
+
+ boolean valid = true;
+
+ for ( VrHelpItem item : vrHelp ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (vrHelp != null) && (vrHelp.size() > 0) && valid) {
parameters.put(KEY_VR_HELP, vrHelp);
} else {
parameters.remove(KEY_VR_HELP);
@@ -378,14 +526,8 @@ public class PerformInteraction extends RPCRequest {
Object obj = parameters.get(KEY_INTERACTION_LAYOUT);
if (obj instanceof LayoutMode) {
return (LayoutMode) obj;
- } else if (obj instanceof String) {
- LayoutMode theCode = null;
- try {
- theCode = LayoutMode.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INTERACTION_LAYOUT, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return LayoutMode.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java
index d2f1f9d9e..ecf5550c4 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
-import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
/**
* PerformInteraction Response is sent, when PerformInteraction has been called
@@ -21,7 +20,7 @@ public class PerformInteractionResponse extends RPCResponse {
* Constructs a new PerformInteractionResponse object
*/
public PerformInteractionResponse() {
- super(FunctionID.PERFORM_INTERACTION);
+ super(FunctionID.PERFORM_INTERACTION.toString());
}
/**
@@ -61,14 +60,8 @@ public class PerformInteractionResponse extends RPCResponse {
Object obj = parameters.get(KEY_TRIGGER_SOURCE);
if (obj instanceof TriggerSource) {
return (TriggerSource) obj;
- } else if (obj instanceof String) {
- TriggerSource theCode = null;
- try {
- theCode = TriggerSource.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TRIGGER_SOURCE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return TriggerSource.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PermissionItem.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PermissionItem.java
index 9930123fb..b017dacf9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PermissionItem.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PermissionItem.java
@@ -3,7 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
public class PermissionItem extends RPCStruct {
public static final String KEY_RPC_NAME = "rpcName";
@@ -33,7 +33,7 @@ public class PermissionItem extends RPCStruct {
try {
return new HMIPermissions((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_PERMISSIONS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_PERMISSIONS, e);
}
}
return null;
@@ -54,7 +54,7 @@ public class PermissionItem extends RPCStruct {
try {
return new ParameterPermissions((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PARAMETER_PERMISSIONS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_PARAMETER_PERMISSIONS, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFile.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFile.java
index 4abdee3d5..0157c0c2f 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFile.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFile.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.rpc.enums.FileType;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.FileType;
/**
* Used to push a binary data onto the SDL module from a mobile device, such as
@@ -29,7 +28,7 @@ public class PutFile extends RPCRequest {
* Constructs a new PutFile object
*/
public PutFile() {
- super(FunctionID.PUT_FILE);
+ super(FunctionID.PUT_FILE.toString());
}
/**
@@ -91,14 +90,8 @@ public class PutFile extends RPCRequest {
Object obj = parameters.get(KEY_FILE_TYPE);
if (obj instanceof FileType) {
return (FileType) obj;
- } else if (obj instanceof String) {
- FileType theCode = null;
- try {
- theCode = FileType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FILE_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return FileType.valueForString((String) obj);
}
return null;
}
@@ -141,7 +134,19 @@ public class PutFile extends RPCRequest {
return getBulkData();
}
+ /**
+ * @deprecated as of SmartDeviceLink 4.0
+ * @param offset
+ */
public void setOffset(Integer offset) {
+ if(offset == null){
+ setOffset((Long)null);
+ }else{
+ setOffset(offset.longValue());
+ }
+ }
+
+ public void setOffset(Long offset) {
if (offset != null) {
parameters.put(KEY_OFFSET, offset);
} else {
@@ -149,16 +154,34 @@ public class PutFile extends RPCRequest {
}
}
- public Integer getOffset() {
+ public Long getOffset() {
final Object o = parameters.get(KEY_OFFSET);
+ if (o == null){
+ return null;
+ }
if (o instanceof Integer) {
- return (Integer) o;
+ return ((Integer) o).longValue();
+ }else if(o instanceof Long){
+ return (Long) o;
}
+
return null;
}
+ /**
+ * @deprecated as of SmartDeviceLink 4.0
+ * @param length
+ */
public void setLength(Integer length) {
+ if(length == null){
+ setLength((Long)null);
+ }else{
+ setLength(length.longValue());
+ }
+ }
+
+ public void setLength(Long length) {
if (length != null) {
parameters.put(KEY_LENGTH, length);
} else {
@@ -166,10 +189,15 @@ public class PutFile extends RPCRequest {
}
}
- public Integer getLength() {
+ public Long getLength() {
final Object o = parameters.get(KEY_LENGTH);
+ if (o == null){
+ return null;
+ }
if (o instanceof Integer) {
- return (Integer) o;
+ return ((Integer) o).longValue();
+ }else if(o instanceof Long){
+ return (Long) o;
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFileResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFileResponse.java
index d37b5b62e..88c0560b3 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFileResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/PutFileResponse.java
@@ -17,7 +17,7 @@ public class PutFileResponse extends RPCResponse {
* Constructs a new PutFileResponse object
*/
public PutFileResponse() {
- super(FunctionID.PUT_FILE);
+ super(FunctionID.PUT_FILE.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java
index b3212eb09..5d66b0b62 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDID.java
@@ -26,7 +26,7 @@ public class ReadDID extends RPCRequest {
* Constructs a new ReadDID object
*/
public ReadDID() {
- super(FunctionID.READ_DID);
+ super(FunctionID.READ_DID.toString());
}
/**
@@ -80,7 +80,16 @@ public class ReadDID extends RPCRequest {
* </ul>
*/
public void setDidLocation(List<Integer> didLocation) {
- if (didLocation != null) {
+
+ boolean valid = true;
+
+ for ( Integer item : didLocation ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (didLocation != null) && (didLocation.size() > 0) && valid) {
parameters.put(KEY_DID_LOCATION, didLocation);
} else {
parameters.remove(KEY_DID_LOCATION);
@@ -98,12 +107,14 @@ public class ReadDID extends RPCRequest {
if (parameters.get(KEY_DID_LOCATION) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_DID_LOCATION);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof Integer) {
- return (List<Integer>) list;
+ for( Object obj : list ) {
+ if (!(obj instanceof Integer)) {
+ return null;
+ }
}
+ return (List<Integer>) list;
}
}
return null;
}
-}
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java
index 8f3bd0f8a..0e797dda7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java
@@ -6,7 +6,6 @@ import java.util.List;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
-import com.smartdevicelink.proxy.rpc.DIDResult;
/**
* Read DID Response is sent, when ReadDID has been called
@@ -17,13 +16,22 @@ public class ReadDIDResponse extends RPCResponse {
public static final String KEY_DID_RESULT = "didResult";
public ReadDIDResponse() {
- super(FunctionID.READ_DID);
+ super(FunctionID.READ_DID.toString());
}
public ReadDIDResponse(Hashtable<String, Object> hash) {
super(hash);
}
public void setDidResult(List<DIDResult> didResult) {
- if (didResult != null) {
+
+ boolean valid = true;
+
+ for ( DIDResult item : didResult ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (didResult != null) && (didResult.size() > 0) && valid) {
parameters.put(KEY_DID_RESULT, didResult);
} else {
parameters.remove(KEY_DID_RESULT);
@@ -34,16 +42,43 @@ public class ReadDIDResponse extends RPCResponse {
if (parameters.get(KEY_DID_RESULT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_DID_RESULT);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof DIDResult) {
- return (List<DIDResult>) list;
- } else if (obj instanceof Hashtable) {
- List<DIDResult> newList = new ArrayList<DIDResult>();
- for (Object hashObj : list) {
- newList.add(new DIDResult((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<DIDResult> didResultList = new ArrayList<DIDResult>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw DIDResult and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof DIDResult) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ didResultList.add(new DIDResult((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<DIDResult>) list;
+ } else if (flagHash) {
+ return didResultList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java
index fdc0b7b80..c54707234 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java
@@ -1,538 +1,611 @@
-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;
-import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
-import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.util.LogTool;
-/**
- * Registers the application's interface with SDL&reg;, declaring properties of
- * the registration, including the messaging interface version, the app name,
- * etc. The mobile application must establish its interface registration with
- * SDL&reg; before any other interaction with SDL&reg; can take place. The
- * registration lasts until it is terminated either by the application calling
- * the <i> {@linkplain UnregisterAppInterface}</i> method, or by SDL&reg;
- * sending an <i> {@linkplain OnAppInterfaceUnregistered}</i> notification, or
- * by loss of the underlying transport connection, or closing of the underlying
- * message transmission protocol RPC session
- * <p>
- * Until the application receives its first <i>{@linkplain OnHMIStatus}</i>
- * Notification, its HMI Status is assumed to be: <i>
- * {@linkplain com.smartdevicelink.proxy.rpc.enums.HMILevel}</i>=NONE, <i>
- * {@linkplain com.smartdevicelink.proxy.rpc.enums.AudioStreamingState}
- * </i>=NOT_AUDIBLE, <i>
- * {@linkplain com.smartdevicelink.proxy.rpc.enums.SystemContext}</i>=MAIN
- * <p>
- * All SDL&reg; resources which the application creates or uses (e.g. Choice
- * Sets, Command Menu, etc.) are associated with the application's interface
- * registration. Therefore, when the interface registration ends, the SDL&reg;
- * resources associated with the application are disposed of. As a result, even
- * though the application itself may continue to run on its host platform (e.g.
- * mobile device) after the interface registration terminates, the application
- * will not be able to use the SDL&reg; HMI without first establishing a new
- * interface registration and re-creating its required SDL&reg; resources. That
- * is, SDL&reg; resources created by (or on behalf of) an application do not
- * persist beyond the life-span of the interface registration
- * <p>
- * Resources and settings whose lifespan is tied to the duration of an
- * application's interface registration:<br/>
- * <ul>
- * <li>Choice Sets</li>
- * <li>Command Menus (built by successive calls to <i>{@linkplain AddCommand}
- * </i>)</li>
- * <li>Media clock timer display value</li>
- * <li>Media clock timer display value</li>
- * <li>Media clock timer display value</li>
- * </ul>
- * <p>
- * The autoActivateID is used to grant an application the HMILevel and
- * AudioStreamingState it had when it last disconnected
- * <p>
- * <b>Notes: </b>The autoActivateID parameter, and associated behavior, is
- * currently ignored by SDL&reg;
- * <p>
- * When first calling this method (i.e. first time within life cycle of mobile
- * app), an autoActivateID should not be included. After successfully
- * registering an interface, an autoActivateID is returned to the mobile
- * application for it to use in subsequent connections. If the connection
- * between SDL&reg; and the mobile application is lost, such as the vehicle is
- * turned off while the application is running, the autoActivateID can then be
- * passed in another call to RegisterAppInterface to re-acquire <i>
- * {@linkplain com.smartdevicelink.proxy.rpc.enums.HMILevel}</i>=FULL
- * <p>
- * If the application intends to stream audio it is important to indicate so via
- * the isMediaApp parameter. When set to true, audio will reliably stream
- * without any configuration required by the user. When not set, audio may
- * stream, depending on what the user might have manually configured as a media
- * source on SDL&reg;
- * <p>
- * There is no time limit for how long the autoActivateID is "valid" (i.e. would
- * confer focus and opt-in)
- * <p>
- * <b>HMILevel is not defined before registering</b><br/>
- * </p>
- *
- * @since SmartDeviceLink 1.0
- * @see UnregisterAppInterface
- * @see OnAppInterfaceUnregistered
- */
-public class RegisterAppInterface extends RPCRequest {
- public static final String KEY_TTS_NAME = "ttsName";
- public static final String KEY_HMI_DISPLAY_LANGUAGE_DESIRED = "hmiDisplayLanguageDesired";
- public static final String KEY_APP_HMI_TYPE = "appHMIType";
- public static final String KEY_APP_ID = "appID";
- public static final String KEY_LANGUAGE_DESIRED = "languageDesired";
- public static final String KEY_DEVICE_INFO = "deviceInfo";
- public static final String KEY_APP_NAME = "appName";
- public static final String KEY_NGN_MEDIA_SCREEN_APP_NAME = "ngnMediaScreenAppName";
- public static final String KEY_IS_MEDIA_APPLICATION = "isMediaApplication";
- public static final String KEY_VR_SYNONYMS = "vrSynonyms";
- public static final String KEY_SDL_MSG_VERSION = "syncMsgVersion";
- public static final String KEY_HASH_ID = "hashID";
- /**
- * Constructs a new RegisterAppInterface object
- */
- public RegisterAppInterface() {
- super(FunctionID.REGISTER_APP_INTERFACE);
- }
- /**
- * Constructs a new RegisterAppInterface object indicated by the Hashtable
- * parameter
- * <p>
- *
- * @param hash
- * The Hashtable to use
- */
- public RegisterAppInterface(Hashtable<String, Object> hash) {
- super(hash);
- }
- /**
- * Gets the version of the SDL&reg; SmartDeviceLink interface
- *
- * @return SdlMsgVersion -a SdlMsgVersion object representing version of
- * the SDL&reg; SmartDeviceLink interface
- */
- @SuppressWarnings("unchecked")
- public SdlMsgVersion getSdlMsgVersion() {
- Object obj = parameters.get(KEY_SDL_MSG_VERSION);
- if (obj instanceof SdlMsgVersion) {
- return (SdlMsgVersion) obj;
- } else if (obj instanceof Hashtable) {
- return new SdlMsgVersion((Hashtable<String, Object>) obj);
- }
- return null;
- }
- /**
- * Sets the version of the SDL&reg; SmartDeviceLink interface
- *
- * @param sdlMsgVersion
- * a SdlMsgVersion object representing version of the SDL&reg;
- * SmartDeviceLink interface
- * <p>
- * <b>Notes: </b>To be compatible, app msg major version number
- * must be less than or equal to SDL&reg; major version number.
- * If msg versions are incompatible, app has 20 seconds to
- * attempt successful RegisterAppInterface (w.r.t. msg version)
- * on underlying protocol session, else will be terminated. Major
- * version number is a compatibility declaration. Minor version
- * number indicates minor functional variations (e.g. features,
- * capabilities, bug fixes) when sent from SDL&reg; to app (in
- * RegisterAppInterface response). However, the minor version
- * number sent from the app to SDL&reg; (in RegisterAppInterface
- * request) is ignored by SDL&reg;
- */
- public void setSdlMsgVersion(SdlMsgVersion sdlMsgVersion) {
- if (sdlMsgVersion != null) {
- parameters.put(KEY_SDL_MSG_VERSION, sdlMsgVersion);
- } else {
- parameters.remove(KEY_SDL_MSG_VERSION);
- }
- }
-
- @SuppressWarnings("unchecked")
- public DeviceInfo getDeviceInfo() {
- Object obj = parameters.get(KEY_DEVICE_INFO);
- if (obj instanceof DeviceInfo) {
- return (DeviceInfo) obj;
- } else if (obj instanceof Hashtable) {
- return new DeviceInfo((Hashtable<String, Object>) obj);
- }
- return null;
- }
-
- public void setDeviceInfo(DeviceInfo deviceInfo) {
- if (deviceInfo != null) {
- parameters.put(KEY_DEVICE_INFO, deviceInfo);
- } else {
- parameters.remove(KEY_DEVICE_INFO);
- }
- }
- /**
- * Gets Mobile Application's Name
- *
- * @return String -a String representing the Mobile Application's Name
- */
- public String getAppName() {
- return (String) parameters.get(KEY_APP_NAME);
- }
- /**
- * Sets Mobile Application's Name, This name is displayed in the SDL&reg;
- * Mobile Applications menu. It also serves as the unique identifier of the
- * application for SmartDeviceLink
- *
- * @param appName
- * a String value representing the Mobile Application's Name
- * <p>
- * <b>Notes: </b>
- * <ul>
- * <li>Must be 1-100 characters in length</li>
- * <li>May not be the same (by case insensitive comparison) as
- * the name or any synonym of any currently-registered
- * application</li>
- * </ul>
- */
- public void setAppName(String appName) {
- if (appName != null) {
- parameters.put(KEY_APP_NAME, appName);
- } else {
- parameters.remove(KEY_APP_NAME);
- }
- }
-
- /**
- * Gets TTS string for VR recognition of the mobile application name
- *
- * @return List<TTSChunk> -List value representing the TTS string
- * @since SmartDeviceLink 2.0
- */
- @SuppressWarnings("unchecked")
- public List<TTSChunk> 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<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>) hashObj));
- }
- return newList;
- }
- }
- }
- return null;
- }
-
- /**
- *
- * @param ttsName
- * a List<TTSChunk> value represeting the TTS Name
- * <p>
- * <b>Notes: </b><br/>
- * <ul>
- * <li>Size must be 1-100</li>
- * <li>Needs to be unique over all applications</li>
- * <li>May not be empty</li>
- * <li>May not start with a new line character</li>
- * <li>May not interfere with any name or synonym of previously
- * registered applications and the following list of words</li>
- * <li>Needs to be unique over all applications. Applications
- * with the same name will be rejected</li>
- * </ul>
- * @since SmartDeviceLink 2.0
- */
- public void setTtsName(List<TTSChunk> ttsName) {
- if (ttsName != null) {
- parameters.put(KEY_TTS_NAME, ttsName);
- } else {
- parameters.remove(KEY_TTS_NAME);
- }
- }
- /**
- * Gets a String representing an abbreviated version of the mobile
- * applincation's name (if necessary) that will be displayed on the NGN
- * media screen
- *
- * @return String -a String value representing an abbreviated version of the
- * mobile applincation's name
- */
- public String getNgnMediaScreenAppName() {
- return (String) parameters.get(KEY_NGN_MEDIA_SCREEN_APP_NAME);
- }
- /**
- * Sets a String representing an abbreviated version of the mobile
- * applincation's name (if necessary) that will be displayed on the NGN
- * media screen
- *
- * @param ngnMediaScreenAppName
- * a String value representing an abbreviated version of the
- * mobile applincation's name
- * <p>
- * <b>Notes: </b>
- * <ul>
- * <li>Must be 1-5 characters</li>
- * <li>If not provided, value will be derived from appName
- * truncated to 5 characters</li>
- * </ul>
- */
- public void setNgnMediaScreenAppName(String ngnMediaScreenAppName) {
- if (ngnMediaScreenAppName != null) {
- parameters.put(KEY_NGN_MEDIA_SCREEN_APP_NAME, ngnMediaScreenAppName);
- } else {
- parameters.remove(KEY_NGN_MEDIA_SCREEN_APP_NAME);
- }
- }
- /**
- * Gets the List<String> representing the an array of 1-100 elements, each
- * element containing a voice-recognition synonym
- *
- * @return List<String> -a List value representing the an array of
- * 1-100 elements, each element containing a voice-recognition
- * synonym
- */
- @SuppressWarnings("unchecked")
- public List<String> 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<String>) 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<String> value representing the an array of 1-100
- * elements
- * <p>
- * <b>Notes: </b>
- * <ul>
- * <li>Each vr synonym is limited to 40 characters, and there can
- * be 1-100 synonyms in array</li>
- * <li>May not be the same (by case insensitive comparison) as
- * the name or any synonym of any currently-registered
- * application</li>
- * </ul>
- */
- public void setVrSynonyms(List<String> vrSynonyms) {
- if (vrSynonyms != null) {
- parameters.put(KEY_VR_SYNONYMS, vrSynonyms);
- } else {
- parameters.remove(KEY_VR_SYNONYMS);
- }
- }
- /**
- * Gets a Boolean representing MediaApplication
- *
- * @return Boolean -a Boolean value representing a mobile application that is
- * a media application or not
- */
- public Boolean getIsMediaApplication() {
- return (Boolean) parameters.get(KEY_IS_MEDIA_APPLICATION);
- }
- /**
- * Sets a Boolean to indicate a mobile application that is a media
- * application or not
- *
- * @param isMediaApplication
- * a Boolean value
- */
- public void setIsMediaApplication(Boolean isMediaApplication) {
- if (isMediaApplication != null) {
- parameters.put(KEY_IS_MEDIA_APPLICATION, isMediaApplication);
- } else {
- parameters.remove(KEY_IS_MEDIA_APPLICATION);
- }
- }
- /**
- * Gets a Language enumeration indicating what language the application
- * intends to use for user interaction (Display, TTS and VR)
- *
- * @return Enumeration -a language enumeration
- */
- public Language getLanguageDesired() {
- Object obj = parameters.get(KEY_LANGUAGE_DESIRED);
- if (obj instanceof Language) {
- return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LANGUAGE_DESIRED, e);
- }
- return theCode;
- }
- return null;
- }
- /**
- * Sets an enumeration indicating what language the application intends to
- * use for user interaction (Display, TTS and VR)
- *
- * @param languageDesired
- * a Language Enumeration
- * <p>
- *
- */
- public void setLanguageDesired(Language languageDesired) {
- if (languageDesired != null) {
- parameters.put(KEY_LANGUAGE_DESIRED, languageDesired);
- } else {
- parameters.remove(KEY_LANGUAGE_DESIRED);
- }
- }
-
- /**
- * Gets an enumeration indicating what language the application intends to
- * use for user interaction ( Display)
- *
- * @return Language - a Language value representing an enumeration
- * indicating what language the application intends to use for user
- * interaction ( Display)
- * @since SmartDeviceLink 2.0
- */
- public Language getHmiDisplayLanguageDesired() {
- Object obj = parameters.get(KEY_HMI_DISPLAY_LANGUAGE_DESIRED);
- if (obj instanceof Language) {
- return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_DISPLAY_LANGUAGE_DESIRED, e);
- }
- return theCode;
- }
- return null;
- }
-
- /**
- * Sets an enumeration indicating what language the application intends to
- * use for user interaction ( Display)
- *
- * @param hmiDisplayLanguageDesired
- * @since SmartDeviceLink 2.0
- */
- public void setHmiDisplayLanguageDesired(Language hmiDisplayLanguageDesired) {
- if (hmiDisplayLanguageDesired != null) {
- parameters.put(KEY_HMI_DISPLAY_LANGUAGE_DESIRED, hmiDisplayLanguageDesired);
- } else {
- parameters.remove(KEY_HMI_DISPLAY_LANGUAGE_DESIRED);
- }
- }
-
- /**
- * Gets a list of all applicable app types stating which classifications to
- * be given to the app.e.g. for platforms , like GEN2, this will determine
- * which "corner(s)" the app can populate
- *
- * @return List<AppHMIType> - a List value representing a list of all
- * applicable app types stating which classifications to be given to
- * the app
- * @since SmartDeviceLinke 2.0
- */
- @SuppressWarnings("unchecked")
- public List<AppHMIType> getAppHMIType() {
- if (parameters.get(KEY_APP_HMI_TYPE) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_APP_HMI_TYPE);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof AppHMIType) {
- return (List<AppHMIType>) list;
- } else if (obj instanceof String) {
- List<AppHMIType> newList = new ArrayList<AppHMIType>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- AppHMIType toAdd = null;
- try {
- toAdd = AppHMIType.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_APP_HMI_TYPE, e); }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
-
- /**
- * Sets a a list of all applicable app types stating which classifications
- * to be given to the app. e.g. for platforms , like GEN2, this will
- * determine which "corner(s)" the app can populate
- *
- * @param appHMIType
- * a List<AppHMIType>
- * <p>
- * <b>Notes: </b>
- * <ul>
- * <li>Array Minsize: = 1</li>
- * <li>Array Maxsize = 100</li>
- * </ul>
- * @since SmartDeviceLink 2.0
- */
- public void setAppHMIType(List<AppHMIType> appHMIType) {
- if (appHMIType != null) {
- parameters.put(KEY_APP_HMI_TYPE, appHMIType);
- } else {
- parameters.remove(KEY_APP_HMI_TYPE);
- }
- }
-
- public String getHashID() {
- return (String) parameters.get(KEY_HASH_ID);
- }
-
- public void setHashID(String hashID) {
- if (hashID != null) {
- parameters.put(KEY_HASH_ID, hashID);
- } else {
- parameters.remove(KEY_HASH_ID);
- }
- }
-
- /**
- * Gets the unique ID, which an app will be given when approved
- *
- * @return String - a String value representing the unique ID, which an app
- * will be given when approved
- * @since SmartDeviceLink 2.0
- */
- public String getAppID() {
- return (String) parameters.get(KEY_APP_ID);
- }
-
- /**
- * Sets a unique ID, which an app will be given when approved
- *
- * @param appID
- * a String value representing a unique ID, which an app will be
- * given when approved
- * <p>
- * <b>Notes: </b>Maxlength = 100
- * @since SmartDeviceLink 2.0
- */
- public void setAppID(String appID) {
- if (appID != null) {
- parameters.put(KEY_APP_ID, appID);
- } else {
- parameters.remove(KEY_APP_ID);
- }
- }
-}
+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;
+import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
+import com.smartdevicelink.proxy.rpc.enums.Language;
+import com.smartdevicelink.util.SdlLog;
+/**
+ * Registers the application's interface with SDL&reg;, declaring properties of
+ * the registration, including the messaging interface version, the app name,
+ * etc. The mobile application must establish its interface registration with
+ * SDL&reg; before any other interaction with SDL&reg; can take place. The
+ * registration lasts until it is terminated either by the application calling
+ * the <i> {@linkplain UnregisterAppInterface}</i> method, or by SDL&reg;
+ * sending an <i> {@linkplain OnAppInterfaceUnregistered}</i> notification, or
+ * by loss of the underlying transport connection, or closing of the underlying
+ * message transmission protocol RPC session
+ * <p>
+ * Until the application receives its first <i>{@linkplain OnHMIStatus}</i>
+ * Notification, its HMI Status is assumed to be: <i>
+ * {@linkplain com.smartdevicelink.proxy.rpc.enums.HMILevel}</i>=NONE, <i>
+ * {@linkplain com.smartdevicelink.proxy.rpc.enums.AudioStreamingState}
+ * </i>=NOT_AUDIBLE, <i>
+ * {@linkplain com.smartdevicelink.proxy.rpc.enums.SystemContext}</i>=MAIN
+ * <p>
+ * All SDL&reg; resources which the application creates or uses (e.g. Choice
+ * Sets, Command Menu, etc.) are associated with the application's interface
+ * registration. Therefore, when the interface registration ends, the SDL&reg;
+ * resources associated with the application are disposed of. As a result, even
+ * though the application itself may continue to run on its host platform (e.g.
+ * mobile device) after the interface registration terminates, the application
+ * will not be able to use the SDL&reg; HMI without first establishing a new
+ * interface registration and re-creating its required SDL&reg; resources. That
+ * is, SDL&reg; resources created by (or on behalf of) an application do not
+ * persist beyond the life-span of the interface registration
+ * <p>
+ * Resources and settings whose lifespan is tied to the duration of an
+ * application's interface registration:<br/>
+ * <ul>
+ * <li>Choice Sets</li>
+ * <li>Command Menus (built by successive calls to <i>{@linkplain AddCommand}
+ * </i>)</li>
+ * <li>Media clock timer display value</li>
+ * <li>Media clock timer display value</li>
+ * <li>Media clock timer display value</li>
+ * </ul>
+ * <p>
+ * The autoActivateID is used to grant an application the HMILevel and
+ * AudioStreamingState it had when it last disconnected
+ * <p>
+ * <b>Notes: </b>The autoActivateID parameter, and associated behavior, is
+ * currently ignored by SDL&reg;
+ * <p>
+ * When first calling this method (i.e. first time within life cycle of mobile
+ * app), an autoActivateID should not be included. After successfully
+ * registering an interface, an autoActivateID is returned to the mobile
+ * application for it to use in subsequent connections. If the connection
+ * between SDL&reg; and the mobile application is lost, such as the vehicle is
+ * turned off while the application is running, the autoActivateID can then be
+ * passed in another call to RegisterAppInterface to re-acquire <i>
+ * {@linkplain com.smartdevicelink.proxy.rpc.enums.HMILevel}</i>=FULL
+ * <p>
+ * If the application intends to stream audio it is important to indicate so via
+ * the isMediaApp parameter. When set to true, audio will reliably stream
+ * without any configuration required by the user. When not set, audio may
+ * stream, depending on what the user might have manually configured as a media
+ * source on SDL&reg;
+ * <p>
+ * There is no time limit for how long the autoActivateID is "valid" (i.e. would
+ * confer focus and opt-in)
+ * <p>
+ * <b>HMILevel is not defined before registering</b><br/>
+ * </p>
+ *
+ * @since SmartDeviceLink 1.0
+ * @see UnregisterAppInterface
+ * @see OnAppInterfaceUnregistered
+ */
+public class RegisterAppInterface extends RPCRequest {
+ public static final String KEY_TTS_NAME = "ttsName";
+ public static final String KEY_HMI_DISPLAY_LANGUAGE_DESIRED = "hmiDisplayLanguageDesired";
+ public static final String KEY_APP_HMI_TYPE = "appHMIType";
+ public static final String KEY_APP_ID = "appID";
+ public static final String KEY_LANGUAGE_DESIRED = "languageDesired";
+ public static final String KEY_DEVICE_INFO = "deviceInfo";
+ public static final String KEY_APP_NAME = "appName";
+ public static final String KEY_NGN_MEDIA_SCREEN_APP_NAME = "ngnMediaScreenAppName";
+ public static final String KEY_IS_MEDIA_APPLICATION = "isMediaApplication";
+ public static final String KEY_VR_SYNONYMS = "vrSynonyms";
+ public static final String KEY_SDL_MSG_VERSION = "syncMsgVersion";
+ public static final String KEY_HASH_ID = "hashID";
+ /**
+ * Constructs a new RegisterAppInterface object
+ */
+ public RegisterAppInterface() {
+ super(FunctionID.REGISTER_APP_INTERFACE.toString());
+ }
+ /**
+ * Constructs a new RegisterAppInterface object indicated by the Hashtable
+ * parameter
+ * <p>
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public RegisterAppInterface(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+ /**
+ * Gets the version of the SDL&reg; SmartDeviceLink interface
+ *
+ * @return SdlMsgVersion -a SdlMsgVersion object representing version of
+ * the SDL&reg; SmartDeviceLink interface
+ */
+ @SuppressWarnings("unchecked")
+ public SdlMsgVersion getSdlMsgVersion() {
+ Object obj = parameters.get(KEY_SDL_MSG_VERSION);
+ if (obj instanceof SdlMsgVersion) {
+ return (SdlMsgVersion) obj;
+ } else if (obj instanceof Hashtable) {
+ return new SdlMsgVersion((Hashtable<String, Object>) obj);
+ }
+ return null;
+ }
+ /**
+ * Sets the version of the SDL&reg; SmartDeviceLink interface
+ *
+ * @param sdlMsgVersion
+ * a SdlMsgVersion object representing version of the SDL&reg;
+ * SmartDeviceLink interface
+ * <p>
+ * <b>Notes: </b>To be compatible, app msg major version number
+ * must be less than or equal to SDL&reg; major version number.
+ * If msg versions are incompatible, app has 20 seconds to
+ * attempt successful RegisterAppInterface (w.r.t. msg version)
+ * on underlying protocol session, else will be terminated. Major
+ * version number is a compatibility declaration. Minor version
+ * number indicates minor functional variations (e.g. features,
+ * capabilities, bug fixes) when sent from SDL&reg; to app (in
+ * RegisterAppInterface response). However, the minor version
+ * number sent from the app to SDL&reg; (in RegisterAppInterface
+ * request) is ignored by SDL&reg;
+ */
+ public void setSdlMsgVersion(SdlMsgVersion sdlMsgVersion) {
+ if (sdlMsgVersion != null) {
+ parameters.put(KEY_SDL_MSG_VERSION, sdlMsgVersion);
+ } else {
+ parameters.remove(KEY_SDL_MSG_VERSION);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public DeviceInfo getDeviceInfo() {
+ Object obj = parameters.get(KEY_DEVICE_INFO);
+ if (obj instanceof DeviceInfo) {
+ return (DeviceInfo) obj;
+ } else if (obj instanceof Hashtable) {
+ return new DeviceInfo((Hashtable<String, Object>) obj);
+ }
+ return null;
+ }
+
+ public void setDeviceInfo(DeviceInfo deviceInfo) {
+ if (deviceInfo != null) {
+ parameters.put(KEY_DEVICE_INFO, deviceInfo);
+ } else {
+ parameters.remove(KEY_DEVICE_INFO);
+ }
+ }
+ /**
+ * Gets Mobile Application's Name
+ *
+ * @return String -a String representing the Mobile Application's Name
+ */
+ public String getAppName() {
+ return (String) parameters.get(KEY_APP_NAME);
+ }
+ /**
+ * Sets Mobile Application's Name, This name is displayed in the SDL&reg;
+ * Mobile Applications menu. It also serves as the unique identifier of the
+ * application for SmartDeviceLink
+ *
+ * @param appName
+ * a String value representing the Mobile Application's Name
+ * <p>
+ * <b>Notes: </b>
+ * <ul>
+ * <li>Must be 1-100 characters in length</li>
+ * <li>May not be the same (by case insensitive comparison) as
+ * the name or any synonym of any currently-registered
+ * application</li>
+ * </ul>
+ */
+ public void setAppName(String appName) {
+ if (appName != null) {
+ parameters.put(KEY_APP_NAME, appName);
+ } else {
+ parameters.remove(KEY_APP_NAME);
+ }
+ }
+
+ /**
+ * Gets TTS string for VR recognition of the mobile application name
+ *
+ * @return List<TTSChunk> -List value representing the TTS string
+ * @since SmartDeviceLink 2.0
+ */
+ @SuppressWarnings("unchecked")
+ public List<TTSChunk> getTtsName() {
+ if (parameters.get(KEY_TTS_NAME) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_TTS_NAME);
+ if (list != null && list.size() > 0) {
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param ttsName
+ * a List<TTSChunk> value represeting the TTS Name
+ * <p>
+ * <b>Notes: </b><br/>
+ * <ul>
+ * <li>Size must be 1-100</li>
+ * <li>Needs to be unique over all applications</li>
+ * <li>May not be empty</li>
+ * <li>May not start with a new line character</li>
+ * <li>May not interfere with any name or synonym of previously
+ * registered applications and the following list of words</li>
+ * <li>Needs to be unique over all applications. Applications
+ * with the same name will be rejected</li>
+ * </ul>
+ * @since SmartDeviceLink 2.0
+ */
+ public void setTtsName(List<TTSChunk> ttsName) {
+
+ boolean valid = true;
+
+ for ( TTSChunk item : ttsName ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (ttsName != null) && (ttsName.size() > 0) && valid) {
+ parameters.put(KEY_TTS_NAME, ttsName);
+ } else {
+ parameters.remove(KEY_TTS_NAME);
+ }
+ }
+ /**
+ * Gets a String representing an abbreviated version of the mobile
+ * applincation's name (if necessary) that will be displayed on the NGN
+ * media screen
+ *
+ * @return String -a String value representing an abbreviated version of the
+ * mobile applincation's name
+ */
+ public String getNgnMediaScreenAppName() {
+ return (String) parameters.get(KEY_NGN_MEDIA_SCREEN_APP_NAME);
+ }
+ /**
+ * Sets a String representing an abbreviated version of the mobile
+ * applincation's name (if necessary) that will be displayed on the NGN
+ * media screen
+ *
+ * @param ngnMediaScreenAppName
+ * a String value representing an abbreviated version of the
+ * mobile applincation's name
+ * <p>
+ * <b>Notes: </b>
+ * <ul>
+ * <li>Must be 1-5 characters</li>
+ * <li>If not provided, value will be derived from appName
+ * truncated to 5 characters</li>
+ * </ul>
+ */
+ public void setNgnMediaScreenAppName(String ngnMediaScreenAppName) {
+ if (ngnMediaScreenAppName != null) {
+ parameters.put(KEY_NGN_MEDIA_SCREEN_APP_NAME, ngnMediaScreenAppName);
+ } else {
+ parameters.remove(KEY_NGN_MEDIA_SCREEN_APP_NAME);
+ }
+ }
+ /**
+ * Gets the List<String> representing the an array of 1-100 elements, each
+ * element containing a voice-recognition synonym
+ *
+ * @return List<String> -a List value representing the an array of
+ * 1-100 elements, each element containing a voice-recognition
+ * synonym
+ */
+ @SuppressWarnings("unchecked")
+ public List<String> getVrSynonyms() {
+ if (parameters.get(KEY_VR_SYNONYMS) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_VR_SYNONYMS);
+ if (list != null && list.size()>0) {
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
+ }
+ return (List<String>) 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<String> value representing the an array of 1-100
+ * elements
+ * <p>
+ * <b>Notes: </b>
+ * <ul>
+ * <li>Each vr synonym is limited to 40 characters, and there can
+ * be 1-100 synonyms in array</li>
+ * <li>May not be the same (by case insensitive comparison) as
+ * the name or any synonym of any currently-registered
+ * application</li>
+ * </ul>
+ */
+ public void setVrSynonyms(List<String> vrSynonyms) {
+
+ boolean valid = true;
+
+ for ( String item : vrSynonyms ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (vrSynonyms != null) && (vrSynonyms.size() > 0) && valid) {
+ parameters.put(KEY_VR_SYNONYMS, vrSynonyms);
+ } else {
+ parameters.remove(KEY_VR_SYNONYMS);
+ }
+ }
+ /**
+ * Gets a Boolean representing MediaApplication
+ *
+ * @return Boolean -a Boolean value representing a mobile application that is
+ * a media application or not
+ */
+ public Boolean getIsMediaApplication() {
+ return (Boolean) parameters.get(KEY_IS_MEDIA_APPLICATION);
+ }
+ /**
+ * Sets a Boolean to indicate a mobile application that is a media
+ * application or not
+ *
+ * @param isMediaApplication
+ * a Boolean value
+ */
+ public void setIsMediaApplication(Boolean isMediaApplication) {
+ if (isMediaApplication != null) {
+ parameters.put(KEY_IS_MEDIA_APPLICATION, isMediaApplication);
+ } else {
+ parameters.remove(KEY_IS_MEDIA_APPLICATION);
+ }
+ }
+ /**
+ * Gets a Language enumeration indicating what language the application
+ * intends to use for user interaction (Display, TTS and VR)
+ *
+ * @return Enumeration -a language enumeration
+ */
+ public Language getLanguageDesired() {
+ Object obj = parameters.get(KEY_LANGUAGE_DESIRED);
+ if (obj instanceof Language) {
+ return (Language) obj;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
+ }
+ return null;
+ }
+ /**
+ * Sets an enumeration indicating what language the application intends to
+ * use for user interaction (Display, TTS and VR)
+ *
+ * @param languageDesired
+ * a Language Enumeration
+ * <p>
+ *
+ */
+ public void setLanguageDesired(Language languageDesired) {
+ if (languageDesired != null) {
+ parameters.put(KEY_LANGUAGE_DESIRED, languageDesired);
+ } else {
+ parameters.remove(KEY_LANGUAGE_DESIRED);
+ }
+ }
+
+ /**
+ * Gets an enumeration indicating what language the application intends to
+ * use for user interaction ( Display)
+ *
+ * @return Language - a Language value representing an enumeration
+ * indicating what language the application intends to use for user
+ * interaction ( Display)
+ * @since SmartDeviceLink 2.0
+ */
+ public Language getHmiDisplayLanguageDesired() {
+ Object obj = parameters.get(KEY_HMI_DISPLAY_LANGUAGE_DESIRED);
+ if (obj instanceof Language) {
+ return (Language) obj;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
+ }
+ return null;
+ }
+
+ /**
+ * Sets an enumeration indicating what language the application intends to
+ * use for user interaction ( Display)
+ *
+ * @param hmiDisplayLanguageDesired
+ * @since SmartDeviceLink 2.0
+ */
+ public void setHmiDisplayLanguageDesired(Language hmiDisplayLanguageDesired) {
+ if (hmiDisplayLanguageDesired != null) {
+ parameters.put(KEY_HMI_DISPLAY_LANGUAGE_DESIRED, hmiDisplayLanguageDesired);
+ } else {
+ parameters.remove(KEY_HMI_DISPLAY_LANGUAGE_DESIRED);
+ }
+ }
+
+ /**
+ * Gets a list of all applicable app types stating which classifications to
+ * be given to the app.e.g. for platforms , like GEN2, this will determine
+ * which "corner(s)" the app can populate
+ *
+ * @return List<AppHMIType> - a List value representing a list of all
+ * applicable app types stating which classifications to be given to
+ * the app
+ * @since SmartDeviceLinke 2.0
+ */
+ @SuppressWarnings("unchecked")
+ public List<AppHMIType> getAppHMIType() {
+ if (parameters.get(KEY_APP_HMI_TYPE) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_APP_HMI_TYPE);
+ if (list != null && list.size() > 0) {
+
+ List<AppHMIType> appHMITypeList = new ArrayList<AppHMIType>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw AppHMIType and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof AppHMIType) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ String strFormat = (String) obj;
+ AppHMIType toAdd = null;
+ try {
+ toAdd = AppHMIType.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_APP_HMI_TYPE, e);
+ }
+
+ if (toAdd != null) {
+ appHMITypeList.add(toAdd);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<AppHMIType>) list;
+ } else if (flagHash) {
+ return appHMITypeList;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sets a a list of all applicable app types stating which classifications
+ * to be given to the app. e.g. for platforms , like GEN2, this will
+ * determine which "corner(s)" the app can populate
+ *
+ * @param appHMIType
+ * a List<AppHMIType>
+ * <p>
+ * <b>Notes: </b>
+ * <ul>
+ * <li>Array Minsize: = 1</li>
+ * <li>Array Maxsize = 100</li>
+ * </ul>
+ * @since SmartDeviceLink 2.0
+ */
+ public void setAppHMIType(List<AppHMIType> appHMIType) {
+
+ boolean valid = true;
+
+ for ( AppHMIType item : appHMIType ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (appHMIType != null) && (appHMIType.size() > 0) && valid) {
+ parameters.put(KEY_APP_HMI_TYPE, appHMIType);
+ } else {
+ parameters.remove(KEY_APP_HMI_TYPE);
+ }
+ }
+
+ public String getHashID() {
+ return (String) parameters.get(KEY_HASH_ID);
+ }
+
+ public void setHashID(String hashID) {
+ if (hashID != null) {
+ parameters.put(KEY_HASH_ID, hashID);
+ } else {
+ parameters.remove(KEY_HASH_ID);
+ }
+ }
+
+ /**
+ * Gets the unique ID, which an app will be given when approved
+ *
+ * @return String - a String value representing the unique ID, which an app
+ * will be given when approved
+ * @since SmartDeviceLink 2.0
+ */
+ public String getAppID() {
+ return (String) parameters.get(KEY_APP_ID);
+ }
+
+ /**
+ * Sets a unique ID, which an app will be given when approved
+ *
+ * @param appID
+ * a String value representing a unique ID, which an app will be
+ * given when approved
+ * <p>
+ * <b>Notes: </b>Maxlength = 100
+ * @since SmartDeviceLink 2.0
+ */
+ public void setAppID(String appID) {
+ if (appID != null) {
+ parameters.put(KEY_APP_ID, appID);
+ } else {
+ parameters.remove(KEY_APP_ID);
+ }
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java
index 3bd941e51..1913a856e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java
@@ -1,570 +1,869 @@
-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.RPCResponse;
-import com.smartdevicelink.proxy.Version;
-import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities;
-import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
-import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
-import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
-import com.smartdevicelink.util.LogTool;
-
-/**
- * Register AppInterface Response is sent, when RegisterAppInterface has been called
- *
- * @since SmartDeviceLink 1.0
- */
-public class RegisterAppInterfaceResponse extends RPCResponse {
- public static final String KEY_VEHICLE_TYPE = "vehicleType";
- public static final String KEY_SPEECH_CAPABILITIES = "speechCapabilities";
- public static final String KEY_VR_CAPABILITIES = "vrCapabilities";
- public static final String KEY_AUDIO_PASS_THRU_CAPABILITIES = "audioPassThruCapabilities";
- public static final String KEY_HMI_ZONE_CAPABILITIES = "hmiZoneCapabilities";
- public static final String KEY_PRERECORDED_SPEECH = "prerecordedSpeech";
- public static final String KEY_SUPPORTED_DIAG_MODES = "supportedDiagModes";
- public static final String KEY_SDL_MSG_VERSION = "syncMsgVersion";
- public static final String KEY_LANGUAGE = "language";
- public static final String KEY_BUTTON_CAPABILITIES = "buttonCapabilities";
- public static final String KEY_DISPLAY_CAPABILITIES = "displayCapabilities";
- public static final String KEY_HMI_DISPLAY_LANGUAGE = "hmiDisplayLanguage";
- public static final String KEY_SOFT_BUTTON_CAPABILITIES = "softButtonCapabilities";
- public static final String KEY_PRESET_BANK_CAPABILITIES = "presetBankCapabilities";
- /**
- * Constructs a new RegisterAppInterfaceResponse object
- */
- public RegisterAppInterfaceResponse() {
- super(FunctionID.REGISTER_APP_INTERFACE);
- }
-
- /**
- * Constructs a new RegisterAppInterfaceResponse object indicated by the Hashtable
- * parameter
- * <p>
- *
- * @param hash
- * The Hashtable to use
- */
- public RegisterAppInterfaceResponse(Hashtable<String, Object> hash) {
- super(hash);
- }
-
- /**
- * Gets the version of the SDL&reg; SmartDeviceLink interface
- *
- * @return SdlMsgVersion -a SdlMsgVersion object representing version of
- * the SDL&reg; SmartDeviceLink interface
- */
- @SuppressWarnings("unchecked")
- public SdlMsgVersion getSdlMsgVersion() {
- Object obj = parameters.get(KEY_SDL_MSG_VERSION);
- if (obj instanceof SdlMsgVersion) {
- return (SdlMsgVersion)obj;
- } else if (obj instanceof Hashtable) {
- return new SdlMsgVersion((Hashtable<String, Object>)obj);
- }
- return null;
- }
-
- /**
- * Sets the version of the SDL&reg; SmartDeviceLink interface
- *
- * @param sdlMsgVersion
- * a SdlMsgVersion object representing version of the SDL&reg;
- * SmartDeviceLink interface
- * <p>
- * <b>Notes: </b>To be compatible, app msg major version number
- * must be less than or equal to SDL&reg; major version number.
- * If msg versions are incompatible, app has 20 seconds to
- * attempt successful RegisterAppInterface (w.r.t. msg version)
- * on underlying protocol session, else will be terminated. Major
- * version number is a compatibility declaration. Minor version
- * number indicates minor functional variations (e.g. features,
- * capabilities, bug fixes) when sent from SDL&reg; to app (in
- * RegisterAppInterface response). However, the minor version
- * number sent from the app to SDL&reg; (in RegisterAppInterface
- * request) is ignored by SDL&reg;
- */
- public void setSdlMsgVersion(SdlMsgVersion sdlMsgVersion) {
- if (sdlMsgVersion != null) {
- parameters.put(KEY_SDL_MSG_VERSION, sdlMsgVersion);
- } else {
- parameters.remove(KEY_SDL_MSG_VERSION);
- }
- }
-
- /**
- * Gets a Language enumeration indicating what language the application
- * intends to use for user interaction (Display, TTS and VR)
- *
- * @return Enumeration -a language enumeration
- */
- public Language getLanguage() {
- Object obj = parameters.get(KEY_LANGUAGE);
- if (obj instanceof Language) {
- return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LANGUAGE, e);
- }
- return theCode;
- }
- return null;
- }
-
- /**
- * Sets an enumeration indicating what language the application intends to
- * use for user interaction (Display, TTS and VR)
- *
- * @param language
- * a Language Enumeration
- * <p>
- *
- */
- public void setLanguage(Language language) {
- if (language != null) {
- parameters.put(KEY_LANGUAGE, language);
- } else {
- parameters.remove(KEY_LANGUAGE);
- }
- }
-
- /**
- * Gets an enumeration indicating what language the application intends to
- * use for user interaction ( Display)
- *
- * @return Language - a Language value representing an enumeration
- * indicating what language the application intends to use for user
- * interaction ( Display)
- * @since SmartDeviceLink 2.0
- */
- public Language getHmiDisplayLanguage() {
- Object obj = parameters.get(KEY_HMI_DISPLAY_LANGUAGE);
- if (obj instanceof Language) {
- return (Language) obj;
- } else if (obj instanceof String) {
- Language theCode = null;
- try {
- theCode = Language.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_DISPLAY_LANGUAGE, e);
- }
- return theCode;
- }
- return null;
- }
-
- /**
- * Sets an enumeration indicating what language the application intends to
- * use for user interaction ( Display)
- *
- * @param hmiDisplayLanguage
- * @since SmartDeviceLink 2.0
- */
- public void setHmiDisplayLanguage(Language hmiDisplayLanguage) {
- if (hmiDisplayLanguage != null) {
- parameters.put(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage);
- } else {
- parameters.remove(KEY_HMI_DISPLAY_LANGUAGE);
- }
- }
-
- /**
- * Gets getDisplayCapabilities set when application interface is registered.
- *
- * @return DisplayCapabilities
- */
- @SuppressWarnings("unchecked")
- public DisplayCapabilities getDisplayCapabilities() {
- Object obj = parameters.get(KEY_DISPLAY_CAPABILITIES);
- if (obj instanceof DisplayCapabilities) {
- return (DisplayCapabilities)obj;
- } else if (obj instanceof Hashtable) {
- return new DisplayCapabilities((Hashtable<String, Object>)obj);
- }
- return null;
- }
- /**
- * Sets Display Capabilities
- * @param displayCapabilities
- */
- public void setDisplayCapabilities(DisplayCapabilities displayCapabilities) {
- if (displayCapabilities != null) {
- parameters.put(KEY_DISPLAY_CAPABILITIES, displayCapabilities);
- } else {
- parameters.remove(KEY_DISPLAY_CAPABILITIES);
- }
- }
-
- /**
- * Gets buttonCapabilities set when application interface is registered.
- *
- * @return buttonCapabilities
- */
- @SuppressWarnings("unchecked")
- public List<ButtonCapabilities> getButtonCapabilities() {
- if (parameters.get(KEY_BUTTON_CAPABILITIES) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_BUTTON_CAPABILITIES);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof ButtonCapabilities) {
- return (List<ButtonCapabilities>) list;
- } else if (obj instanceof Hashtable) {
- List<ButtonCapabilities> newList = new ArrayList<ButtonCapabilities>();
- for (Object hashObj : list) {
- newList.add(new ButtonCapabilities((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Sets Button Capabilities
- * @param buttonCapabilities
- */
- public void setButtonCapabilities(List<ButtonCapabilities> buttonCapabilities) {
- if (buttonCapabilities != null) {
- parameters.put(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
- } else {
- parameters.remove(KEY_BUTTON_CAPABILITIES);
- }
- }
- /**
- * Gets getSoftButtonCapabilities set when application interface is registered.
- *
- * @return SoftButtonCapabilities
- */
- @SuppressWarnings("unchecked")
- public List<SoftButtonCapabilities> getSoftButtonCapabilities() {
- if (parameters.get(KEY_SOFT_BUTTON_CAPABILITIES) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTON_CAPABILITIES);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof SoftButtonCapabilities) {
- return (List<SoftButtonCapabilities>) list;
- } else if (obj instanceof Hashtable) {
- List<SoftButtonCapabilities> newList = new ArrayList<SoftButtonCapabilities>();
- for (Object hashObj : list) {
- newList.add(new SoftButtonCapabilities((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Sets softButtonCapabilities
- * @param softButtonCapabilities
- */
- public void setSoftButtonCapabilities(List<SoftButtonCapabilities> softButtonCapabilities) {
- if (softButtonCapabilities != null) {
- parameters.put(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities);
- } else {
- parameters.remove(KEY_SOFT_BUTTON_CAPABILITIES);
- }
- }
-
- /**
- * Gets getPresetBankCapabilities set when application interface is registered.
- *
- * @return PresetBankCapabilities
- */
- @SuppressWarnings("unchecked")
- public PresetBankCapabilities getPresetBankCapabilities() {
- Object obj = parameters.get(KEY_PRESET_BANK_CAPABILITIES);
- if (obj instanceof PresetBankCapabilities) {
- return (PresetBankCapabilities)obj;
- } else if (obj instanceof Hashtable) {
- return new PresetBankCapabilities((Hashtable<String, Object>)obj);
- }
- return null;
- }
- /**
- * Sets presetBankCapabilities
- * @param presetBankCapabilities
- */
- public void setPresetBankCapabilities(PresetBankCapabilities presetBankCapabilities) {
- if (presetBankCapabilities != null) {
- parameters.put(KEY_PRESET_BANK_CAPABILITIES, presetBankCapabilities);
- } else {
- parameters.remove(KEY_PRESET_BANK_CAPABILITIES);
- }
- }
-
- /**
- * Gets hmiZoneCapabilities set when application interface is registered.
- *
- * @return HmiZoneCapabilities
- */
- @SuppressWarnings("unchecked")
- public List<HmiZoneCapabilities> getHmiZoneCapabilities() {
- if (parameters.get(KEY_HMI_ZONE_CAPABILITIES) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_HMI_ZONE_CAPABILITIES);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof HmiZoneCapabilities) {
- return (List<HmiZoneCapabilities>) list;
- } else if (obj instanceof String) {
- List<HmiZoneCapabilities> newList = new ArrayList<HmiZoneCapabilities>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- HmiZoneCapabilities toAdd = null;
- try {
- toAdd = HmiZoneCapabilities.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_ZONE_CAPABILITIES, e);
- }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Sets hmiZoneCapabilities
- * @param hmiZoneCapabilities
- */
- public void setHmiZoneCapabilities(List<HmiZoneCapabilities> hmiZoneCapabilities) {
- if (hmiZoneCapabilities != null) {
- parameters.put(KEY_HMI_ZONE_CAPABILITIES, hmiZoneCapabilities);
- } else {
- parameters.remove(KEY_HMI_ZONE_CAPABILITIES);
- }
- }
-
- /**
- * Gets speechCapabilities set when application interface is registered.
- *
- * @return SpeechCapabilities
- */
- @SuppressWarnings("unchecked")
- public List<SpeechCapabilities> getSpeechCapabilities() {
- if (parameters.get(KEY_SPEECH_CAPABILITIES) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_SPEECH_CAPABILITIES);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof SpeechCapabilities) {
- return (List<SpeechCapabilities>) list;
- } else if (obj instanceof String) {
- List<SpeechCapabilities> newList = new ArrayList<SpeechCapabilities>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- SpeechCapabilities toAdd = null;
- try {
- toAdd = SpeechCapabilities.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEECH_CAPABILITIES, e);
- }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Sets speechCapabilities
- * @param speechCapabilities
- */
- public void setSpeechCapabilities(List<SpeechCapabilities> speechCapabilities) {
- if (speechCapabilities != null) {
- parameters.put(KEY_SPEECH_CAPABILITIES, speechCapabilities);
- } else {
- parameters.remove(KEY_SPEECH_CAPABILITIES);
- }
- }
-
-
- @SuppressWarnings("unchecked")
- public List<PrerecordedSpeech> getPrerecordedSpeech() {
- if (parameters.get(KEY_PRERECORDED_SPEECH) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_PRERECORDED_SPEECH);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof PrerecordedSpeech) {
- return (List<PrerecordedSpeech>) list;
- } else if (obj instanceof String) {
- List<PrerecordedSpeech> newList = new ArrayList<PrerecordedSpeech>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- PrerecordedSpeech toAdd = null;
- try {
- toAdd = PrerecordedSpeech.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRERECORDED_SPEECH, e);
- }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
-
- public void setPrerecordedSpeech(List<PrerecordedSpeech> prerecordedSpeech) {
- if (prerecordedSpeech != null) {
- parameters.put(KEY_PRERECORDED_SPEECH, prerecordedSpeech);
- } else {
- parameters.remove(KEY_PRERECORDED_SPEECH);
- }
- }
-
-
- /**
- * Gets vrCapabilities set when application interface is registered.
- *
- * @return VrCapabilities
- */
- @SuppressWarnings("unchecked")
- public List<VrCapabilities> getVrCapabilities() {
- if (parameters.get(KEY_VR_CAPABILITIES) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_VR_CAPABILITIES);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof VrCapabilities) {
- return (List<VrCapabilities>) list;
- } else if (obj instanceof String) {
- List<VrCapabilities> newList = new ArrayList<VrCapabilities>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- VrCapabilities toAdd = null;
- try {
- toAdd = VrCapabilities.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_VR_CAPABILITIES, e);
- }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Sets VrCapabilities
- * @param vrCapabilities
- */
- public void setVrCapabilities(List<VrCapabilities> vrCapabilities) {
- if (vrCapabilities != null) {
- parameters.put(KEY_VR_CAPABILITIES, vrCapabilities);
- } else {
- parameters.remove(KEY_VR_CAPABILITIES);
- }
- }
-
- /**
- * Gets getVehicleType set when application interface is registered.
- *
- * @return vehicleType
- */
- @SuppressWarnings("unchecked")
- public VehicleType getVehicleType() {
- Object obj = parameters.get(KEY_VEHICLE_TYPE);
- if (obj instanceof VehicleType) {
- return (VehicleType)obj;
- } else if (obj instanceof Hashtable) {
- return new VehicleType((Hashtable<String, Object>)obj);
- }
- return null;
- }
- /**
- * Sets vehicleType
- * @param vehicleType
- */
- public void setVehicleType(VehicleType vehicleType) {
- if (vehicleType != null) {
- parameters.put(KEY_VEHICLE_TYPE, vehicleType);
- } else {
- parameters.remove(KEY_VEHICLE_TYPE);
- }
- }
-
- /**
- * Gets AudioPassThruCapabilities set when application interface is registered.
- *
- * @return AudioPassThruCapabilities
- */
- @SuppressWarnings("unchecked")
- public List<AudioPassThruCapabilities> getAudioPassThruCapabilities() {
- if (parameters.get(KEY_AUDIO_PASS_THRU_CAPABILITIES) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_AUDIO_PASS_THRU_CAPABILITIES);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof AudioPassThruCapabilities) {
- return (List<AudioPassThruCapabilities>) list;
- } else if (obj instanceof Hashtable) {
- List<AudioPassThruCapabilities> newList = new ArrayList<AudioPassThruCapabilities>();
- for (Object hashObj : list) {
- newList.add(new AudioPassThruCapabilities((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Sets AudioPassThruCapabilities
- * @param audioPassThruCapabilities
- */
- public void setAudioPassThruCapabilities(List<AudioPassThruCapabilities> audioPassThruCapabilities) {
- if (audioPassThruCapabilities != null) {
- parameters.put(KEY_AUDIO_PASS_THRU_CAPABILITIES, audioPassThruCapabilities);
- } else {
- parameters.remove(KEY_AUDIO_PASS_THRU_CAPABILITIES);
- }
- }
- public String getProxyVersionInfo() {
- if (Version.VERSION != null)
- return Version.VERSION;
-
- return null;
- }
- public void setSupportedDiagModes(List<Integer> supportedDiagModes) {
- if (supportedDiagModes != null) {
- parameters.put(KEY_SUPPORTED_DIAG_MODES, supportedDiagModes);
- }
- else
- {
- parameters.remove(KEY_SUPPORTED_DIAG_MODES);
- }
- }
-
- @SuppressWarnings("unchecked")
- public List<Integer> getSupportedDiagModes() {
-
- if (parameters.get(KEY_SUPPORTED_DIAG_MODES) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get( KEY_SUPPORTED_DIAG_MODES);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof Integer) {
- return (List<Integer>) list;
- }
- }
- }
- return null;
- }
-}
+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.RPCResponse;
+import com.smartdevicelink.proxy.Version;
+import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.Language;
+import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
+import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
+import com.smartdevicelink.util.SdlLog;
+
+/**
+ * Register AppInterface Response is sent, when RegisterAppInterface has been called
+ *
+ * @since SmartDeviceLink 1.0
+ */
+public class RegisterAppInterfaceResponse extends RPCResponse {
+ public static final String KEY_VEHICLE_TYPE = "vehicleType";
+ public static final String KEY_SPEECH_CAPABILITIES = "speechCapabilities";
+ public static final String KEY_VR_CAPABILITIES = "vrCapabilities";
+ public static final String KEY_AUDIO_PASS_THRU_CAPABILITIES = "audioPassThruCapabilities";
+ public static final String KEY_HMI_ZONE_CAPABILITIES = "hmiZoneCapabilities";
+ public static final String KEY_PRERECORDED_SPEECH = "prerecordedSpeech";
+ public static final String KEY_SUPPORTED_DIAG_MODES = "supportedDiagModes";
+ public static final String KEY_SDL_MSG_VERSION = "syncMsgVersion";
+ public static final String KEY_LANGUAGE = "language";
+ public static final String KEY_BUTTON_CAPABILITIES = "buttonCapabilities";
+ public static final String KEY_DISPLAY_CAPABILITIES = "displayCapabilities";
+ public static final String KEY_HMI_DISPLAY_LANGUAGE = "hmiDisplayLanguage";
+ public static final String KEY_SOFT_BUTTON_CAPABILITIES = "softButtonCapabilities";
+ public static final String KEY_PRESET_BANK_CAPABILITIES = "presetBankCapabilities";
+ public static final String KEY_HMI_CAPABILITIES = "hmiCapabilities"; //As of v4.0
+ public static final String KEY_SDL_VERSION = "sdlVersion"; //As of v4.0
+ public static final String KEY_SYSTEM_SOFTWARE_VERSION = "systemSoftwareVersion"; //As of v4.0
+
+
+ /**
+ * Constructs a new RegisterAppInterfaceResponse object
+ */
+ public RegisterAppInterfaceResponse() {
+ super(FunctionID.REGISTER_APP_INTERFACE.toString());
+ }
+
+ /**
+ * Constructs a new RegisterAppInterfaceResponse object indicated by the Hashtable
+ * parameter
+ * <p>
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public RegisterAppInterfaceResponse(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Gets the version of the SDL&reg; SmartDeviceLink interface
+ *
+ * @return SdlMsgVersion -a SdlMsgVersion object representing version of
+ * the SDL&reg; SmartDeviceLink interface
+ */
+ @SuppressWarnings("unchecked")
+ public SdlMsgVersion getSdlMsgVersion() {
+ Object obj = parameters.get(KEY_SDL_MSG_VERSION);
+ if (obj instanceof SdlMsgVersion) {
+ return (SdlMsgVersion)obj;
+ } else if (obj instanceof Hashtable) {
+ return new SdlMsgVersion((Hashtable<String, Object>)obj);
+ }
+ return null;
+ }
+
+ /**
+ * Sets the version of the SDL&reg; SmartDeviceLink interface
+ *
+ * @param sdlMsgVersion
+ * a SdlMsgVersion object representing version of the SDL&reg;
+ * SmartDeviceLink interface
+ * <p>
+ * <b>Notes: </b>To be compatible, app msg major version number
+ * must be less than or equal to SDL&reg; major version number.
+ * If msg versions are incompatible, app has 20 seconds to
+ * attempt successful RegisterAppInterface (w.r.t. msg version)
+ * on underlying protocol session, else will be terminated. Major
+ * version number is a compatibility declaration. Minor version
+ * number indicates minor functional variations (e.g. features,
+ * capabilities, bug fixes) when sent from SDL&reg; to app (in
+ * RegisterAppInterface response). However, the minor version
+ * number sent from the app to SDL&reg; (in RegisterAppInterface
+ * request) is ignored by SDL&reg;
+ */
+ public void setSdlMsgVersion(SdlMsgVersion sdlMsgVersion) {
+ if (sdlMsgVersion != null) {
+ parameters.put(KEY_SDL_MSG_VERSION, sdlMsgVersion);
+ } else {
+ parameters.remove(KEY_SDL_MSG_VERSION);
+ }
+ }
+
+ /**
+ * Gets a Language enumeration indicating what language the application
+ * intends to use for user interaction (Display, TTS and VR)
+ *
+ * @return Enumeration -a language enumeration
+ */
+ public Language getLanguage() {
+ Object obj = parameters.get(KEY_LANGUAGE);
+ if (obj instanceof Language) {
+ return (Language) obj;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
+ }
+ return null;
+ }
+
+ /**
+ * Sets an enumeration indicating what language the application intends to
+ * use for user interaction (Display, TTS and VR)
+ *
+ * @param language
+ * a Language Enumeration
+ * <p>
+ *
+ */
+ public void setLanguage(Language language) {
+ if (language != null) {
+ parameters.put(KEY_LANGUAGE, language);
+ } else {
+ parameters.remove(KEY_LANGUAGE);
+ }
+ }
+
+ /**
+ * Gets an enumeration indicating what language the application intends to
+ * use for user interaction ( Display)
+ *
+ * @return Language - a Language value representing an enumeration
+ * indicating what language the application intends to use for user
+ * interaction ( Display)
+ * @since SmartDeviceLink 2.0
+ */
+ public Language getHmiDisplayLanguage() {
+ Object obj = parameters.get(KEY_HMI_DISPLAY_LANGUAGE);
+ if (obj instanceof Language) {
+ return (Language) obj;
+ } else if (obj instanceof String) {
+ return Language.valueForString((String) obj);
+ }
+ return null;
+ }
+
+ /**
+ * Sets an enumeration indicating what language the application intends to
+ * use for user interaction ( Display)
+ *
+ * @param hmiDisplayLanguage
+ * @since SmartDeviceLink 2.0
+ */
+ public void setHmiDisplayLanguage(Language hmiDisplayLanguage) {
+ if (hmiDisplayLanguage != null) {
+ parameters.put(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage);
+ } else {
+ parameters.remove(KEY_HMI_DISPLAY_LANGUAGE);
+ }
+ }
+
+ /**
+ * Gets getDisplayCapabilities set when application interface is registered.
+ *
+ * @return DisplayCapabilities
+ */
+ @SuppressWarnings("unchecked")
+ public DisplayCapabilities getDisplayCapabilities() {
+ Object obj = parameters.get(KEY_DISPLAY_CAPABILITIES);
+ if (obj instanceof DisplayCapabilities) {
+ return (DisplayCapabilities)obj;
+ } else if (obj instanceof Hashtable) {
+ return new DisplayCapabilities((Hashtable<String, Object>)obj);
+ }
+ return null;
+ }
+ /**
+ * Sets Display Capabilities
+ * @param displayCapabilities
+ */
+ public void setDisplayCapabilities(DisplayCapabilities displayCapabilities) {
+ if (displayCapabilities != null) {
+ parameters.put(KEY_DISPLAY_CAPABILITIES, displayCapabilities);
+ } else {
+ parameters.remove(KEY_DISPLAY_CAPABILITIES);
+ }
+ }
+
+ /**
+ * Gets buttonCapabilities set when application interface is registered.
+ *
+ * @return buttonCapabilities
+ */
+ @SuppressWarnings("unchecked")
+ public List<ButtonCapabilities> getButtonCapabilities() {
+ if (parameters.get(KEY_BUTTON_CAPABILITIES) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_BUTTON_CAPABILITIES);
+ if (list != null && list.size() > 0) {
+
+ List<ButtonCapabilities> buttonCapabilitiesList = new ArrayList<ButtonCapabilities>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw ButtonCapabilities and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof ButtonCapabilities) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ buttonCapabilitiesList.add(new ButtonCapabilities((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<ButtonCapabilities>) list;
+ } else if (flagHash) {
+ return buttonCapabilitiesList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Sets Button Capabilities
+ * @param buttonCapabilities
+ */
+ public void setButtonCapabilities(List<ButtonCapabilities> buttonCapabilities) {
+
+ boolean valid = true;
+
+ for (ButtonCapabilities item : buttonCapabilities ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (buttonCapabilities != null) && (buttonCapabilities.size() > 0) && valid) {
+ parameters.put(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
+ } else {
+ parameters.remove(KEY_BUTTON_CAPABILITIES);
+ }
+ }
+ /**
+ * Gets getSoftButtonCapabilities set when application interface is registered.
+ *
+ * @return SoftButtonCapabilities
+ */
+ @SuppressWarnings("unchecked")
+ public List<SoftButtonCapabilities> getSoftButtonCapabilities() {
+ if (parameters.get(KEY_SOFT_BUTTON_CAPABILITIES) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTON_CAPABILITIES);
+ if (list != null && list.size() > 0) {
+
+ List<SoftButtonCapabilities> softButtonCapabilitiesList = new ArrayList<SoftButtonCapabilities>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButtonCapabilities and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButtonCapabilities) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ softButtonCapabilitiesList.add(new SoftButtonCapabilities((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SoftButtonCapabilities>) list;
+ } else if (flagHash) {
+ return softButtonCapabilitiesList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Sets softButtonCapabilities
+ * @param softButtonCapabilities
+ */
+ public void setSoftButtonCapabilities(List<SoftButtonCapabilities> softButtonCapabilities) {
+
+ boolean valid = true;
+
+ for (SoftButtonCapabilities item : softButtonCapabilities ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (softButtonCapabilities != null) && (softButtonCapabilities.size() > 0) && valid) {
+ parameters.put(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities);
+ } else {
+ parameters.remove(KEY_SOFT_BUTTON_CAPABILITIES);
+ }
+ }
+
+ /**
+ * Gets getPresetBankCapabilities set when application interface is registered.
+ *
+ * @return PresetBankCapabilities
+ */
+ @SuppressWarnings("unchecked")
+ public PresetBankCapabilities getPresetBankCapabilities() {
+ Object obj = parameters.get(KEY_PRESET_BANK_CAPABILITIES);
+ if (obj instanceof PresetBankCapabilities) {
+ return (PresetBankCapabilities)obj;
+ } else if (obj instanceof Hashtable) {
+ return new PresetBankCapabilities((Hashtable<String, Object>)obj);
+ }
+ return null;
+ }
+ /**
+ * Sets presetBankCapabilities
+ * @param presetBankCapabilities
+ */
+ public void setPresetBankCapabilities(PresetBankCapabilities presetBankCapabilities) {
+ if (presetBankCapabilities != null) {
+ parameters.put(KEY_PRESET_BANK_CAPABILITIES, presetBankCapabilities);
+ } else {
+ parameters.remove(KEY_PRESET_BANK_CAPABILITIES);
+ }
+ }
+
+ /**
+ * Gets hmiZoneCapabilities set when application interface is registered.
+ *
+ * @return HmiZoneCapabilities
+ */
+ @SuppressWarnings("unchecked")
+ public List<HmiZoneCapabilities> getHmiZoneCapabilities() {
+ if (parameters.get(KEY_HMI_ZONE_CAPABILITIES) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_HMI_ZONE_CAPABILITIES);
+ if (list != null && list.size() > 0) {
+
+ List<HmiZoneCapabilities> hmiZoneCapabilitiesList = new ArrayList<HmiZoneCapabilities>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw HmiZoneCapabilities and a String value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof HmiZoneCapabilities) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof String) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ String strFormat = (String) obj;
+ HmiZoneCapabilities toAdd = null;
+ try {
+ toAdd = HmiZoneCapabilities.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_ZONE_CAPABILITIES, e);
+ }
+ if (toAdd != null) {
+ hmiZoneCapabilitiesList.add(toAdd);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<HmiZoneCapabilities>) list;
+ } else if (flagHash) {
+ return hmiZoneCapabilitiesList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Sets hmiZoneCapabilities
+ * @param hmiZoneCapabilities
+ */
+ public void setHmiZoneCapabilities(List<HmiZoneCapabilities> hmiZoneCapabilities) {
+
+ boolean valid = true;
+
+ for (HmiZoneCapabilities item : hmiZoneCapabilities ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (hmiZoneCapabilities != null) && (hmiZoneCapabilities.size() > 0) && valid) {
+ parameters.put(KEY_HMI_ZONE_CAPABILITIES, hmiZoneCapabilities);
+ } else {
+ parameters.remove(KEY_HMI_ZONE_CAPABILITIES);
+ }
+ }
+
+ /**
+ * Gets speechCapabilities set when application interface is registered.
+ *
+ * @return SpeechCapabilities
+ */
+ @SuppressWarnings("unchecked")
+ public List<SpeechCapabilities> getSpeechCapabilities() {
+ if (parameters.get(KEY_SPEECH_CAPABILITIES) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_SPEECH_CAPABILITIES);
+ if (list != null && list.size() > 0) {
+
+ List<SpeechCapabilities> speechCapabilitiesList = new ArrayList<SpeechCapabilities>();
+
+ boolean flagRaw = false;
+ boolean flagStr = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SpeechCapabilities and a String value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SpeechCapabilities) {
+ if (flagStr) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof String) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagStr = true;
+ String strFormat = (String) obj;
+ SpeechCapabilities toAdd = null;
+ try {
+ toAdd = SpeechCapabilities.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEECH_CAPABILITIES, e);
+ }
+ if (toAdd != null) {
+ speechCapabilitiesList.add(toAdd);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SpeechCapabilities>) list;
+ } else if (flagStr) {
+ return speechCapabilitiesList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Sets speechCapabilities
+ * @param speechCapabilities
+ */
+ public void setSpeechCapabilities(List<SpeechCapabilities> speechCapabilities) {
+
+ boolean valid = true;
+
+ for (SpeechCapabilities item : speechCapabilities ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (speechCapabilities != null) && (speechCapabilities.size() > 0) && valid) {
+ parameters.put(KEY_SPEECH_CAPABILITIES, speechCapabilities);
+ } else {
+ parameters.remove(KEY_SPEECH_CAPABILITIES);
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public List<PrerecordedSpeech> getPrerecordedSpeech() {
+ if (parameters.get(KEY_PRERECORDED_SPEECH) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_PRERECORDED_SPEECH);
+ if (list != null && list.size() > 0) {
+
+ List<PrerecordedSpeech> prerecordedSpeechList = new ArrayList<PrerecordedSpeech>();
+
+ boolean flagRaw = false;
+ boolean flagStr = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw PrerecordedSpeech and a String value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof PrerecordedSpeech) {
+ if (flagStr) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof String) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagStr = true;
+ String strFormat = (String) obj;
+ PrerecordedSpeech toAdd = null;
+ try {
+ toAdd = PrerecordedSpeech.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRERECORDED_SPEECH, e);
+ }
+ if (toAdd != null) {
+ prerecordedSpeechList.add(toAdd);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<PrerecordedSpeech>) list;
+ } else if (flagStr) {
+ return prerecordedSpeechList;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setPrerecordedSpeech(List<PrerecordedSpeech> prerecordedSpeech) {
+
+ boolean valid = true;
+
+ for ( PrerecordedSpeech item : prerecordedSpeech ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (prerecordedSpeech != null) && (prerecordedSpeech.size() > 0) && valid) {
+ parameters.put(KEY_PRERECORDED_SPEECH, prerecordedSpeech);
+ } else {
+ parameters.remove(KEY_PRERECORDED_SPEECH);
+ }
+ }
+
+
+ /**
+ * Gets vrCapabilities set when application interface is registered.
+ *
+ * @return VrCapabilities
+ */
+ @SuppressWarnings("unchecked")
+ public List<VrCapabilities> getVrCapabilities() {
+ if (parameters.get(KEY_VR_CAPABILITIES) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_VR_CAPABILITIES);
+ if (list != null && list.size() > 0) {
+
+ List<VrCapabilities> vrCapabilitiesList = new ArrayList<VrCapabilities>();
+
+ boolean flagRaw = false;
+ boolean flagStr = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw VrCapabilities and a String value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof VrCapabilities) {
+ if (flagStr) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof String) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagStr = true;
+ String strFormat = (String) obj;
+ VrCapabilities toAdd = null;
+ try {
+ toAdd = VrCapabilities.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_VR_CAPABILITIES, e);
+ }
+ if (toAdd != null) {
+ vrCapabilitiesList.add(toAdd);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<VrCapabilities>) list;
+ } else if (flagStr) {
+ return vrCapabilitiesList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Sets VrCapabilities
+ * @param vrCapabilities
+ */
+ public void setVrCapabilities(List<VrCapabilities> vrCapabilities) {
+
+ boolean valid = true;
+
+ for ( VrCapabilities item : vrCapabilities ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (vrCapabilities != null) && (vrCapabilities.size() > 0) && valid) {
+ parameters.put(KEY_VR_CAPABILITIES, vrCapabilities);
+ } else {
+ parameters.remove(KEY_VR_CAPABILITIES);
+ }
+ }
+
+ /**
+ * Gets getVehicleType set when application interface is registered.
+ *
+ * @return vehicleType
+ */
+ @SuppressWarnings("unchecked")
+ public VehicleType getVehicleType() {
+ Object obj = parameters.get(KEY_VEHICLE_TYPE);
+ if (obj instanceof VehicleType) {
+ return (VehicleType)obj;
+ } else if (obj instanceof Hashtable) {
+ return new VehicleType((Hashtable<String, Object>)obj);
+ }
+ return null;
+ }
+ /**
+ * Sets vehicleType
+ * @param vehicleType
+ */
+ public void setVehicleType(VehicleType vehicleType) {
+ if (vehicleType != null) {
+ parameters.put(KEY_VEHICLE_TYPE, vehicleType);
+ } else {
+ parameters.remove(KEY_VEHICLE_TYPE);
+ }
+ }
+
+ /**
+ * Gets AudioPassThruCapabilities set when application interface is registered.
+ *
+ * @return AudioPassThruCapabilities
+ */
+ @SuppressWarnings("unchecked")
+ public List<AudioPassThruCapabilities> getAudioPassThruCapabilities() {
+ if (parameters.get(KEY_AUDIO_PASS_THRU_CAPABILITIES) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_AUDIO_PASS_THRU_CAPABILITIES);
+ if (list != null && list.size() > 0) {
+
+ List<AudioPassThruCapabilities> audioPassThruCapabilitiesList = new ArrayList<AudioPassThruCapabilities>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw AudioPassThruCapabilities and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof AudioPassThruCapabilities) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ audioPassThruCapabilitiesList.add(new AudioPassThruCapabilities((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<AudioPassThruCapabilities>) list;
+ } else if (flagHash) {
+ return audioPassThruCapabilitiesList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Sets AudioPassThruCapabilities
+ * @param audioPassThruCapabilities
+ */
+ public void setAudioPassThruCapabilities(List<AudioPassThruCapabilities> audioPassThruCapabilities) {
+
+ boolean valid = true;
+
+ for ( AudioPassThruCapabilities item : audioPassThruCapabilities ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (audioPassThruCapabilities != null) && (audioPassThruCapabilities.size() > 0) && valid) {
+ parameters.put(KEY_AUDIO_PASS_THRU_CAPABILITIES, audioPassThruCapabilities);
+ } else {
+ parameters.remove(KEY_AUDIO_PASS_THRU_CAPABILITIES);
+ }
+ }
+ public String getProxyVersionInfo() {
+ if (Version.VERSION != null)
+ return Version.VERSION;
+
+ return null;
+ }
+ public void setSupportedDiagModes(List<Integer> supportedDiagModes) {
+
+ boolean valid = true;
+
+ for ( Integer item : supportedDiagModes ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (supportedDiagModes != null) && (supportedDiagModes.size() > 0) && valid) {
+ parameters.put(KEY_SUPPORTED_DIAG_MODES, supportedDiagModes);
+ }
+ else
+ {
+ parameters.remove(KEY_SUPPORTED_DIAG_MODES);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Integer> getSupportedDiagModes() {
+
+ if (parameters.get(KEY_SUPPORTED_DIAG_MODES) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get( KEY_SUPPORTED_DIAG_MODES);
+ if (list != null && list.size() > 0) {
+ for( Object obj : list ) {
+ if (!(obj instanceof Integer)) {
+ return null;
+ }
+ }
+ return (List<Integer>) list;
+ }
+ }
+ return null;
+ }
+
+ public void setHmiCapabilities(HMICapabilities hmiCapabilities) {
+ if (hmiCapabilities != null) {
+ parameters.put(KEY_HMI_CAPABILITIES, hmiCapabilities);
+ }else{
+ parameters.remove(KEY_HMI_CAPABILITIES);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public HMICapabilities getHmiCapabilities() {
+ Object obj = parameters.get(KEY_HMI_CAPABILITIES);
+ if (obj instanceof HMICapabilities) {
+ return (HMICapabilities)obj;
+ } else if (obj instanceof Hashtable) {
+ return new HMICapabilities((Hashtable<String, Object>)obj);
+ }
+ return null;
+ }
+
+ public void setSdlVersion(String sdlVersion) {
+ if (sdlVersion != null) {
+ parameters.put(KEY_SDL_VERSION, sdlVersion);
+ }else{
+ parameters.remove(KEY_SDL_VERSION);
+ }
+ }
+
+ public String getSdlVersion() {
+ return (String) parameters.get(KEY_SDL_VERSION);
+ }
+
+ public void setSystemSoftwareVersion(String systemSoftwareVersion) {
+ if (systemSoftwareVersion != null) {
+ parameters.put(KEY_SYSTEM_SOFTWARE_VERSION, systemSoftwareVersion);
+ }else{
+ parameters.remove(KEY_SYSTEM_SOFTWARE_VERSION);
+ }
+ }
+
+ public String getSystemSoftwareVersion() {
+ return (String) parameters.get(KEY_SYSTEM_SOFTWARE_VERSION);
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java
index a824ec36a..aa841e154 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java
@@ -1,99 +1,135 @@
-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;
-import com.smartdevicelink.proxy.rpc.enums.GlobalProperty;
-import com.smartdevicelink.util.LogTool;
-/**
- * Resets the passed global properties to their default values as defined by
- * SDL
- * <p>
- * The HELPPROMPT global property default value is generated by SDL consists of
- * the first vrCommand of each Command Menu item defined at the moment PTT is
- * pressed<br/>
- * The TIMEOUTPROMPT global property default value is the same as the HELPPROMPT
- * global property default value
- * <p>
- * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b>
- * </p>
- *
- * @since SmartDeviceLink 1.0
- * @see SetGlobalProperties
- */
-public class ResetGlobalProperties extends RPCRequest {
- public static final String KEY_PROPERTIES = "properties";
- /**
- * Constructs a new ResetGlobalProperties object
- */
- public ResetGlobalProperties() {
- super(FunctionID.RESET_GLOBAL_PROPERTIES);
- }
- /**
- * Constructs a new ResetGlobalProperties object indicated by the Hashtable
- * parameter
- * <p>
- *
- * @param hash
- * The Hashtable to use
- */
- public ResetGlobalProperties(Hashtable<String, Object> hash) {
- super(hash);
- }
- /**
- * Gets an array of one or more GlobalProperty enumeration elements
- * indicating which global properties to reset to their default value
- *
- * @return List<GlobalProperty> -an array of one or more GlobalProperty
- * enumeration elements
- */
- @SuppressWarnings("unchecked")
- public List<GlobalProperty> getProperties() {
- if (parameters.get(KEY_PROPERTIES) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_PROPERTIES);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof GlobalProperty) {
- return (List<GlobalProperty>) list;
- } else if (obj instanceof String) {
- List<GlobalProperty> newList = new ArrayList<GlobalProperty>();
- for (Object hashObj : list) {
- String strFormat = (String)hashObj;
- GlobalProperty toAdd = null;
- try {
- toAdd = GlobalProperty.valueForString(strFormat);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PROPERTIES, e);
- }
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
- }
- /**
- * Sets an array of one or more GlobalProperty enumeration elements
- * indicating which global properties to reset to their default value
- *
- * @param properties
- * a List<GlobalProperty> An array of one or more
- * GlobalProperty enumeration elements indicating which global
- * properties to reset to their default value
- * <p>
- * <b>Notes: </b>Array must have at least one element
- */
- public void setProperties( List<GlobalProperty> properties ) {
- if (properties != null) {
- parameters.put(KEY_PROPERTIES, properties );
- } else {
- parameters.remove(KEY_PROPERTIES);
- }
- }
-}
+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;
+import com.smartdevicelink.proxy.rpc.enums.GlobalProperty;
+import com.smartdevicelink.util.SdlLog;
+/**
+ * Resets the passed global properties to their default values as defined by
+ * SDL
+ * <p>
+ * The HELPPROMPT global property default value is generated by SDL consists of
+ * the first vrCommand of each Command Menu item defined at the moment PTT is
+ * pressed<br/>
+ * The TIMEOUTPROMPT global property default value is the same as the HELPPROMPT
+ * global property default value
+ * <p>
+ * <b>HMILevel needs to be FULL, LIMITED or BACKGROUND</b>
+ * </p>
+ *
+ * @since SmartDeviceLink 1.0
+ * @see SetGlobalProperties
+ */
+public class ResetGlobalProperties extends RPCRequest {
+ public static final String KEY_PROPERTIES = "properties";
+ /**
+ * Constructs a new ResetGlobalProperties object
+ */
+ public ResetGlobalProperties() {
+ super(FunctionID.RESET_GLOBAL_PROPERTIES.toString());
+ }
+ /**
+ * Constructs a new ResetGlobalProperties object indicated by the Hashtable
+ * parameter
+ * <p>
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public ResetGlobalProperties(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+ /**
+ * Gets an array of one or more GlobalProperty enumeration elements
+ * indicating which global properties to reset to their default value
+ *
+ * @return List<GlobalProperty> -an array of one or more GlobalProperty
+ * enumeration elements
+ */
+ @SuppressWarnings("unchecked")
+ public List<GlobalProperty> getProperties() {
+ if (parameters.get(KEY_PROPERTIES) instanceof List<?>) {
+ List<?> list = (List<?>)parameters.get(KEY_PROPERTIES);
+ if (list != null && list.size() > 0) {
+
+ List<GlobalProperty> globalPropertyList = new ArrayList<GlobalProperty>();
+
+ boolean flagRaw = false;
+ boolean flagStr = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw GlobalProperty and a String value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButton) {
+ if (flagStr) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof String) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagStr = true;
+ String strFormat = (String) obj;
+ GlobalProperty toAdd = null;
+ try {
+ toAdd = GlobalProperty.valueForString(strFormat);
+ } catch (Exception e) {
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_PROPERTIES, e);
+ }
+ if (toAdd != null) {
+ globalPropertyList.add(toAdd);
+ }
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<GlobalProperty>) list;
+ } else if (flagStr) {
+ return globalPropertyList;
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Sets an array of one or more GlobalProperty enumeration elements
+ * indicating which global properties to reset to their default value
+ *
+ * @param properties
+ * a List<GlobalProperty> An array of one or more
+ * GlobalProperty enumeration elements indicating which global
+ * properties to reset to their default value
+ * <p>
+ * <b>Notes: </b>Array must have at least one element
+ */
+ public void setProperties( List<GlobalProperty> properties ) {
+
+ boolean valid = true;
+
+ for (GlobalProperty item : properties ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (properties != null) && (properties.size() > 0) && valid) {
+ parameters.put(KEY_PROPERTIES, properties );
+ } else {
+ parameters.remove(KEY_PROPERTIES);
+ }
+ }
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalPropertiesResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalPropertiesResponse.java
index 0fe7f0d80..3390fb814 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalPropertiesResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ResetGlobalPropertiesResponse.java
@@ -16,7 +16,7 @@ public class ResetGlobalPropertiesResponse extends RPCResponse {
* Constructs a new ResetGlobalPropertiesResponse object
*/
public ResetGlobalPropertiesResponse() {
- super(FunctionID.RESET_GLOBAL_PROPERTIES);
+ super(FunctionID.RESET_GLOBAL_PROPERTIES.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScreenParams.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScreenParams.java
index c5ca0692d..142ed89d7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScreenParams.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScreenParams.java
@@ -3,9 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.ImageResolution;
-import com.smartdevicelink.proxy.rpc.TouchEventCapabilities;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
public class ScreenParams extends RPCStruct {
public static final String KEY_RESOLUTION = "resolution";
@@ -26,7 +24,7 @@ public class ScreenParams extends RPCStruct {
try {
return new ImageResolution((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RESOLUTION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_RESOLUTION, e);
}
}
return null;
@@ -48,7 +46,7 @@ public class ScreenParams extends RPCStruct {
try {
return new TouchEventCapabilities((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TOUCH_EVENT_AVAILABLE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_TOUCH_EVENT_AVAILABLE, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java
index 22eb073cf..8f8b5d6c3 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessage.java
@@ -25,7 +25,7 @@ public class ScrollableMessage extends RPCRequest {
* Constructs a new ScrollableMessage object
*/
public ScrollableMessage() {
- super(FunctionID.SCROLLABLE_MESSAGE);
+ super(FunctionID.SCROLLABLE_MESSAGE.toString());
}
/**
@@ -103,7 +103,16 @@ public class ScrollableMessage extends RPCRequest {
* <b>Notes: </b>Minsize=0, Maxsize=8
*/
public void setSoftButtons(List<SoftButton> softButtons) {
- if (softButtons != null) {
+
+ boolean valid = true;
+
+ for (SoftButton item : softButtons ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
parameters.put(KEY_SOFT_BUTTONS, softButtons);
} else {
parameters.remove(KEY_SOFT_BUTTONS);
@@ -119,16 +128,43 @@ public class ScrollableMessage extends RPCRequest {
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<SoftButton>) list;
- } else if (obj instanceof Hashtable) {
- List<SoftButton> newList = new ArrayList<SoftButton>();
- for (Object hashObj : list) {
- newList.add(new SoftButton((Hashtable<String, Object>) hashObj));
- }
- return newList;
- }
+
+ List<SoftButton> softButtonList = new ArrayList<SoftButton>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButton and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButton) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SoftButton>) list;
+ } else if (flagHash) {
+ return softButtonList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessageResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessageResponse.java
index f1f5b8a03..970782f35 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessageResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ScrollableMessageResponse.java
@@ -16,7 +16,7 @@ public class ScrollableMessageResponse extends RPCResponse {
* Constructs a new ScrollableMessageResponse object
*/
public ScrollableMessageResponse() {
- super(FunctionID.SCROLLABLE_MESSAGE);
+ super(FunctionID.SCROLLABLE_MESSAGE.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java
index cd37eea74..e357e3356 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocation.java
@@ -5,6 +5,7 @@ import java.util.List;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.util.SdlDataTypeConverter;
/**
@@ -27,7 +28,7 @@ public class SendLocation extends RPCRequest{
* Constructs a new SendLocation object
*/
public SendLocation(){
- super(FunctionID.SEND_LOCATION);
+ super(FunctionID.SEND_LOCATION.toString());
}
/**
@@ -44,17 +45,24 @@ public class SendLocation extends RPCRequest{
/**
* Getter for longitude of the location to send.
+ *
+ * <p><b>IMPORTANT NOTE:</b> A previous version of this method call returned a Float
+ * value, however, it has been changed to return a Double. This will compile,
+ * but cause a ClassCastException if your value is not also a Double type.
+ * @since SmartDeviceLink v4.0
+ *
* @return The longitude of the location
*/
- public Float getLongitudeDegrees(){
- return (Float) parameters.get(KEY_LON_DEGREES);
+ public Double getLongitudeDegrees(){
+ Object value = parameters.get(KEY_LON_DEGREES);
+ return SdlDataTypeConverter.objectToDouble(value);
}
/**
* Setter for longitude of the location to send.
* @param longitudeDegrees
*/
- public void setLongitudeDegrees(Float longitudeDegrees){
+ public void setLongitudeDegrees(Double longitudeDegrees){
if(longitudeDegrees != null){
parameters.put(KEY_LON_DEGREES, longitudeDegrees);
}
@@ -65,17 +73,24 @@ public class SendLocation extends RPCRequest{
/**
* Getter for latitude of the location to send.
+ *
+ * <p><b>IMPORTANT NOTE:</b> A previous version of this method call returned a Float
+ * value, however, it has been changed to return a Double. This will compile,
+ * but cause a ClassCastException if your value is not also a Double type.
+ * @since SmartDeviceLink v4.0
+ *
* @return The latitude of the location
*/
- public Float getLatitudeDegrees(){
- return (Float) parameters.get(KEY_LAT_DEGREES);
+ public Double getLatitudeDegrees(){
+ Object value = parameters.get(KEY_LAT_DEGREES);
+ return SdlDataTypeConverter.objectToDouble(value);
}
/**
* Setter for latitude of the location to send.
* @param latitudeDegrees
*/
- public void setLatitudeDegrees(Float latitudeDegrees){
+ public void setLatitudeDegrees(Double latitudeDegrees){
if(latitudeDegrees != null){
parameters.put(KEY_LAT_DEGREES, latitudeDegrees);
}
@@ -156,10 +171,12 @@ public class SendLocation extends RPCRequest{
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<String>) list;
- }
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
+ }
+ return (List<String>) list;
}
}
return null;
@@ -170,7 +187,16 @@ public class SendLocation extends RPCRequest{
* @param addressLines The address lines of the location
*/
public void setAddressLines(List<String> addressLines){
- if(addressLines != null){
+
+ boolean valid = true;
+
+ for (String item : addressLines ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (addressLines != null) && (addressLines.size() > 0) && valid) {
parameters.put(KEY_ADDRESS_LINES, addressLines);
}
else{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java
index 32037188c..dcee04e9a 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SendLocationResponse.java
@@ -13,7 +13,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class SendLocationResponse extends RPCResponse{
public SendLocationResponse(){
- super(FunctionID.SEND_LOCATION);
+ super(FunctionID.SEND_LOCATION.toString());
}
public SendLocationResponse(Hashtable<String, Object> hash){
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIcon.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIcon.java
index 4eb2ce3ec..1a5d5a22e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIcon.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIcon.java
@@ -19,7 +19,7 @@ public class SetAppIcon extends RPCRequest {
* Constructs a new SetAppIcon object
*/
public SetAppIcon() {
- super(FunctionID.SET_APP_ICON);
+ super(FunctionID.SET_APP_ICON.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIconResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIconResponse.java
index 3af51b2a6..9d154bebf 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIconResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetAppIconResponse.java
@@ -8,7 +8,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class SetAppIconResponse extends RPCResponse {
public SetAppIconResponse() {
- super(FunctionID.SET_APP_ICON);
+ super(FunctionID.SET_APP_ICON.toString());
}
public SetAppIconResponse(Hashtable<String, Object> hash) {
super(hash);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java
index d62d4f6a4..ec3b1e62e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java
@@ -18,7 +18,7 @@ public class SetDisplayLayout extends RPCRequest {
* Constructs a new SetDisplayLayout object
*/
public SetDisplayLayout() {
- super(FunctionID.SET_DISPLAY_LAYOUT);
+ super(FunctionID.SET_DISPLAY_LAYOUT.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java
index b531b2bc1..6d0a83b36 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java
@@ -22,7 +22,7 @@ public class SetDisplayLayoutResponse extends RPCResponse {
* Constructs a new SetDisplayLayoutResponse object
*/
public SetDisplayLayoutResponse() {
- super(FunctionID.SET_DISPLAY_LAYOUT);
+ super(FunctionID.SET_DISPLAY_LAYOUT.toString());
}
/**
@@ -61,23 +61,59 @@ public class SetDisplayLayoutResponse extends RPCResponse {
if (parameters.get(KEY_BUTTON_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_BUTTON_CAPABILITIES);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof ButtonCapabilities) {
- return (List<ButtonCapabilities>) list;
- } else if (obj instanceof Hashtable) {
- List<ButtonCapabilities> newList = new ArrayList<ButtonCapabilities>();
- for (Object hashObj : list) {
- newList.add(new ButtonCapabilities((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<ButtonCapabilities> buttonCapabilitiesList = new ArrayList<ButtonCapabilities>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw ButtonCapabilities and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof ButtonCapabilities) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ buttonCapabilitiesList.add(new ButtonCapabilities((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<ButtonCapabilities>) list;
+ } else if (flagHash) {
+ return buttonCapabilitiesList;
+ }
}
}
return null;
}
public void setButtonCapabilities(List<ButtonCapabilities> buttonCapabilities) {
- if (buttonCapabilities != null) {
+
+ boolean valid = true;
+
+ for (ButtonCapabilities item : buttonCapabilities ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (buttonCapabilities != null) && (buttonCapabilities.size() > 0) && valid) {
parameters.put(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
} else {
parameters.remove(KEY_BUTTON_CAPABILITIES);
@@ -89,23 +125,59 @@ public class SetDisplayLayoutResponse extends RPCResponse {
if (parameters.get(KEY_SOFT_BUTTON_CAPABILITIES) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTON_CAPABILITIES);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof SoftButtonCapabilities) {
- return (List<SoftButtonCapabilities>) list;
- } else if (obj instanceof Hashtable) {
- List<SoftButtonCapabilities> newList = new ArrayList<SoftButtonCapabilities>();
- for (Object hashObj : list) {
- newList.add(new SoftButtonCapabilities((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<SoftButtonCapabilities> softButtonCapabilitiesList = new ArrayList<SoftButtonCapabilities>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButtonCapabilities and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButtonCapabilities) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ softButtonCapabilitiesList.add(new SoftButtonCapabilities((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SoftButtonCapabilities>) list;
+ } else if (flagHash) {
+ return softButtonCapabilitiesList;
+ }
}
}
return null;
}
public void setSoftButtonCapabilities(List<SoftButtonCapabilities> softButtonCapabilities) {
- if (softButtonCapabilities != null) {
+
+ boolean valid = true;
+
+ for (SoftButtonCapabilities item : softButtonCapabilities ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (softButtonCapabilities != null) && (softButtonCapabilities.size() > 0) && valid) {
parameters.put(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities);
} else {
parameters.remove(KEY_SOFT_BUTTON_CAPABILITIES);
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 bec5aabed..0d55dab8c 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java
@@ -6,7 +6,7 @@ import java.util.List;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
/**
* Sets value(s) for the specified global property(ies)
* <p>
@@ -29,7 +29,7 @@ public class SetGlobalProperties extends RPCRequest {
* Constructs a new SetGlobalProperties object
*/
public SetGlobalProperties() {
- super(FunctionID.SET_GLOBAL_PROPERTIES);
+ super(FunctionID.SET_GLOBAL_PROPERTIES.toString());
}
/**
* Constructs a new SetGlobalProperties object indicated by the Hashtable
@@ -55,16 +55,43 @@ public class SetGlobalProperties extends RPCRequest {
if (parameters.get(KEY_HELP_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_HELP_PROMPT);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TTSChunk) {
- return (List<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -84,7 +111,16 @@ public class SetGlobalProperties extends RPCRequest {
* </ul>
*/
public void setHelpPrompt(List<TTSChunk> helpPrompt) {
- if (helpPrompt != null) {
+
+ boolean valid = true;
+
+ for (TTSChunk item : helpPrompt ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (helpPrompt != null) && (helpPrompt.size() > 0) && valid) {
parameters.put(KEY_HELP_PROMPT, helpPrompt);
} else {
parameters.remove(KEY_HELP_PROMPT);
@@ -103,16 +139,43 @@ public class SetGlobalProperties extends RPCRequest {
if (parameters.get(KEY_TIMEOUT_PROMPT) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_TIMEOUT_PROMPT);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TTSChunk) {
- return (List<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -124,7 +187,16 @@ public class SetGlobalProperties extends RPCRequest {
*
*/
public void setTimeoutPrompt(List<TTSChunk> timeoutPrompt) {
- if (timeoutPrompt != null) {
+
+ boolean valid = true;
+
+ for (TTSChunk item : timeoutPrompt ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (timeoutPrompt != null) && (timeoutPrompt.size() > 0) && valid) {
parameters.put(KEY_TIMEOUT_PROMPT, timeoutPrompt);
} else {
parameters.remove(KEY_TIMEOUT_PROMPT);
@@ -179,16 +251,43 @@ public class SetGlobalProperties extends RPCRequest {
if (parameters.get(KEY_VR_HELP) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_VR_HELP);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof VrHelpItem) {
- return (List<VrHelpItem>) list;
- } else if (obj instanceof Hashtable) {
- List<VrHelpItem> newList = new ArrayList<VrHelpItem>();
- for (Object hashObj : list) {
- newList.add(new VrHelpItem((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<VrHelpItem> vrHelpItemList = new ArrayList<VrHelpItem>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw VrHelpItem and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof VrHelpItem) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ vrHelpItemList.add(new VrHelpItem((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<VrHelpItem>) list;
+ } else if (flagHash) {
+ return vrHelpItemList;
+ }
}
}
return null;
@@ -216,7 +315,16 @@ public class SetGlobalProperties extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setVrHelp(List<VrHelpItem> vrHelp) {
- if (vrHelp != null) {
+
+ boolean valid = true;
+
+ for (VrHelpItem item : vrHelp ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (vrHelp != null) && (vrHelp.size() > 0) && valid) {
parameters.put(KEY_VR_HELP, vrHelp);
} else {
parameters.remove(KEY_VR_HELP);
@@ -252,7 +360,7 @@ public class SetGlobalProperties extends RPCRequest {
try {
return new Image((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MENU_ICON, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_MENU_ICON, e);
}
}
return null;
@@ -275,7 +383,7 @@ public class SetGlobalProperties extends RPCRequest {
try {
return new KeyboardProperties((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_KEYBOARD_PROPERTIES, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_KEYBOARD_PROPERTIES, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalPropertiesResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalPropertiesResponse.java
index 00d4b9e61..bef494e69 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalPropertiesResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetGlobalPropertiesResponse.java
@@ -16,7 +16,7 @@ public class SetGlobalPropertiesResponse extends RPCResponse {
* Constructs a new SetGlobalPropertiesResponse object
*/
public SetGlobalPropertiesResponse() {
- super(FunctionID.SET_GLOBAL_PROPERTIES);
+ super(FunctionID.SET_GLOBAL_PROPERTIES.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java
index 73885a0c5..67a21662a 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
/**
* Sets the media clock/timer value and the update method (e.g.count-up,
* count-down, etc.)
@@ -24,7 +23,7 @@ public class SetMediaClockTimer extends RPCRequest {
* Constructs a new SetMediaClockTimer object
*/
public SetMediaClockTimer() {
- super(FunctionID.SET_MEDIA_CLOCK_TIMER);
+ super(FunctionID.SET_MEDIA_CLOCK_TIMER.toString());
}
/**
* Constructs a new SetMediaClockTimer object indicated by the Hashtable
@@ -102,14 +101,8 @@ public class SetMediaClockTimer extends RPCRequest {
Object obj = parameters.get(KEY_UPDATE_MODE);
if (obj instanceof UpdateMode) {
return (UpdateMode) obj;
- } else if (obj instanceof String) {
- UpdateMode theCode = null;
- try {
- theCode = UpdateMode.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_UPDATE_MODE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return UpdateMode.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimerResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimerResponse.java
index 43b10d3db..410b5b68c 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimerResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SetMediaClockTimerResponse.java
@@ -16,7 +16,7 @@ public class SetMediaClockTimerResponse extends RPCResponse {
* Constructs a new SetMediaClockTimerResponse object
*/
public SetMediaClockTimerResponse() {
- super(FunctionID.SET_MEDIA_CLOCK_TIMER);
+ super(FunctionID.SET_MEDIA_CLOCK_TIMER.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java
index ede0bf3ac..ae3ca9e90 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Show.java
@@ -7,7 +7,7 @@ import java.util.List;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
/**
* Updates the application's display text area, regardless of whether or not
@@ -49,7 +49,7 @@ public class Show extends RPCRequest {
* Constructs a new Show object
*/
public Show() {
- super(FunctionID.SHOW);
+ super(FunctionID.SHOW.toString());
}
/**
* Constructs a new Show object indicated by the Hashtable parameter
@@ -216,14 +216,8 @@ public class Show extends RPCRequest {
Object obj = parameters.get(KEY_ALIGNMENT);
if (obj instanceof TextAlignment) {
return (TextAlignment) obj;
- } else if (obj instanceof String) {
- TextAlignment theCode = null;
- try {
- theCode = TextAlignment.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ALIGNMENT, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return TextAlignment.valueForString((String) obj);
}
return null;
}
@@ -379,7 +373,7 @@ public class Show extends RPCRequest {
try {
return new Image((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GRAPHIC, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_GRAPHIC, e);
}
}
return null;
@@ -404,7 +398,7 @@ public class Show extends RPCRequest {
try {
return new Image((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SECONDARY_GRAPHIC, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_SECONDARY_GRAPHIC, e);
}
}
return null;
@@ -423,16 +417,43 @@ public class Show extends RPCRequest {
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<SoftButton>) list;
- } else if (obj instanceof Hashtable) {
- List<SoftButton> newList = new ArrayList<SoftButton>();
- for (Object hashObj : list) {
- newList.add(new SoftButton((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<SoftButton> softButtonList = new ArrayList<SoftButton>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButton and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButton) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SoftButton>) list;
+ } else if (flagHash) {
+ return softButtonList;
+ }
}
}
return null;
@@ -456,11 +477,21 @@ public class Show extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setSoftButtons(List<SoftButton> softButtons) {
- if (softButtons != null) {
- parameters.put(KEY_SOFT_BUTTONS, softButtons);
- } else {
- parameters.remove(KEY_SOFT_BUTTONS);
- }
+
+ boolean valid = true;
+
+ for (SoftButton item : softButtons ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
+ parameters.put(KEY_SOFT_BUTTONS, softButtons);
+ }
+ else{
+ parameters.remove(KEY_SOFT_BUTTONS);
+ }
}
/**
@@ -474,11 +505,13 @@ public class Show extends RPCRequest {
public List<String> getCustomPresets() {
if (parameters.get(KEY_CUSTOM_PRESETS) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_CUSTOM_PRESETS);
- if (list != null && list.size()>0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
- }
+ if (list != null && list.size() > 0) {
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
+ }
+ return (List<String>) list;
}
}
return null;
@@ -499,7 +532,16 @@ public class Show extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setCustomPresets(List<String> customPresets) {
- if (customPresets != null) {
+
+ boolean valid = true;
+
+ for (String item : customPresets ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (customPresets != null) && (customPresets.size() > 0) && valid) {
parameters.put(KEY_CUSTOM_PRESETS, customPresets);
} else {
parameters.remove(KEY_CUSTOM_PRESETS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java
index e53851e94..2c4bd5173 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java
@@ -38,7 +38,7 @@ public class ShowConstantTbt extends RPCRequest{
* Constructs a new ShowConstantTbt object
*/
public ShowConstantTbt(){
- super(FunctionID.SHOW_CONSTANT_TBT);
+ super(FunctionID.SHOW_CONSTANT_TBT.toString());
}
/**
@@ -307,12 +307,21 @@ public class ShowConstantTbt extends RPCRequest{
* a List<SoftButton> value
*/
public void setSoftButtons(List<SoftButton> softButtons){
- if(softButtons != null){
- parameters.put(KEY_SOFT_BUTTONS, softButtons);
- }
- else{
- parameters.remove(KEY_SOFT_BUTTONS);
- }
+
+ boolean valid = true;
+
+ for (SoftButton item : softButtons ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
+ parameters.put(KEY_SOFT_BUTTONS, softButtons);
+ }
+ else{
+ parameters.remove(KEY_SOFT_BUTTONS);
+ }
}
/**
@@ -326,16 +335,43 @@ public class ShowConstantTbt extends RPCRequest{
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<SoftButton>) list;
- } else if (obj instanceof Hashtable) {
- List<SoftButton> newList = new ArrayList<SoftButton>();
- for (Object hashObj : list) {
- newList.add(new SoftButton((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<SoftButton> softButtonList = new ArrayList<SoftButton>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButton and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButton) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SoftButton>) list;
+ } else if (flagHash) {
+ return softButtonList;
+ }
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java
index fb00da92e..a3e2dbaf1 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowConstantTbtResponse.java
@@ -13,7 +13,7 @@ import com.smartdevicelink.proxy.RPCResponse;
public class ShowConstantTbtResponse extends RPCResponse{
public ShowConstantTbtResponse() {
- super(FunctionID.SHOW_CONSTANT_TBT);
+ super(FunctionID.SHOW_CONSTANT_TBT.toString());
}
public ShowConstantTbtResponse(Hashtable<String, Object> hash) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowResponse.java
index 8f28e0df7..e12c09029 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/ShowResponse.java
@@ -16,7 +16,7 @@ public class ShowResponse extends RPCResponse {
* Constructs a new ShowResponse object
*/
public ShowResponse() {
- super(FunctionID.SHOW);
+ super(FunctionID.SHOW.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SingleTireStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SingleTireStatus.java
index fe26b0b3c..a8496c35e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SingleTireStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SingleTireStatus.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
/**
* Tire pressure status of a single tire.
@@ -63,14 +62,8 @@ public class SingleTireStatus extends RPCStruct {
Object obj = store.get(KEY_STATUS);
if (obj instanceof ComponentVolumeStatus) {
return (ComponentVolumeStatus) obj;
- } else if (obj instanceof String) {
- ComponentVolumeStatus theCode = null;
- try {
- theCode = ComponentVolumeStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_STATUS, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ComponentVolumeStatus.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java
index 47a6840d9..c4675ec84 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Slider.java
@@ -29,7 +29,7 @@ public class Slider extends RPCRequest {
* Constructs a new Slider object
*/
public Slider() {
- super(FunctionID.SLIDER);
+ super(FunctionID.SLIDER.toString());
}
/**
@@ -131,7 +131,16 @@ public class Slider extends RPCRequest {
* <b>Notes: </b>Maxlength=500; Minvalue=1; Maxvalue=26
*/
public void setSliderFooter(List<String> sliderFooter) {
- if (sliderFooter != null) {
+
+ boolean valid = true;
+
+ for (String item : sliderFooter ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (sliderFooter != null) && (sliderFooter.size() > 0) && valid) {
parameters.put(KEY_SLIDER_FOOTER, sliderFooter);
} else {
parameters.remove(KEY_SLIDER_FOOTER);
@@ -147,11 +156,13 @@ public class Slider extends RPCRequest {
public List<String> getSliderFooter() {
if (parameters.get(KEY_SLIDER_FOOTER) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_SLIDER_FOOTER);
- if (list != null && list.size()>0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
+ if (list != null && list.size() > 0) {
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
}
+ return (List<String>) list;
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SliderResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SliderResponse.java
index 8df4fc511..6d168b6ea 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SliderResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SliderResponse.java
@@ -17,7 +17,7 @@ public class SliderResponse extends RPCResponse {
* Constructs a new SliderResponse object
*/
public SliderResponse() {
- super(FunctionID.SLIDER);
+ super(FunctionID.SLIDER.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SoftButton.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SoftButton.java
index b3fddcd1b..048be2015 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SoftButton.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SoftButton.java
@@ -5,7 +5,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.SoftButtonType;
import com.smartdevicelink.proxy.rpc.enums.SystemAction;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
public class SoftButton extends RPCStruct {
@@ -31,14 +31,8 @@ public class SoftButton extends RPCStruct {
Object obj = store.get(KEY_TYPE);
if (obj instanceof SoftButtonType) {
return (SoftButtonType) obj;
- } else if (obj instanceof String) {
- SoftButtonType theCode = null;
- try {
- theCode = SoftButtonType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return SoftButtonType.valueForString((String) obj);
}
return null;
}
@@ -68,7 +62,7 @@ public class SoftButton extends RPCStruct {
try {
return new Image((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
}
}
return null;
@@ -104,14 +98,8 @@ public class SoftButton extends RPCStruct {
Object obj = store.get(KEY_SYSTEM_ACTION);
if (obj instanceof SystemAction) {
return (SystemAction) obj;
- } else if (obj instanceof String) {
- SystemAction theCode = null;
- try {
- theCode = SystemAction.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SYSTEM_ACTION, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return SystemAction.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java
index 5e74da031..93c5b8a04 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/Speak.java
@@ -79,7 +79,7 @@ public class Speak extends RPCRequest {
* Constructs a new Speak object
*/
public Speak() {
- super(FunctionID.SPEAK);
+ super(FunctionID.SPEAK.toString());
}
/**
* Constructs a new Speak object indicated by the Hashtable parameter
@@ -102,16 +102,43 @@ public class Speak extends RPCRequest {
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<TTSChunk>) list;
- } else if (obj instanceof Hashtable) {
- List<TTSChunk> newList = new ArrayList<TTSChunk>();
- for (Object hashObj : list) {
- newList.add(new TTSChunk((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
+
+ List<TTSChunk> ttsChunkList = new ArrayList<TTSChunk>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TTSChunk and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TTSChunk) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ ttsChunkList.add(new TTSChunk((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TTSChunk>) list;
+ } else if (flagHash) {
+ return ttsChunkList;
+ }
}
}
return null;
@@ -133,7 +160,16 @@ public class Speak extends RPCRequest {
* </ul>
*/
public void setTtsChunks( List<TTSChunk> ttsChunks ) {
- if (ttsChunks != null) {
+
+ boolean valid = true;
+
+ for (TTSChunk item : ttsChunks ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (ttsChunks != null) && (ttsChunks.size() > 0) && valid) {
parameters.put(KEY_TTS_CHUNKS, ttsChunks );
} else {
parameters.remove(KEY_TTS_CHUNKS);
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SpeakResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SpeakResponse.java
index 700beda0b..3e7be103c 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SpeakResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SpeakResponse.java
@@ -16,7 +16,7 @@ public class SpeakResponse extends RPCResponse {
* Constructs a new SpeakResponse object
*/
public SpeakResponse() {
- super(FunctionID.SPEAK);
+ super(FunctionID.SPEAK.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java
new file mode 100644
index 000000000..bd75bef6d
--- /dev/null
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java
@@ -0,0 +1,41 @@
+package com.smartdevicelink.proxy.rpc;
+
+import java.util.Hashtable;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCResponse;
+
+public class StreamRPCResponse extends RPCResponse {
+ public static final String KEY_FILENAME = "fileName";
+ public static final String KEY_FILESIZE = "fileSize";
+
+ public StreamRPCResponse() {
+ super(FunctionID.STREAM_RPC.toString());
+ }
+ public StreamRPCResponse(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ public void setFileName(String fileName) {
+ if (fileName != null) {
+ parameters.put(KEY_FILENAME, fileName);
+ } else {
+ parameters.remove(KEY_FILENAME);
+ }
+ }
+ public String getFileName() {
+ return (String) parameters.get(KEY_FILENAME);
+ }
+
+ public void setFileSize(Long fileSize) {
+ if (fileSize != null) {
+ parameters.put(KEY_FILESIZE, fileSize);
+ } else {
+ parameters.remove(KEY_FILESIZE);
+ }
+ }
+ public Long getFileSize() {
+ return (Long) parameters.get(KEY_FILESIZE);
+ }
+
+}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButton.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButton.java
index 4fe52e20e..ef6feb986 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButton.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButton.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.rpc.enums.ButtonName;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.ButtonName;
/**
* Establishes a subscription to button notifications for HMI buttons. Buttons
* are not necessarily physical buttons, but can also be "soft" buttons on a
@@ -63,7 +62,7 @@ public class SubscribeButton extends RPCRequest {
* Constructs a new SubscribeButton object
*/
public SubscribeButton() {
- super(FunctionID.SUBSCRIBE_BUTTON);
+ super(FunctionID.SUBSCRIBE_BUTTON.toString());
}
/**
* Constructs a new SubscribeButton object indicated by the Hashtable
@@ -84,14 +83,8 @@ public class SubscribeButton extends RPCRequest {
Object obj = parameters.get(KEY_BUTTON_NAME);
if (obj instanceof ButtonName) {
return (ButtonName) obj;
- } else if (obj instanceof String) {
- ButtonName theCode = null;
- try {
- theCode = ButtonName.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BUTTON_NAME, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ButtonName.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButtonResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButtonResponse.java
index cc70b95bd..b51f75eee 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButtonResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeButtonResponse.java
@@ -16,7 +16,7 @@ public class SubscribeButtonResponse extends RPCResponse {
* Constructs a new SubscribeButtonResponse object
*/
public SubscribeButtonResponse() {
- super(FunctionID.SUBSCRIBE_BUTTON);
+ super(FunctionID.SUBSCRIBE_BUTTON.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java
index 222e1a958..10333d3d0 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java
@@ -51,7 +51,7 @@ public class SubscribeVehicleData extends RPCRequest {
* Constructs a new SubscribeVehicleData object
*/
public SubscribeVehicleData() {
- super(FunctionID.SUBSCRIBE_VEHICLE_DATA);
+ super(FunctionID.SUBSCRIBE_VEHICLE_DATA.toString());
}
/**
@@ -171,11 +171,7 @@ public class SubscribeVehicleData extends RPCRequest {
*/
@Deprecated
public void setFuelLevel_State(Boolean fuelLevel_State) {
- if (fuelLevel_State != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevel_State);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setFuelLevelState(fuelLevel_State);
}
/**
@@ -187,7 +183,7 @@ public class SubscribeVehicleData extends RPCRequest {
*/
@Deprecated
public Boolean getFuelLevel_State() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL_STATE);
+ return getFuelLevelState();
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java
index a4f3e1054..422027d33 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java
@@ -4,7 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
/**
* Subscribe Vehicle Data Response is sent, when SubscribeVehicleData has been called
@@ -41,7 +41,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
* Constructs a new SubscribeVehicleDataResponse object
*/
public SubscribeVehicleDataResponse() {
- super(FunctionID.SUBSCRIBE_VEHICLE_DATA);
+ super(FunctionID.SUBSCRIBE_VEHICLE_DATA.toString());
}
/**
@@ -79,7 +79,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
}
}
return null;
@@ -108,7 +108,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEED, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEED, e);
}
}
return null;
@@ -137,7 +137,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RPM, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_RPM, e);
}
}
return null;
@@ -166,7 +166,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL, e);
}
}
return null;
@@ -177,30 +177,15 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@Deprecated
public void setFuelLevel_State(VehicleDataResult fuelLevel_State) {
- if (fuelLevel_State != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevel_State);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setFuelLevelState(fuelLevel_State);
}
/**
* Gets Fuel Level State
* @return VehicleDataResult
*/
@Deprecated
- @SuppressWarnings("unchecked")
- public VehicleDataResult getFuelLevel_State() {
- Object obj = parameters.get(KEY_FUEL_LEVEL_STATE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
- }
- }
- return null;
+ public VehicleDataResult getFuelLevel_State() {
+ return getFuelLevelState();
}
/**
* Sets Fuel Level State
@@ -251,7 +236,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INSTANT_FUEL_CONSUMPTION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_INSTANT_FUEL_CONSUMPTION, e);
}
}
return null;
@@ -280,7 +265,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EXTERNAL_TEMPERATURE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_EXTERNAL_TEMPERATURE, e);
}
}
return null;
@@ -309,7 +294,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRNDL, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRNDL, e);
}
}
return null;
@@ -338,7 +323,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
}
}
return null;
@@ -367,7 +352,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ODOMETER, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_ODOMETER, e);
}
}
return null;
@@ -396,7 +381,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
}
}
return null;
@@ -425,7 +410,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
}
}
return null;
@@ -454,7 +439,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
}
}
return null;
@@ -483,7 +468,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BRAKING, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BRAKING, e);
}
}
return null;
@@ -512,7 +497,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_WIPER_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_WIPER_STATUS, e);
}
}
return null;
@@ -541,7 +526,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
}
}
return null;
@@ -570,7 +555,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ENGINE_TORQUE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_ENGINE_TORQUE, e);
}
}
return null;
@@ -599,7 +584,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ACC_PEDAL_POSITION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_ACC_PEDAL_POSITION, e);
}
}
return null;
@@ -622,7 +607,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_STEERING_WHEEL_ANGLE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_STEERING_WHEEL_ANGLE, e);
}
}
return null;
@@ -644,7 +629,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
}
}
return null;
@@ -665,7 +650,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
}
}
return null;
@@ -686,7 +671,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
}
}
return null;
@@ -707,7 +692,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
}
}
return null;
@@ -728,7 +713,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java
index c4238ce04..42df65ef7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequest.java
@@ -1,24 +1,23 @@
package com.smartdevicelink.proxy.rpc;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.rpc.enums.RequestType;
-import com.smartdevicelink.util.LogTool;
-
import java.util.Hashtable;
import java.util.List;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.enums.RequestType;
+
public class SystemRequest extends RPCRequest {
public static final String KEY_FILE_NAME = "fileName";
public static final String KEY_REQUEST_TYPE = "requestType";
public static final String KEY_DATA = "data";
public SystemRequest() {
- super(FunctionID.SYSTEM_REQUEST);
+ super(FunctionID.SYSTEM_REQUEST.toString());
}
public SystemRequest(boolean bLegacy) {
- super(FunctionID.ENCODED_SYNC_P_DATA);
+ super(FunctionID.ENCODED_SYNC_P_DATA.toString());
}
public SystemRequest(Hashtable<String, Object> hash) {
@@ -30,17 +29,28 @@ public class SystemRequest extends RPCRequest {
if (parameters.get(KEY_DATA) instanceof List<?>) {
List<?> list = (List<?>)parameters.get(KEY_DATA);
if (list != null && list.size()>0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
+ for( Object obj : list ) {
+ if (!(obj instanceof String)) {
+ return null;
+ }
}
+ return (List<String>) list;
}
}
return null;
}
- public void setLegacyData( List<String> data ) {
- if ( data!= null) {
+ public void setLegacyData( List<String> data ) {
+
+ boolean valid = true;
+
+ for ( String item : data ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (data != null) && (data.size() > 0) && valid ) {
parameters.put(KEY_DATA, data );
} else {
parameters.remove(KEY_DATA);
@@ -63,16 +73,8 @@ public class SystemRequest extends RPCRequest {
Object obj = parameters.get(KEY_REQUEST_TYPE);
if (obj instanceof RequestType) {
return (RequestType) obj;
- } else if (obj instanceof String) {
- RequestType theCode = null;
- try {
- theCode = RequestType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError(
- "Failed to parse " + getClass().getSimpleName() + "." +
- KEY_REQUEST_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return RequestType.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequestResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequestResponse.java
index 0f9307258..201c186c8 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequestResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/SystemRequestResponse.java
@@ -1,13 +1,13 @@
package com.smartdevicelink.proxy.rpc;
+import java.util.Hashtable;
+
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
-import java.util.Hashtable;
-
public class SystemRequestResponse extends RPCResponse {
public SystemRequestResponse() {
- super(FunctionID.SYSTEM_REQUEST);
+ super(FunctionID.SYSTEM_REQUEST.toString());
}
public SystemRequestResponse(Hashtable<String, Object> hash) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TTSChunk.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TTSChunk.java
index 88b5d4ba4..2ffd17936 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TTSChunk.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TTSChunk.java
@@ -3,8 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
/**
* Specifies what is to be spoken. This can be simply a text phrase, which SDL will speak according to its own rules.
@@ -78,14 +77,8 @@ public class TTSChunk extends RPCStruct {
Object obj = store.get(KEY_TYPE);
if (obj instanceof SpeechCapabilities) {
return (SpeechCapabilities) obj;
- } else if (obj instanceof String) {
- SpeechCapabilities theCode = null;
- try {
- theCode = SpeechCapabilities.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return SpeechCapabilities.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TextField.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TextField.java
index 906769f12..05ef20ab9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TextField.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TextField.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.CharacterSet;
-import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
/**
* Struct defining the characteristics of a displayed field on the HMI.
@@ -78,14 +77,8 @@ public class TextField extends RPCStruct {
Object obj = store.get(KEY_NAME);
if (obj instanceof TextFieldName) {
return (TextFieldName) obj;
- } else if (obj instanceof String) {
- TextFieldName theCode = null;
- try {
- theCode = TextFieldName.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_NAME, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return TextFieldName.valueForString((String) obj);
}
return null;
}
@@ -108,14 +101,8 @@ public class TextField extends RPCStruct {
Object obj = store.get(KEY_CHARACTER_SET);
if (obj instanceof CharacterSet) {
return (CharacterSet) obj;
- } else if (obj instanceof String) {
- CharacterSet theCode = null;
- try {
- theCode = CharacterSet.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CHARACTER_SET, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return CharacterSet.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TireStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TireStatus.java
index 55da37d50..d9abce099 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TireStatus.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TireStatus.java
@@ -4,7 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.WarningLightStatus;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
public class TireStatus extends RPCStruct {
public static final String KEY_PRESSURE_TELL_TALE = "pressureTellTale";
@@ -30,14 +30,8 @@ public class TireStatus extends RPCStruct {
Object obj = store.get(KEY_PRESSURE_TELL_TALE);
if (obj instanceof WarningLightStatus) {
return (WarningLightStatus) obj;
- } else if (obj instanceof String) {
- WarningLightStatus theCode = null;
- try {
- theCode = WarningLightStatus.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRESSURE_TELL_TALE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return WarningLightStatus.valueForString((String) obj);
}
return null;
}
@@ -57,7 +51,7 @@ public class TireStatus extends RPCStruct {
try {
return new SingleTireStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LEFT_FRONT, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_LEFT_FRONT, e);
}
}
return null;
@@ -78,7 +72,7 @@ public class TireStatus extends RPCStruct {
try {
return new SingleTireStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_FRONT, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_FRONT, e);
}
}
return null;
@@ -99,7 +93,7 @@ public class TireStatus extends RPCStruct {
try {
return new SingleTireStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LEFT_REAR, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_LEFT_REAR, e);
}
}
return null;
@@ -120,7 +114,7 @@ public class TireStatus extends RPCStruct {
try {
return new SingleTireStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_REAR, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_REAR, e);
}
}
return null;
@@ -141,7 +135,7 @@ public class TireStatus extends RPCStruct {
try {
return new SingleTireStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INNER_LEFT_REAR, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_INNER_LEFT_REAR, e);
}
}
return null;
@@ -162,7 +156,7 @@ public class TireStatus extends RPCStruct {
try {
return new SingleTireStatus((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INNER_RIGHT_REAR, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_INNER_RIGHT_REAR, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java
index 34fa27c53..4cf11da23 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/TouchEvent.java
@@ -10,60 +10,106 @@ public class TouchEvent extends RPCStruct {
public static final String KEY_ID = "id";
public static final String KEY_TS = "ts";
public static final String KEY_C = "c";
+
public TouchEvent() { }
public TouchEvent(Hashtable<String, Object> hash) {
super(hash);
}
+
public void setId(Integer id) {
if (id != null) {
store.put(KEY_ID, id);
} else {
store.remove(KEY_ID);
}
- }
+ }
+
public Integer getId() {
return (Integer) store.get(KEY_ID);
- }
+ }
+
@SuppressWarnings("unchecked")
- public List<Integer> getTs() {
+ public List<Long> getTs() {
if(store.get(KEY_TS) instanceof List<?>){
List<?> list = (List<?>)store.get(KEY_TS);
if(list != null && list.size()>0){
- Object obj = list.get(0);
- if(obj instanceof Integer){
- return (List<Integer>) list;
+ for( Object obj : list ) {
+ if (!(obj instanceof Integer) || !(obj instanceof Long)) {
+ return null;
+ }
}
- }
+
+ if (list.get(0) instanceof Integer) {
+ List<Integer> listOfInt = (List<Integer>) list;
+ List<Long> listofLongs = new ArrayList<Long>(list.size());
+ for(int i = 0; i < list.size(); i++){
+ listofLongs.add(listOfInt.get(i).longValue());
+ }
+ return listofLongs;
+ } else if (list.get(0) instanceof Long) {
+ return (List<Long>) list;
+ }
+ }
}
return null;
}
- public void setTs(List<Integer> ts) {
+
+ public void setTs(List<Long> ts) {
if (ts != null) {
store.put(KEY_TS, ts);
} else {
store.remove(KEY_TS);
}
}
+
@SuppressWarnings("unchecked")
public List<TouchCoord> getC() {
if (store.get(KEY_C) instanceof List<?>) {
List<?> list = (List<?>)store.get(KEY_C);
if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TouchCoord) {
- return (List<TouchCoord>) list;
- } else if (obj instanceof Hashtable) {
- List<TouchCoord> newList = new ArrayList<TouchCoord>();
- for (Object hashObj : list) {
- newList.add(new TouchCoord((Hashtable<String, Object>) hashObj));
- }
- return newList;
- }
+
+ List<TouchCoord> touchCoordList = new ArrayList<TouchCoord>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw TouchCoord and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof TouchCoord) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ touchCoordList.add(new TouchCoord((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<TouchCoord>) list;
+ } else if (flagHash) {
+ return touchCoordList;
+ }
}
}
return null;
}
+
public void setC( List<TouchCoord> c ) {
if (c != null) {
store.put(KEY_C, c );
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterface.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterface.java
index 5990f7a83..aafdb53f9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterface.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterface.java
@@ -26,7 +26,7 @@ public class UnregisterAppInterface extends RPCRequest {
* Constructs a new UnregisterAppInterface object
*/
public UnregisterAppInterface() {
- super(FunctionID.UNREGISTER_APP_INTERFACE);
+ super(FunctionID.UNREGISTER_APP_INTERFACE.toString());
}
/**
* Constructs a new UnregisterAppInterface object indicated by the Hashtable
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterfaceResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterfaceResponse.java
index d9b56ca79..db425a503 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterfaceResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnregisterAppInterfaceResponse.java
@@ -16,7 +16,7 @@ public class UnregisterAppInterfaceResponse extends RPCResponse {
* Constructs a new UnregisterAppInterfaceResponse object
*/
public UnregisterAppInterfaceResponse() {
- super(FunctionID.UNREGISTER_APP_INTERFACE);
+ super(FunctionID.UNREGISTER_APP_INTERFACE.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java
index 92af2559e..37051409a 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.rpc.enums.ButtonName;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.ButtonName;
/**
* Deletes a subscription to button notifications for the specified button. For
@@ -27,7 +26,7 @@ public class UnsubscribeButton extends RPCRequest {
* Constructs a new UnsubscribeButton object
*/
public UnsubscribeButton() {
- super(FunctionID.UNSUBSCRIBE_BUTTON);
+ super(FunctionID.UNSUBSCRIBE_BUTTON.toString());
}
/**
* Constructs a new UnsubscribeButton object indicated by the Hashtable
@@ -50,14 +49,8 @@ public class UnsubscribeButton extends RPCRequest {
Object obj = parameters.get(KEY_BUTTON_NAME);
if (obj instanceof ButtonName) {
return (ButtonName) obj;
- } else if (obj instanceof String) {
- ButtonName theCode = null;
- try {
- theCode = ButtonName.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BUTTON_NAME, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return ButtonName.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButtonResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButtonResponse.java
index 1d4c3e23a..58f7326e1 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButtonResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeButtonResponse.java
@@ -16,7 +16,7 @@ public class UnsubscribeButtonResponse extends RPCResponse {
* Constructs a new UnsubscribeButtonResponse object
*/
public UnsubscribeButtonResponse() {
- super(FunctionID.UNSUBSCRIBE_BUTTON);
+ super(FunctionID.UNSUBSCRIBE_BUTTON.toString());
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java
index 20f9e2e84..429049d59 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java
@@ -49,7 +49,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* Constructs a new UnsubscribeVehicleData object
*/
public UnsubscribeVehicleData() {
- super(FunctionID.UNSUBSCRIBE_VEHICLE_DATA);
+ super(FunctionID.UNSUBSCRIBE_VEHICLE_DATA.toString());
}
/**
@@ -169,11 +169,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
*/
@Deprecated
public void setFuelLevel_State(Boolean fuelLevel_State) {
- if (fuelLevel_State != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevel_State);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setFuelLevelState(fuelLevel_State);
}
/**
@@ -185,7 +181,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
*/
@Deprecated
public Boolean getFuelLevel_State() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL_STATE);
+ return getFuelLevelState();
}
/**
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java
index ddb9b1289..44d3fe050 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java
@@ -4,7 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
/**
* Unsubscribe Vehicle Data Response is sent, when UnsubscribeVehicleData has been called
@@ -41,7 +41,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
* Constructs a new UnsubscribeVehicleDataResponse object
*/
public UnsubscribeVehicleDataResponse() {
- super(FunctionID.UNSUBSCRIBE_VEHICLE_DATA);
+ super(FunctionID.UNSUBSCRIBE_VEHICLE_DATA.toString());
}
/**
@@ -79,7 +79,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
}
}
return null;
@@ -108,7 +108,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEED, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEED, e);
}
}
return null;
@@ -137,7 +137,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RPM, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_RPM, e);
}
}
return null;
@@ -166,7 +166,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL, e);
}
}
return null;
@@ -177,30 +177,15 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@Deprecated
public void setFuelLevel_State(VehicleDataResult fuelLevel_State) {
- if (fuelLevel_State != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevel_State);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setFuelLevel(fuelLevel_State);
}
/**
* Gets Fuel Level State
* @return VehicleDataResult
*/
@Deprecated
- @SuppressWarnings("unchecked")
- public VehicleDataResult getFuelLevel_State() {
- Object obj = parameters.get(KEY_FUEL_LEVEL_STATE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
- }
- }
- return null;
+ public VehicleDataResult getFuelLevel_State() {
+ return getFuelLevelState();
}
/**
* Sets Fuel Level State
@@ -251,7 +236,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INSTANT_FUEL_CONSUMPTION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_INSTANT_FUEL_CONSUMPTION, e);
}
}
return null;
@@ -280,7 +265,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EXTERNAL_TEMPERATURE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_EXTERNAL_TEMPERATURE, e);
}
}
return null;
@@ -309,7 +294,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRNDL, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRNDL, e);
}
}
return null;
@@ -338,7 +323,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
}
}
return null;
@@ -367,7 +352,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ODOMETER, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_ODOMETER, e);
}
}
return null;
@@ -396,7 +381,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
}
}
return null;
@@ -425,7 +410,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
}
}
return null;
@@ -454,7 +439,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
}
}
return null;
@@ -483,7 +468,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BRAKING, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BRAKING, e);
}
}
return null;
@@ -512,7 +497,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_WIPER_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_WIPER_STATUS, e);
}
}
return null;
@@ -541,7 +526,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
}
}
return null;
@@ -570,7 +555,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ENGINE_TORQUE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_ENGINE_TORQUE, e);
}
}
return null;
@@ -599,7 +584,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ACC_PEDAL_POSITION, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_ACC_PEDAL_POSITION, e);
}
}
return null;
@@ -622,7 +607,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_STEERING_WHEEL_ANGLE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_STEERING_WHEEL_ANGLE, e);
}
}
return null;
@@ -644,7 +629,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
}
}
return null;
@@ -665,7 +650,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
}
}
return null;
@@ -686,7 +671,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
}
}
return null;
@@ -707,7 +692,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
}
}
return null;
@@ -728,7 +713,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
try {
return new VehicleDataResult((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
}
}
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
index 442c0dee2..48aa4b2b6 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnList.java
@@ -27,7 +27,7 @@ public class UpdateTurnList extends RPCRequest{
* Constructs a new UpdateTurnList object
*/
public UpdateTurnList() {
- super(FunctionID.UPDATE_TURN_LIST);
+ super(FunctionID.UPDATE_TURN_LIST.toString());
}
/**
@@ -52,7 +52,16 @@ public class UpdateTurnList extends RPCRequest{
* <b>Notes: </b>Minsize=1; Maxsize=100
*/
public void setTurnList(List<Turn> turnList){
- if(turnList != null){
+
+ boolean valid = true;
+
+ for (Turn item : turnList ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (turnList != null) && (turnList.size() > 0) && valid) {
parameters.put(KEY_TURN_LIST, turnList);
}
else{
@@ -67,20 +76,46 @@ public class UpdateTurnList extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public List<Turn> getTurnList(){
- if(parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>){
- List<?> list = (List<?>) parameters.get(KEY_SOFT_BUTTONS);
+ if(parameters.get(KEY_TURN_LIST) instanceof List<?>){
+ List<?> list = (List<?>) parameters.get(KEY_TURN_LIST);
if(list != null && list.size() > 0){
- Object obj = list.get(0);
- if(obj instanceof Turn){
- return (List<Turn>) list;
- }
- else if(obj instanceof Hashtable){
- List<Turn> newList = new ArrayList<Turn>();
- for(Object hashObj : list){
- newList.add(new Turn((Hashtable<String, Object>) hashObj));
- }
- return newList;
- }
+
+ List<Turn> turnList = new ArrayList<Turn>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw Turn and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof Turn) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ turnList.add(new Turn((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<Turn>) list;
+ } else if (flagHash) {
+ return turnList;
+ }
}
}
return null;
@@ -97,17 +132,43 @@ public class UpdateTurnList extends RPCRequest{
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<SoftButton>) list;
- }
- else if(obj instanceof Hashtable){
- List<SoftButton> newList = new ArrayList<SoftButton>();
- for(Object hashObj : list){
- newList.add(new SoftButton((Hashtable<String, Object>) hashObj));
- }
- return newList;
- }
+
+ List<SoftButton> softButtonList = new ArrayList<SoftButton>();
+
+ boolean flagRaw = false;
+ boolean flagHash = false;
+
+ for ( Object obj : list ) {
+
+ // This does not currently allow for a mixing of types, meaning
+ // there cannot be a raw SoftButton and a Hashtable value in the
+ // same same list. It will not be considered valid currently.
+ if (obj instanceof SoftButton) {
+ if (flagHash) {
+ return null;
+ }
+
+ flagRaw = true;
+
+ } else if (obj instanceof Hashtable) {
+ if (flagRaw) {
+ return null;
+ }
+
+ flagHash = true;
+ softButtonList.add(new SoftButton((Hashtable<String, Object>) obj));
+
+ } else {
+ return null;
+ }
+
+ }
+
+ if (flagRaw) {
+ return (List<SoftButton>) list;
+ } else if (flagHash) {
+ return softButtonList;
+ }
}
}
return null;
@@ -129,7 +190,16 @@ public class UpdateTurnList extends RPCRequest{
*/
public void setSoftButtons(List<SoftButton> softButtons){
- if(softButtons != null){
+
+ boolean valid = true;
+
+ for (SoftButton item : softButtons ) {
+ if (item == null) {
+ valid = false;
+ }
+ }
+
+ if ( (softButtons != null) && (softButtons.size() > 0) && valid) {
parameters.put(KEY_SOFT_BUTTONS, softButtons);
}
else{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java
index c62315188..add51c5a5 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/UpdateTurnListResponse.java
@@ -16,7 +16,7 @@ public class UpdateTurnListResponse extends RPCResponse{
* Constructs a new UpdateTurnListResponse object
*/
public UpdateTurnListResponse() {
- super(FunctionID.UPDATE_TURN_LIST);
+ super(FunctionID.UPDATE_TURN_LIST.toString());
}
public UpdateTurnListResponse(Hashtable<String, Object> hash) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VehicleDataResult.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VehicleDataResult.java
index 153384887..8766f7906 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VehicleDataResult.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VehicleDataResult.java
@@ -4,8 +4,7 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode;
-import com.smartdevicelink.proxy.rpc.enums.VehicleDataType;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataType;
public class VehicleDataResult extends RPCStruct {
public static final String KEY_DATA_TYPE = "dataType";
@@ -26,14 +25,8 @@ public class VehicleDataResult extends RPCStruct {
Object obj = store.get(KEY_DATA_TYPE);
if (obj instanceof VehicleDataType) {
return (VehicleDataType) obj;
- } else if (obj instanceof String) {
- VehicleDataType theCode = null;
- try {
- theCode = VehicleDataType.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DATA_TYPE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataType.valueForString((String) obj);
}
return null;
}
@@ -48,14 +41,8 @@ public class VehicleDataResult extends RPCStruct {
Object obj = store.get(KEY_RESULT_CODE);
if (obj instanceof VehicleDataResultCode) {
return (VehicleDataResultCode) obj;
- } else if (obj instanceof String) {
- VehicleDataResultCode theCode = null;
- try {
- theCode = VehicleDataResultCode.valueForString((String) obj);
- } catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RESULT_CODE, e);
- }
- return theCode;
+ } else if (obj instanceof String) {
+ return VehicleDataResultCode.valueForString((String) obj);
}
return null;
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VrHelpItem.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VrHelpItem.java
index dcc8cbc5a..4f8175793 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VrHelpItem.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/VrHelpItem.java
@@ -3,7 +3,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.util.SdlLog;
public class VrHelpItem extends RPCStruct {
public static final String KEY_POSITION = "position";
@@ -40,7 +40,7 @@ public class VrHelpItem extends RPCStruct {
try {
return new Image((Hashtable<String, Object>) obj);
} catch (Exception e) {
- LogTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
+ SdlLog.e("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
}
}
return null;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/AppInterfaceUnregisteredReason.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/AppInterfaceUnregisteredReason.java
index 9b20704b5..617fe9796 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/AppInterfaceUnregisteredReason.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/AppInterfaceUnregisteredReason.java
@@ -75,7 +75,14 @@ public enum AppInterfaceUnregisteredReason {
*
* @since SmartDeviceLink 2.0
*/
- APP_UNAUTHORIZED;
+ APP_UNAUTHORIZED,
+ /**
+ * The app has committed a protocol violation.
+ *
+ * @since SmartDeviceLink 4.0
+ */
+ PROTOCOL_VIOLATION,
+ ;
public static AppInterfaceUnregisteredReason valueForString(String value) {
try{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/GearShiftAdviceStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/GearShiftAdviceStatus.java
deleted file mode 100644
index 58eed6f62..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/GearShiftAdviceStatus.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.smartdevicelink.proxy.rpc.enums;
-
-public enum GearShiftAdviceStatus {
- NO_INDICATION,
- UPSHIFT_FUEL_ECONOMY,
- UPSHIFT_PERFORMANCE,
- UPSHIFT_WARNING,
- DOWNSHIFT_RECOMMENDATION,
- SHIFT_TO_NEUTRAL;
-
- public static GearShiftAdviceStatus valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java
index fb88cec4d..34971d10d 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/ImageFieldName.java
@@ -11,7 +11,14 @@ public enum ImageFieldName {
appIcon,
graphic,
showConstantTBTIcon,
- showConstantTBTNextTurnIcon;
+ showConstantTBTNextTurnIcon,
+ /**
+ * The optional image of a destination / location
+ *
+ * @since SmartDeviceLink 4.0
+ */
+ locationImage,
+ ;
public static ImageFieldName valueForString(String value) {
try{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/KeyboardEvent.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/KeyboardEvent.java
index 89c1c5f7d..524ee632c 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/KeyboardEvent.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/KeyboardEvent.java
@@ -5,7 +5,12 @@ public enum KeyboardEvent {
KEYPRESS,
ENTRY_SUBMITTED,
ENTRY_CANCELLED,
- ENTRY_ABORTED;
+ ENTRY_ABORTED,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ ENTRY_VOICE,
+ ;
public static KeyboardEvent valueForString(String value) {
try{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/LightSwitchStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/LightSwitchStatus.java
deleted file mode 100644
index 23595da9c..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/LightSwitchStatus.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.smartdevicelink.proxy.rpc.enums;
-
-public enum LightSwitchStatus {
- OFF,
- PARKLAMP,
- HEADLAMP,
- AUTOLAMP;
-
- public static LightSwitchStatus valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/MaintenanceModeStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/MaintenanceModeStatus.java
deleted file mode 100644
index a4e2fcf2f..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/MaintenanceModeStatus.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.smartdevicelink.proxy.rpc.enums;
-
-public enum MaintenanceModeStatus {
- NORMAL,
- NEAR,
- ACTIVE,
- FEATURE_NOT_PRESENT;
-
- public static MaintenanceModeStatus valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/MessageType.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/MessageType.java
deleted file mode 100644
index 85da8deb7..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/MessageType.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.smartdevicelink.proxy.rpc.enums;
-
-public enum MessageType {
- request,
- response,
- notification;
-
- public static MessageType valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/PermissionStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/PermissionStatus.java
deleted file mode 100644
index e96a03a40..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/PermissionStatus.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.smartdevicelink.proxy.rpc.enums;
-
-/**
- * Enumeration that describes possible permission states of a policy table entry.
- * @since SmartDeviceLink 2.0
- */
-public enum PermissionStatus {
- ALLOWED,
- DISALLOWED,
- USER_DISALLOWED,
- USER_CONSENT_PENDING;
-
- /**
- * Convert String to PermissionStatus
- * @param value String
- * @return PermissionStatus
- */
- public static PermissionStatus valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/RequestType.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/RequestType.java
index eac743ee4..4fccffa14 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/RequestType.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/RequestType.java
@@ -7,7 +7,64 @@ public enum RequestType {
AUTH_REQUEST,
AUTH_CHALLENGE,
AUTH_ACK,
- PROPRIETARY;
+ PROPRIETARY,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ QUERY_APPS,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ LAUNCH_APP,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ LOCK_SCREEN_ICON_URL,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ TRAFFIC_MESSAGE_CHANNEL,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ DRIVER_PROFILE,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ VOICE_SEARCH,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ NAVIGATION,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ PHONE,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ CLIMATE,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ SETTINGS,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ VEHICLE_DIAGNOSTICS,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ EMERGENCY,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ MEDIA,
+ /**
+ * @since SmartDeviceLink 4.0
+ */
+ FOTA,
+ ;
public static RequestType valueForString(String value) {
try{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/Result.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/Result.java
index 8cba57e39..557069c15 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/Result.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/Result.java
@@ -88,9 +88,12 @@ public enum Result {
*/
IN_USE,
/**
- * There is already an existing subscription for this item
+ *The user has turned off access to vehicle data, and it is globally unavailable to mobile applications.
*/
VEHICLE_DATA_NOT_ALLOWED,
+ /**
+ * The requested vehicle data is not available on this vehicle or is not published.
+ */
VEHICLE_DATA_NOT_AVAILABLE,
/**
* The requested operation was rejected. No attempt was made to perform the
@@ -114,18 +117,57 @@ public enum Result {
* information on supported buttons on the currently connected SDL platform
*/
UNSUPPORTED_RESOURCE,
+ /**
+ * A specified file could not be found on Sync.
+ */
FILE_NOT_FOUND,
+ /**
+ * Provided data is valid but something went wrong in the lower layers.
+ */
GENERIC_ERROR,
+ /**
+ * RPC is not authorized in local policy table.
+ */
DISALLOWED,
+ /**
+ * RPC is included in a functional group explicitly blocked by the user.
+ */
USER_DISALLOWED,
+ /**
+ * Overlay reached the maximum timeout and closed.
+ */
TIMED_OUT,
+ /**
+ * User selected to Cancel Route.
+ */
CANCEL_ROUTE,
+ /**
+ * The RPC (e.g. ReadDID) executed successfully but the data exceeded the platform maximum threshold and thus, only part of the data is available.
+ */
TRUNCATED_DATA,
+ /**
+ * The user interrupted the RPC (e.g. PerformAudioPassThru) and indicated to start over. Note, the app must issue the new RPC.
+ */
RETRY,
+ /**
+ * The RPC (e.g. SubscribeVehicleData) executed successfully but one or more items have a warning or failure.
+ */
WARNINGS,
+ /**
+ * The RPC (e.g. Slider) executed successfully and the user elected to save the current position / value.
+ */
SAVED,
+ /**
+ * The certificate provided during authentication is invalid.
+ */
INVALID_CERT,
+ /**
+ * The certificate provided during authentication is expired.
+ */
EXPIRED_CERT,
+ /**
+ * The provided hash ID does not match the hash of the current set of registered data or the core could not resume the previous data.
+ */
RESUME_FAILED;
public static Result valueForString(String value) {
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/SdlDisconnectedReason.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/SdlDisconnectedReason.java
index f46494d0c..ac1ba6ac1 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/SdlDisconnectedReason.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/SdlDisconnectedReason.java
@@ -31,6 +31,9 @@ public enum SdlDisconnectedReason {
}
public static SdlDisconnectedReason convertAppInterfaceUnregisteredReason(AppInterfaceUnregisteredReason reason) {
+ if(reason == null){
+ return null;
+ }
SdlDisconnectedReason returnReason = SdlDisconnectedReason.DEFAULT;
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java
index 26a3e9de2..073741e3a 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TextFieldName.java
@@ -24,7 +24,32 @@ public enum TextFieldName {
menuName,
secondaryText,
tertiaryText,
- menuTitle;
+ menuTitle,
+ /**
+ * Optional name / title of intended location for SendLocation.
+ *
+ * @since SmartDeviceLink 4.0
+ */
+ locationName,
+ /**
+ * Optional description of intended location / establishment (if applicable) for SendLocation
+ *
+ * @since SmartDeviceLink 4.0
+ */
+ locationDescription,
+ /**
+ * Optional location address (if applicable) for SendLocation.
+ *
+ * @since SmartDeviceLink 4.0
+ */
+ addressLines,
+ /**
+ * Optional hone number of intended location / establishment (if applicable) for SendLocation.
+ *
+ * @since SmartDeviceLink 4.0
+ */
+ phoneNumber,
+ ;
public static TextFieldName valueForString(String value) {
try{
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TirePressureTellTale.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TirePressureTellTale.java
deleted file mode 100644
index 881cf3575..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/TirePressureTellTale.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.smartdevicelink.proxy.rpc.enums;
-
-public enum TirePressureTellTale {
- OFF,
- ON,
- FLASH;
-
- public static TirePressureTellTale valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataActiveStatus.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataActiveStatus.java
deleted file mode 100644
index 3238ae667..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataActiveStatus.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.smartdevicelink.proxy.rpc.enums;
-
-public enum VehicleDataActiveStatus {
- INACTIVE_NOT_CONFIRMED,
- INACTIVE_CONFIRMED,
- ACTIVE_NOT_CONFIRMED,
- ACTIVE_CONFIRMED,
- FAULT;
-
- public static VehicleDataActiveStatus valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataResultCode.java b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataResultCode.java
index 2df9f3bae..8de4ca88f 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataResultCode.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/rpc/enums/VehicleDataResultCode.java
@@ -2,6 +2,12 @@ package com.smartdevicelink.proxy.rpc.enums;
public enum VehicleDataResultCode {
SUCCESS,
+ /**
+ *DTC / DID request successful, however, not all active DTCs or full contents of DID location available
+ *
+ * @since SmartDeviceLink 4.0
+ */
+ TRUNCATED_DATA,
DISALLOWED,
USER_DISALLOWED,
INVALID_ID,
diff --git a/sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java b/sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java
index 65795d9de..6ed975f8d 100644
--- a/sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/streaming/AbstractPacketizer.java
@@ -14,7 +14,7 @@ abstract public class AbstractPacketizer {
protected SessionType _session = null;
protected InputStream is = null;
- protected byte[] buffer = new byte[1488];
+ protected byte[] buffer = new byte[1000000];
protected boolean upts = false;
protected RPCRequest _request = null;
protected byte _wiproVersion = 1;
@@ -42,9 +42,7 @@ abstract public class AbstractPacketizer {
public abstract void stop();
- protected static String printBuffer(byte[] buffer, int start,int end) {
- String str = "";
- for (int i=start;i<end;i++) str+=","+Integer.toHexString(buffer[i]&0xFF);
- return str;
- }
-}
+ public abstract void pause();
+
+ public abstract void resume();
+} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
index 36ad712d9..06a16ee1d 100644
--- a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
@@ -3,6 +3,7 @@ package com.smartdevicelink.streaming;
import java.io.IOException;
import java.io.InputStream;
+import com.smartdevicelink.SdlConnection.SdlConnection;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
@@ -10,10 +11,17 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
public final static String TAG = "StreamPacketizer";
- private Thread t = null;
+ private Thread t = null;
+ private final static int BUFF_READ_SIZE = 1000000;
+
+ public SdlConnection sdlConnection = null;
+ private Object mPauseLock;
+ private boolean mPaused;
public StreamPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID) throws IOException {
super(streamListener, is, sType, rpcSessionID);
+ mPauseLock = new Object();
+ mPaused = false;
}
public void start() throws IOException {
@@ -33,10 +41,24 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
public void run() {
int length;
+
+ try
+ {
+ while (t != null && !t.isInterrupted())
+ {
+ synchronized(mPauseLock)
+ {
+ while (mPaused)
+ {
+ try
+ {
+ mPauseLock.wait();
+ }
+ catch (InterruptedException e) {}
+ }
+ }
- try {
- while (!Thread.interrupted()) {
- length = is.read(buffer, 0, 1488);
+ length = is.read(buffer, 0, BUFF_READ_SIZE);
if (length >= 0) {
ProtocolMessage pm = new ProtocolMessage();
@@ -53,4 +75,19 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
e.printStackTrace();
}
}
+
+ @Override
+ public void pause() {
+ synchronized (mPauseLock) {
+ mPaused = true;
+ }
+ }
+
+ @Override
+ public void resume() {
+ synchronized (mPauseLock) {
+ mPaused = false;
+ mPauseLock.notifyAll();
+ }
+ }
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java
index bac1ea466..1fdc50351 100644
--- a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamRPCPacketizer.java
@@ -2,6 +2,7 @@ package com.smartdevicelink.streaming;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Hashtable;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.ProtocolMessage;
@@ -9,45 +10,174 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.protocol.enums.MessageType;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.RPCResponse;
+import com.smartdevicelink.proxy.SdlProxyBase;
+import com.smartdevicelink.proxy.interfaces.IProxyListenerBase;
+import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener;
+import com.smartdevicelink.proxy.rpc.OnStreamRPC;
import com.smartdevicelink.proxy.rpc.PutFile;
+import com.smartdevicelink.proxy.rpc.PutFileResponse;
+import com.smartdevicelink.proxy.rpc.StreamRPCResponse;
+import com.smartdevicelink.proxy.rpc.enums.Result;
-public class StreamRPCPacketizer extends AbstractPacketizer implements Runnable{
+public class StreamRPCPacketizer extends AbstractPacketizer implements IPutFileResponseListener, Runnable{
- public final static String TAG = "StreamPacketizer";
- public final static int BUFF_READ_SIZE = 1000;
+ private Integer iInitialCorrID = 0;
+ private final static int BUFF_READ_SIZE = 1000000;
+ private Hashtable<Integer, OnStreamRPC> notificationList = new Hashtable<Integer, OnStreamRPC>();
+ private Thread thread = null;
+ private long lFileSize = 0;
+ private String sFileName;
+ private SdlProxyBase<IProxyListenerBase> _proxy;
+ private IProxyListenerBase _proxyListener;
- private Thread t = null;
+ private Object mPauseLock;
+ private boolean mPaused;
- public StreamRPCPacketizer(IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion) throws IOException {
+ public StreamRPCPacketizer(SdlProxyBase<IProxyListenerBase> proxy, IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, long iLength) throws IOException {
super(streamListener, is, request, sType, rpcSessionID, wiproVersion);
+ lFileSize = iLength;
+ iInitialCorrID = request.getCorrelationID();
+ mPauseLock = new Object();
+ mPaused = false;
+ if (proxy != null)
+ {
+ _proxy = proxy;
+ _proxyListener = _proxy.getProxyListener();
+ _proxy.addPutFileResponseListener(this);
+ }
}
+ @Override
public void start() throws IOException {
- if (t == null) {
- t = new Thread(this);
- t.start();
+ if (thread == null) {
+ thread = new Thread(this);
+ thread.start();
}
}
+ @Override
public void stop() {
try {
is.close();
} catch (IOException ignore) {}
- t.interrupt();
- t = null;
+ if (thread != null)
+ {
+ thread.interrupt();
+ thread = null;
+ }
+ }
+
+ private void handleStreamSuccess(RPCResponse rpc, Long iSize)
+ {
+ StreamRPCResponse result = new StreamRPCResponse();
+ result.setSuccess(rpc.getSuccess());
+ result.setResultCode(rpc.getResultCode());
+ result.setInfo(rpc.getInfo());
+ result.setFileName(sFileName);
+ result.setFileSize(iSize);
+ result.setCorrelationID(iInitialCorrID);
+ if (_proxyListener != null)
+ _proxyListener.onStreamRPCResponse(result);
+ stop();
+ _proxy.remPutFileResponseListener(this);
+ return;
+ }
+
+ private void handleStreamException(RPCResponse rpc, Exception e, String error)
+ {
+ StreamRPCResponse result = new StreamRPCResponse();
+ result.setFileName(sFileName);
+ result.setCorrelationID(iInitialCorrID);
+ if (rpc != null)
+ {
+ result.setSuccess(rpc.getSuccess());
+ result.setResultCode(rpc.getResultCode());
+ result.setInfo(rpc.getInfo());
+ }
+ else
+ {
+ result.setSuccess(false);
+ result.setResultCode(Result.GENERIC_ERROR);
+ String sException = "";
+
+ if (e != null)
+ sException = sException + " " + e.toString();
+
+ sException = sException + " " + error;
+ result.setInfo(sException);
+ }
+ if (_proxyListener != null)
+ _proxyListener.onStreamRPCResponse(result);
+ if (e != null)
+ e.printStackTrace();
+ stop();
+ _proxy.remPutFileResponseListener(this);
+ return;
}
- public void run() {
+ @Override
+ public void pause() {
+ synchronized (mPauseLock) {
+ mPaused = true;
+ }
+ }
+
+ @Override
+ public void resume() {
+ synchronized (mPauseLock) {
+ mPaused = false;
+ mPauseLock.notifyAll();
+ }
+ }
+
+ public void run() {
int length;
+ byte[] msgBytes;
+ ProtocolMessage pm;
+ OnStreamRPC notification;
+ // Moves the current Thread into the background
+ android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
try {
int iCorrID = 0;
PutFile msg = (PutFile) _request;
- int iOffsetCounter = msg.getOffset();
+ long iOffsetCounter = msg.getOffset();
+ sFileName = msg.getSdlFileName();
+
+ if (lFileSize != 0)
+ {
+ Long iFileSize = (long) lFileSize;
+ //TODO: PutFile RPC needs to be updated to accept Long as we might run into overflows since a Long can store a wider range than an Integer
+ msg.setLength(iFileSize);
+ }
+ Long iFileLength = msg.getLength();
+ notificationList.clear();
+
+ //start reading from the stream at the given offset
+ long iSkipBytes = is.skip(iOffsetCounter);
+
+ if (iOffsetCounter != iSkipBytes)
+ {
+ handleStreamException(null,null," Error, PutFile offset invalid for file: " + sFileName);
+ }
+
while (!Thread.interrupted()) {
+ synchronized (mPauseLock)
+ {
+ while (mPaused)
+ {
+ try
+ {
+ mPauseLock.wait();
+ }
+ catch (InterruptedException e) {}
+ }
+ }
+
length = is.read(buffer, 0, BUFF_READ_SIZE);
if (length == -1)
@@ -56,30 +186,69 @@ public class StreamRPCPacketizer extends AbstractPacketizer implements Runnable{
if (length >= 0) {
if (msg.getOffset() != 0)
- msg.setLength(null); //only need to send length when offset 0
+ msg.setLength((Long)null); //only need to send length when offset 0
- byte[] msgBytes = JsonRPCMarshaller.marshall(msg, _wiproVersion);
- ProtocolMessage pm = new ProtocolMessage();
+ msgBytes = JsonRPCMarshaller.marshall(msg, _wiproVersion);
+ pm = new ProtocolMessage();
pm.setData(msgBytes);
pm.setSessionID(_rpcSessionID);
pm.setMessageType(MessageType.RPC);
pm.setSessionType(_session);
- pm.setFunctionID(FunctionID.getFunctionID(msg.getFunctionName()));
+ pm.setFunctionID(FunctionID.getFunctionId(msg.getFunctionName()));
- pm.setBulkData(buffer, length);
+ if (buffer.length != length)
+ pm.setBulkData(buffer, length);
+ else
+ pm.setBulkDataNoCopy(buffer);
+
pm.setCorrID(msg.getCorrelationID());
- _streamListener.sendStreamPacket(pm);
-
+ notification = new OnStreamRPC();
+ notification.setFileName(msg.getSdlFileName());
+ notification.setFileSize(iFileLength);
iOffsetCounter = iOffsetCounter + length;
+ notification.setBytesComplete(iOffsetCounter);
+ notificationList.put(msg.getCorrelationID(),notification);
+
msg.setOffset(iOffsetCounter);
iCorrID = msg.getCorrelationID() + 1;
msg.setCorrelationID(iCorrID);
+
+ _streamListener.sendStreamPacket(pm);
}
}
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ handleStreamException(null, e, "");
+ }
+ }
+
+ @Override
+ public void onPutFileResponse(PutFileResponse response)
+ {
+ OnStreamRPC streamNote = notificationList.get(response.getCorrelationID());
+ if (streamNote == null) return;
+
+ if (response.getSuccess())
+ {
+ if (_proxyListener != null)
+ _proxyListener.onOnStreamRPC(streamNote);
+ }
+ else
+ {
+ handleStreamException(response, null, "");
+ }
+
+ if (response.getSuccess() && streamNote.getBytesComplete().equals(streamNote.getFileSize()) )
+ {
+ handleStreamSuccess(response, streamNote.getBytesComplete());
}
}
+
+ @Override
+ public void onPutFileStreamError(Exception e, String info)
+ {
+ if (thread != null)
+ handleStreamException(null, e, info);
+ }
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/Mime.java b/sdl_android_lib/src/com/smartdevicelink/trace/Mime.java
index 514cd4d36..026f31721 100644
--- a/sdl_android_lib/src/com/smartdevicelink/trace/Mime.java
+++ b/sdl_android_lib/src/com/smartdevicelink/trace/Mime.java
@@ -13,13 +13,13 @@ public class Mime {
b64String = base64Encode(strBytes);
} catch (Exception ex) {
// Don't care?
- } // end-catch
+ }
return b64String;
- } // end-method
+ }
public static String base64Encode(byte bytesToEncode[]) {
return base64Encode(bytesToEncode, 0, bytesToEncode.length);
- } // end-method
+ }
public static String base64Encode(byte bytesToEncode[], int offset, int length) {
StringBuilder sb = new StringBuilder();
@@ -42,9 +42,9 @@ public class Mime {
sb.append(m_base64Chars.charAt(b64idx));
b64idx = bytesToEncode[idxin] & 0x3f;
break;
- } // end-switch
+ }
sb.append(m_base64Chars.charAt(b64idx));
- } // end-for
+ }
switch ((idxin-offset) % 3) {
case 0:
@@ -59,128 +59,7 @@ public class Mime {
sb.append(m_base64Chars.charAt(b64idx));
sb.append('=');
break;
- } // end-switch
-
+ }
return sb.toString();
-
- } // end-method
-
- @SuppressWarnings("unused")
- private byte[] base64Decode(String base64String) {
- byte[] outBytes = null;
- byte[] base64ASCIIString = null;
- final String ASCII_Encoding = "US-ASCII";
-
- // Convert b64 string to raw bytes
- try {
- base64ASCIIString = base64String.getBytes(ASCII_Encoding);
- } catch (Exception ex) {
- return null;
- }
-
- if (!m_decodeInitComplete) {
- m_decodeInitComplete = true;
- initForDecode();
- } // end-if
-
- int numInChars = base64ASCIIString.length;
-
- if ((numInChars % 4) > 0) {
- return null;
- } // end-if
-
- int numOutBytes = base64ASCIIString.length / 4;
- numOutBytes *= 3;
- int eqpos = base64String.indexOf("=");
- if (eqpos >= 0) {
- numOutBytes--;
- if (base64String.substring(eqpos).indexOf("==") >= 0) {
- numOutBytes--;
- } // end-if
- } // end-if
- outBytes = new byte[numOutBytes];
-
- byte b64idxbits = 0x00;
- int iidx = 0, oidx = 0;
- byte writeByte = 0x00;
- byte b64ASCIIChar = 0x00;
- for (iidx=0, oidx=0;iidx < numInChars;iidx++) {
- b64ASCIIChar = base64ASCIIString[iidx];
- if (b64ASCIIChar == 0x3d /*'='*/) {
- return outBytes;
- } // end-if
-
- if (!isb64char(b64ASCIIChar)) {
- return null;
- } // end-if
-
- switch (iidx % 4) {
- case 0:
- break;
- case 1:
- b64idxbits = b64decode[base64ASCIIString[iidx-1]];
- writeByte = (byte)((b64idxbits << 2) | ((b64decode[b64ASCIIChar] >> 4) & 0x03));
- outBytes[oidx++] = writeByte;
- break;
- case 2:
- b64idxbits = b64decode[base64ASCIIString[iidx-1]];
- writeByte = (byte)(((b64idxbits << 4) & 0xf0) | ((b64decode[b64ASCIIChar] >> 2) & 0x0f));
- outBytes[oidx++] = writeByte;
- break;
- case 3:
- b64idxbits = b64decode[base64ASCIIString[iidx-1]];
- writeByte = (byte)(((b64idxbits << 6) & 0xc0) | ((b64decode[b64ASCIIChar]) & 0x3f));
- outBytes[oidx++] = writeByte;
- break;
- } // end-switch
- } // end-for
-
- return outBytes;
-
- } // end-method
-
-
- private static byte[] b64decode = new byte[256];
- // A-Z is 0x41-0x5a
- // a-z is 0x61-0x7a
- // 0-9 is 0x30-0x39
- // + is 0x2b
- // / is 0x2f
-
- private static boolean m_decodeInitComplete = false;
-
- private void initForDecode() {
- int aidx = 0;
- int lidx = 0;
- // Set A-Z
- for (aidx=0x41, lidx=0;aidx <= 0x5a;aidx++, lidx++) {
- b64decode[aidx] = (byte)lidx;
- } // end-for
- // Set a-z
- for (aidx=0x61;aidx <= 0x7a;aidx++, lidx++) {
- b64decode[aidx] = (byte)lidx;
- } // end-for
- // Set 0-9
- for (aidx=0x30;aidx <= 0x39;aidx++, lidx++) {
- b64decode[aidx] = (byte)lidx;
- } // end-for
- // Set '+'
- b64decode[0x2b] = (byte)lidx++;
- // Set '/'
- b64decode[0x2f] = (byte)lidx++;
- } // end-method
-
- private boolean isb64char(byte b) {
- // A-Z is 0x41-0x5a
- // a-z is 0x61-0x7a
- // 0-9 is 0x30-0x39
- // + is 0x2b
- // / is 0x2f
- return ( (b >= 0x41 && b <= 0x5a)
- || (b >= 0x61 && b <= 0x7a)
- || (b >= 0x30 && b <= 0x39)
- || (b == 0x2b)
- || (b == 0x2f)
- );
- } // end-method
-} // end-class \ No newline at end of file
+ }
+} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java b/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java
index 4cc6c1381..0528cd9e9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java
+++ b/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java
@@ -1,471 +1,454 @@
-package com.smartdevicelink.trace;
-
-import java.sql.Timestamp;
-import android.annotation.SuppressLint;
-import android.bluetooth.BluetoothDevice;
-import android.os.Build;
-import android.os.Debug;
-import android.os.Process;
-import com.smartdevicelink.protocol.ProtocolFrameHeader;
-import com.smartdevicelink.protocol.enums.FrameDataControlFrameType;
-import com.smartdevicelink.protocol.enums.FrameType;
-import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.proxy.RPCMessage;
-import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.RPCResponse;
-import com.smartdevicelink.trace.enums.DetailLevel;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
-import com.smartdevicelink.trace.enums.Mod;
-import com.smartdevicelink.transport.SiphonServer;
-import com.smartdevicelink.util.BitConverter;
-import com.smartdevicelink.util.LogTool;
-
-/* This class handles the global TraceSettings as requested by the users either through the combination of the following
- 1. System defaults
- 2. Application XML config
- 3. Programmatic requests from application itself
-
- It is manifested in the <SmartDeviceLink>...</SmartDeviceLink> tags
- */
-
-@SuppressLint("DefaultLocale")
-public class SdlTrace {
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
-
- static boolean canWriteLogs = false;
-
- public static final String SYSTEM_LOG_TAG = "SdlTrace";
-
- private static long baseTics = java.lang.System.currentTimeMillis();
- private final static String KeyStr = SDL_LIB_TRACE_KEY;
- private static boolean acceptAPITraceAdjustments = true;
-
- protected static ISTListener m_appTraceListener = null;
-
- ///
- /// The PUBLIC interface to SdlTrace starts here
- ///
-
-
- public static void setAcceptAPITraceAdjustments(Boolean APITraceAdjustmentsAccepted) {
- if (APITraceAdjustmentsAccepted != null) {
- acceptAPITraceAdjustments = APITraceAdjustmentsAccepted;
- }
- }
-
- public static boolean getAcceptAPITraceAdjustments() {
- return acceptAPITraceAdjustments;
- }
-
- public static void setAppTraceListener(ISTListener listener) {
- m_appTraceListener = listener;
- } // end-method
-
- public static void setTracingEnable(Boolean enable) {
- if (enable != null) {
- canWriteLogs = enable;
- }
- } // end-method
-
- public static void setAppTraceLevel(DetailLevel dt) {
- if ( dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.app, dt);
- } // end-method
-
- public static void setProxyTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.proxy, dt);
- } // end-method
-
- public static void setRpcTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.rpc, dt);
- } // end-method
-
- public static void setMarshallingTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.mar, dt);
- } // end-method
-
- public static void setProtocolTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.proto, dt);
- } // end-method
-
- public static void setTransportTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.tran, dt);
- } // end-method
-
- private static String encodeTraceMessage(long timestamp, Mod module, InterfaceActivityDirection msgDirection, String msgBodyXml) {
- StringBuilder sb = new StringBuilder("<msg><dms>");
- sb.append(timestamp);
- sb.append("</dms><pid>");
- sb.append(Process.myPid());
- sb.append("</pid><tid>");
- sb.append(Thread.currentThread().getId());
- sb.append("</tid><mod>");
- sb.append(module.toString());
- sb.append("</mod>");
- if (msgDirection != InterfaceActivityDirection.None) {
- sb.append("<dir>");
- sb.append(interfaceActivityDirectionToString(msgDirection));
- sb.append("</dir>");
- } // end-if
- sb.append(msgBodyXml);
- sb.append("</msg>");
-
- return sb.toString();
- } // end-method
-
- private static String interfaceActivityDirectionToString(InterfaceActivityDirection iaDirection) {
- String str = "";
- switch (iaDirection) {
- case Receive:
- str = "rx";
- break;
- case Transmit:
- str = "tx";
- break;
- default:
- break;
- } // end-switch
- return str;
- } // end-method
-
- static String B64EncodeForXML(String data) {
- return Mime.base64Encode(data);
- // Base64 only available in 2.2, when SmartDeviceLink base is 2.2 use: return Base64.encodeToString(data.getBytes(), Base64.DEFAULT);
- } // end-method
-
- public static void logProxyEvent(String eventText, String token) {
- if (DiagLevel.getLevel(Mod.proxy) == DetailLevel.OFF || !token.equals(KeyStr)) {
- return;
- } // end-if
-
- String msg = SdlTrace.B64EncodeForXML(eventText);
- String xml = SdlTrace.encodeTraceMessage(SdlTrace.getBaseTicsDelta(), Mod.proxy, InterfaceActivityDirection.None, "<d>" + msg + "</d>");
- writeXmlTraceMessage(xml);
- } // end-method
-
- public static void logAppEvent(String eventText) {
- if (DiagLevel.getLevel(Mod.app) == DetailLevel.OFF) {
- return;
- } // end-if
-
- long timestamp = SdlTrace.getBaseTicsDelta();
- String msg = SdlTrace.B64EncodeForXML(eventText);
- String xml = SdlTrace.encodeTraceMessage(timestamp, Mod.app, InterfaceActivityDirection.None, "<d>" + msg + "</d>");
- writeXmlTraceMessage(xml);
- } // end-method
-
- public static void logRPCEvent(InterfaceActivityDirection msgDirection, RPCMessage rpcMsg, String token) {
- DetailLevel dl = DiagLevel.getLevel(Mod.rpc);
- if (dl == DetailLevel.OFF || !token.equals(KeyStr)) {
- return;
- } // end-if
-
- long timestamp = SdlTrace.getBaseTicsDelta();
- String xml = SdlTrace.encodeTraceMessage(timestamp, Mod.rpc, msgDirection, rpc2Xml(dl, rpcMsg));
- writeXmlTraceMessage(xml);
- } // end-method
-
- private static String rpc2Xml(DetailLevel dl, RPCMessage rpcMsg) {
- StringBuilder rpcAsXml = new StringBuilder();
- rpcAsXml.append("<op>");
- rpcAsXml.append(rpcMsg.getFunctionName());
- rpcAsXml.append("</op>");
- boolean hasCorrelationID = false;
- Integer correlationID = -1;
- if (rpcMsg instanceof RPCRequest) {
- hasCorrelationID = true;
- correlationID = ((RPCRequest)rpcMsg).getCorrelationID();
- } else if (rpcMsg instanceof RPCResponse) {
- hasCorrelationID = true;
- correlationID = ((RPCResponse)rpcMsg).getCorrelationID();
- } // end-if
- if (hasCorrelationID) {
- rpcAsXml.append("<cid>");
- rpcAsXml.append(correlationID);
- rpcAsXml.append("</cid>");
- } // end-if
- rpcAsXml.append("<type>");
- rpcAsXml.append(rpcMsg.getMessageType());
- rpcAsXml.append("</type>");
- //rpcAsXml.append(newline);
-
- if (dl == DetailLevel.VERBOSE) {
- OpenRPCMessage orpcmsg = new OpenRPCMessage(rpcMsg);
- String rpcParamList = orpcmsg.msgDump();
- String msg = SdlTrace.B64EncodeForXML(rpcParamList);
- rpcAsXml.append("<d>");
- rpcAsXml.append(msg);
- rpcAsXml.append("</d>");
- } // end-if
- return rpcAsXml.toString();
- } // end-method
-
- public static void logMarshallingEvent(InterfaceActivityDirection msgDirection, byte[] marshalledMessage, String token) {
- DetailLevel dl = DiagLevel.getLevel(Mod.mar);
- if (dl == DetailLevel.OFF || !token.equals(KeyStr)) {
- return;
- } // end-fif
-
- long timestamp = SdlTrace.getBaseTicsDelta();
- StringBuilder msg = new StringBuilder();
- msg.append("<sz>");
- msg.append(marshalledMessage.length);
- msg.append("</sz>");
- if (dl == DetailLevel.VERBOSE) {
- msg.append("<d>");
- msg.append(Mime.base64Encode(marshalledMessage));
- // Base64 only available in 2.2, when SmartDeviceLink base is 2.2 use: msg.append(Base64.encodeToString(marshalledMessage, Base64.DEFAULT));
- msg.append("</d>");
- } // end-if
- String xml = SdlTrace.encodeTraceMessage(timestamp, Mod.mar, msgDirection, msg.toString());
- writeXmlTraceMessage(xml);
- } // end-method
-
- public static void logProtocolEvent(InterfaceActivityDirection frameDirection, ProtocolFrameHeader frameHeader, byte[] frameData, int frameDataOffset, int frameDataLength, String token) {
- DetailLevel dl = DiagLevel.getLevel(Mod.proto);
- if (dl == DetailLevel.OFF || !token.equals(KeyStr)) {
- return;
- } // end-if
-
- StringBuffer protoMsg = new StringBuffer();
- protoMsg.append("<frame>");
- protoMsg.append(SdlTrace.getProtocolFrameHeaderInfo(frameHeader, frameData));
- if (dl == DetailLevel.VERBOSE) {
- if (frameData != null && frameDataLength > 0) {
- protoMsg.append("<d>");
- String bytesInfo = "";
- bytesInfo = Mime.base64Encode(frameData, frameDataOffset, frameDataLength);
- // Base64 only available in 2.2, when SmartDeviceLink base is 2.2 use: bytesInfo = Base64.encodeToString(frameData, frameDataOffset, frameDataLength, Base64.DEFAULT);
- protoMsg.append(bytesInfo);
- protoMsg.append("</d>");
- } // end-if
- } // end-if
- protoMsg.append("</frame>");
- String xml = SdlTrace.encodeTraceMessage(SdlTrace.getBaseTicsDelta(), Mod.proto, frameDirection, protoMsg.toString());
- writeXmlTraceMessage(xml);
- } // end-method
-
- private static String getProtocolFrameType(FrameType f) {
- if (f == FrameType.Control)
- return "Control";
- else if (f == FrameType.Consecutive)
- return "Consecutive";
- else if (f == FrameType.First)
- return "First";
- else if (f == FrameType.Single)
- return "Single";
-
- return "Unknown";
- } // end-method
-
- private static String getProtocolSessionType(SessionType serviceType) {
- String s;
- if (serviceType == SessionType.RPC )
- s = "rpc";
- else if (serviceType == SessionType.Bulk_Data)
- s = "bulk";
- else
- s = "Unknown";
- return s;
- } // end-method
-
- private static String getProtocolFrameHeaderInfo(ProtocolFrameHeader hdr, byte[] buf) {
- StringBuilder sb = new StringBuilder();
- sb.append("<hdr>");
- sb.append("<ver>");
- sb.append(hdr.getVersion());
- sb.append("</ver><cmp>");
- sb.append(hdr.isCompressed());
- sb.append("</cmp><ft>");
- sb.append(getProtocolFrameType(hdr.getFrameType()));
- sb.append("</ft><st>");
- sb.append(getProtocolSessionType(hdr.getSessionType()));
- sb.append("</st><sid>");
- sb.append(hdr.getSessionID());
- sb.append("</sid><sz>");
- sb.append(hdr.getDataSize());
- sb.append("</sz>");
-
- int frameData = hdr.getFrameData();
- if (hdr.getFrameType() == FrameType.Control) {
- sb.append("<ca>");
- if (frameData == FrameDataControlFrameType.StartSession.getValue())
- sb.append("StartSession");
- else if (frameData == FrameDataControlFrameType.StartSessionACK.getValue())
- sb.append("StartSessionACK");
- else if (frameData == FrameDataControlFrameType.StartSessionNACK.getValue())
- sb.append("StartSessionNACK");
- else if (frameData == FrameDataControlFrameType.EndSession.getValue())
- sb.append("EndSession");
- sb.append("</ca>");
- } else if (hdr.getFrameType() == FrameType.Consecutive ) {
- sb.append("<fsn>");
- if (frameData == 0 )
- sb.append("lastFrame");
- else
- sb.append(String.format("%02X",frameData));
- sb.append("</fsn>");
- } else if (hdr.getFrameType() == FrameType.First ) {
- int totalSize = BitConverter.intFromByteArray(buf, 0);
- int numFrames = BitConverter.intFromByteArray(buf, 4);
- sb.append("<total>" + totalSize + "</total><numframes>" + numFrames + "</numframes>");
- } else if (hdr.getFrameType() == FrameType.Single ) {
- sb.append("<single/>");
- }
-
- sb.append("</hdr>");
-
- return sb.toString();
- } // end-method
-
- public static String getBTDeviceInfo(BluetoothDevice btDevice) {
- StringBuilder sb = new StringBuilder();
- sb.append("<btp>");
- String btdn = btDevice.getName();
- sb.append("<btn>");
- sb.append(SdlTrace.B64EncodeForXML(btdn));
- sb.append("</btn>");
- sb.append("<bta>" + btDevice.getAddress() + "</bta>");
- sb.append("<bts>" + btDevice.getBondState() + "</bts>");
- sb.append("</btp>");
- return sb.toString();
- } // end-method
-
- public static void logTransportEvent(String preamble, String transportSpecificInfoXml, InterfaceActivityDirection msgDirection, byte buf[], int byteLength, String token) {
- logTransportEvent(preamble, transportSpecificInfoXml, msgDirection, buf, 0, byteLength, token);
- } // end-method
-
- private static void checkB64(String x, byte[] buf, int offset, int byteLength) {
- if ((x.length() % 4) != 0) {
- LogTool.logWarning(SdlTrace.SYSTEM_LOG_TAG, "b64 string length (" + x.length() + ") isn't multiple of 4: buf.length=" + buf.length + ", offset=" + offset + ", len=" + byteLength);
- } // end-if
- } // end-method
-
- public static void logTransportEvent(String preamble, String transportSpecificInfoXml, InterfaceActivityDirection msgDirection, byte buf[], int offset, int byteLength, String token) {
- if (DiagLevel.getLevel(Mod.tran) == DetailLevel.OFF || !token.equals(KeyStr)) {
- return;
- } // end-if
-
- StringBuilder msg = new StringBuilder();
- if (transportSpecificInfoXml != null && transportSpecificInfoXml.length() > 0) {
- msg.append(transportSpecificInfoXml);
- } // end-if
- if (preamble != null && preamble.length() > 0) {
- msg.append("<desc>");
- msg.append(preamble);
- msg.append("</desc>");
- } // end-if
- if (buf != null) {
- msg.append("<sz>");
- msg.append(byteLength);
- msg.append("</sz>");
- DetailLevel dl = DiagLevel.getLevel(Mod.tran);
- if (dl == DetailLevel.VERBOSE) {
- if (buf != null && byteLength > 0) {
- msg.append("<d>");
- String bytesInfo = Mime.base64Encode(buf, offset, byteLength);
- checkB64(bytesInfo, buf, offset, byteLength);
- msg.append(bytesInfo);
- msg.append("</d>");
- } // end-if
- } // end-if
- } // end-if
- String xml = SdlTrace.encodeTraceMessage(SdlTrace.getBaseTicsDelta(), Mod.tran, msgDirection, msg.toString());
- writeXmlTraceMessage(xml);
- } // end-method
-
- // Package-scoped
- static long getBaseTicsDelta() {
- return java.lang.System.currentTimeMillis() - getBaseTics();
- }
-
- // Package-scoped
- static long getBaseTics() {
- return baseTics;
- } // end-method
-
- public static Boolean writeMessageToSiphonServer(String info) {
- return SiphonServer.sendFormattedTraceMessage(info);
- }
-
- private static void writeXmlTraceMessage(String msg) {
- try {
- // Attempt to write formatted message to the Siphon
- if (false == writeMessageToSiphonServer(msg)) {
- // If writing to the Siphon fails, write to the native log
- LogTool.logInfo(SdlTrace.SYSTEM_LOG_TAG, msg);
- }
-
- ISTListener localTraceListener = m_appTraceListener;
-
- if (localTraceListener != null) {
- try {
- localTraceListener.logXmlMsg(msg, KeyStr);
- } catch (Exception ex) {
- LogTool.logError("Failure calling ISTListener: " + ex.toString(), ex);
- } // end-catch
- } // end-if
- } catch (Exception ex) {
- LogTool.logError(SdlTrace.SYSTEM_LOG_TAG, "Failure writing XML trace message: " + ex.toString());
- }
- } // end-method
-
- // Package-scoped
- @SuppressWarnings("deprecation")
- public static String getLogHeader(String dumpReason, int seqNo) {
- final String Sep = "-";
- StringBuilder write = new StringBuilder("<?xml version=\"1.0\"?>" + "<logs>");
- write.append("<info>");
- StringBuilder infoBlock = new StringBuilder();
- String hostInfo = Build.BRAND + Sep + Build.MANUFACTURER + Sep + Build.MODEL + "(" + Build.HOST + ")";
- infoBlock.append("<host>" + SdlTrace.B64EncodeForXML(hostInfo) + "</host>");
- String osv = Build.VERSION.RELEASE + " (" + Build.VERSION.CODENAME + ")";
- infoBlock.append("<osv>" + SdlTrace.B64EncodeForXML(osv) + "</osv>");
- infoBlock.append(TraceDeviceInfo.getTelephonyHeader());
-
- long heapSize = Debug.getNativeHeapFreeSize() / 1024;
- long heapAllocated = Debug.getNativeHeapAllocatedSize() / 1024;
- infoBlock.append("<mem><hf>" + heapSize + "KB</hf><ha>" + heapAllocated + "KB</ha></mem>");
- infoBlock.append("<np>" + Runtime.getRuntime().availableProcessors() + "</np>");
- infoBlock.append("<pid>" + Process.myPid() + "</pid>");
- infoBlock.append("<tid>" + Thread.currentThread().getId() + "</tid>");
-
- // String dateStamp = (String)
- // DateFormat.format("yy-MM-dd hh:mm:ss SSS", new Timestamp(baseTics));
- Timestamp stamp = new Timestamp(SdlTrace.getBaseTics());
- String GMTtime = stamp.toGMTString().substring(0, 19);
- long fracSec = stamp.getNanos() / 1000000; // divide by a million
- String fracSecStr = String.format("%03d", fracSec);
- infoBlock.append("<utc>" + GMTtime + "." + fracSecStr + "</utc>");
-
- infoBlock.append(TraceDeviceInfo.getLogHeaderBluetoothPairs());
- infoBlock.append(getSmartDeviceLinkTraceRoot(dumpReason, seqNo));
-
- write.append(infoBlock);
-
- write.append("</info>" + "<msgs>");
- return write.toString();
- } // end-method
-
- private static String getSmartDeviceLinkTraceRoot(String dumpReason, int seqNo) {
- StringBuilder write = new StringBuilder("<SmartDeviceLinktraceroot>" + "<sequencenum>" + seqNo
- + "</sequencenum>" + "<dumpreason>" + dumpReason
- + "</dumpreason><tracelevel>");
-
- write.append("<tran>" + DiagLevel.getLevel(Mod.tran) + "</tran>");
- write.append("<proto>" + DiagLevel.getLevel(Mod.proto) + "</proto>");
- write.append("<mar>" + DiagLevel.getLevel(Mod.mar) + "</mar>");
- write.append("<rpc>" + DiagLevel.getLevel(Mod.rpc) + "</rpc>");
- write.append("<proxy>" + DiagLevel.getLevel(Mod.proxy) + "</proxy>");
- write.append("<app>" + DiagLevel.getLevel(Mod.app) + "</app>");
-
- write.append("</tracelevel>");
- write.append("</SmartDeviceLinktraceroot>");
- return write.toString();
- } // end-method
+package com.smartdevicelink.trace;
+
+import java.sql.Timestamp;
+
+import android.annotation.SuppressLint;
+import android.bluetooth.BluetoothDevice;
+import android.os.Build;
+import android.os.Debug;
+import android.os.Process;
+
+import com.smartdevicelink.protocol.ProtocolFrameHeader;
+import com.smartdevicelink.protocol.enums.FrameDataControlFrameType;
+import com.smartdevicelink.protocol.enums.FrameType;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.RPCResponse;
+import com.smartdevicelink.trace.enums.DetailLevel;
+import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
+import com.smartdevicelink.trace.enums.Mod;
+import com.smartdevicelink.util.BitConverter;
+import com.smartdevicelink.util.SdlLog;
+
+/* This class handles the global TraceSettings as requested by the users either through the combination of the following
+ 1. System defaults
+ 2. Application XML config
+ 3. Programmatic requests from application itself
+
+ It is manifested in the <SmartDeviceLink>...</SmartDeviceLink> tags
+ */
+
+@SuppressLint("DefaultLocale")
+public class SdlTrace {
+ private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
+
+ public static final String SYSTEM_LOG_TAG = "SdlTrace";
+
+ private static long baseTics = java.lang.System.currentTimeMillis();
+ private static boolean acceptAPITraceAdjustments = true;
+
+ protected static ISTListener m_appTraceListener = null;
+
+ ///
+ /// The PUBLIC interface to SdlTrace starts here
+ ///
+
+
+ public static void setAcceptAPITraceAdjustments(Boolean APITraceAdjustmentsAccepted) {
+ if (APITraceAdjustmentsAccepted != null) {
+ acceptAPITraceAdjustments = APITraceAdjustmentsAccepted;
+ }
+ }
+
+ public static boolean getAcceptAPITraceAdjustments() {
+ return acceptAPITraceAdjustments;
+ }
+
+ public static void setAppTraceListener(ISTListener listener) {
+ m_appTraceListener = listener;
+ } // end-method
+
+ public static void setAppTraceLevel(DetailLevel dt) {
+ if ( dt != null && acceptAPITraceAdjustments)
+ DiagLevel.setLevel(Mod.app, dt);
+ } // end-method
+
+ public static void setProxyTraceLevel(DetailLevel dt) {
+ if (dt != null && acceptAPITraceAdjustments)
+ DiagLevel.setLevel(Mod.proxy, dt);
+ } // end-method
+
+ public static void setRpcTraceLevel(DetailLevel dt) {
+ if (dt != null && acceptAPITraceAdjustments)
+ DiagLevel.setLevel(Mod.rpc, dt);
+ } // end-method
+
+ public static void setMarshallingTraceLevel(DetailLevel dt) {
+ if (dt != null && acceptAPITraceAdjustments)
+ DiagLevel.setLevel(Mod.mar, dt);
+ } // end-method
+
+ public static void setProtocolTraceLevel(DetailLevel dt) {
+ if (dt != null && acceptAPITraceAdjustments)
+ DiagLevel.setLevel(Mod.proto, dt);
+ } // end-method
+
+ public static void setTransportTraceLevel(DetailLevel dt) {
+ if (dt != null && acceptAPITraceAdjustments)
+ DiagLevel.setLevel(Mod.tran, dt);
+ } // end-method
+
+ private static String encodeTraceMessage(long timestamp, Mod module, InterfaceActivityDirection msgDirection, String msgBodyXml) {
+ StringBuilder sb = new StringBuilder("<msg><dms>");
+ sb.append(timestamp);
+ sb.append("</dms><pid>");
+ sb.append(Process.myPid());
+ sb.append("</pid><tid>");
+ sb.append(Thread.currentThread().getId());
+ sb.append("</tid><mod>");
+ sb.append(module.toString());
+ sb.append("</mod>");
+ if (msgDirection != InterfaceActivityDirection.None) {
+ sb.append("<dir>");
+ sb.append(interfaceActivityDirectionToString(msgDirection));
+ sb.append("</dir>");
+ } // end-if
+ sb.append(msgBodyXml);
+ sb.append("</msg>");
+
+ return sb.toString();
+ } // end-method
+
+ private static String interfaceActivityDirectionToString(InterfaceActivityDirection iaDirection) {
+ String str = "";
+ switch (iaDirection) {
+ case Receive:
+ str = "rx";
+ break;
+ case Transmit:
+ str = "tx";
+ break;
+ default:
+ break;
+ } // end-switch
+ return str;
+ } // end-method
+
+ static String B64EncodeForXML(String data) {
+ return Mime.base64Encode(data);
+ // Base64 only available in 2.2, when SmartDeviceLink base is 2.2 use: return Base64.encodeToString(data.getBytes(), Base64.DEFAULT);
+ } // end-method
+
+ public static boolean logProxyEvent(String eventText, String token) {
+ if (DiagLevel.getLevel(Mod.proxy) == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
+ return false;
+ }
+
+ String msg = SdlTrace.B64EncodeForXML(eventText);
+ String xml = SdlTrace.encodeTraceMessage(SdlTrace.getBaseTicsDelta(), Mod.proxy, InterfaceActivityDirection.None, "<d>" + msg + "</d>");
+ return writeXmlTraceMessage(xml);
+ }
+
+ public static boolean logAppEvent(String eventText) {
+ if (DiagLevel.getLevel(Mod.app) == DetailLevel.OFF) {
+ return false;
+ }
+
+ long timestamp = SdlTrace.getBaseTicsDelta();
+ String msg = SdlTrace.B64EncodeForXML(eventText);
+ String xml = SdlTrace.encodeTraceMessage(timestamp, Mod.app, InterfaceActivityDirection.None, "<d>" + msg + "</d>");
+ return writeXmlTraceMessage(xml);
+ }
+
+ public static boolean logRPCEvent(InterfaceActivityDirection msgDirection, RPCMessage rpcMsg, String token) {
+ DetailLevel dl = DiagLevel.getLevel(Mod.rpc);
+ if (dl == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
+ return false;
+ }
+
+ long timestamp = SdlTrace.getBaseTicsDelta();
+ String xml = SdlTrace.encodeTraceMessage(timestamp, Mod.rpc, msgDirection, rpc2Xml(dl, rpcMsg));
+ return writeXmlTraceMessage(xml);
+ }
+
+ private static String rpc2Xml(DetailLevel dl, RPCMessage rpcMsg) {
+ StringBuilder rpcAsXml = new StringBuilder();
+ rpcAsXml.append("<op>");
+ rpcAsXml.append(rpcMsg.getFunctionName());
+ rpcAsXml.append("</op>");
+ boolean hasCorrelationID = false;
+ Integer correlationID = -1;
+ if (rpcMsg instanceof RPCRequest) {
+ hasCorrelationID = true;
+ correlationID = ((RPCRequest)rpcMsg).getCorrelationID();
+ } else if (rpcMsg instanceof RPCResponse) {
+ hasCorrelationID = true;
+ correlationID = ((RPCResponse)rpcMsg).getCorrelationID();
+ } // end-if
+ if (hasCorrelationID) {
+ rpcAsXml.append("<cid>");
+ rpcAsXml.append(correlationID);
+ rpcAsXml.append("</cid>");
+ } // end-if
+ rpcAsXml.append("<type>");
+ rpcAsXml.append(rpcMsg.getMessageType());
+ rpcAsXml.append("</type>");
+ //rpcAsXml.append(newline);
+
+ if (dl == DetailLevel.VERBOSE) {
+ OpenRPCMessage orpcmsg = new OpenRPCMessage(rpcMsg);
+ String rpcParamList = orpcmsg.msgDump();
+ String msg = SdlTrace.B64EncodeForXML(rpcParamList);
+ rpcAsXml.append("<d>");
+ rpcAsXml.append(msg);
+ rpcAsXml.append("</d>");
+ } // end-if
+ return rpcAsXml.toString();
+ } // end-method
+
+ public static boolean logMarshallingEvent(InterfaceActivityDirection msgDirection, byte[] marshalledMessage, String token) {
+ DetailLevel dl = DiagLevel.getLevel(Mod.mar);
+ if (dl == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
+ return false;
+ }
+
+ long timestamp = SdlTrace.getBaseTicsDelta();
+ StringBuilder msg = new StringBuilder();
+ msg.append("<sz>");
+ msg.append(marshalledMessage.length);
+ msg.append("</sz>");
+ if (dl == DetailLevel.VERBOSE) {
+ msg.append("<d>");
+ msg.append(Mime.base64Encode(marshalledMessage));
+ // Base64 only available in 2.2, when SmartDeviceLink base is 2.2 use: msg.append(Base64.encodeToString(marshalledMessage, Base64.DEFAULT));
+ msg.append("</d>");
+ }
+ String xml = SdlTrace.encodeTraceMessage(timestamp, Mod.mar, msgDirection, msg.toString());
+ return writeXmlTraceMessage(xml);
+ }
+
+ public static boolean logProtocolEvent(InterfaceActivityDirection frameDirection, ProtocolFrameHeader frameHeader, byte[] frameData, int frameDataOffset, int frameDataLength, String token) {
+ DetailLevel dl = DiagLevel.getLevel(Mod.proto);
+ if (dl == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
+ return false;
+ }
+
+ StringBuffer protoMsg = new StringBuffer();
+ protoMsg.append("<frame>");
+ protoMsg.append(SdlTrace.getProtocolFrameHeaderInfo(frameHeader, frameData));
+ if (dl == DetailLevel.VERBOSE) {
+ if (frameData != null && frameDataLength > 0) {
+ protoMsg.append("<d>");
+ String bytesInfo = "";
+ bytesInfo = Mime.base64Encode(frameData, frameDataOffset, frameDataLength);
+ // Base64 only available in 2.2, when SmartDeviceLink base is 2.2 use: bytesInfo = Base64.encodeToString(frameData, frameDataOffset, frameDataLength, Base64.DEFAULT);
+ protoMsg.append(bytesInfo);
+ protoMsg.append("</d>");
+ }
+ }
+ protoMsg.append("</frame>");
+ String xml = SdlTrace.encodeTraceMessage(SdlTrace.getBaseTicsDelta(), Mod.proto, frameDirection, protoMsg.toString());
+ return writeXmlTraceMessage(xml);
+ }
+
+ private static String getProtocolFrameType(FrameType f) {
+ if (f == FrameType.Control)
+ return "Control";
+ else if (f == FrameType.Consecutive)
+ return "Consecutive";
+ else if (f == FrameType.First)
+ return "First";
+ else if (f == FrameType.Single)
+ return "Single";
+
+ return "Unknown";
+ } // end-method
+
+ private static String getProtocolSessionType(SessionType serviceType) {
+ String s;
+ if (serviceType == SessionType.RPC )
+ s = "rpc";
+ else if (serviceType == SessionType.BULK_DATA)
+ s = "bulk";
+ else
+ s = "Unknown";
+ return s;
+ } // end-method
+
+ private static String getProtocolFrameHeaderInfo(ProtocolFrameHeader hdr, byte[] buf) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<hdr>");
+ sb.append("<ver>");
+ sb.append(hdr.getVersion());
+ sb.append("</ver><cmp>");
+ sb.append(hdr.isCompressed());
+ sb.append("</cmp><ft>");
+ sb.append(getProtocolFrameType(hdr.getFrameType()));
+ sb.append("</ft><st>");
+ sb.append(getProtocolSessionType(hdr.getSessionType()));
+ sb.append("</st><sid>");
+ sb.append(hdr.getSessionID());
+ sb.append("</sid><sz>");
+ sb.append(hdr.getDataSize());
+ sb.append("</sz>");
+
+ int frameData = hdr.getFrameData();
+ if (hdr.getFrameType() == FrameType.Control) {
+ sb.append("<ca>");
+ if (frameData == FrameDataControlFrameType.StartSession.getValue())
+ sb.append("StartSession");
+ else if (frameData == FrameDataControlFrameType.StartSessionACK.getValue())
+ sb.append("StartSessionACK");
+ else if (frameData == FrameDataControlFrameType.StartSessionNACK.getValue())
+ sb.append("StartSessionNACK");
+ else if (frameData == FrameDataControlFrameType.EndSession.getValue())
+ sb.append("EndSession");
+ sb.append("</ca>");
+ } else if (hdr.getFrameType() == FrameType.Consecutive ) {
+ sb.append("<fsn>");
+ if (frameData == 0 )
+ sb.append("lastFrame");
+ else
+ sb.append(String.format("%02X",frameData));
+ sb.append("</fsn>");
+ } else if (hdr.getFrameType() == FrameType.First ) {
+ int totalSize = BitConverter.intFromByteArray(buf, 0);
+ int numFrames = BitConverter.intFromByteArray(buf, 4);
+ sb.append("<total>" + totalSize + "</total><numframes>" + numFrames + "</numframes>");
+ } else if (hdr.getFrameType() == FrameType.Single ) {
+ sb.append("<single/>");
+ }
+
+ sb.append("</hdr>");
+
+ return sb.toString();
+ } // end-method
+
+ public static String getBTDeviceInfo(BluetoothDevice btDevice) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<btp>");
+ String btdn = btDevice.getName();
+ sb.append("<btn>");
+ sb.append(SdlTrace.B64EncodeForXML(btdn));
+ sb.append("</btn>");
+ sb.append("<bta>" + btDevice.getAddress() + "</bta>");
+ sb.append("<bts>" + btDevice.getBondState() + "</bts>");
+ sb.append("</btp>");
+ return sb.toString();
+ } // end-method
+
+ public static boolean logTransportEvent(String preamble, String transportSpecificInfoXml, InterfaceActivityDirection msgDirection, byte buf[], int byteLength, String token) {
+ return logTransportEvent(preamble, transportSpecificInfoXml, msgDirection, buf, 0, byteLength, token);
+ }
+
+ private static void checkB64(String x, byte[] buf, int offset, int byteLength) {
+ if ((x.length() % 4) != 0) {
+ SdlLog.w("b64 string length (" + x.length() + ") isn't multiple of 4: buf.length=" + buf.length + ", offset=" + offset + ", len=" + byteLength);
+ } // end-if
+ } // end-method
+
+ public static boolean logTransportEvent(String preamble, String transportSpecificInfoXml, InterfaceActivityDirection msgDirection, byte buf[], int offset, int byteLength, String token) {
+ if (DiagLevel.getLevel(Mod.tran) == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
+ return false;
+ }
+
+ StringBuilder msg = new StringBuilder();
+ if (transportSpecificInfoXml != null && transportSpecificInfoXml.length() > 0) {
+ msg.append(transportSpecificInfoXml);
+ }
+ if (preamble != null && preamble.length() > 0) {
+ msg.append("<desc>");
+ msg.append(preamble);
+ msg.append("</desc>");
+ }
+ if (buf != null) {
+ msg.append("<sz>");
+ msg.append(byteLength);
+ msg.append("</sz>");
+ DetailLevel dl = DiagLevel.getLevel(Mod.tran);
+ if (dl == DetailLevel.VERBOSE) {
+ if (buf != null && byteLength > 0) {
+ msg.append("<d>");
+ String bytesInfo = Mime.base64Encode(buf, offset, byteLength);
+ checkB64(bytesInfo, buf, offset, byteLength);
+ msg.append(bytesInfo);
+ msg.append("</d>");
+ }
+ }
+ }
+ String xml = SdlTrace.encodeTraceMessage(SdlTrace.getBaseTicsDelta(), Mod.tran, msgDirection, msg.toString());
+ return writeXmlTraceMessage(xml);
+ }
+
+ // Package-scoped
+ static long getBaseTicsDelta() {
+ return java.lang.System.currentTimeMillis() - getBaseTics();
+ }
+
+ // Package-scoped
+ static long getBaseTics() {
+ return baseTics;
+ } // end-method
+
+ private static boolean writeXmlTraceMessage(String msg) {
+ try {
+ ISTListener localTraceListener = m_appTraceListener;
+
+ if (localTraceListener != null) {
+ try {
+ localTraceListener.logXmlMsg(msg, SDL_LIB_TRACE_KEY);
+ } catch (Exception ex) {
+ SdlLog.e("Failure calling ISTListener: " + ex.toString(), ex);
+ }
+ }
+ } catch (Exception ex) {
+ SdlLog.e("Failure writing XML trace message: " + ex);
+ }
+ return true;
+ }
+
+ // Package-scoped
+ @SuppressWarnings("deprecation")
+ public static String getLogHeader(String dumpReason, int seqNo) {
+ final String Sep = "-";
+ StringBuilder write = new StringBuilder("<?xml version=\"1.0\"?>" + "<logs>");
+ write.append("<info>");
+ StringBuilder infoBlock = new StringBuilder();
+ String hostInfo = Build.BRAND + Sep + Build.MANUFACTURER + Sep + Build.MODEL + "(" + Build.HOST + ")";
+ infoBlock.append("<host>" + SdlTrace.B64EncodeForXML(hostInfo) + "</host>");
+ String osv = Build.VERSION.RELEASE + " (" + Build.VERSION.CODENAME + ")";
+ infoBlock.append("<osv>" + SdlTrace.B64EncodeForXML(osv) + "</osv>");
+ infoBlock.append(TraceDeviceInfo.getTelephonyHeader());
+
+ long heapSize = Debug.getNativeHeapFreeSize() / 1024;
+ long heapAllocated = Debug.getNativeHeapAllocatedSize() / 1024;
+ infoBlock.append("<mem><hf>" + heapSize + "KB</hf><ha>" + heapAllocated + "KB</ha></mem>");
+ infoBlock.append("<np>" + Runtime.getRuntime().availableProcessors() + "</np>");
+ infoBlock.append("<pid>" + Process.myPid() + "</pid>");
+ infoBlock.append("<tid>" + Thread.currentThread().getId() + "</tid>");
+
+ // String dateStamp = (String)
+ // DateFormat.format("yy-MM-dd hh:mm:ss SSS", new Timestamp(baseTics));
+ Timestamp stamp = new Timestamp(SdlTrace.getBaseTics());
+ String GMTtime = stamp.toGMTString().substring(0, 19);
+ long fracSec = stamp.getNanos() / 1000000; // divide by a million
+ String fracSecStr = String.format("%03d", fracSec);
+ infoBlock.append("<utc>" + GMTtime + "." + fracSecStr + "</utc>");
+
+ infoBlock.append(TraceDeviceInfo.getLogHeaderBluetoothPairs());
+ infoBlock.append(getSmartDeviceLinkTraceRoot(dumpReason, seqNo));
+
+ write.append(infoBlock);
+
+ write.append("</info>" + "<msgs>");
+ return write.toString();
+ } // end-method
+
+ private static String getSmartDeviceLinkTraceRoot(String dumpReason, int seqNo) {
+ StringBuilder write = new StringBuilder("<SmartDeviceLinktraceroot>" + "<sequencenum>" + seqNo
+ + "</sequencenum>" + "<dumpreason>" + dumpReason
+ + "</dumpreason><tracelevel>");
+
+ write.append("<tran>" + DiagLevel.getLevel(Mod.tran) + "</tran>");
+ write.append("<proto>" + DiagLevel.getLevel(Mod.proto) + "</proto>");
+ write.append("<mar>" + DiagLevel.getLevel(Mod.mar) + "</mar>");
+ write.append("<rpc>" + DiagLevel.getLevel(Mod.rpc) + "</rpc>");
+ write.append("<proxy>" + DiagLevel.getLevel(Mod.proxy) + "</proxy>");
+ write.append("<app>" + DiagLevel.getLevel(Mod.app) + "</app>");
+
+ write.append("</tracelevel>");
+ write.append("</SmartDeviceLinktraceroot>");
+ return write.toString();
+ } // end-method
} // end-class \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java b/sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java
index 1e35296fe..702372a11 100644
--- a/sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java
+++ b/sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java
@@ -6,12 +6,12 @@ package com.smartdevicelink.trace;
import java.util.Iterator;
import java.util.Set;
-import com.smartdevicelink.util.LogTool;
-
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.telephony.TelephonyManager;
+import com.smartdevicelink.util.SdlLog;
+
/**
* @author vvolkman
*
@@ -43,7 +43,7 @@ public class TraceDeviceInfo {
try { // getDeviceId() requires android.permission.READ_PHONE_STATE
info = "<deviceid>" + m_telephonyManager.getDeviceId() + "</deviceid>";
} catch (Exception e1) {
- LogTool.logError("Failure getting telephony device ID: " + e1.toString(), e1);
+ SdlLog.e("Failure getting telephony device ID: " + e1.toString(), e1);
}
info = "<pt>";
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java
index a6180215d..2350d08e4 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java
@@ -16,7 +16,8 @@ import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.transport.enums.TransportType;
+import com.smartdevicelink.util.SdlLog;
/**
* Bluetooth Transport Implementation. This transport advertises its existence to SDL by publishing an SDP record and waiting for an incoming connection from SDL. Connection is verified by checking for the SDL UUID. For more detailed information please refer to the <a href="#bluetoothTransport">Bluetooth Transport Guide</a>.
@@ -201,11 +202,6 @@ public class BTTransport extends SdlTransport {
_transportReader.setName("TransportReader");
_transportReader.setDaemon(true);
_transportReader.start();
-
- // Initialize the SiphonServer
- if (SiphonServer.getSiphonEnabledStatus()) {
- SiphonServer.init();
- }
} // end-method
@@ -240,7 +236,7 @@ public class BTTransport extends SdlTransport {
_transportReader = null;
}
} catch (Exception e) {
- LogTool.logError("Failed to stop transport reader thread.", e);
+ SdlLog.e("Failed to stop transport reader thread.", e);
} // end-catch
try {
@@ -249,7 +245,7 @@ public class BTTransport extends SdlTransport {
_bluetoothAdapterMonitor = null;
}
} catch (Exception e) {
- LogTool.logError("Failed to stop adapter monitor thread.", e);
+ SdlLog.e("Failed to stop adapter monitor thread.", e);
}
try {
@@ -258,7 +254,7 @@ public class BTTransport extends SdlTransport {
_serverSocket = null;
}
} catch (Exception e) {
- LogTool.logError("Failed to close serverSocket", e);
+ SdlLog.e("Failed to close serverSocket", e);
} // end-catch
try {
@@ -267,7 +263,7 @@ public class BTTransport extends SdlTransport {
_activeSocket = null;
}
} catch (Exception e) {
- LogTool.logError("Failed to close activeSocket", e);
+ SdlLog.e("Failed to close activeSocket", e);
} // end-catch
try {
@@ -276,7 +272,7 @@ public class BTTransport extends SdlTransport {
_input = null;
}
} catch (Exception e) {
- LogTool.logError("Failed to close input stream", e);
+ SdlLog.e("Failed to close input stream", e);
} // end-catch
try {
@@ -285,7 +281,7 @@ public class BTTransport extends SdlTransport {
_output = null;
}
} catch (Exception e) {
- LogTool.logError("Failed to close output stream", e);
+ SdlLog.e("Failed to close output stream", e);
} // end-catch
if (ex == null) {
@@ -311,7 +307,7 @@ public class BTTransport extends SdlTransport {
_output.write(msgBytes, offset, length);
sendResult = true;
} catch (Exception ex) {
- LogTool.logError("Error writing to Bluetooth socket: " + ex.toString(), ex);
+ SdlLog.e("Error writing to Bluetooth socket: " + ex.toString(), ex);
handleTransportError("Error writing to Bluetooth socket:", ex);
sendResult = false;
} // end-catch
@@ -400,7 +396,7 @@ public class BTTransport extends SdlTransport {
// When bytesRead == -1, it indicates end of stream
if (!isHalted) {
// Only call disconnect if the thread has not been halted
- LogTool.logError("End of stream reached!");
+ SdlLog.e("End of stream reached!");
disconnect("End of stream reached.", null);
}
}
@@ -408,7 +404,7 @@ public class BTTransport extends SdlTransport {
if (!isHalted) {
// Only call disconnect if the thread has not been halted
String errString = "Failure in BTTransport reader thread: " + excp.toString();
- LogTool.logError(errString, excp);
+ SdlLog.e(errString, excp);
disconnect(errString, excp);
}
return;
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/BTTransportConfig.java b/sdl_android_lib/src/com/smartdevicelink/transport/BTTransportConfig.java
index d4634192a..5de6022b2 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/BTTransportConfig.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/BTTransportConfig.java
@@ -1,5 +1,7 @@
package com.smartdevicelink.transport;
+import com.smartdevicelink.transport.enums.TransportType;
+
/**
* Container of Bluetooth transport specific configuration.
*/
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/BaseTransportConfig.java b/sdl_android_lib/src/com/smartdevicelink/transport/BaseTransportConfig.java
index c499ab91c..4b7fe79be 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/BaseTransportConfig.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/BaseTransportConfig.java
@@ -1,5 +1,7 @@
package com.smartdevicelink.transport;
+import com.smartdevicelink.transport.enums.TransportType;
+
/**
* Defines base abstract class for transport configurations.
*/
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java
index b4945ea4a..0543e71ad 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java
@@ -3,7 +3,8 @@ package com.smartdevicelink.transport;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
-import com.smartdevicelink.util.LogTool;
+import com.smartdevicelink.transport.enums.TransportType;
+import com.smartdevicelink.util.SdlLog;
public abstract class SdlTransport {
private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
@@ -33,14 +34,12 @@ public abstract class SdlTransport {
try {
// Trace received data
if (receivedBytesLength > 0) {
- // Send transport data to the siphon server
- SiphonServer.sendBytesFromSDL(receivedBytes, 0, receivedBytesLength);
SdlTrace.logTransportEvent("", null, InterfaceActivityDirection.Receive, receivedBytes, receivedBytesLength, SDL_LIB_TRACE_KEY);
_transportListener.onTransportBytesReceived(receivedBytes, receivedBytesLength);
} // end-if
} catch (Exception excp) {
- LogTool.logError(FailurePropagating_Msg + "handleBytesFromTransport: " + excp.toString(), excp);
+ SdlLog.e(FailurePropagating_Msg + "handleBytesFromTransport: " + excp.toString(), excp);
handleTransportError(FailurePropagating_Msg, excp);
} // end-catch
} // end-method
@@ -62,10 +61,7 @@ public abstract class SdlTransport {
boolean bytesWereSent = false;
synchronized (_sendLockObj) {
bytesWereSent = sendBytesOverTransport(message, offset, length);
- } // end-lock
- // Send transport data to the siphon server
- SiphonServer.sendBytesFromAPP(message, offset, length);
-
+ }
SdlTrace.logTransportEvent("", null, InterfaceActivityDirection.Transmit, message, offset, length, SDL_LIB_TRACE_KEY);
return bytesWereSent;
} // end-method
@@ -80,7 +76,7 @@ public abstract class SdlTransport {
SdlTrace.logTransportEvent("Transport.connected", null, InterfaceActivityDirection.Receive, null, 0, SDL_LIB_TRACE_KEY);
_transportListener.onTransportConnected();
} catch (Exception excp) {
- LogTool.logError(FailurePropagating_Msg + "onTransportConnected: " + excp.toString(), excp);
+ SdlLog.e(FailurePropagating_Msg + "onTransportConnected: " + excp.toString(), excp);
handleTransportError(FailurePropagating_Msg + "onTransportConnected", excp);
} // end-catch
} // end-method
@@ -94,7 +90,7 @@ public abstract class SdlTransport {
SdlTrace.logTransportEvent("Transport.disconnect: " + info, null, InterfaceActivityDirection.Transmit, null, 0, SDL_LIB_TRACE_KEY);
_transportListener.onTransportDisconnected(info);
} catch (Exception excp) {
- LogTool.logError(FailurePropagating_Msg + "onTransportDisconnected: " + excp.toString(), excp);
+ SdlLog.e(FailurePropagating_Msg + "onTransportDisconnected: " + excp.toString(), excp);
} // end-catch
} // end-method
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/SiphonServer.java b/sdl_android_lib/src/com/smartdevicelink/transport/SiphonServer.java
deleted file mode 100644
index 0872cd920..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/transport/SiphonServer.java
+++ /dev/null
@@ -1,384 +0,0 @@
-package com.smartdevicelink.transport;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.BindException;
-import java.net.ServerSocket;
-import java.net.Socket;
-
-import com.smartdevicelink.util.*;
-
-public class SiphonServer {
- // Prohibit use of no-arg ctor
- private SiphonServer() {}
-
- enum SiphonDataType {
- fromSdl,
- fromApp,
- appLog,
- formattedTrace,
- baselineTimeStamp,
- traceSettings
- }
-
- // Boolean to enable/disable the siphon
- private static Boolean m_siphonEnabled = false;
-
- // Boolean to determine if the siphon has been initialized
- private static Boolean m_siphonInitialized = false;
- private static Boolean m_foundOpenSocket = false;
- private static Socket m_siphonSocket = null;
- private static Object m_siphonLock = new Object();
- private static ServerSocket m_listeningSocket = null;
- private static short m_listenPort = -1;
- private static OutputStream m_siphonSocketOutputStream = null;
- private static SiphonServerThread m_siphonClientThread = null;
-
- // Initial timestamp in MS
- private static long m_startTimeStamp = 0;
-
- // SDL Trace Message Version
- private static byte m_sdlTraceMsgVersionNumber = 1;
-
- // Max number of ports to attempt a connection on
- private final static Integer MAX_NUMBER_OF_PORT_ATTEMPTS = 20;
-
- // Starting port for future port attempts
- private final static short FIRST_PORT_TO_ATTEMPT_CONNECTION = 7474;
-
- // Boolean to determine if formatted trace is being sent
- private static Boolean m_sendingFormattedTrace = false;
-
- public static short enableSiphonServer() {
- m_siphonEnabled = true;
- SiphonServer.init();
- return m_listenPort;
- }
-
- public static Boolean getSiphonEnabledStatus() {
- return m_siphonEnabled;
- }
-
- public static short disableSiphonServer() {
- if (!m_siphonEnabled) {
- m_listenPort = -1;
- } else {
- m_siphonEnabled = false;
- }
-
- m_siphonInitialized = false;
-
- try {
- SiphonServer.closeServer();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return m_listenPort;
- }
-
- public static boolean init() {
- // Only initialize if the siphon has not been initialized previously
-
- // Check here to be lean. If true, no need to sdlhronize
- if (m_siphonInitialized) {
- return true;
- }
-
- synchronized (m_siphonLock) {
- // To prevent a race condition, re-check m_siphonInitialized inside of sdlhronize block
- if (!m_siphonInitialized) {
- if (m_siphonClientThread == null) {
- // Set current time stamp
- m_startTimeStamp = System.currentTimeMillis();
-
- // Start Siphon Thread
- m_siphonClientThread = new SiphonServerThread();
- m_siphonClientThread.setName("Siphon");
- m_siphonClientThread.setDaemon(true);
- m_foundOpenSocket = m_siphonClientThread.findOpenSocket(FIRST_PORT_TO_ATTEMPT_CONNECTION);
- m_siphonClientThread.start();
-
- m_siphonInitialized = true;
- } // end-if
- } // end-lock
- }
-
- return m_siphonInitialized;
- } // end-method
-
- public static void closeServer() throws IOException {
-
- if (m_siphonClientThread != null) {
- m_siphonClientThread.halt();
- m_siphonClientThread = null;
- }
-
- if (m_listeningSocket != null) {
- m_listeningSocket.close();
- m_listeningSocket = null;
- }
-
- if (m_siphonSocket != null) {
- m_siphonSocket.close();
- m_siphonSocket = null;
- }
-
- if (m_siphonSocketOutputStream != null) {
- m_siphonSocketOutputStream.close();
- m_siphonSocketOutputStream = null;
- }
- }
-
- public static Boolean sendBytesFromAPP(byte[] msgBytes, int offset, int length) {
-
- if (m_sendingFormattedTrace) {
- return false;
- }
-
- return sendSiphonData(SiphonDataType.fromApp, msgBytes, offset, length);
- } // end-method
-
- public static Boolean sendBytesFromSDL(byte[] msgBytes, int offset, int length) {
-
- if (m_sendingFormattedTrace) {
- return false;
- }
-
- return sendSiphonData(SiphonDataType.fromSdl, msgBytes, offset, length);
- } // end-method
-
- public static Boolean sendSiphonLogData(String message) {
-
- if (m_sendingFormattedTrace) {
- return false;
- }
-
- if (message == null || message.length() == 0) {
- return false;
- }
-
- byte messageBytes[] = null;
- int messageLength = 0;
-
- try {
- messageBytes = message.getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- return false;
- }
-
- messageLength = messageBytes.length;
- return sendSiphonData(SiphonDataType.appLog, messageBytes, 0, messageLength);
-
- }
-
- public static Boolean sendFormattedTraceMessage(String message) {
-
- if (message == null || message.length() == 0) {
- return false;
- }
-
- byte messageBytes[] = null;
- int messageLength = 0;
-
- try {
- messageBytes = message.getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- return false;
- }
-
- messageLength = messageBytes.length;
- if (sendSiphonData(SiphonDataType.formattedTrace, messageBytes, 0, messageLength)) {
- m_sendingFormattedTrace = true;
- return true;
- } else {
- return false;
- }
- }
-
- private static Boolean sendSiphonData(SiphonDataType direction, byte[] msgBytes, int offset, int length) {
- byte siphonDataTypeIndicator = 0x00;
-
- long currentDateTime = System.currentTimeMillis();
- Integer deltaTimeMills = null;
-
- deltaTimeMills = (int)(currentDateTime - m_startTimeStamp);
-
- switch(direction) {
- case fromSdl:
- siphonDataTypeIndicator = 0x00;
- break;
- case fromApp:
- siphonDataTypeIndicator = 0x01;
- break;
- case appLog:
- siphonDataTypeIndicator = 0x02;
- break;
- case formattedTrace:
- siphonDataTypeIndicator = 0x03;
- break;
- case baselineTimeStamp:
- siphonDataTypeIndicator = 0x04;
- break;
- case traceSettings:
- siphonDataTypeIndicator = 0x05;
- break;
- default:
- siphonDataTypeIndicator = 0x00;
- break;
- }
-
- // Set high bit to indicate new format
- siphonDataTypeIndicator = (byte)((byte)0x80 | siphonDataTypeIndicator);
-
- return sendDataToSiphonSocket(siphonDataTypeIndicator, deltaTimeMills, msgBytes, offset, length);
- }
-
- private synchronized static Boolean sendDataToSiphonSocket(byte directionIndicator, Integer timeStamp,
- byte[] msgBytes, int offset, int length) {
- if (!m_siphonEnabled) {
- return false;
- }
-
- if (msgBytes == null || length == 0) {
- return false;
- }
-
- OutputStream siphonOutputStream = null;
-
- synchronized (m_siphonLock) {
- siphonOutputStream = m_siphonSocketOutputStream;
- } // end-lock
-
- if (siphonOutputStream == null) {
- return false;
- }
-
- try {
- // blobSize = length(of message) + 1(size of direction indicator)
- // + 1 (size of msgVersionNumber) + 4 (size of timeStamp)
- int blobSize = length + 1 + 1 + 4;
-
- siphonOutputStream.write(BitConverter.intToByteArray(blobSize));
- siphonOutputStream.write(new byte[] {directionIndicator});
- siphonOutputStream.write(new byte[] {m_sdlTraceMsgVersionNumber});
- siphonOutputStream.write(intToByteArray(timeStamp));
- siphonOutputStream.write(msgBytes, offset, length);
- } catch (Exception ex) {
- return false;
- } // end-catch
-
- return true;
- } // end-method
-
- private static class SiphonServerThread extends Thread {
-
- private Boolean isHalted = false;
- short listenPort;
-
- public void halt() {
- isHalted = true;
- }
-
- private boolean findOpenSocket(short port) {
- // Accept incoming sihpon connection from trace utility.
- Boolean foundOpenPort = false;
- listenPort = port;
-
- // Listen to accept incoming connection from SDL
- while (!foundOpenPort) {
- try {
- m_listeningSocket = new ServerSocket(listenPort);
- foundOpenPort = true;
- m_listenPort = listenPort;
- } catch (BindException ex) {
- listenPort++;
- if(listenPort > port + MAX_NUMBER_OF_PORT_ATTEMPTS) {
- return false;
- }
- } catch (IOException e) {
- return false;
- }
- }
-
- return foundOpenPort;
- }
-
- private void startServerOnPort() throws IOException {
- Socket newSocket = null;
-
- // Wait for a connection
- newSocket = m_listeningSocket.accept();
-
- // If isHalted after accept() delay, return
- if (isHalted) {
- return;
- }
-
- synchronized (m_siphonLock) {
- // Reset siphonSocketOutputStream
- if (m_siphonSocketOutputStream != null) {
- try {
- m_siphonSocketOutputStream.close();
- } catch (IOException e) {
- // Do nothing
- }
- m_siphonSocketOutputStream = null;
- }
-
- // Reset siphonSocket
- if (m_siphonSocket != null) {
- try {
- m_siphonSocket.close();
- } catch (IOException e) {
- // Do nothing
- }
- m_siphonSocket = null;
- }
-
- // Store the new socket
- m_siphonSocket = newSocket;
-
- // Set Socket Options
- m_siphonSocket.setKeepAlive(true);
-
- // Get the output stream of the connection
- m_siphonSocketOutputStream = m_siphonSocket.getOutputStream();
-
- // Output version number to the Siphon upon connection (version number prepending to logInfo)
- LogTool.logInfo("Siphon connected.");
- } // end-lock
- } // end-method
-
- @Override
- public void run() {
- try {
- if (m_foundOpenSocket){
- while (!isHalted) {
- startServerOnPort();
- }
- }
- } catch (Exception ex) {
- // Do nothing
- } finally {
- if (m_listeningSocket != null) {
- try {
- m_listeningSocket.close();
- } catch (IOException e) {
- // Do nothing
- }
- m_listeningSocket = null;
- }
- }
- }
- }
-
- private static final byte[] intToByteArray(int value) {
- return new byte[] {
- (byte)(value >>> 24),
- (byte)(value >>> 16),
- (byte)(value >>> 8),
- (byte)value};
- }
-} // end-class \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/TCPTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/TCPTransport.java
index ea1721b77..d09623728 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/TCPTransport.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/TCPTransport.java
@@ -4,6 +4,7 @@ import android.util.Log;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
+import com.smartdevicelink.transport.enums.TransportType;
import java.io.IOException;
import java.io.InputStream;
@@ -155,12 +156,6 @@ public class TCPTransport extends SdlTransport {
mThread = new TCPTransportThread();
mThread.setDaemon(true);
mThread.start();
-
- // Initialize the SiphonServer
- if (SiphonServer.getSiphonEnabledStatus()) {
- SiphonServer.init();
- }
-
} catch (Exception e) {
logError("TCPTransport: Exception during transport thread starting", e);
throw new SdlException(e);
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/TCPTransportConfig.java b/sdl_android_lib/src/com/smartdevicelink/transport/TCPTransportConfig.java
index a8ab3f1a8..8ff3f2172 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/TCPTransportConfig.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/TCPTransportConfig.java
@@ -1,5 +1,7 @@
package com.smartdevicelink.transport;
+import com.smartdevicelink.transport.enums.TransportType;
+
/**
* Container of TCP transport specific configuration.
*/
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java
index 9776385e7..a066240fe 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java
@@ -1,5 +1,12 @@
package com.smartdevicelink.transport;
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -13,18 +20,8 @@ import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
-import com.smartdevicelink.transport.ITransportListener;
-import com.smartdevicelink.transport.SdlTransport;
-import com.smartdevicelink.transport.SiphonServer;
-import com.smartdevicelink.transport.TransportType;
-import com.smartdevicelink.util.LogTool;
-
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import com.smartdevicelink.transport.enums.TransportType;
+import com.smartdevicelink.util.SdlLog;
/**
* Class that implements USB transport.
@@ -75,14 +72,6 @@ public class USBTransport extends SdlTransport {
*/
private final static String ACCESSORY_VERSION = "1.0";
/**
- * Prefix string to indicate debug output.
- */
- private static final String DEBUG_PREFIX = "DEBUG: ";
- /**
- * String to prefix exception output.
- */
- private static final String EXCEPTION_STRING = " Exception String: ";
- /**
* Broadcast receiver that receives different USB-related intents: USB
* accessory connected, disconnected, and permission granted.
*/
@@ -90,21 +79,21 @@ public class USBTransport extends SdlTransport {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- logD("USBReceiver Action: " + action);
+ SdlLog.d("USBReceiver Action: " + action);
UsbAccessory accessory =
intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
if (accessory != null) {
if (ACTION_USB_ACCESSORY_ATTACHED.equals(action)) {
- logI("Accessory " + accessory + " attached");
+ SdlLog.i("Accessory " + accessory + " attached");
if (isAccessorySupported(accessory)) {
connectToAccessory(accessory);
} else {
- logW("Attached accessory is not supported!");
+ SdlLog.w("Attached accessory is not supported!");
}
} else if (UsbManager.ACTION_USB_ACCESSORY_DETACHED
.equals(action)) {
- logI("Accessory " + accessory + " detached");
+ SdlLog.i("Accessory " + accessory + " detached");
final String msg = "USB accessory has been detached";
disconnect(msg, new SdlException(msg,
SdlExceptionCause.SDL_USB_DETACHED));
@@ -112,18 +101,18 @@ public class USBTransport extends SdlTransport {
boolean permissionGranted = intent.getBooleanExtra(
UsbManager.EXTRA_PERMISSION_GRANTED, false);
if (permissionGranted) {
- logI("Permission granted for accessory " + accessory);
+ SdlLog.i("Permission granted for accessory " + accessory);
openAccessory(accessory);
} else {
final String msg =
"Permission denied for accessory " + accessory;
- logW(msg);
+ SdlLog.w(msg);
disconnect(msg, new SdlException(msg,
SdlExceptionCause.SDL_USB_PERMISSION_DENIED));
}
}
} else {
- logW("Accessory is null");
+ SdlLog.w("Accessory is null");
}
}
};
@@ -191,7 +180,7 @@ public class USBTransport extends SdlTransport {
* @param state New state
*/
private void setState(State state) {
- logD("Changing state " + this.mState + " to " + state);
+ SdlLog.d("Changing state " + this.mState + " to " + state);
this.mState = state;
}
@@ -206,7 +195,7 @@ public class USBTransport extends SdlTransport {
@Override
protected boolean sendBytesOverTransport(byte[] msgBytes, int offset,
int length) {
- logD("SendBytes: array size " + msgBytes.length + ", offset " + offset +
+ SdlLog.d("SendBytes: array size " + msgBytes.length + ", offset " + offset +
", length " + length);
boolean result = false;
@@ -219,27 +208,27 @@ public class USBTransport extends SdlTransport {
mOutputStream.write(msgBytes, offset, length);
result = true;
- logI("Bytes successfully sent");
+ SdlLog.i("Bytes successfully sent");
SdlTrace.logTransportEvent(TAG + ": bytes sent",
null, InterfaceActivityDirection.Transmit,
msgBytes, offset, length,
SDL_LIB_TRACE_KEY);
} catch (IOException e) {
final String msg = "Failed to send bytes over USB";
- logW(msg, e);
+ SdlLog.e(msg, e);
handleTransportError(msg, e);
}
} else {
final String msg =
"Can't send bytes when output stream is null";
- logW(msg);
+ SdlLog.w(msg);
handleTransportError(msg, null);
}
}
break;
default:
- logW("Can't send bytes from " + state + " state");
+ SdlLog.w("Can't send bytes from " + state + " state");
break;
}
@@ -268,11 +257,11 @@ public class USBTransport extends SdlTransport {
switch (state) {
case IDLE:
synchronized (this) {
- logI("openConnection()");
+ SdlLog.i("openConnection()");
setState(State.LISTENING);
}
- logD("Registering receiver");
+ SdlLog.d("Registering receiver");
try {
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_USB_ACCESSORY_ATTACHED);
@@ -283,7 +272,7 @@ public class USBTransport extends SdlTransport {
initializeAccessory();
} catch (Exception e) {
String msg = "Couldn't start opening connection";
- logE(msg, e);
+ SdlLog.e(msg, e);
throw new SdlException(msg, e,
SdlExceptionCause.SDL_CONNECTION_FAILED);
}
@@ -291,7 +280,7 @@ public class USBTransport extends SdlTransport {
break;
default:
- logW("openConnection() called from state " + state +
+ SdlLog.w("openConnection() called from state " + state +
"; doing nothing");
break;
}
@@ -311,7 +300,7 @@ public class USBTransport extends SdlTransport {
*/
//@Override
public void stopReading() {
- LogTool.logInfo("USBTransport: stop reading requested, doing nothing");
+ SdlLog.i("USBTransport: stop reading requested, doing nothing");
// TODO - put back stopUSBReading(); @see <a href="https://adc.luxoft.com/jira/browse/SmartDeviceLink-3450">SmartDeviceLink-3450</a>
}
@@ -320,14 +309,14 @@ public class USBTransport extends SdlTransport {
final State state = getState();
switch (state) {
case CONNECTED:
- logI("Stopping reading");
+ SdlLog.i("Stopping reading");
synchronized (this) {
stopReaderThread();
}
break;
default:
- logW("Stopping reading called from state " + state +
+ SdlLog.w("Stopping reading called from state " + state +
"; doing nothing");
break;
}
@@ -338,12 +327,12 @@ public class USBTransport extends SdlTransport {
*/
private void stopReaderThread() {
if (mReaderThread != null) {
- logI("Interrupting USB reader");
+ SdlLog.i("Interrupting USB reader");
mReaderThread.interrupt();
// don't join() now
mReaderThread = null;
} else {
- logD("USB reader is null");
+ SdlLog.d("USB reader is null");
}
}
@@ -359,7 +348,7 @@ public class USBTransport extends SdlTransport {
case LISTENING:
case CONNECTED:
synchronized (this) {
- logI("Disconnect from state " + getState() + "; message: " +
+ SdlLog.i("Disconnect from state " + getState() + "; message: " +
msg + "; exception: " + ex);
setState(State.IDLE);
@@ -374,7 +363,7 @@ public class USBTransport extends SdlTransport {
try {
mOutputStream.close();
} catch (IOException e) {
- logW("Can't close output stream", e);
+ SdlLog.e("Can't close output stream", e);
mOutputStream = null;
}
}
@@ -382,7 +371,7 @@ public class USBTransport extends SdlTransport {
try {
mInputStream.close();
} catch (IOException e) {
- logW("Can't close input stream", e);
+ SdlLog.e("Can't close input stream", e);
mInputStream = null;
}
}
@@ -390,7 +379,7 @@ public class USBTransport extends SdlTransport {
try {
mParcelFD.close();
} catch (IOException e) {
- logW("Can't close file descriptor", e);
+ SdlLog.e("Can't close file descriptor", e);
mParcelFD = null;
}
}
@@ -399,11 +388,11 @@ public class USBTransport extends SdlTransport {
}
}
- logD("Unregistering receiver");
+ SdlLog.d("Unregistering receiver");
try {
getContext().unregisterReceiver(mUSBReceiver);
} catch (IllegalArgumentException e) {
- logW("Receiver was already unregistered", e);
+ SdlLog.e("Receiver was already unregistered", e);
}
String disconnectMsg = (msg == null ? "" : msg);
@@ -414,18 +403,18 @@ public class USBTransport extends SdlTransport {
if (ex == null) {
// This disconnect was not caused by an error, notify the
// proxy that the transport has been disconnected.
- logI("Disconnect is correct. Handling it");
+ SdlLog.i("Disconnect is correct. Handling it");
handleTransportDisconnected(disconnectMsg);
} else {
// This disconnect was caused by an error, notify the proxy
// that there was a transport error.
- logI("Disconnect is incorrect. Handling it as error");
+ SdlLog.i("Disconnect is incorrect. Handling it as error");
handleTransportError(disconnectMsg, ex);
}
break;
default:
- logW("Disconnect called from state " + state +
+ SdlLog.w("Disconnect called from state " + state +
"; doing nothing");
break;
}
@@ -435,7 +424,7 @@ public class USBTransport extends SdlTransport {
* Returns the type of the transport.
*
* @return TransportType.USB
- * @see com.smartdevicelink.transport.TransportType
+ * @see com.smartdevicelink.transport.enums.TransportType
*/
@Override
public TransportType getTransportType() {
@@ -446,11 +435,11 @@ public class USBTransport extends SdlTransport {
* Looks for an already connected compatible accessory and connect to it.
*/
private void initializeAccessory() {
- logI("Looking for connected accessories");
+ SdlLog.i("Looking for connected accessories");
UsbManager usbManager = getUsbManager();
UsbAccessory[] accessories = usbManager.getAccessoryList();
if (accessories != null) {
- logD("Found total " + accessories.length + " accessories");
+ SdlLog.d("Found total " + accessories.length + " accessories");
for (UsbAccessory accessory : accessories) {
if (isAccessorySupported(accessory)) {
connectToAccessory(accessory);
@@ -458,7 +447,7 @@ public class USBTransport extends SdlTransport {
}
}
} else {
- logI("No connected accessories found");
+ SdlLog.i("No connected accessories found");
}
}
@@ -491,10 +480,10 @@ public class USBTransport extends SdlTransport {
case LISTENING:
UsbManager usbManager = getUsbManager();
if (usbManager.hasPermission(accessory)) {
- logI("Already have permission to use " + accessory);
+ SdlLog.i("Already have permission to use " + accessory);
openAccessory(accessory);
} else {
- logI("Requesting permission to use " + accessory);
+ SdlLog.i("Requesting permission to use " + accessory);
PendingIntent permissionIntent = PendingIntent
.getBroadcast(getContext(), 0,
@@ -505,7 +494,7 @@ public class USBTransport extends SdlTransport {
break;
default:
- logW("connectToAccessory() called from state " + state +
+ SdlLog.w("connectToAccessory() called from state " + state +
"; doing nothing");
}
}
@@ -532,7 +521,7 @@ public class USBTransport extends SdlTransport {
switch (state) {
case LISTENING:
synchronized (this) {
- logI("Opening accessory " + accessory);
+ SdlLog.i("Opening accessory " + accessory);
mAccessory = accessory;
mReaderThread = new Thread(new USBTransportReader());
@@ -540,75 +529,17 @@ public class USBTransport extends SdlTransport {
mReaderThread
.setName(USBTransportReader.class.getSimpleName());
mReaderThread.start();
-
- // Initialize the SiphonServer
- if (SiphonServer.getSiphonEnabledStatus()) {
- SiphonServer.init();
- }
}
break;
default:
- logW("openAccessory() called from state " + state +
+ SdlLog.w("openAccessory() called from state " + state +
"; doing nothing");
}
}
/**
- * Logs the string and the throwable with ERROR level.
- *
- * @param s string to log
- * @param tr throwable to log
- */
- private void logE(String s, Throwable tr) {
- LogTool.logError(s, tr);
- }
-
- /**
- * Logs the string with WARN level.
- *
- * @param s string to log
- */
- private void logW(String s) {
- LogTool.logWarning(s);
- }
-
- /**
- * Logs the string and the throwable with WARN level.
- *
- * @param s string to log
- * @param tr throwable to log
- */
- private void logW(String s, Throwable tr) {
- StringBuilder res = new StringBuilder(s);
- if (tr != null) {
- res.append(EXCEPTION_STRING);
- res.append(tr.toString());
- }
- logW(res.toString());
- }
-
- /**
- * Logs the string with INFO level.
- *
- * @param s string to log
- */
- private void logI(String s) {
- LogTool.logInfo(s);
- }
-
- /**
- * Logs the string with DEBUG level.
- *
- * @param s string to log
- */
- private void logD(String s) {
- // LogTool doesn't support DEBUG level, so we use INFO instead
- LogTool.logInfo(DEBUG_PREFIX + s);
- }
-
- /**
* Returns Context to communicate with the OS.
*
* @return current context to be used by the USB transport
@@ -668,13 +599,13 @@ public class USBTransport extends SdlTransport {
*/
@Override
public void run() {
- logD("USB reader started!");
+ SdlLog.d("USB reader started!");
if (connect()) {
readFromTransport();
}
- logD("USB reader finished!");
+ SdlLog.d("USB reader finished!");
}
/**
@@ -684,7 +615,7 @@ public class USBTransport extends SdlTransport {
*/
private boolean connect() {
if (isInterrupted()) {
- logI("Thread is interrupted, not connecting");
+ SdlLog.i("Thread is interrupted, not connecting");
return false;
}
@@ -699,15 +630,15 @@ public class USBTransport extends SdlTransport {
} catch (Exception e) {
final String msg =
"Have no permission to open the accessory";
- logE(msg, e);
+ SdlLog.e(msg, e);
disconnect(msg, e);
return false;
}
if (mParcelFD == null) {
if (isInterrupted()) {
- logW("Can't open accessory, and thread is interrupted");
+ SdlLog.w("Can't open accessory, and thread is interrupted");
} else {
- logW("Can't open accessory, disconnecting!");
+ SdlLog.w("Can't open accessory, disconnecting!");
String msg = "Failed to open USB accessory";
disconnect(msg, new SdlException(msg,
SdlExceptionCause.SDL_CONNECTION_FAILED));
@@ -719,7 +650,7 @@ public class USBTransport extends SdlTransport {
mOutputStream = new FileOutputStream(fd);
}
- logI("Accessory opened!");
+ SdlLog.i("Accessory opened!");
synchronized (USBTransport.this) {
setState(State.CONNECTED);
@@ -728,7 +659,7 @@ public class USBTransport extends SdlTransport {
break;
default:
- logW("connect() called from state " + state +
+ SdlLog.w("connect() called from state " + state +
", will not try to connect");
return false;
}
@@ -751,30 +682,30 @@ public class USBTransport extends SdlTransport {
bytesRead = mInputStream.read(buffer);
if (bytesRead == -1) {
if (isInterrupted()) {
- logI("EOF reached, and thread is interrupted");
+ SdlLog.i("EOF reached, and thread is interrupted");
} else {
- logI("EOF reached, disconnecting!");
+ SdlLog.i("EOF reached, disconnecting!");
disconnect("EOF reached", null);
}
return;
}
} catch (IOException e) {
if (isInterrupted()) {
- logW("Can't read data, and thread is interrupted", e);
+ SdlLog.e("Can't read data, and thread is interrupted", e);
} else {
- logW("Can't read data, disconnecting!", e);
+ SdlLog.e("Can't read data, disconnecting!", e);
disconnect("Can't read data from USB", e);
}
return;
}
- logD("Read " + bytesRead + " bytes");
+ SdlLog.d("Read " + bytesRead + " bytes");
SdlTrace.logTransportEvent(TAG + ": read bytes", null,
InterfaceActivityDirection.Receive, buffer, bytesRead,
SDL_LIB_TRACE_KEY);
if (isInterrupted()) {
- logI("Read some data, but thread is interrupted");
+ SdlLog.i("Read some data, but thread is interrupted");
return;
}
@@ -785,33 +716,6 @@ public class USBTransport extends SdlTransport {
}
}
}
-
- // Log functions
-
- private void logD(String s) {
- LogTool.logInfo(DEBUG_PREFIX + s);
- }
-
- private void logI(String s) {
- LogTool.logInfo(s);
- }
-
- private void logW(String s) {
- LogTool.logWarning(s);
- }
-
- private void logW(String s, Throwable tr) {
- StringBuilder res = new StringBuilder(s);
- if (tr != null) {
- res.append(EXCEPTION_STRING);
- res.append(tr.toString());
- }
- logW(res.toString());
- }
-
- private void logE(String s, Throwable tr) {
- LogTool.logError(s, tr);
- }
}
@Override
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/USBTransportConfig.java b/sdl_android_lib/src/com/smartdevicelink/transport/USBTransportConfig.java
index 9cc747407..0309753a9 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/USBTransportConfig.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/USBTransportConfig.java
@@ -1,5 +1,7 @@
package com.smartdevicelink.transport;
+import com.smartdevicelink.transport.enums.TransportType;
+
import android.content.Context;
import android.hardware.usb.UsbAccessory;
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/TransportType.java b/sdl_android_lib/src/com/smartdevicelink/transport/enums/TransportType.java
index a1fd08d71..46e0c49ab 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/TransportType.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/enums/TransportType.java
@@ -1,4 +1,4 @@
-package com.smartdevicelink.transport;
+package com.smartdevicelink.transport.enums;
/**
* Defines available types of the transports.
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/Base64.java b/sdl_android_lib/src/com/smartdevicelink/util/Base64.java
deleted file mode 100644
index 50b1fd4af..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/util/Base64.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.smartdevicelink.util;
-
-public class Base64 {
-
- private static final String defaultString = "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure";
-
- private static char[] map = new char[64];
- private static byte[] unmap = new byte['z' + 1];
- static {
- byte i = 0;
- for (char c = 'A'; c <= 'Z'; c++) {
- unmap[c] = i;
- map[i++] = c;
- }
- for (char c = 'a'; c <= 'z'; c++) {
- unmap[c] = i;
- map[i++] = c;
- }
- for (char c = '0'; c <= '9'; c++) {
- unmap[c] = i;
- map[i++] = c;
- }
- unmap['+'] = i;
- map[i++] = '+';
- unmap['/'] = i;
- map[i++] = '/';
-
- unmap['='] = 0;
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- String toEncode = defaultString;
- if (args.length > 0) {
- toEncode = args[0];
- }
- System.out.println(toEncode);
- String encoded = encode(toEncode.getBytes());
- System.out.println(encoded);
- String decoded = new String(decode(encoded));
- System.out.println(decoded);
- }
-
- public static String encode(byte[] toEncode) {
-
- int iSrc = 0;
- int iDest = 0;
- int srcLen = toEncode.length;
- int destLen = (srcLen * 4 + 2) / 3;
- int padLen = ((srcLen + 2) / 3) * 4;
- char[] dest = new char[padLen];
-
- while (iSrc < srcLen) {
- int src1 = toEncode[iSrc++];
- int src2 = (iSrc < srcLen) ? toEncode[iSrc++] : 0;
- int src3 = (iSrc < srcLen) ? toEncode[iSrc++] : 0;
- int dest1 = (src1 >>> 2);
- int dest2 = (src1 << 4) | (src2 >> 4);
- dest2 &= 0x3F;
- int dest3 = (src2 << 2) | (src3 >>> 6);
- dest3 &= 0x3F;
- int dest4 = src3 & 0x3F;
- dest[iDest++] = map[dest1];
- dest[iDest++] = map[dest2];
- dest[iDest] = iDest < destLen ? map[dest3] : '=';
- iDest++;
- dest[iDest] = iDest < destLen ? map[dest4] : '=';
- iDest++;
- }
-
- return new String(dest);
- }
-
- public static byte[] decode(String toDecode) {
- int iSrc = 0;
- int iDest = 0;
- char[] src = toDecode.toCharArray();
- int srcLen = src.length;
- int destLen = ((srcLen / 4) * 3);
- if (src[srcLen - 1] == '=') {
- destLen--;
- }
- if (src[srcLen - 2] == '=') {
- destLen--;
- }
- byte[] dest = new byte[destLen];
-
- while (iSrc < srcLen) {
- byte src1 = unmap[src[iSrc++]];
- byte src2 = unmap[src[iSrc++]];
- byte src3 = unmap[src[iSrc++]];
- byte src4 = unmap[src[iSrc++]];
- int dest1 = (src1 << 2) | (src2 >>> 4);
- int dest2 = (src2 << 4) | (src3 >>> 2);
- int dest3 = (src3 << 6) | src4;
- dest[iDest++] = (byte) dest1;
- if (iDest < destLen) {
- dest[iDest++] = (byte) dest2;
- }
- if (iDest < destLen) {
- dest[iDest++] = (byte) dest3;
- }
- }
-
- return dest;
- }
-
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/ByteEnumer.java b/sdl_android_lib/src/com/smartdevicelink/util/ByteEnumer.java
index ed9946c0f..0b67d9992 100644
--- a/sdl_android_lib/src/com/smartdevicelink/util/ByteEnumer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/util/ByteEnumer.java
@@ -30,10 +30,14 @@ public abstract class ByteEnumer {
public static ByteEnumer get(Vector<?> theList, byte value) {
Enumeration<?> enumer = theList.elements();
- while (enumer.hasMoreElements()) {
- ByteEnumer current = (ByteEnumer)enumer.nextElement();
- if (current.getValue() == value) {
- return current;
+ while (enumer.hasMoreElements()) {
+ try {
+ ByteEnumer current = (ByteEnumer)enumer.nextElement();
+ if (current.getValue() == value) {
+ return current;
+ }
+ } catch (ClassCastException e) {
+ return null;
}
}
return null;
@@ -42,11 +46,15 @@ public abstract class ByteEnumer {
public static ByteEnumer get(Vector<?> theList, String name) {
Enumeration<?> enumer = theList.elements();
while (enumer.hasMoreElements()) {
+ try {
ByteEnumer current = (ByteEnumer)enumer.nextElement();
if (current.getName().equals(name)) {
return current;
}
+ } catch (ClassCastException e) {
+ return null;
+ }
}
return null;
}
-}
+} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/IConsole.java b/sdl_android_lib/src/com/smartdevicelink/util/IConsole.java
deleted file mode 100644
index 8d6d4a0f1..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/util/IConsole.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.smartdevicelink.util;
-
-
-public interface IConsole {
- void logInfo(String msg);
- void logError(String msg);
- void logError(String msg, Throwable ex);
- void logRPCSend(String rpcMsg);
- void logRPCReceive(String rpcMsg);
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/LogTool.java b/sdl_android_lib/src/com/smartdevicelink/util/LogTool.java
deleted file mode 100644
index 902b4ef6c..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/util/LogTool.java
+++ /dev/null
@@ -1,643 +0,0 @@
-package com.smartdevicelink.util;
-
-import java.util.Vector;
-
-import android.util.Log;
-
-import com.smartdevicelink.proxy.SdlProxyBase;
-import com.smartdevicelink.proxy.Version;
-import com.smartdevicelink.transport.SiphonServer;
-
-/**
- * A utility class for logging library specific messages to the native Android
- * log output, the Siphon Server and the list of console listeners.
- *
- * @since SmartDeviceLink v4.0
- * @see {@link android.util.Log}
- * @see {@link com.smartdevicelink.transport.SiphonServer}
- */
-public class LogTool {
-
- /**
- * A boolean flag that indicates whether the INFO and WARNING priority
- * constants will be logged to the native Android output.
- */
- private static boolean isNativeLoggingEnabled = true;
-
- /**
- * A boolean flag that indicates whether to log messages to the Siphon
- * Server.
- */
- private static boolean isSiphonServerLoggingEnabled = false;
-
- /**
- * A boolean flag that indicates whether to log messages to the list of
- * console listeners.
- */
- private static boolean isConsoleListenerLoggingEnabled = false;
-
- /**
- * An integer constant representing the maximum character length of an
- * individual message logged to the native Android output.
- */
- private static final int CHUNK_SIZE = 4000;
-
- /**
- * An integer constant flag used to indicate that a log message is an RPC
- * sent message for console listeners.
- */
- private static final int LOG_RPC_SENT = 1;
-
- /**
- * An integer constant flag used to indicate that a log message is an RPC
- * received message for console listeners.
- */
- private static final int LOG_RPC_RECEIVED = 2;
-
- /**
- * An integer constant flag used to indicate that a log message is a
- * transport message for console listeners.
- */
- private static final int LOG_TRANSPORT = 3;
-
- /**
- * An integer constant flag used to indicate that a log message is an
- * error message for console listeners.
- */
- private static final int LOG_ERROR = 4;
-
- /**
- * The prefix to an error message displayed if an exception occured during
- * the logging procees.
- */
- private static final String LOG_FAILURE = "Failure writing message fragments to android log: ";
-
- /**
- * The prefix to an error message displayed if the message logged was not
- * equivalent to the message scheduled to be logged.
- */
- private static final String LOG_PARTIAL = "Failure writing full message length (expected, actual) : ";
-
- /**
- * The list of console listeners that, if enabled, will receive transport
- * and RPC message logs.
- */
- private static Vector<IConsole> consoleListenerList = new Vector<IConsole>();
-
- /**
- * Enables messages with the INFO and WARNING priority constant tags to be
- * logged to the native Android output.
- */
- public static void setNativeLoggingEnabled () {
- isNativeLoggingEnabled = true;
- }
-
- /**
- * Disables messages with the INFO and WARN priority constant tags from
- * being logged to the native Android output.
- */
- public static void setNativeLoggingDisabled () {
- isNativeLoggingEnabled = false;
- }
-
- /**
- * Sends the current value of the {@link #isNativeLoggingEnabled} boolean
- * flag.
- *
- * @return {@link #isNativeLoggingEnabled} A boolean flag that indicates
- * whether INFO and WARNING marked messages will be logged to the native
- * Android output.
- */
- public static boolean isNativeLoggingEnabled () {
- return isNativeLoggingEnabled;
- }
-
- /**
- * Enables messages to be logged to the Siphon Server output.
- */
- public static void setSiphonServerLoggingEnabled () {
- isSiphonServerLoggingEnabled = true;
- }
-
- /**
- * Disables messages from being logged to the Siphon Server output.
- */
- public static void setSiphonServerLoggingDisabled () {
- isSiphonServerLoggingEnabled = false;
- }
-
- /**
- * Sends the current value of the {@link #isSiphonServerLoggingEnabled}
- * boolean flag.
- *
- * @return {@link #isSiphonServerLoggingEnabled} A boolean flag that
- * indicates whether messages will be logged to the Siphon Server output.
- */
- public static boolean isSiphonServerLoggingEnabled () {
- return isSiphonServerLoggingEnabled;
- }
-
- /**
- * Enables messages to be logged to the list of console listeners.
- */
- public static void setConsoleListenerLoggingEnabled () {
- isConsoleListenerLoggingEnabled = true;
- }
-
- /**
- * Disables messages from being logged to the list of console listeners.
- */
- public static void setConsoleListenerLoggingDisabled () {
- isConsoleListenerLoggingEnabled = false;
- }
-
- /**
- * Sends the current value of the {@link #isConsoleListenerLoggingEnabled}
- * boolean flag.
- *
- * @return {@link #isConsoleListenerLoggingEnabled} A boolean flag that
- * indicates whether messages will be logged to the list of console
- * listeners.
- */
- public static boolean isConsoleListenerLoggingEnabled () {
- return isConsoleListenerLoggingEnabled;
- }
-
- /**
- * Adds a console listener to the list of listeners that will potentially
- * be receiving transport and RPC message logs.
- *
- * @param console A console listener object to be added.
- * @return (boolean) Whether the console listener was added to the list
- * successfully.
- */
- public static boolean addConsole (IConsole console) {
-
- if (console == null) {
- return false;
- }
-
- synchronized(consoleListenerList) {
- consoleListenerList.addElement(console);
-
- if (consoleListenerList.contains(console)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Removes a console listener from the list of listeners that will
- * potentially be receiving transport and RPC message logs.
- *
- * @param console A console listener object to be removed.
- * @return (boolean) Whether the console listener was removed from the list
- * successfully.
- */
- public static boolean removeConsole (IConsole console) {
-
- if (console == null) {
- return false;
- }
-
- synchronized(consoleListenerList) {
- consoleListenerList.removeElement(console);
-
- if (!consoleListenerList.contains(console)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Removes all console listeners from the list of listeners that will
- * potentially be receiving transport and RPC message logs.
- *
- * @return (boolean) Whether the console listeners were all successfully
- * removed.
- */
- public static boolean clearConsoles () {
- synchronized(consoleListenerList) {
- consoleListenerList.removeAllElements();
-
- if (consoleListenerList.isEmpty()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Logs the message provided with the INFO priority constant to the native
- * Android and Siphon Server outputs.
- *
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logInfo (String message) {
- return logInfo(SdlProxyBase.TAG, message);
- }
-
- /**
- * Logs the message provided with the INFO priority constant to the native
- * Android and Siphon Server outputs.
- *
- * @param message A string to be logged.
- * @param prepend A flag to indicate if the message is to be prepended with
- * the version info before being sent to the Siphon Server output.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logInfo (String message, boolean prepend) {
- return logInfo(SdlProxyBase.TAG, message, prepend);
- }
-
- /**
- * Logs the message provided with the INFO priority constant and tag to the
- * native Android and Siphon Server outputs.
- *
- * @param tag A string representing the sender of the message.
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logInfo (String tag, String message) {
-
- Boolean wasLogged = true;
-
- if (isSiphonServerLoggingEnabled) {
- String siphonMessage = prependVersionInfo(message);
- wasLogged = logToSiphon(siphonMessage);
- }
-
- if (wasLogged == null || wasLogged == false) {
- return false;
- }
-
- if (isNativeLoggingEnabled) {
- return log(Log.INFO, tag, message);
- }
-
- return wasLogged;
- }
-
- /**
- * Logs the message provided with the INFO priority constant and tag to the
- * native Android and Siphon Server outputs.
- *
- * @param tag A string representing the sender of the message.
- * @param message A string to be logged.
- * @param prepend A flag to indicate if the message is to be prepended with
- * the version info before being sent to the Siphon Server output.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logInfo (String tag, String message, boolean prepend) {
-
- Boolean wasLogged = true;
-
- if (isSiphonServerLoggingEnabled) {
- if (prepend) {
- String siphonMessage = prependVersionInfo(message);
- wasLogged = logToSiphon(siphonMessage);
- } else {
- wasLogged = logToSiphon(message);
- }
- }
-
- if (wasLogged == null || wasLogged == false) {
- return false;
- }
-
- if (isNativeLoggingEnabled) {
- return log(Log.INFO, tag, message);
- }
-
- return wasLogged;
- }
-
- /**
- * Logs the message provided with the WARN priority constant to the native
- * Android and Siphon Server outputs.
- *
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logWarning (String message) {
- return logWarning(SdlProxyBase.TAG, message);
- }
-
- /**
- * Logs the message provided with the WARN priority constant and tag to the
- * native Android and Siphon Server outputs.
- *
- * @param tag A string representing the sender of the message.
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logWarning (String tag, String message) {
-
- Boolean wasLogged = true;
-
- if (isSiphonServerLoggingEnabled) {
- String siphonMessage = prependVersionInfo(message);
- wasLogged = logToSiphon(siphonMessage);
- }
-
- if (wasLogged == null || wasLogged == false) {
- return false;
- }
-
- if (isNativeLoggingEnabled) {
- return log(Log.WARN, tag, message);
- }
-
- return wasLogged;
- }
-
- /**
- * Logs the message provided with the ERROR priority constant to the native
- * Android and Siphon Server outputs.
- *
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logError (String message) {
- return logError(SdlProxyBase.TAG, message);
- }
-
- /**
- * Logs the message provided with the ERROR priority constant and throwable
- * to the native Android and Siphon Server outputs.
- *
- * @param message A string to be logged.
- * @param throwable Details of what caused the error.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logError (String message, Throwable throwable) {
- return logError(SdlProxyBase.TAG, message, throwable);
- }
-
- /**
- * Logs the message provided with the ERROR priority constant and tag to the
- * native Android and Siphon Server outputs.
- *
- * @param tag A string representing the sender of the message.
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logError (String tag, String message) {
-
- String siphonMessage = prependVersionInfo(message);
- Boolean wasLogged = logToSiphon(siphonMessage);
-
- if (wasLogged == null || wasLogged == false) {
- return false;
- }
-
- return log(Log.ERROR, tag, message);
- }
-
- /**
- * Logs the message provided with the ERROR priority constant, tag and
- * throwable to the native Android and Siphon Server outputs.
- *
- * @param tag A string representing the sender of the message.
- * @param message A string to be logged.
- * @param throwable Details of what caused the error.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- public static boolean logError (String tag, String message, Throwable throwable) {
-
- // If a throwable was provided then write directly to the system log.
- if (throwable != null) {
-
- String siphonMessage = prependVersionInfo(message);
- Boolean wasLogged = logToSiphon(siphonMessage);
-
- if (wasLogged == null || wasLogged == false) {
- return false;
- }
-
- Log.e(tag, message, throwable);
- return true;
- } else {
- return logError(tag, message);
- }
- }
-
- /**
- * Logs the message provided with the appropriate target and tag to the
- * native Android output.
- *
- * @param target The type of information being sent (INFO/WARN/ERROR).
- * @param tag A string representing the sender of the message.
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled outputs.
- */
- private static boolean log (int target, String tag, String message) {
-
- // Do not log empty messages.
- if (message == null || message.length() == 0) {
- return false;
- }
-
- int bytesWritten = 0;
- int substringSize = 0;
-
- try {
-
- for (int index = 0; index < message.length(); index += substringSize) {
-
- substringSize = Math.min(CHUNK_SIZE, message.length() - index);
- String chunk = message.substring(index, index + substringSize);
-
- // Log to output with the appropriate priority constant.
- switch (target) {
- case Log.INFO:
- bytesWritten = Log.i(tag, chunk);
- break;
- case Log.WARN:
- bytesWritten = Log.w(tag, chunk);
- break;
- case Log.ERROR:
- bytesWritten = Log.e(tag, chunk);
- break;
- }
-
- // Check that the entire message was logged.
- if (bytesWritten < chunk.length()) {
- Log.e(tag, LOG_PARTIAL + chunk.length() + "," + bytesWritten);
- return false;
- }
- }
- } catch (Exception exception) {
- Log.e(tag, LOG_FAILURE + exception.toString());
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends log messages to the Siphon Server, initializing the server if it
- * has not already been initialized.
- *
- * @param message A string to be logged.
- * @return (Boolean) Whether the string was logged successfully to the
- * Siphon Server output.
- */
- private static Boolean logToSiphon (String message) {
-
- // Initialize the SiphonServer; if it has already been initialized this
- // call will be ignored.
- SiphonServer.init();
-
- return SiphonServer.sendSiphonLogData(message);
- }
-
- /**
- * Sends transport log messages to the native Android and Siphon Server
- * ouputs as well as the list of console listeners.
- *
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled logging options.
- */
- public static boolean logTransport (String message) {
- if (isConsoleListenerLoggingEnabled) {
- boolean wasLogged = logToConsole(LOG_TRANSPORT, message, null);
-
- if (wasLogged) {
- return logInfo(message);
- }
- }
- return false;
- }
-
- /**
- * Sends RPC sent log messages to the native Android and Siphon Server
- * outputs as well as the list of console listeners.
- *
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled logging options.
- */
- public static boolean logRpcSent (String message) {
- if (isConsoleListenerLoggingEnabled) {
- boolean wasLogged = logToConsole(LOG_RPC_SENT, message, null);
-
- if (wasLogged) {
- return logInfo("RPC message sent: " + message);
- }
- }
- return false;
- }
-
- /**
- * Sends RPC received log messages to the native Android and Siphon Server
- * outputs as well as the list of console listeners.
- *
- * @param message A string to be logged.
- * @return (boolean) Whether the string was logged successfully to all
- * enabled logging options.
- */
- public static boolean logRpcReceived (String message) {
- if (isConsoleListenerLoggingEnabled) {
- boolean wasLogged = logToConsole(LOG_RPC_RECEIVED, message, null);
-
- if (wasLogged) {
- return logInfo("RPC message received: " + message);
- }
- }
- return false;
- }
-
- /**
- * Sends log messages to the list of console listeners.
- *
- * @param flag An integer indicating what kind of message was provided.
- * @param message A string to be logged.
- * @param throwable (optional) If provided, and the kind of message is an
- * error, then the log will also send it to the console listeners.
- */
- @SuppressWarnings("unchecked")
- public static boolean logToConsole (int flag, String message, Throwable throwable) {
-
- Vector<IConsole> localList = null;
-
- synchronized (consoleListenerList) {
- localList = (Vector<IConsole>) consoleListenerList.clone();
- }
-
- if (localList == null) {
- return false;
- }
-
- for (int index = 0; index < localList.size(); index++) {
- IConsole listener = (IConsole) localList.elementAt(index);
-
- try {
-
- // Determine the type of message that is to be sent to the
- // console listeners.
- switch (flag) {
- case LOG_ERROR:
- if (throwable == null) {
- listener.logError(message);
- } else {
- listener.logError(message, throwable);
- }
- break;
- case LOG_TRANSPORT:
- listener.logInfo(message);
- break;
- case LOG_RPC_SENT:
- listener.logRPCSend(message);
- break;
- case LOG_RPC_RECEIVED:
- listener.logRPCReceive(message);
- break;
- default:
- return false;
- }
-
- } catch (Exception exception) {
- Log.e(SdlProxyBase.TAG, LOG_FAILURE + exception.toString());
- return false;
- }
- }
- return true;
- }
-
- /**
- * Prepends the version information to the string.
- *
- * @param message The string to add the version info prefix to.
- * @return (String) The prefixed message string.
- */
- private static String prependVersionInfo (String message) {
-
- if (message != null) {
- StringBuilder builder = new StringBuilder();
- builder.append(Version.VERSION);
- builder.append(": ");
- builder.append(message);
- message = builder.toString();
- }
-
- return message;
- }
-} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/Mime.java b/sdl_android_lib/src/com/smartdevicelink/util/Mime.java
deleted file mode 100644
index 8180aa3dc..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/util/Mime.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package com.smartdevicelink.util;
-
-public class Mime {
-
- private static String m_base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
- public static Boolean isSafeASCII(String check) {
- if (check.contains("&") || check.contains("<") || check.contains("]]") || check.contains("}") )
- return false; // these things aren't reliably CDATA encodable
-
- return true;
- }
-
- public static String base64Encode(String toEncode) {
-
- byte[] bytesToEncode = new byte[toEncode.length()];
- for (int i=0; i< toEncode.length(); i++)
- bytesToEncode[i] = (byte)toEncode.charAt(i);
-
- StringBuilder sb = new StringBuilder();
-
- int idxin = 0;
- int b64idx = 0;
-
- for (idxin=0;idxin < bytesToEncode.length;idxin++) {
- switch (idxin % 3) {
- case 0:
- b64idx = (bytesToEncode[idxin] >> 2) & 0x3f;
- break;
- case 1:
- b64idx = (bytesToEncode[idxin] >> 4) & 0x0f;
- b64idx |= ((bytesToEncode[idxin-1] << 4)& 0x30);
- break;
- case 2:
- b64idx = (bytesToEncode[idxin] >> 6) & 0x03;
- b64idx |= ((bytesToEncode[idxin-1] << 2)& 0x3c);
- sb.append(m_base64Chars.charAt(b64idx));
- b64idx = bytesToEncode[idxin] & 0x3f;
- break;
- } // end-switch
- sb.append(m_base64Chars.charAt(b64idx));
- } // end-for
-
- switch (idxin % 3) {
- case 0:
- break;
- case 1:
- b64idx = (bytesToEncode[idxin-1] << 4) & 0x30;
- sb.append(m_base64Chars.charAt(b64idx));
- sb.append("==");
- break;
- case 2:
- b64idx = ((bytesToEncode[idxin-1] << 2)& 0x3c);
- sb.append(m_base64Chars.charAt(b64idx));
- sb.append('=');
- break;
- } // end-switch
-
- return sb.toString();
- } // end-method
-
-
- @SuppressWarnings("unused")
- private byte[] base64Decode(String base64String) {
- byte[] outBytes = null;
- byte[] base64ASCIIString = null;
- final String ASCII_Encoding = "US-ASCII";
-
- // Convert b64 string to raw bytes
- try {
- base64ASCIIString = base64String.getBytes(ASCII_Encoding);
- } catch (Exception ex){
- // TODO
- //publishStatus("Failure converting b64string to ASCII string: " + ex.toString());
- return null;
- }
-
- if (!m_decodeInitComplete) {
- m_decodeInitComplete = true;
- initForDecode();
- } // end-if
-
- int numInChars = base64ASCIIString.length;
-
- if ((numInChars % 4) > 0) {
- return null;
- } // end-if
-
- int numOutBytes = base64ASCIIString.length / 4;
- numOutBytes *= 3;
- int eqpos = base64String.indexOf("=");
- if (eqpos >= 0) {
- numOutBytes--;
- if (base64String.substring(eqpos).indexOf("==") >= 0) {
- numOutBytes--;
- } // end-if
- } // end-if
- outBytes = new byte[numOutBytes];
-
- byte b64idxbits = 0x00;
- int iidx = 0, oidx = 0;
- byte writeByte = 0x00;
- byte b64ASCIIChar = 0x00;
- for (iidx=0, oidx=0;iidx < numInChars;iidx++) {
- b64ASCIIChar = base64ASCIIString[iidx];
- if (b64ASCIIChar == 0x3d /*'='*/) {
- return outBytes;
- } // end-if
-
- if (!isb64char(b64ASCIIChar)) {
- return null;
- } // end-if
-
- switch (iidx % 4) {
- case 0:
- break;
- case 1:
- b64idxbits = b64decode[base64ASCIIString[iidx-1]];
- writeByte = (byte)((b64idxbits << 2) | ((b64decode[b64ASCIIChar] >> 4) & 0x03));
- outBytes[oidx++] = writeByte;
- break;
- case 2:
- b64idxbits = b64decode[base64ASCIIString[iidx-1]];
- writeByte = (byte)(((b64idxbits << 4) & 0xf0) | ((b64decode[b64ASCIIChar] >> 2) & 0x0f));
- outBytes[oidx++] = writeByte;
- break;
- case 3:
- b64idxbits = b64decode[base64ASCIIString[iidx-1]];
- writeByte = (byte)(((b64idxbits << 6) & 0xc0) | ((b64decode[b64ASCIIChar]) & 0x3f));
- outBytes[oidx++] = writeByte;
- break;
- } // end-switch
- } // end-for
-
- return outBytes;
-
- } // end-method
-
-
- private static byte[] b64decode = new byte[256];
- // A-Z is 0x41-0x5a
- // a-z is 0x61-0x7a
- // 0-9 is 0x30-0x39
- // + is 0x2b
- // / is 0x2f
-
- private static boolean m_decodeInitComplete = false;
-
- private void initForDecode() {
- int aidx = 0;
- int lidx = 0;
- // Set A-Z
- for (aidx=0x41, lidx=0;aidx <= 0x5a;aidx++, lidx++) {
- b64decode[aidx] = (byte)lidx;
- } // end-for
- // Set a-z
- for (aidx=0x61;aidx <= 0x7a;aidx++, lidx++) {
- b64decode[aidx] = (byte)lidx;
- } // end-for
- // Set 0-9
- for (aidx=0x30;aidx <= 0x39;aidx++, lidx++) {
- b64decode[aidx] = (byte)lidx;
- } // end-for
- // Set '+'
- b64decode[0x2b] = (byte)lidx++;
- // Set '/'
- b64decode[0x2f] = (byte)lidx++;
- } // end-method
-
- private boolean isb64char(byte b) {
- // A-Z is 0x41-0x5a
- // a-z is 0x61-0x7a
- // 0-9 is 0x30-0x39
- // + is 0x2b
- // / is 0x2f
- return ( (b >= 0x41 && b <= 0x5a)
- || (b >= 0x61 && b <= 0x7a)
- || (b >= 0x30 && b <= 0x39)
- || (b == 0x2b)
- || (b == 0x2f)
- );
- } // end-method
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/SdlDataTypeConverter.java b/sdl_android_lib/src/com/smartdevicelink/util/SdlDataTypeConverter.java
index db0aa527b..fa958596e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/util/SdlDataTypeConverter.java
+++ b/sdl_android_lib/src/com/smartdevicelink/util/SdlDataTypeConverter.java
@@ -1,21 +1,34 @@
package com.smartdevicelink.util;
+/**
+ * This is a utility class to aid in handling values stored in the RPC classes.
+ */
public class SdlDataTypeConverter {
- public static Double objectToDouble(Object obj) {
- if (obj == null) {
+ /**
+ * Converts values that are retrieved from an RPC parameters Hashtable as an
+ * Object into the standard number value of the mobile API, Double.
+ *
+ * @param originalValue The value retrieved from an RPC parameters Hashtable.
+ * @return The Double representation of an integer or double value stored in
+ * the Object, or null if the value could not be converted.
+ */
+ public static Double objectToDouble(Object originalValue) {
+
+ if (originalValue == null) {
return null;
}
- Double D = null;
- if (obj instanceof Integer) {
- int i = ((Integer) obj).intValue();
- double d = (double) i;
- D = Double.valueOf(d);
- } else if (obj instanceof Double){
- D = (Double) obj;
+
+ Double result = null;
+
+ // Uses reflection to determine if the object is a valid type.
+ if (originalValue instanceof Integer) {
+ result = ((Integer) originalValue).doubleValue();
+ } else if (originalValue instanceof Double){
+ result = (Double) originalValue;
}
- return D;
+ return result;
}
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java b/sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java
index 8925101f6..3573ad351 100644
--- a/sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java
+++ b/sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java
@@ -1,27 +1,70 @@
package com.smartdevicelink.util;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+
import android.util.Log;
public class SdlLog {
- private static final String TAG = "SDL Logger";
- private static final String SDL_TAG = "<SDL> ";
- private static final String SDL_TRACE_TAG = "<SDL> Trace: ";
+
+ private final static String TAG = "SDL Log";
+ private final static String SDL_TAG = "<SDL> ";
+ private final static String SDL_TRACE_TAG = "<SDL TRACE> ";
+
+
public static final int SDL_LOG_LEVEL_OFF = 0;
+ /**
+ * Used to log low-level SDL specific information.
+ */
public static final int SDL_LOG_LEVEL_TRACE = 10;
+ /**
+ * Used for non-critical information needed for development only.
+ */
public static final int SDL_LOG_LEVEL_VERBOSE = 20;
+ /**
+ *Used for information needed for development only.
+ */
public static final int SDL_LOG_LEVEL_DEBUG = 30;
+ /**
+ * Used to log information reports of successful operations.
+ */
public static final int SDL_LOG_LEVEL_INFO = 40;
+ /**
+ * Used to log information when an unexpected but tolerable
+ * behavior occurs.
+ */
public static final int SDL_LOG_LEVEL_WARN = 50;
+ /**
+ * Used to log information when an unexpected breaking behavior
+ * occurs.
+ */
public static final int SDL_LOG_LEVEL_ERROR = 60;
+ /**
+ * Used to log cases that should never happen
+ */
public static final int SDL_LOG_LEVEL_WTF = 100;
+
+ private static boolean isFileLoggingEnabled = false;
private static int logLevel = SDL_LOG_LEVEL_OFF;
/**
* Sets the level of logging this application would like to receive.
* Since logging can force an app to take a performance hit, make sure to
* turn off before pushing to production.
+ * /**
+ *
+ * <p><table border="1" rules="all">
+ * <tr><td>SDL_LOG_LEVEL_OFF</td><td>0</td><td>All Disabled</td></tr>
+ * <tr><td>SDL_LOG_LEVEL_TRACE</td><td>1</td><td>All Enabled</td></tr>
+ * <tr><td>SDL_LOG_LEVEL_VERBOSE</td><td>2</td><td>2-7</td></tr>
+ * <tr><td>SDL_LOG_LEVEL_DEBUG</td><td>3</td><td>3 - 7 Enabled</td></tr>
+ * <tr><td>SDL_LOG_LEVEL_INFO</td><td>4</td><td>4 - 7 Enabled</td></tr>
+ * <tr><td>SDL_LOG_LEVEL_WARN</td><td>5</td><td>5 - 7 Enabled</td></tr>
+ * <tr><td>SDL_LOG_LEVEL_ERROR</td><td>6</td><td>6 - 7 Enabled</td></tr>
+ * <tr><td>SDL_LOG_LEVEL_WTF</td><td>7</td><td>7 Enabled</td></tr>
* @param logLevel level constants contained in this class
*/
public static void setDebugLevel(int logLevel){
@@ -49,60 +92,111 @@ public class SdlLog {
return logLevel == SdlLog.SDL_LOG_LEVEL_TRACE;
}
- public static void trace(String tag, String message){
- internalLog(SDL_LOG_LEVEL_TRACE, tag, message);
+ /**
+ * Provides whether file logging is enabled or disabled.
+ *
+ * @return (boolean) The file logging toggle.
+ */
+ public static boolean isFileLoggingEnabled() {
+ return isFileLoggingEnabled;
+ }
+
+ /** Toggles the file logging functionality.
+ *
+ * @param log Whether file logging is to be enabled or disabled.
+ */
+ public static void enableWritingToFile(boolean log) {
+ isFileLoggingEnabled = log;
+ Log.i(TAG, "File Logging " + ((log) ? "On" : "Off"));
}
-
+
+
+
/**
- * Send a VERBOSE SDL log message. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
+ * Send a VERBOSE SDL log message.Logs messages to the native Android log tool if the log level allowed
+ * does not exceed the verbose level. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
* @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
* @param message The message you would like logged.
*/
- public static void v(String tag, String message){
- internalLog(SDL_LOG_LEVEL_TRACE, tag, message);
+ public static boolean v(String tag, String message){
+ return internalLog(SDL_LOG_LEVEL_TRACE, tag, message, null);
}
/**
- * Send a DEBUG SDL log message. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
+ * Send a DEBUG SDL log message. Logs messages to the native Android log tool if the log level allowed
+ * does not exceed the debug level.<br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
* @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
* @param message The message you would like logged.
*/
- public static void d(String tag, String message){
- internalLog(SDL_LOG_LEVEL_DEBUG, tag, message);
+ public static boolean d(String tag, String message){
+ return internalLog(SDL_LOG_LEVEL_DEBUG, tag, message, null);
}
/**
- * Send a INFO SDL log message. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
+ * Send a INFO SDL log message. Logs messages to the native Android log tool if the log level allowed
+ * does not exceed the info level.<br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
* @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
* @param message The message you would like logged.
*/
- public static void i(String tag, String message){
- internalLog(SDL_LOG_LEVEL_INFO, tag, message);
+ public static boolean i(String tag, String message){
+ return internalLog(SDL_LOG_LEVEL_INFO, tag, message, null);
}
/**
- * Send a WARNING SDL log message. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
+ * Send a WARNING SDL log message. Logs messages to the native Android log tool if the log level allowed
+ * does not exceed the warning level.<br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
* @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
* @param message The message you would like logged.
*/
- public static void w(String tag, String message){
- internalLog(SDL_LOG_LEVEL_WARN, tag, message);
+ public static boolean w(String tag, String message){
+ return internalLog(SDL_LOG_LEVEL_WARN, tag, message, null);
}
/**
- * Send a ERROR SDL log message. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
+ * Send a ERROR SDL log message.Logs messages to the native Android log tool if the log level allowed
+ * does not exceed the error level. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
* @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
* @param message The message you would like logged.
*/
- public static void e(String tag, String message){
- internalLog(SDL_LOG_LEVEL_ERROR, tag, message);
+ public static boolean e(String tag, String message){
+ return internalLog(SDL_LOG_LEVEL_ERROR, tag, message, null);
}
/**
- * What a Terrible Failure: Report a condition that should never happen. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
+ * Send a ERROR SDL log message.Logs messages to the native Android log tool if the log level allowed
+ * does not exceed the error level. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
* @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
* @param message The message you would like logged.
+ * @param throwable The details of an exception or error, may be null.
*/
- public static void wtf(String tag, String message){
- internalLog(SDL_LOG_LEVEL_WTF, tag, message);
+ public static boolean e(String tag, String message,Throwable throwable){
+ return internalLog(SDL_LOG_LEVEL_ERROR, tag, message, throwable);
}
-
- private static void internalLog(int level, String tag, String message){
+ /**
+ * What a Terrible Failure: Report a condition that should never happen. Logs messages to the native Android log tool if the log level allowed
+ * does not exceed the what a terrible failure level. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
+ * @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
+ * @param message The message you would like logged.
+ */
+ public static boolean wtf(String tag, String message){
+ return internalLog(SDL_LOG_LEVEL_WTF, tag, message, null);
+ }
+ /**
+ * What a Terrible Failure: Report a condition that should never happen. Logs messages to the native Android log tool if the log level allowed
+ * does not exceed the what a terrible failure level. <br>It will have the string "<b>&lt;SDL&gt;</b>" attached to the tag for easy filtering
+ * @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
+ * @param message The message you would like logged.
+ * @param throwable The details of an exception or error, may be null.
+ */
+ public static boolean wtf(String tag, String message,Throwable throwable){
+ return internalLog(SDL_LOG_LEVEL_WTF, tag, message, throwable);
+ }
+ /**
+ * Logs messages that exceed the allowed log level to the native Android log
+ * tool.
+ *
+ * @param level The logging level of the message.
+ * @param tag Used to identify the source of a log message. It usually identifies the class or activity where the log call occurs.
+ * @param message The message to be logged, may not be null or empty.
+ * @param throwable The details of an exception or error, may be null.
+ * @return (boolean) Whether the message was logged successfully.
+ */
+ private static boolean internalLog(int level, String tag, String message, Throwable throwable){
if(logLevel>0 && logLevel<=level){
if(tag!=null && message!=null){
switch(level){
@@ -127,16 +221,68 @@ public class SdlLog {
case SDL_LOG_LEVEL_WTF:
Log.wtf(tag, SDL_TAG + message);
break;
+ default:
+ return false;
}
- }
- else{
+ }else{
logError();
+ return false;
}
}//else we don't log it
+ if (isFileLoggingEnabled) {
+ try {
+ StringBuilder build = new StringBuilder(TAG);
+ if (level == SDL_LOG_LEVEL_TRACE) {
+ build.append(SDL_TRACE_TAG);
+ }else{
+ build.append(SDL_TAG);
+ }
+ build.append(message);
+ build.append("\n");
+ if (throwable != null) {
+ build.append(throwable.getMessage());
+ writeToDisk(build.toString());
+ }
+ } catch (Throwable t) {
+ // This should never happen!
+ Log.wtf(TAG, "Logging failure!", t);
+ return false;
+ }
+ }
+ return true;
}
private static void logError(){
Log.e(TAG, SDL_TAG + "ERROR LOGGING");
}
+
+ private static boolean writeToDisk(String message) {
+
+ File logFile = new File("sdcard/sdllog.txt");
+
+ if (!logFile.exists()) {
+ try {
+ logFile.createNewFile();
+ } catch (Throwable t) {
+ e(TAG,"Could not create log file on device.", t);
+ return false;
+ }
+ }
+
+ try {
+ i(TAG,"Logging to file 'sdllog.txt' on external storage.");
+ BufferedWriter buff = new BufferedWriter(new FileWriter(logFile, true));
+ buff.append(message);
+ buff.newLine();
+ buff.close();
+ } catch (Throwable t) {
+ e(TAG,"Error writing to log file on device.", t);
+ return false;
+ }
+
+ return true;
+ }
}
+
+
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/StringEnumer.java b/sdl_android_lib/src/com/smartdevicelink/util/StringEnumer.java
deleted file mode 100644
index 34ab1a300..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/util/StringEnumer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.smartdevicelink.util;
-
-import java.util.Vector;
-
-public abstract class StringEnumer {
-
- protected StringEnumer(int value, String name) {
- this.value = value;
- this.name = name;
- }
-
- private int value;
- private String name;
-
- public int getValue() { return value; }
- public String getName() { return name; }
-
- public boolean equals(StringEnumer other) {
- return name == other.getName();
- }
-
- public boolean eq(StringEnumer other) {
- return equals(other);
- }
-
- public String toString() {
- return name;
- }
-
- public static StringEnumer get(Vector<? extends StringEnumer> theList, int value) {
- for (StringEnumer current : theList) {
- if (current.getValue() == value) {
- return current;
- }
- }
- return null;
- }
-
- public static StringEnumer get(Vector<? extends StringEnumer> theList, String name) {
- for (StringEnumer current : theList) {
- if (current.getName().equalsIgnoreCase(name)) {
- return current;
- }
- }
- return null;
- }
-}