summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2017-10-30 14:54:34 -0400
committerJoey Grover <joeygrover@gmail.com>2017-10-30 14:54:34 -0400
commit83c28f5dcd40214fdaedd9013f9bbe60264ed319 (patch)
tree80bd3a414deac49c9148adfb581a050d2dad13c5
parent13a70ef1deb527a0a3c9bdc07e6512f2ede0fa84 (diff)
parente8c439ebf6dfb342cfad1d5b0241f6592925acbc (diff)
downloadsdl_android-83c28f5dcd40214fdaedd9013f9bbe60264ed319.tar.gz
Merge branch 'release/4.4.0-rc1' of https://github.com/smartdevicelink/sdl_android4.4.0
-rw-r--r--.github/CONTRIBUTING.md (renamed from CONTRIBUTING.md)0
-rw-r--r--.github/ISSUE_TEMPLATE.md23
-rw-r--r--.github/PULL_REQUEST_TEMPLATE.md33
-rw-r--r--.travis.yml30
-rw-r--r--CHANGELOG.md71
-rw-r--r--README.md7
-rw-r--r--sdl_android/bintray.gradle71
-rw-r--r--sdl_android/bintray.properties8
-rw-r--r--sdl_android/build.gradle29
-rw-r--r--sdl_android/src/androidTest/assets/json/ButtonPress.json15
-rw-r--r--sdl_android/src/androidTest/assets/json/DeleteInteractionChoiceSet.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/DeleteSubMenu.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/DialNumber.json13
-rw-r--r--sdl_android/src/androidTest/assets/json/GetInteriorVehicleData.json38
-rw-r--r--sdl_android/src/androidTest/assets/json/GetSystemCapability.json18
-rw-r--r--sdl_android/src/androidTest/assets/json/GetWayPoints.json18
-rw-r--r--sdl_android/src/androidTest/assets/json/PerformInteraction.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/PutFile.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/RegisterAppInterface.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/SendHapticData.json22
-rw-r--r--sdl_android/src/androidTest/assets/json/SendLocation.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/SetGlobalProperties.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/SetInteriorVehicleData.json56
-rw-r--r--sdl_android/src/androidTest/assets/json/ShowConstantTBT.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/Slider.json2
-rw-r--r--sdl_android/src/androidTest/assets/json/StreamRPC.json10
-rw-r--r--sdl_android/src/androidTest/assets/json/SubscribeWayPoints.json10
-rw-r--r--sdl_android/src/androidTest/assets/json/UnsubscribeWayPoints.json10
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/SdlConnection/SdlConnectionTest.java18
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/protocol/WiProProtocolTests.java63
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java2
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java50
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java264
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java674
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/encoder/EncoderUtilsTest.java116
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCMessageTests.java141
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java80
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestTest.java48
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java158
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java507
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java173
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ClimateControlCapabilitiesTests.java160
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ClimateControlDataTests.java130
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/CoordinateTests.java73
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DateTimeTests.java109
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HMICapabilitiesTests.java74
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java73
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/LocationDetailsTests.java113
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/MetadataTagsTests.java110
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ModuleDataTests.java95
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/NavigationCapabilityTests.java69
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/OasisAddressTests.java95
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PhoneCapabilityTests.java64
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RadioControlCapabilitiesTests.java112
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RadioControlDataTests.java124
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RdsDataTests.java101
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RectangleTests.java79
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RemoteControlCapabilitiesTests.java131
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java9
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SystemCapabilityTests.java108
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/TemperatureTests.java72
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingCapabilityTests.java96
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingFormatTests.java70
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java14
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ButtonNameTests.java77
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DefrostZoneTests.java79
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DisplayTypeTests.java36
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/LanguageTests.java62
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MetadataTypeTests.java114
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ModuleTypeTests.java71
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/RadioBandTests.java75
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/RadioStateTests.java79
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java10
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java115
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TouchTypeTests.java17
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VentilationModeTests.java79
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VideoStreamingCodecTests.java79
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VideoStreamingProtocolTests.java82
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnInteriorVehicleDataTests.java69
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSdlChoiceChosenTests.java8
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnStreamRPCTests.java76
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnWayPointChangeTests.java86
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ButtonPressTests.java113
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java97
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java105
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java95
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java96
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java86
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java102
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java35
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java73
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java73
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java74
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java74
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java110
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java97
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java123
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java104
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java2
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/StreamRPCResponseTests.java89
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java73
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java73
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java2
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java112
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java61
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java33
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockStreamListener.java13
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java471
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java14
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java882
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java139
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/trace/DiagLevelTests.java2
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java55
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/util/BitConverterTests.java10
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/util/DeviceUtil.java17
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlDataTypeConverterTests.java2
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/test/util/VersionTest.java31
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java14
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java145
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java51
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/transport/SdlRouterServiceTests.java132
-rw-r--r--sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java74
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java4
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java11
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java191
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java107
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java63
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java400
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/haptic/HapticInterfaceManager.java131
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/AbstractProtocol.java7
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java2
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java5
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/ProtocolMessage.java8
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java34
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java244
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java85
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java8
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java14
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java55
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequest.java5
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java142
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java1671
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java2260
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java167
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IAudioStreamListener.java71
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java20
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java116
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdlServiceListener.java11
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IVideoStreamListener.java90
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/OnSystemCapabilityListener.java6
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java69
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java28
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java116
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java107
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java57
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java49
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java216
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java78
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java38
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPress.java94
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPressResponse.java28
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java94
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java92
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlCapabilities.java280
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlData.java106
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java53
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java16
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java38
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java30
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java20
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java72
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java49
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java110
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java38
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java22
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java10
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java153
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java48
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java69
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java161
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java20
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java33
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleData.java79
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java70
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapability.java48
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java48
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java211
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java347
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java14
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java24
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java51
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java60
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java82
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java30
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java86
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Image.java26
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java74
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java22
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java87
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java31
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java97
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java28
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MetadataTags.java116
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ModuleData.java75
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java14
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/NavigationCapability.java35
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java72
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java18
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java40
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java40
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java26
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java18
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java47
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java13
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnInteriorVehicleData.java47
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java26
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java32
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java37
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java28
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java28
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnStreamRPC.java24
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java90
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java18
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java44
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java345
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java24
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java38
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java104
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java162
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java34
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java45
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PhoneCapability.java27
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java60
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlCapabilities.java236
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlData.java223
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RdsData.java180
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java31
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java30
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java109
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java170
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java318
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RemoteControlCapabilities.java82
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java35
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java45
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java46
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java45
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java86
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticDataResponse.java54
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java135
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java14
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java81
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java128
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleData.java51
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java47
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java47
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Show.java180
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java133
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java18
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java55
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java12
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java70
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java36
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java30
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java28
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java20
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java19
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java196
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java433
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java67
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java46
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java26
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Temperature.java56
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java46
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java130
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java16
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java46
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java24
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java28
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java18
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java192
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java430
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java57
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java28
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java36
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java52
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingFormat.java46
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java34
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/AppHMIType.java11
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ButtonName.java23
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/DefrostZone.java17
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Language.java89
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/MetadataType.java96
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ModuleType.java15
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RadioBand.java16
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RadioState.java20
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java11
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java400
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TemperatureUnit.java14
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TouchType.java6
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VentilationMode.java17
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VideoStreamingCodec.java50
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VideoStreamingProtocol.java44
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java34
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java164
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingCodec.java49
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingLPCMParams.java64
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingParams.java55
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/streaming/video/RTPH264Packetizer.java507
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java208
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java218
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/trace/DiagLevel.java33
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/trace/Mime.java71
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java168
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java1
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java20
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java231
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/SdlPsm.java2
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java150
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java3
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java11
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java29
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/util/BitConverter.java34
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java141
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/util/Version.java47
-rw-r--r--sdl_android/src/test/java/com/smartdevicelink/haptic/HapticInterfaceManagerTest.java169
334 files changed, 20879 insertions, 8875 deletions
diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 8c8821977..8c8821977 100644
--- a/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 000000000..c8cc89515
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,23 @@
+[Delete any non-applicable sections, but we may ask for more information.]
+
+### Bug Report
+[Summary]
+
+##### Reproduction Steps
+1. [Step 1]
+2. [Step 2]
+3. [Step 3]
+
+##### Expected Behavior
+[Some expected behavior]
+
+##### Observed Behavior
+[Some observed behavior]
+
+##### OS & Version Information
+* Android Version: [What version of Android are you using when the bug occurred]
+* SDL Android Version: [What version of the library has this bug been seen on]
+* Testing Against: [What you tested with to observe this behavior]
+
+##### Test Case, Sample Code, and / or Example App
+[Paste a link to a PR, gist, or other code that exemplifies this behavior]
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 000000000..8581b12e8
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,33 @@
+[Things to note: Pull Requests **must** fix an issue. Discussion about the feature / bug takes place in the issue, discussion of the implementation takes place in the PR. Please also see the [Contributing Guide](https://github.com/smartdevicelink/sdl_android/blob/master/.github/CONTRIBUTING.md) for information on branch naming and the CLA.
+
+Delete the above section when you've read it.]
+
+Fixes #[issue number]
+
+This PR is **[ready / not ready]** for review.
+
+### Risk
+This PR makes **[no / minor / major]** API changes.
+
+### Testing Plan
+[Describe how you plan to unit test the changes in this PR]
+
+### Summary
+[Summary of PR changes]
+
+### Changelog
+##### Breaking Changes
+* [Breaking change info]
+
+##### Enhancements
+* [Enhancement info]
+
+##### Bug Fixes
+* [Bug Fix Info]
+
+### Tasks Remaining:
+- [ ] [Task 1]
+- [ ] [Task 2]
+
+### CLA
+- [ ] I have signed [the CLA](https://docs.google.com/forms/d/e/1FAIpQLSdsgJY33VByaX482zHzi-xUm49JNnmuJOyAM6uegPQ2LXYVfA/viewform) \ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index b35079b14..fb7fc4dbe 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,18 +4,30 @@ sudo: false
android:
components:
# use the latest revision of Android SDK Tools
- - platform-tools
- tools
+ - tools
+ - platform-tools
+ - ndk-bundle
# The BuildTools version used by your project
- - build-tools-25.0.2
+ - build-tools-26.0.1
# The SDK version used to compile your project
- - android-19
+ - android-26
+ - android-22 #For emulator
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- - sys-img-armeabi-v7a-android-21
- # - sys-img-x86-android-17
+ - sys-img-armeabi-v7a-android-22
+ # - sys-img-x86-android-26
+
+ # Android Support Repos
+ - extra-android-m2repository
+ - extra-google-m2repository
+
+licenses:
+ - 'android-sdk-preview-license-.+'
+ - 'android-sdk-license-.+'
+ - 'google-gdk-license-.+'
env:
global:
@@ -24,7 +36,7 @@ env:
# Emulator Management: Create, Start and Wait
before_script:
- - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
+ - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
@@ -32,3 +44,9 @@ before_script:
script:
- android list target
- ./gradlew connectedAndroidTest
+
+before_install:
+ - pip install --user codecov #Install codecov
+
+after_success:
+ - codecov #Run codecov
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fe1aee747..057a576dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,37 +1,48 @@
-# 4.3.0 Release Notes
+# 4.4.0 Release Notes
### API New Features & Breaking Changes
-* The library has now moved to Android Studio as its default IDE. All files and folders have been moved to align with proper Android Studio project structure.
-* The target API level is now `19` instead of `18`. Apps will also need to target this version or higher to continue using this library.
-* `Java 7` is now used to compile the library and its features can be used moving forward.
+- Now uses compile version 26 to handle breaking changes in Android Oreo
+- `MOBILE_PROJECTION` added as an app type
+- Gesture cancellation was added as a touch even type
+- More languages were added to the `Language` enum
+- `SystemCapaibilityQuery` was added with a new `SystemCapabilityManager` that can retrieve capabilities
+- `VideoStreamingCapabilities` were added. Includes supported codecs, resolution, etc
+- Added constructed payloads using BSON
+- SDL Remote Control functionality was added. Supports radio and climate controls.
+- Added `MetadataType` to `Show` lines
+- Spatial data for video streaming apps added with `HapticData`
+
### Enhancements
-* Multiplexing bluetooth, legacy bluetooth, and TCP transport has been improved in performance by switching to buffer reads vs single byte read from transport.
-* Trusted router service checking feature is now adjustable by developers.
-* More unit tests were created.
-* Router service will now check to make sure the app that propagated it has permissions to use bluetooth.
-* Packet streaming classes will now use the agreed upon MTU instead of the hardcoded 1024 when the stream is not encrypted.
-* App IDs sent between the client apps and the router service are now Strings instead of Longs to support longer IDs.
+- Enhanced video streaming APIs
+- Added much more test coverage
+- Updated buffer read in sizes and streaming packetizers to use TLS max record size
+- Consolidated all references to `sdl.router.startservice` string into single constant
+- Refactored RPC classes to consolidate redundant code for retrieving items from underlying data structures
+- `MultiplexBluetoothTransport` is no longer a singleton
+- Improved inline documentation
+- h.264 streaming now includes SPS/PPS NAL units with every I frame to match iOS library
+- Real-time Transport Protocol (RTP) video streaming is now supported
+- Correlation IDs are now set automatically. Can be retrieved or overwritten by developer.
+- Introduced new video streaming callback and deprecated used of pipped streams
+- Added an internal interface for common functions between different managers
### Bug Fixes
-* Fixed issue with AOA transport not clearing old accessory reference after disconnect
-* Fixed missing setting of error state in multiplexing bluetooth transport
-* Fixed potential OOMs when corrupted packets are recieved in:
- * `SdlPsm`
- * `WiProProtocol`
- * `BinaryFrameHeader`
-* Fixed possible NPEs in:
- * `SdlRouterService` when checking for correct process
- * `MultiplexingBluetoothTransport` during reads and writes
- * `SdlConnection` during session registration
- * `SdlProxyBase` when clearing RPC response and notification listeners during close
- * `TransportBroker` when sending a message to router service
- * `SdlBroadcastReceiver` during check for running router service
- * `HttpRequestTask` that happens when a server can't be reached
- * `SdlSecurityBase` when a security lib would become initialized after the base has been reset.
-* Added synchronization to a cancel call in the `MultiplexTransport`
-* Refactor code in `SdlBroadcastReceiver` to protect against a potential SecurityException
-* Added try/catch around bluetooth system calls that can fail in Android classes
-* Added try/catch when attempting to build `LocalRouterService` object from parcel when parcel could be corrupt
-* Fixed version checking flow in the router service to be cleaner and correctly synched
+- Fixed potential out of bounds exception in `BinaryFrameHeader`
+- Fixed issues with unit tests and TravisCI
+- Fixed potential NPE in `SdlProxyBase`method, `performBaseCommon()`
+- Fixed potential NPE in `MultiplexTransport` constructor
+- Fixed potential NPE in `SdlRouterService`method, `handleMessaage()` for `AltTransportHandler`
+- Fixed potential NPE in `SdlRouterService`method, `writeBytesToTransport()`
+- Removed hardcoded `androidDebuggable = "true"` from manifest
+- Added fixes to be compatible with Android Oreo (Does not supported target API level 26 yet)
+- Fixed issue where intent from router service was delayed
+- Apps now trust themselves as router service hosts
+- Removed ambiguous validation call in `SdlBroadcastReceiver` and unused intent extra
+- Cleared all warnings from `SdlProxyBase`
+### Meta
+- Added integration that will deploy to Bintray
+- Issue and pull request templates were added for GitHub
+- Codecov integration was added
+- Updated README links
diff --git a/README.md b/README.md
index 0cfead7f5..1af436d8f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,7 @@
+[![Build Status](https://travis-ci.org/smartdevicelink/sdl_android.svg?branch=master)](https://travis-ci.org/smartdevicelink/sdl_android)
+[![codecov](https://codecov.io/gh/smartdevicelink/sdl_android/branch/master/graph/badge.svg)](https://codecov.io/gh/smartdevicelink/sdl_android)
[![Slack Status](http://sdlslack.herokuapp.com/badge.svg)](http://slack.smartdevicelink.com)
+[ ![Download](https://api.bintray.com/packages/smartdevicelink/sdl_android/sdl_android/images/download.svg) ](https://bintray.com/smartdevicelink/sdl_android/sdl_android/_latestVersion)
# 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.
@@ -19,6 +22,8 @@ The mobile library component of SDL is meant to run on the end user’s smart-de
## 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).
+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://smartdevicelink.com)
You can also find some branches that have yet to be merged into this GitHub project on the GENIVI page [here](http://git.projects.genivi.org/?p=smartdevicelink_android.git;a=summary).
+
+For easy integration of SmartDeviceLink Android into your project using Gradle, Maven or Ivy please grab a snippet from [Bintray](https://bintray.com/smartdevicelink/sdl_android/sdl_android)
diff --git a/sdl_android/bintray.gradle b/sdl_android/bintray.gradle
new file mode 100644
index 000000000..ebbf65599
--- /dev/null
+++ b/sdl_android/bintray.gradle
@@ -0,0 +1,71 @@
+apply plugin: "com.jfrog.bintray"
+apply plugin: 'com.github.dcendents.android-maven'
+apply plugin: 'maven-publish'
+
+def siteUrl = 'https://github.com/smartdevicelink/sdl_android' // Homepage URL of the library
+def gitUrl = 'https://github.com/smartdevicelink/sdl_android.git' // Git repository URL
+group = "com.smartdevicelink" // Maven Group ID for the artifact
+def libDescription = 'SmartDeviceLink mobile library for Android'
+
+install {
+ repositories.mavenInstaller {
+ pom {
+ project {
+ packaging 'aar'
+
+ // Add your description here
+ name 'com.smartdevicelink:sdl_android'
+ description = libDescription
+ url siteUrl
+
+ // Set your license
+ licenses {
+ license {
+ name 'BSD 3-Clause'
+ url 'https://opensource.org/licenses/BSD-3-Clause'
+ }
+ }
+ scm {
+ connection gitUrl
+ developerConnection gitUrl
+ url siteUrl
+ }
+ }
+ }
+ }
+}
+
+task sourcesJar(type: Jar) {
+ from android.sourceSets.main.java.srcDirs
+ classifier = 'sources'
+}
+
+artifacts {
+ archives sourcesJar
+}
+
+bintray {
+ Properties props = new Properties()
+ props.load(new FileInputStream("$projectDir/bintray.properties"))
+
+ // Authorization
+ user = props.getProperty("bintray.user")
+ key = props.getProperty("bintray.key")
+
+ configurations = ['archives']
+ pkg {
+ repo = props.getProperty("bintray.repo")
+ name = props.getProperty("bintray.artifact")
+ websiteUrl = siteUrl
+ vcsUrl = gitUrl
+ userOrg = props.getProperty("bintray.userorg")
+ licenses = ["BSD 3-Clause"]
+ publish = props.getProperty("bintray.publish") // Will upload to jCenter
+ version {
+ name = props.getProperty("bintray.version") // Change to release version
+ desc = libDescription
+ released = new Date() // Will be the current date & time
+ vcsTag = props.getProperty("bintray.vcs") // Should match git tag
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/bintray.properties b/sdl_android/bintray.properties
new file mode 100644
index 000000000..760f99904
--- /dev/null
+++ b/sdl_android/bintray.properties
@@ -0,0 +1,8 @@
+bintray.user=username
+bintray.key=apikey
+bintray.repo=sdl_android
+bintray.artifact=sdl_android
+bintray.userorg=smartdevicelink
+bintray.publish=true
+bintray.version=X.X.X
+bintray.vcs=X.X.X \ No newline at end of file
diff --git a/sdl_android/build.gradle b/sdl_android/build.gradle
index 1871a063c..843dd2af0 100644
--- a/sdl_android/build.gradle
+++ b/sdl_android/build.gradle
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'
android {
- compileSdkVersion 19
+ compileSdkVersion 26
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 8
@@ -15,6 +15,9 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
+ debug {
+ testCoverageEnabled = true
+ }
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
@@ -23,12 +26,36 @@ android {
lintOptions {
abortOnError false
}
+
+ testOptions {
+ unitTests.returnDefaultValues = true
+ }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile ('com.smartdevicelink:bson_java_port:1.0.0@aar'){
+ transitive = true
+ }
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
+ testCompile 'org.mockito:mockito-core:2.9.0'
+
}
+
+buildscript {
+ repositories {
+ jcenter()
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
+ classpath 'com.trickyandroid:jacoco-everywhere:0.2.1'
+ }
+}
+
+apply from: 'bintray.gradle'
+apply plugin: 'jacoco-everywhere' \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/ButtonPress.json b/sdl_android/src/androidTest/assets/json/ButtonPress.json
new file mode 100644
index 000000000..e74e857be
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/ButtonPress.json
@@ -0,0 +1,15 @@
+{
+ "request":{
+ "name":"ButtonPress",
+ "correlationID":215,
+ "parameters":{
+ "buttonName":"OK",
+ "buttonPressMode":"LONG",
+ "moduleType":"CLIMATE"
+ }
+ },
+ "response":{
+ "name":"ButtonPressResponse",
+ "correlationID":216
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/DeleteInteractionChoiceSet.json b/sdl_android/src/androidTest/assets/json/DeleteInteractionChoiceSet.json
index 40419f005..60f9a6c61 100644
--- a/sdl_android/src/androidTest/assets/json/DeleteInteractionChoiceSet.json
+++ b/sdl_android/src/androidTest/assets/json/DeleteInteractionChoiceSet.json
@@ -3,7 +3,7 @@
"name":"DeleteInteractionChoiceSet",
"correlationID":119,
"parameters":{
- "interactionChoiceSetID":56,
+ "interactionChoiceSetID":56
}
},
"response":{
diff --git a/sdl_android/src/androidTest/assets/json/DeleteSubMenu.json b/sdl_android/src/androidTest/assets/json/DeleteSubMenu.json
index d0619a1f6..c31eb189d 100644
--- a/sdl_android/src/androidTest/assets/json/DeleteSubMenu.json
+++ b/sdl_android/src/androidTest/assets/json/DeleteSubMenu.json
@@ -3,7 +3,7 @@
"name":"DeleteSubMenu",
"correlationID":121,
"parameters":{
- "menuID":765,
+ "menuID":765
}
},
"response":{
diff --git a/sdl_android/src/androidTest/assets/json/DialNumber.json b/sdl_android/src/androidTest/assets/json/DialNumber.json
new file mode 100644
index 000000000..cb79aad84
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/DialNumber.json
@@ -0,0 +1,13 @@
+{
+ "request":{
+ "name":"DialNumber",
+ "correlationID":194,
+ "parameters":{
+ "wayPointType":"DESTINATION"
+ }
+ },
+ "response":{
+ "name":"DialNumberResponse",
+ "correlationID":195
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/GetInteriorVehicleData.json b/sdl_android/src/androidTest/assets/json/GetInteriorVehicleData.json
new file mode 100644
index 000000000..7000d2918
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/GetInteriorVehicleData.json
@@ -0,0 +1,38 @@
+{
+ "request":{
+ "name":"GetInteriorVehicleData",
+ "correlationID":101,
+ "parameters":{
+ "subscribe":true,
+ "moduleType":"CLIMATE"
+ }
+ },
+ "response":{
+ "name":"GetInteriorVehicleDataResponse",
+ "correlationID":102,
+ "parameters":{
+ "isSubscribed":true,
+ "moduleData":{
+ "moduleType":"CLIMATE",
+ "climateControlData":{
+ "circulateAirEnable":true,
+ "ventilationMode":"UPPER",
+ "acEnable":true,
+ "currentTemperature":{
+ "unit":"CELSIUS",
+ "value":100.0
+ },
+ "acMaxEnable":true,
+ "desiredTemperature":{
+ "unit":"CELSIUS",
+ "value":100.0
+ },
+ "dualModeEnable":true,
+ "autoModeEnable":true,
+ "fanSpeed":100,
+ "defrostZone":"FRONT"
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/GetSystemCapability.json b/sdl_android/src/androidTest/assets/json/GetSystemCapability.json
new file mode 100644
index 000000000..c96bf6013
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/GetSystemCapability.json
@@ -0,0 +1,18 @@
+{
+ "request":{
+ "name":"GetSystemCapability",
+ "correlationID":203,
+ "parameters":{
+ "systemCapabilityType":"NAVIGATION"
+ }
+ },
+ "response":{
+ "name":"GetSystemCapabilityResponse",
+ "correlationID":204,
+ "parameters":{
+ "systemCapability":{
+ "systemCapabilityType":"NAVIGATION"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/GetWayPoints.json b/sdl_android/src/androidTest/assets/json/GetWayPoints.json
new file mode 100644
index 000000000..8d06a9dd6
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/GetWayPoints.json
@@ -0,0 +1,18 @@
+{
+ "request":{
+ "name":"GetWayPoints",
+ "correlationID":196,
+ "parameters":{
+ "wayPointType":"DESTINATION"
+ }
+ },
+ "response":{
+ "name":"GetWayPointsResponse",
+ "correlationID":197,
+ "parameters":{
+ "wayPoints":[
+ {}, {}
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/PerformInteraction.json b/sdl_android/src/androidTest/assets/json/PerformInteraction.json
index 1096d9c4d..b8965ee61 100644
--- a/sdl_android/src/androidTest/assets/json/PerformInteraction.json
+++ b/sdl_android/src/androidTest/assets/json/PerformInteraction.json
@@ -69,7 +69,7 @@
"parameters":{
"manualTextEntry":"Text Entry",
"triggerSource":"MENU",
- "choiceID":45,
+ "choiceID":45
}
}
} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/PutFile.json b/sdl_android/src/androidTest/assets/json/PutFile.json
index 1b14dc798..70e80a09a 100644
--- a/sdl_android/src/androidTest/assets/json/PutFile.json
+++ b/sdl_android/src/androidTest/assets/json/PutFile.json
@@ -20,7 +20,7 @@
"name":"PutFileResponse",
"correlationID":138,
"parameters":{
- "spaceAvailable":43567543,
+ "spaceAvailable":43567543
}
}
} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/RegisterAppInterface.json b/sdl_android/src/androidTest/assets/json/RegisterAppInterface.json
index abb7611ae..fe1edb518 100644
--- a/sdl_android/src/androidTest/assets/json/RegisterAppInterface.json
+++ b/sdl_android/src/androidTest/assets/json/RegisterAppInterface.json
@@ -50,7 +50,7 @@
"make":"Chrysler",
"model":"Crossfire",
"modelYear":"1820",
- "trim":"Gold",
+ "trim":"Gold"
},
"speechCapabilities":[
"SAPI_PHONEMES",
diff --git a/sdl_android/src/androidTest/assets/json/SendHapticData.json b/sdl_android/src/androidTest/assets/json/SendHapticData.json
new file mode 100644
index 000000000..42b863aae
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/SendHapticData.json
@@ -0,0 +1,22 @@
+{
+ "request":{
+ "name":"SendHapticData",
+ "correlationID":1234,
+ "parameters":{
+ "hapticRectData":[
+ {"id":123,
+ "rect":{
+ "height":1,
+ "width":1,
+ "x":1,
+ "y":1
+ }
+ }
+ ]
+ }
+ },
+ "response":{
+ "name":"SendHapticData",
+ "correlationID":1234
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/SendLocation.json b/sdl_android/src/androidTest/assets/json/SendLocation.json
index c6553c59c..9b0ae8901 100644
--- a/sdl_android/src/androidTest/assets/json/SendLocation.json
+++ b/sdl_android/src/androidTest/assets/json/SendLocation.json
@@ -16,7 +16,7 @@
"line1",
"line2",
"line3"
- ],
+ ]
}
},
"response":{
diff --git a/sdl_android/src/androidTest/assets/json/SetGlobalProperties.json b/sdl_android/src/androidTest/assets/json/SetGlobalProperties.json
index 955d657a2..60cdfbffb 100644
--- a/sdl_android/src/androidTest/assets/json/SetGlobalProperties.json
+++ b/sdl_android/src/androidTest/assets/json/SetGlobalProperties.json
@@ -17,7 +17,7 @@
"b"
],
"autoCompleteText":"something goes here",
- "language":"EN-US",
+ "language":"EN-US"
},
"helpPrompt":[
{
diff --git a/sdl_android/src/androidTest/assets/json/SetInteriorVehicleData.json b/sdl_android/src/androidTest/assets/json/SetInteriorVehicleData.json
new file mode 100644
index 000000000..9bcdc01dc
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/SetInteriorVehicleData.json
@@ -0,0 +1,56 @@
+{
+ "request":{
+ "name":"SetInteriorVehicleData",
+ "correlationID":126,
+ "parameters":{
+ "moduleData":{
+ "moduleType":"CLIMATE",
+ "climateControlData":{
+ "circulateAirEnable":true,
+ "ventilationMode":"BOTH",
+ "acEnable":true,
+ "currentTemperature":{
+ "unit":"CELSIUS",
+ "value":100.0
+ },
+ "acMaxEnable":true,
+ "desiredTemperature":{
+ "unit":"CELSIUS",
+ "value":100.0
+ },
+ "dualModeEnable":true,
+ "autoModeEnable":true,
+ "fanSpeed":100,
+ "defrostZone":"ALL"
+ }
+ }
+ }
+ },
+ "response":{
+ "name":"SetInteriorVehicleDataResponse",
+ "correlationID":127,
+ "parameters":{
+ "moduleData":{
+ "moduleType":"CLIMATE",
+ "climateControlData":{
+ "circulateAirEnable":true,
+ "ventilationMode":"BOTH",
+ "acEnable":true,
+ "currentTemperature":{
+ "unit":"CELSIUS",
+ "value":100.0
+ },
+ "acMaxEnable":true,
+ "desiredTemperature":{
+ "unit":"CELSIUS",
+ "value":100.0
+ },
+ "dualModeEnable":true,
+ "autoModeEnable":true,
+ "fanSpeed":100,
+ "defrostZone":"ALL"
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/ShowConstantTBT.json b/sdl_android/src/androidTest/assets/json/ShowConstantTBT.json
index 10e064992..0a0c30b0c 100644
--- a/sdl_android/src/androidTest/assets/json/ShowConstantTBT.json
+++ b/sdl_android/src/androidTest/assets/json/ShowConstantTBT.json
@@ -42,7 +42,7 @@
}
}
],
- "timeToDestination":"52 minutes",
+ "timeToDestination":"52 minutes"
}
},
"response":{
diff --git a/sdl_android/src/androidTest/assets/json/Slider.json b/sdl_android/src/androidTest/assets/json/Slider.json
index 4bd5761ed..38f033df4 100644
--- a/sdl_android/src/androidTest/assets/json/Slider.json
+++ b/sdl_android/src/androidTest/assets/json/Slider.json
@@ -12,7 +12,7 @@
"Header Line 4"
],
"position":11,
- "timeout":30000,
+ "timeout":30000
}
},
"response":{
diff --git a/sdl_android/src/androidTest/assets/json/StreamRPC.json b/sdl_android/src/androidTest/assets/json/StreamRPC.json
new file mode 100644
index 000000000..ff20ffc93
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/StreamRPC.json
@@ -0,0 +1,10 @@
+{
+ "response":{
+ "name":"StreamRPCResponse",
+ "correlationID":198,
+ "parameters":{
+ "fileName":"test",
+ "fileSize":100
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/SubscribeWayPoints.json b/sdl_android/src/androidTest/assets/json/SubscribeWayPoints.json
new file mode 100644
index 000000000..bd1eee5c6
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/SubscribeWayPoints.json
@@ -0,0 +1,10 @@
+{
+ "request":{
+ "name":"SubscribeWayPoints",
+ "correlationID":199
+ },
+ "response":{
+ "name":"SubscribeWayPointsResponse",
+ "correlationID":200
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/assets/json/UnsubscribeWayPoints.json b/sdl_android/src/androidTest/assets/json/UnsubscribeWayPoints.json
new file mode 100644
index 000000000..60e2a98e4
--- /dev/null
+++ b/sdl_android/src/androidTest/assets/json/UnsubscribeWayPoints.json
@@ -0,0 +1,10 @@
+{
+ "request":{
+ "name":"UnsubscribeWayPoints",
+ "correlationID":201
+ },
+ "response":{
+ "name":"UnsubscribeWayPointsResponse",
+ "correlationID":202
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/SdlConnection/SdlConnectionTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/SdlConnection/SdlConnectionTest.java
index 90122905a..0b8e37ea0 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/SdlConnection/SdlConnectionTest.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/SdlConnection/SdlConnectionTest.java
@@ -3,6 +3,7 @@ package com.smartdevicelink.SdlConnection;
import android.test.AndroidTestCase;
import com.smartdevicelink.test.SdlUnitTestContants;
+import com.smartdevicelink.test.util.DeviceUtil;
import com.smartdevicelink.transport.BTTransportConfig;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.MultiplexTransportConfig;
@@ -41,16 +42,15 @@ public class SdlConnectionTest extends AndroidTestCase {
assertNotNull(SdlConnectionTestClass.cachedMultiConfig);
-
-
connection.forceHardwareConnectEvent(TransportType.MULTIPLEX);
assertFalse(connection.connected);
-
- assertNotNull(SdlConnectionTestClass.cachedMultiConfig.getService());
+ SdlConnectionTestClass.cachedMultiConfig.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_OFF);
- assertEquals(TransportType.MULTIPLEX, connection.getCurrentTransportType());
-
+ if(!DeviceUtil.isEmulator()) { // Cannot perform MBT operations in emulator
+ assertNotNull(SdlConnectionTestClass.cachedMultiConfig.getService());
+ assertEquals(TransportType.MULTIPLEX, connection.getCurrentTransportType());
+ }
// Test for handling of null service
MultiplexTransportConfig null_service_config = new MultiplexTransportConfig(this.mContext,SdlUnitTestContants.TEST_APP_ID);
@@ -72,7 +72,11 @@ public class SdlConnectionTest extends AndroidTestCase {
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_NONE);
MultiplexTransportConfig config = new MultiplexTransportConfig(this.mContext,SdlUnitTestContants.TEST_APP_ID);
SdlConnection connection = new SdlConnection(config,rsvp);
- assertEquals(TransportType.MULTIPLEX, connection.getCurrentTransportType());
+ if(DeviceUtil.isEmulator()){ // Cannot perform MBT operations in emulator
+ assertEquals(TransportType.BLUETOOTH, connection.getCurrentTransportType());
+ }else{
+ assertEquals(TransportType.MULTIPLEX, connection.getCurrentTransportType());
+ }
}
public void testMultiplexConstructorInsalledFrom(){
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/protocol/WiProProtocolTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/protocol/WiProProtocolTests.java
index 5eb04ca81..1055f5deb 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/protocol/WiProProtocolTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/protocol/WiProProtocolTests.java
@@ -1,29 +1,22 @@
package com.smartdevicelink.protocol;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import junit.framework.Assert;
+import android.test.AndroidTestCase;
+import android.util.Log;
-import com.smartdevicelink.protocol.IProtocolListener;
-import com.smartdevicelink.protocol.ProtocolMessage;
-import com.smartdevicelink.protocol.SdlPacket;
-import com.smartdevicelink.protocol.WiProProtocol;
+import com.smartdevicelink.SdlConnection.SdlConnection;
import com.smartdevicelink.protocol.WiProProtocol.MessageFrameAssembler;
-import com.smartdevicelink.protocol.enums.MessageType;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.test.SampleRpc;
-import com.smartdevicelink.util.DebugTool;
-import java.io.ByteArrayOutputStream;
-
-import com.smartdevicelink.SdlConnection.SdlConnection;
import com.smartdevicelink.test.SdlUnitTestContants;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.MultiplexTransportConfig;
import com.smartdevicelink.transport.RouterServiceValidator;
-import android.test.AndroidTestCase;
-import android.util.Log;
+import junit.framework.Assert;
+
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Method;
+import java.util.List;
/**
* This is a unit test class for the SmartDeviceLink library project class :
@@ -45,7 +38,7 @@ public class WiProProtocolTests extends AndroidTestCase {
@Override
public void onProtocolSessionStarted(SessionType sessionType,byte sessionID, byte version, String correlationID, int hashID,boolean isEncrypted){}
@Override
- public void onProtocolSessionNACKed(SessionType sessionType,byte sessionID, byte version, String correlationID) {}
+ public void onProtocolSessionNACKed(SessionType sessionType,byte sessionID, byte version, String correlationID, List<String> rejectedParams) {}
@Override
public void onProtocolSessionEnded(SessionType sessionType,byte sessionID, String correlationID) {}
@Override
@@ -84,7 +77,7 @@ public class WiProProtocolTests extends AndroidTestCase {
@Override
public void onProtocolSessionStarted(SessionType sessionType,byte sessionID, byte version, String correlationID, int hashID,boolean isEncrypted){}
@Override
- public void onProtocolSessionNACKed(SessionType sessionType,byte sessionID, byte version, String correlationID) {}
+ public void onProtocolSessionNACKed(SessionType sessionType,byte sessionID, byte version, String correlationID, List<String> rejectedParams) {}
@Override
public void onProtocolSessionEnded(SessionType sessionType,byte sessionID, String correlationID) {}
@Override
@@ -126,11 +119,15 @@ public class WiProProtocolTests extends AndroidTestCase {
wiProProtocol = new WiProProtocol(defaultListener);
wiProProtocol.setVersion((byte)0x04);
assertEquals((byte)0x04,wiProProtocol.getVersion());
-
- //If we get newer than 4, it should fall back to 4
+
wiProProtocol = new WiProProtocol(defaultListener);
wiProProtocol.setVersion((byte)0x05);
- assertEquals((byte)0x04,wiProProtocol.getVersion());
+ assertEquals((byte)0x05,wiProProtocol.getVersion());
+
+ //If we get newer than 5, it should fall back to 5
+ wiProProtocol = new WiProProtocol(defaultListener);
+ wiProProtocol.setVersion((byte)0x06);
+ assertEquals((byte)0x05,wiProProtocol.getVersion());
//Is this right?
wiProProtocol = new WiProProtocol(defaultListener);
@@ -144,31 +141,27 @@ public class WiProProtocolTests extends AndroidTestCase {
wiProProtocol.setVersion((byte)0x01);
try{
- Field field = wiProProtocol.getClass().getDeclaredField("MAX_DATA_SIZE");
- field.setAccessible(true);
- int mtu = (Integer) field.get(wiProProtocol);
- assertEquals(mtu, 1500-8);
- //Ok our reflection works we can test the rest of the cases
-
+ assertEquals(wiProProtocol.getMtu(), 1500-8);
+
//Version 2
wiProProtocol.setVersion((byte)0x02);
- mtu = (Integer) field.get(wiProProtocol);
- assertEquals(mtu, 1500-12);
+ assertEquals(wiProProtocol.getMtu(), 1500-12);
//Version 3
wiProProtocol.setVersion((byte)0x03);
- mtu = (Integer) field.get(wiProProtocol);
- assertEquals(mtu, 131072);
+ assertEquals(wiProProtocol.getMtu(), 131072);
//Version 4
wiProProtocol.setVersion((byte)0x04);
- mtu = (Integer) field.get(wiProProtocol);
- assertEquals(mtu, 131072);
+ assertEquals(wiProProtocol.getMtu(), 131072);
- //Version 4+
+ //Version 5
wiProProtocol.setVersion((byte)0x05);
- mtu = (Integer) field.get(wiProProtocol);
- assertEquals(mtu, 1500-12);
+ assertEquals(wiProProtocol.getMtu(), 131072);
+
+ //Version 5+
+ wiProProtocol.setVersion((byte)0x06);
+ assertEquals(wiProProtocol.getMtu(), 131072);
}catch(Exception e){
Assert.fail("Exceptin during reflection");
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java
index 9670492b0..c30f26a7f 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java
@@ -168,7 +168,7 @@ public abstract class BaseRpcTests extends AndroidTestCase {
Integer correlationId;
if (msg instanceof RPCRequest) {
correlationId = ((RPCRequest) msg).getCorrelationID();
- assertNull("Correlation ID of the RPC message was not null.", correlationId);
+ assertNotNull("Correlation ID of the RPC message was null.", correlationId);
//assertEquals("Correlation ID didn't match expected correlation ID.", CORR_ID, (int) correlationId);
}
else if (msg instanceof RPCResponse) {
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java
new file mode 100644
index 000000000..ec7bf710a
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/SdlConnection/SdlSessionTests.java
@@ -0,0 +1,50 @@
+package com.smartdevicelink.test.SdlConnection;
+
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.TTSChunkFactory;
+import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
+import com.smartdevicelink.proxy.rpc.TTSChunk;
+import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.transport.TCPTransportConfig;
+
+import junit.framework.TestCase;
+
+import java.util.Vector;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.SdlConnection.SdlSession}
+ */
+public class SdlSessionTests extends TestCase {
+
+ public void testServiceListeners(){
+ SdlSession session = SdlSession.createSession((byte)5,null, new TCPTransportConfig(8080,"",false));
+ ISdlServiceListener test = new ISdlServiceListener() {
+ @Override
+ public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) {
+
+ }
+
+ @Override
+ public void onServiceEnded(SdlSession session, SessionType type) {
+
+ }
+
+ @Override
+ public void onServiceError(SdlSession session, SessionType type, String reason) {
+
+ }
+ };
+
+ session.addServiceListener(SessionType.RPC, test);
+
+ assertTrue(session.removeServiceListener(SessionType.RPC, test));
+
+ assertFalse(session.removeServiceListener(SessionType.RPC, test));
+
+ }
+
+
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java
index 9acf6e24e..46f4e89be 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Test.java
@@ -1,37 +1,47 @@
package com.smartdevicelink.test;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import android.util.Log;
import com.smartdevicelink.proxy.TTSChunkFactory;
import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities;
import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
import com.smartdevicelink.proxy.rpc.Choice;
+import com.smartdevicelink.proxy.rpc.ClimateControlCapabilities;
+import com.smartdevicelink.proxy.rpc.ClimateControlData;
+import com.smartdevicelink.proxy.rpc.Coordinate;
import com.smartdevicelink.proxy.rpc.DIDResult;
import com.smartdevicelink.proxy.rpc.DeviceInfo;
import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
+import com.smartdevicelink.proxy.rpc.HMICapabilities;
import com.smartdevicelink.proxy.rpc.HMIPermissions;
+import com.smartdevicelink.proxy.rpc.HapticRect;
import com.smartdevicelink.proxy.rpc.Image;
import com.smartdevicelink.proxy.rpc.ImageField;
import com.smartdevicelink.proxy.rpc.ImageResolution;
import com.smartdevicelink.proxy.rpc.KeyboardProperties;
+import com.smartdevicelink.proxy.rpc.LocationDetails;
import com.smartdevicelink.proxy.rpc.MenuParams;
+import com.smartdevicelink.proxy.rpc.ModuleData;
+import com.smartdevicelink.proxy.rpc.NavigationCapability;
+import com.smartdevicelink.proxy.rpc.MetadataTags;
+import com.smartdevicelink.proxy.rpc.OasisAddress;
import com.smartdevicelink.proxy.rpc.ParameterPermissions;
import com.smartdevicelink.proxy.rpc.PermissionItem;
+import com.smartdevicelink.proxy.rpc.PhoneCapability;
import com.smartdevicelink.proxy.rpc.PresetBankCapabilities;
+import com.smartdevicelink.proxy.rpc.RadioControlCapabilities;
+import com.smartdevicelink.proxy.rpc.RadioControlData;
+import com.smartdevicelink.proxy.rpc.RdsData;
+import com.smartdevicelink.proxy.rpc.RemoteControlCapabilities;
+import com.smartdevicelink.proxy.rpc.Rectangle;
import com.smartdevicelink.proxy.rpc.ScreenParams;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.SoftButton;
import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
import com.smartdevicelink.proxy.rpc.StartTime;
+import com.smartdevicelink.proxy.rpc.SystemCapability;
import com.smartdevicelink.proxy.rpc.TTSChunk;
+import com.smartdevicelink.proxy.rpc.Temperature;
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.TouchCoord;
import com.smartdevicelink.proxy.rpc.TouchEvent;
@@ -39,6 +49,8 @@ import com.smartdevicelink.proxy.rpc.TouchEventCapabilities;
import com.smartdevicelink.proxy.rpc.Turn;
import com.smartdevicelink.proxy.rpc.VehicleDataResult;
import com.smartdevicelink.proxy.rpc.VehicleType;
+import com.smartdevicelink.proxy.rpc.VideoStreamingCapability;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
import com.smartdevicelink.proxy.rpc.VrHelpItem;
import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
@@ -53,6 +65,7 @@ import com.smartdevicelink.proxy.rpc.enums.CarModeStatus;
import com.smartdevicelink.proxy.rpc.enums.CharacterSet;
import com.smartdevicelink.proxy.rpc.enums.CompassDirection;
import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
+import com.smartdevicelink.proxy.rpc.enums.DefrostZone;
import com.smartdevicelink.proxy.rpc.enums.DeviceLevelStatus;
import com.smartdevicelink.proxy.rpc.enums.Dimension;
import com.smartdevicelink.proxy.rpc.enums.DisplayType;
@@ -75,19 +88,25 @@ import com.smartdevicelink.proxy.rpc.enums.Language;
import com.smartdevicelink.proxy.rpc.enums.LayoutMode;
import com.smartdevicelink.proxy.rpc.enums.LockScreenStatus;
import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
+import com.smartdevicelink.proxy.rpc.enums.ModuleType;
import com.smartdevicelink.proxy.rpc.enums.PowerModeQualificationStatus;
import com.smartdevicelink.proxy.rpc.enums.PowerModeStatus;
import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
import com.smartdevicelink.proxy.rpc.enums.PrimaryAudioSource;
+import com.smartdevicelink.proxy.rpc.enums.RadioBand;
+import com.smartdevicelink.proxy.rpc.enums.RadioState;
import com.smartdevicelink.proxy.rpc.enums.RequestType;
import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
import com.smartdevicelink.proxy.rpc.enums.SoftButtonType;
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
import com.smartdevicelink.proxy.rpc.enums.SystemAction;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.enums.SystemContext;
import com.smartdevicelink.proxy.rpc.enums.TBTState;
+import com.smartdevicelink.proxy.rpc.enums.TemperatureUnit;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
+import com.smartdevicelink.proxy.rpc.enums.MetadataType;
import com.smartdevicelink.proxy.rpc.enums.TouchType;
import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
@@ -96,9 +115,20 @@ import com.smartdevicelink.proxy.rpc.enums.VehicleDataNotificationStatus;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataType;
+import com.smartdevicelink.proxy.rpc.enums.VentilationMode;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
import com.smartdevicelink.proxy.rpc.enums.WarningLightStatus;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
public class Test {
// Test Failure Messages
@@ -112,9 +142,10 @@ public class Test {
// RPC Request/Response/Notification/Datatype Test Values
public static final int GENERAL_INT = 100;
+ public static final Integer GENERAL_INTEGER = 100;
public static final Long GENERAL_LONG = 100L;
public static final Turn GENERAL_TURN = new Turn();
- public static final float GENERAL_FLOAT = 100f;
+ public static final Float GENERAL_FLOAT = 100f;
public static final Image GENERAL_IMAGE = new Image();
public static final Choice GENERAL_CHOICE = new Choice();
public static final String GENERAL_STRING = "test";
@@ -126,6 +157,9 @@ public class Test {
public static final HMILevel GENERAL_HMILEVEL = HMILevel.HMI_FULL;
public static final DIDResult GENERAL_DIDRESULT = new DIDResult();
public static final TextField GENERAL_TEXTFIELD = new TextField();
+ public static final OasisAddress GENERAL_OASISADDRESS = new OasisAddress();
+ public static final Coordinate GENERAL_COORDINATE = new Coordinate();
+ public static final LocationDetails GENERAL_LOCATIONDETAILS = new LocationDetails();
public static final Dimension GENERAL_DIMENSION = Dimension._2D;
public static final ImageType GENERAL_IMAGETYPE = ImageType.DYNAMIC;
public static final AudioType GENERAL_AUDIOTYPE = AudioType.PCM;
@@ -196,7 +230,36 @@ public class Test {
public static final PowerModeQualificationStatus GENERAL_POWERMODEQUALIFICATIONSTATUS = PowerModeQualificationStatus.POWER_MODE_OK;
public static final VehicleDataNotificationStatus GENERAL_VEHICLEDATANOTIFICATIONSTATUS = VehicleDataNotificationStatus.NORMAL;
public static final AppInterfaceUnregisteredReason GENERAL_APPINTERFACEUNREGISTEREDREASON = AppInterfaceUnregisteredReason.BLUETOOTH_OFF;
-
+ public static final SystemCapabilityType GENERAL_SYSTEMCAPABILITYTYPE = SystemCapabilityType.NAVIGATION;
+ public static final NavigationCapability GENERAL_NAVIGATIONCAPABILITY = new NavigationCapability();
+ public static final PhoneCapability GENERAL_PHONECAPABILITY = new PhoneCapability();
+ public static final RemoteControlCapabilities GENERAL_REMOTECONTROLCAPABILITIES = new RemoteControlCapabilities();
+ public static final SystemCapability GENERAL_SYSTEMCAPABILITY = new SystemCapability();
+ public static final VideoStreamingProtocol GENERAL_VIDEOSTREAMINGPROTOCOL = VideoStreamingProtocol.RAW;
+ public static final VideoStreamingCodec GENERAL_VIDEOSTREAMINGCODEC = VideoStreamingCodec.H264;
+ public static final VideoStreamingCapability GENERAL_VIDEOSTREAMINGCAPABILITY = new VideoStreamingCapability();
+ public static final VideoStreamingFormat GENERAL_VIDEOSTREAMINGFORMAT = new VideoStreamingFormat();
+
+ public static final ModuleType GENERAL_MODULETYPE = ModuleType.CLIMATE;
+ public static final Temperature GENERAL_TEMPERATURE = new Temperature();
+ public static final TemperatureUnit GENERAL_TEMPERATUREUNIT = TemperatureUnit.CELSIUS;
+ public static final DefrostZone GENERAL_DEFROSTZONE = DefrostZone.ALL;
+ public static final VentilationMode GENERAL_VENTILATIONMODE = VentilationMode.BOTH;
+ public static final RadioBand GENERAL_RADIOBAND = RadioBand.AM;
+ public static final ClimateControlData GENERAL_CLIMATECONTROLDATA = new ClimateControlData();
+ public static final RdsData GENERAL_RDSDATA = new RdsData();
+ public static final RadioState GENERAL_RADIOSTATE = RadioState.ACQUIRED;
+ public static final RadioControlData GENERAL_RADIOCONTROLDATA = new RadioControlData();
+ public static final ModuleData GENERAL_MODULEDATA = new ModuleData();
+ public static final ClimateControlCapabilities GENERAL_CLIMATECONTROLCAPABILITIES = new ClimateControlCapabilities();
+ public static final RadioControlCapabilities GENERAL_RADIOCONTROLCAPABILITIES = new RadioControlCapabilities();
+
+ public static final HMICapabilities GENERAL_HMICAPABILITIES = new HMICapabilities();
+
+ public static final MetadataTags GENERAL_METADATASTRUCT = new MetadataTags();
+ public static final Rectangle GENERAL_RECTANGLE = new Rectangle();
+ public static final HapticRect GENERAL_HAPTIC_RECT = new HapticRect();
+
public static final List<Long> GENERAL_LONG_LIST = Arrays.asList(new Long[]{ 1L, 2L });
public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>();
public static final List<Choice> GENERAL_CHOICE_LIST = new ArrayList<Choice>();
@@ -224,7 +287,12 @@ public class Test {
public static final List<HmiZoneCapabilities> GENERAL_HMIZONECAPABILITIES_LIST = new ArrayList<HmiZoneCapabilities>(2);
public static final List<SoftButtonCapabilities> GENERAL_SOFTBUTTONCAPABILITIES_LIST = new ArrayList<SoftButtonCapabilities>(1);
public static final List<AudioPassThruCapabilities> GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST = new ArrayList<AudioPassThruCapabilities>(1);
-
+ public static final List<VideoStreamingFormat> GENERAL_VIDEOSTREAMINGFORMAT_LIST = new ArrayList<VideoStreamingFormat>(2);
+ public static final List<DefrostZone> GENERAL_DEFROSTZONE_LIST = Arrays.asList(new DefrostZone[]{DefrostZone.FRONT, DefrostZone.REAR});
+ public static final List<VentilationMode> GENERAL_VENTILATIONMODE_LIST = Arrays.asList(new VentilationMode[]{VentilationMode.LOWER, VentilationMode.UPPER});
+ public static final List<ClimateControlCapabilities> GENERAL_CLIMATECONTROLCAPABILITIES_LIST = new ArrayList<ClimateControlCapabilities>(1);
+ public static final List<RadioControlCapabilities> GENERAL_RADIOCONTROLCAPABILITIES_LIST = new ArrayList<RadioControlCapabilities>(1);
+
public static final JSONArray JSON_TURNS = new JSONArray();
public static final JSONArray JSON_CHOICES = new JSONArray();
public static final JSONArray JSON_HMILEVELS = new JSONArray();
@@ -240,7 +308,9 @@ public class Test {
public static final JSONArray JSON_BUTTONCAPABILITIES = new JSONArray();
public static final JSONArray JSON_SOFTBUTTONCAPABILITIES = new JSONArray();
public static final JSONArray JSON_AUDIOPASSTHRUCAPABILITIES = new JSONArray();
-
+ public static final JSONArray JSON_RADIOCONTROLCAPABILITIES = new JSONArray();
+ public static final JSONArray JSON_CLIMATECONTROLCAPABILITIES = new JSONArray();
+ public static final JSONArray JSON_TEXTFIELDTYPES = new JSONArray();
public static final JSONObject JSON_TURN = new JSONObject();
public static final JSONObject JSON_IMAGE = new JSONObject();
public static final JSONObject JSON_CHOICE = new JSONObject();
@@ -264,15 +334,52 @@ public class Test {
public static final JSONObject JSON_PARAMETERPERMISSIONS = new JSONObject();
public static final JSONObject JSON_PRESETBANKCAPABILITIES = new JSONObject();
public static final JSONObject JSON_TOUCHEVENTCAPABILITIES = new JSONObject();
-
+
static {
GENERAL_TOUCHEVENTCAPABILITIES.setDoublePressAvailable(GENERAL_BOOLEAN);
GENERAL_TOUCHEVENTCAPABILITIES.setMultiTouchAvailable(GENERAL_BOOLEAN);
GENERAL_TOUCHEVENTCAPABILITIES.setPressAvailable(GENERAL_BOOLEAN);
GENERAL_IMAGERESOLUTION.setResolutionHeight(GENERAL_INT);
- GENERAL_IMAGERESOLUTION.setResolutionWidth(GENERAL_INT);
-
+ GENERAL_IMAGERESOLUTION.setResolutionWidth(GENERAL_INT);
+
+ GENERAL_TEMPERATURE.setUnit(GENERAL_TEMPERATUREUNIT);
+ GENERAL_TEMPERATURE.setValue(GENERAL_FLOAT);
+
+ GENERAL_CLIMATECONTROLDATA.setFanSpeed(GENERAL_INT);
+ GENERAL_CLIMATECONTROLDATA.setCurrentTemperature(GENERAL_TEMPERATURE);
+ GENERAL_CLIMATECONTROLDATA.setDesiredTemperature(GENERAL_TEMPERATURE);
+ GENERAL_CLIMATECONTROLDATA.setAcEnable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLDATA.setCirculateAirEnable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLDATA.setAutoModeEnable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLDATA.setDualModeEnable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLDATA.setAcMaxEnable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLDATA.setDefrostZone(GENERAL_DEFROSTZONE);
+ GENERAL_CLIMATECONTROLDATA.setVentilationMode(GENERAL_VENTILATIONMODE);
+
+ GENERAL_RDSDATA.setProgramService(GENERAL_STRING);
+ GENERAL_RDSDATA.setRadioText(GENERAL_STRING);
+ GENERAL_RDSDATA.setClockText(GENERAL_STRING);
+ GENERAL_RDSDATA.setProgramIdentification(GENERAL_STRING);
+ GENERAL_RDSDATA.setRegion(GENERAL_STRING);
+ GENERAL_RDSDATA.setTrafficProgram(GENERAL_BOOLEAN);
+ GENERAL_RDSDATA.setTrafficAnnouncement(GENERAL_BOOLEAN);
+ GENERAL_RDSDATA.setProgramType(GENERAL_INT);
+
+ GENERAL_RADIOCONTROLDATA.setFrequencyInteger(GENERAL_INT);
+ GENERAL_RADIOCONTROLDATA.setFrequencyFraction(GENERAL_INT);
+ GENERAL_RADIOCONTROLDATA.setBand(GENERAL_RADIOBAND);
+ GENERAL_RADIOCONTROLDATA.setRdsData(GENERAL_RDSDATA);
+ GENERAL_RADIOCONTROLDATA.setAvailableHDs(GENERAL_INT);
+ GENERAL_RADIOCONTROLDATA.setHdChannel(GENERAL_INT);
+ GENERAL_RADIOCONTROLDATA.setSignalStrength(GENERAL_INT);
+ GENERAL_RADIOCONTROLDATA.setSignalChangeThreshold(GENERAL_INT);
+ GENERAL_RADIOCONTROLDATA.setRadioEnable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLDATA.setState(GENERAL_RADIOSTATE);
+
+ GENERAL_MODULEDATA.setModuleType(GENERAL_MODULETYPE);
+ GENERAL_MODULEDATA.setClimateControlData(GENERAL_CLIMATECONTROLDATA);
+
GENERAL_CHOICE.setMenuName(GENERAL_STRING);
GENERAL_CHOICE.setSecondaryText(GENERAL_STRING);
GENERAL_CHOICE.setTertiaryText(GENERAL_STRING);
@@ -295,6 +402,27 @@ public class Test {
GENERAL_TEXTFIELD.setWidth(GENERAL_INT);
GENERAL_TEXTFIELD.setCharacterSet(GENERAL_CHARACTERSET);
GENERAL_TEXTFIELD_LIST.add(GENERAL_TEXTFIELD);
+
+ GENERAL_COORDINATE.setLongitudeDegrees(GENERAL_FLOAT);
+ GENERAL_COORDINATE.setLatitudeDegrees(GENERAL_FLOAT);
+
+ GENERAL_OASISADDRESS.setCountryName(GENERAL_STRING);
+ GENERAL_OASISADDRESS.setThoroughfare(GENERAL_STRING);
+ GENERAL_OASISADDRESS.setSubThoroughfare(GENERAL_STRING);
+ GENERAL_OASISADDRESS.setCountryCode(GENERAL_STRING);
+ GENERAL_OASISADDRESS.setPostalCode(GENERAL_STRING);
+ GENERAL_OASISADDRESS.setLocality(GENERAL_STRING);
+ GENERAL_OASISADDRESS.setSubLocality(GENERAL_STRING);
+ GENERAL_OASISADDRESS.setAdministrativeArea(GENERAL_STRING);
+ GENERAL_OASISADDRESS.setSubAdministrativeArea(GENERAL_STRING);
+
+ GENERAL_LOCATIONDETAILS.setAddressLines(GENERAL_STRING_LIST);
+ GENERAL_LOCATIONDETAILS.setCoordinate(GENERAL_COORDINATE);
+ GENERAL_LOCATIONDETAILS.setLocationDescription(GENERAL_STRING);
+ GENERAL_LOCATIONDETAILS.setLocationImage(GENERAL_IMAGE);
+ GENERAL_LOCATIONDETAILS.setLocationName(GENERAL_STRING);
+ GENERAL_LOCATIONDETAILS.setSearchAddress(GENERAL_OASISADDRESS);
+ GENERAL_LOCATIONDETAILS.setPhoneNumber(GENERAL_STRING);
GENERAL_FILETYPE_LIST.add(GENERAL_FILETYPE);
@@ -430,8 +558,78 @@ public class Test {
GENERAL_PERMISSIONITEM.setHMIPermissions(GENERAL_HMIPERMISSIONS);
GENERAL_PERMISSIONITEM.setParameterPermissions(GENERAL_PARAMETERPERMISSIONS);
GENERAL_PERMISSIONITEM_LIST.add(GENERAL_PERMISSIONITEM);
+
+ GENERAL_SYSTEMCAPABILITY.setSystemCapabilityType(GENERAL_SYSTEMCAPABILITYTYPE);
+
+ GENERAL_NAVIGATIONCAPABILITY.setSendLocationEnabled(GENERAL_BOOLEAN);
+ GENERAL_NAVIGATIONCAPABILITY.setWayPointsEnabled(GENERAL_BOOLEAN);
+
+ GENERAL_PHONECAPABILITY.setDialNumberEnabled(GENERAL_BOOLEAN);
+
+ GENERAL_VIDEOSTREAMINGFORMAT.setProtocol(GENERAL_VIDEOSTREAMINGPROTOCOL);
+ GENERAL_VIDEOSTREAMINGFORMAT.setCodec(GENERAL_VIDEOSTREAMINGCODEC);
+
+ GENERAL_VIDEOSTREAMINGFORMAT_LIST.add(GENERAL_VIDEOSTREAMINGFORMAT);
+ GENERAL_VIDEOSTREAMINGFORMAT_LIST.add(GENERAL_VIDEOSTREAMINGFORMAT);
+
+ GENERAL_VIDEOSTREAMINGCAPABILITY.setMaxBitrate(GENERAL_INT);
+ GENERAL_VIDEOSTREAMINGCAPABILITY.setPreferredResolution(GENERAL_IMAGERESOLUTION);
+ GENERAL_VIDEOSTREAMINGCAPABILITY.setSupportedFormats(GENERAL_VIDEOSTREAMINGFORMAT_LIST);
+
+ GENERAL_CLIMATECONTROLCAPABILITIES.setModuleName(GENERAL_STRING);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setFanSpeedAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setDesiredTemperatureAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setAcEnableAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setAcMaxEnableAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setCirculateAirEnableAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setAutoModeEnableAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setDualModeEnableAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setDefrostZoneAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setDefrostZone(GENERAL_DEFROSTZONE_LIST);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setVentilationModeAvailable(GENERAL_BOOLEAN);
+ GENERAL_CLIMATECONTROLCAPABILITIES.setVentilationMode(GENERAL_VENTILATIONMODE_LIST);
+ GENERAL_CLIMATECONTROLCAPABILITIES_LIST.add(GENERAL_CLIMATECONTROLCAPABILITIES);
+
+ GENERAL_RADIOCONTROLCAPABILITIES.setModuleName(GENERAL_STRING);
+ GENERAL_RADIOCONTROLCAPABILITIES.setRadioEnableAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES.setRadioBandAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES.setRadioFrequencyAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES.setHdChannelAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES.setRdsDataAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES.setAvailableHDsAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES.setStateAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES.setSignalStrengthAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES.setSignalChangeThresholdAvailable(GENERAL_BOOLEAN);
+ GENERAL_RADIOCONTROLCAPABILITIES_LIST.add(GENERAL_RADIOCONTROLCAPABILITIES);
+
+ GENERAL_REMOTECONTROLCAPABILITIES.setButtonCapabilities(GENERAL_BUTTONCAPABILITIES_LIST);
+ GENERAL_REMOTECONTROLCAPABILITIES.setClimateControlCapabilities(GENERAL_CLIMATECONTROLCAPABILITIES_LIST);
+ GENERAL_REMOTECONTROLCAPABILITIES.setRadioControlCapabilities(GENERAL_RADIOCONTROLCAPABILITIES_LIST);
+
+ GENERAL_HMICAPABILITIES.setNavigationAvilable(GENERAL_BOOLEAN);
+ GENERAL_HMICAPABILITIES.setVideoStreamingAvailable(GENERAL_BOOLEAN);
+ GENERAL_HMICAPABILITIES.setPhoneCallAvilable(GENERAL_BOOLEAN);
+
+ List<MetadataType> exampleList = new ArrayList<>();
+ exampleList.add(0, MetadataType.CURRENT_TEMPERATURE);
+ exampleList.add(1, MetadataType.MEDIA_ALBUM);
+ exampleList.add(2, MetadataType.MEDIA_ARTIST);
+
+ GENERAL_METADATASTRUCT.setMainField1(exampleList);
+ GENERAL_METADATASTRUCT.setMainField2(exampleList);
+ GENERAL_METADATASTRUCT.setMainField3(exampleList);
+ GENERAL_METADATASTRUCT.setMainField4(exampleList);
+
+ GENERAL_RECTANGLE.setX(GENERAL_FLOAT);
+ GENERAL_RECTANGLE.setY(GENERAL_FLOAT);
+ GENERAL_RECTANGLE.setWidth(GENERAL_FLOAT);
+ GENERAL_RECTANGLE.setHeight(GENERAL_FLOAT);
+
+ GENERAL_HAPTIC_RECT.setId(GENERAL_INTEGER);
+ GENERAL_HAPTIC_RECT.setRect(GENERAL_RECTANGLE);
+
- try {
+ try {
JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_ALLOWED, GENERAL_HMILEVEL_LIST);
JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_USER_DISALLOWED, GENERAL_HMILEVEL_LIST);
@@ -532,7 +730,35 @@ public class Test {
jsonButton.put(ButtonCapabilities.KEY_UP_DOWN_AVAILABLE, GENERAL_BOOLEAN);
jsonButton.put(ButtonCapabilities.KEY_NAME, ButtonName.SEEKRIGHT);
JSON_BUTTONCAPABILITIES.put(jsonButton);
-
+
+ JSONObject jsonRadioControlCapabilities = new JSONObject();
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_MODULE_NAME, GENERAL_STRING);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_RADIO_ENABLE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_RADIO_BAND_AVAILABLE, GENERAL_BOOLEAN);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_RADIO_FREQUENCY_AVAILABLE, GENERAL_BOOLEAN);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_HD_CHANNEL_AVAILABLE, GENERAL_BOOLEAN);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_RDS_DATA_AVAILABLE, GENERAL_BOOLEAN);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_AVAILABLE_HDS_AVAILABLE, GENERAL_BOOLEAN);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_STATE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_SIGNAL_STRENGTH_AVAILABLE, GENERAL_BOOLEAN);
+ jsonRadioControlCapabilities.put(RadioControlCapabilities.KEY_SIGNAL_CHANGE_THRESHOLD_AVAILABLE, GENERAL_BOOLEAN);
+ JSON_RADIOCONTROLCAPABILITIES.put(jsonRadioControlCapabilities);
+
+ JSONObject jsonClimateControlCapabilities = new JSONObject();
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_MODULE_NAME, GENERAL_STRING);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_FAN_SPEED_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_DESIRED_TEMPERATURE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_AC_ENABLE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_AC_MAX_ENABLE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_CIRCULATE_AIR_ENABLE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_AUTO_MODE_ENABLE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_DUAL_MODE_ENABLE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_DEFROST_ZONE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_DEFROST_ZONE, GENERAL_DEFROSTZONE_LIST);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_VENTILATION_MODE_AVAILABLE, GENERAL_BOOLEAN);
+ jsonClimateControlCapabilities.put(ClimateControlCapabilities.KEY_VENTILATION_MODE, GENERAL_VENTILATIONMODE_LIST);
+ JSON_CLIMATECONTROLCAPABILITIES.put(jsonClimateControlCapabilities);
+
jsonButton = new JSONObject();
jsonButton.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, GENERAL_BOOLEAN);
jsonButton.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, GENERAL_BOOLEAN);
@@ -582,6 +808,10 @@ public class Test {
JSON_TOUCHEVENT.put(TouchEvent.KEY_ID, GENERAL_INT);
JSON_TOUCHEVENT.put(TouchEvent.KEY_TS, JsonUtils.createJsonArray(GENERAL_LONG_LIST));
JSON_TOUCHEVENTS.put(JSON_TOUCHEVENT);
+
+ JSON_TEXTFIELDTYPES.put(MetadataType.CURRENT_TEMPERATURE);
+ JSON_TEXTFIELDTYPES.put(MetadataType.MEDIA_ALBUM);
+ JSON_TEXTFIELDTYPES.put(MetadataType.MEDIA_ARTIST);
} catch (JSONException e) {
Log.e("Test", "Static Json Construction Failed.", e);
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java
index e20098a60..1e99e96a5 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java
@@ -13,7 +13,10 @@ import com.smartdevicelink.proxy.rpc.BeltStatus;
import com.smartdevicelink.proxy.rpc.BodyInformation;
import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
import com.smartdevicelink.proxy.rpc.Choice;
+import com.smartdevicelink.proxy.rpc.ClimateControlCapabilities;
+import com.smartdevicelink.proxy.rpc.ClimateControlData;
import com.smartdevicelink.proxy.rpc.ClusterModeStatus;
+import com.smartdevicelink.proxy.rpc.Coordinate;
import com.smartdevicelink.proxy.rpc.DIDResult;
import com.smartdevicelink.proxy.rpc.DeviceInfo;
import com.smartdevicelink.proxy.rpc.DeviceStatus;
@@ -21,6 +24,7 @@ import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
import com.smartdevicelink.proxy.rpc.ECallInfo;
import com.smartdevicelink.proxy.rpc.EmergencyEvent;
import com.smartdevicelink.proxy.rpc.GPSData;
+import com.smartdevicelink.proxy.rpc.HMICapabilities;
import com.smartdevicelink.proxy.rpc.HMIPermissions;
import com.smartdevicelink.proxy.rpc.HeadLampStatus;
import com.smartdevicelink.proxy.rpc.Headers;
@@ -29,10 +33,19 @@ import com.smartdevicelink.proxy.rpc.ImageField;
import com.smartdevicelink.proxy.rpc.ImageResolution;
import com.smartdevicelink.proxy.rpc.KeyboardProperties;
import com.smartdevicelink.proxy.rpc.MenuParams;
+import com.smartdevicelink.proxy.rpc.ModuleData;
import com.smartdevicelink.proxy.rpc.MyKey;
+import com.smartdevicelink.proxy.rpc.NavigationCapability;
+import com.smartdevicelink.proxy.rpc.OasisAddress;
import com.smartdevicelink.proxy.rpc.ParameterPermissions;
import com.smartdevicelink.proxy.rpc.PermissionItem;
+import com.smartdevicelink.proxy.rpc.PhoneCapability;
import com.smartdevicelink.proxy.rpc.PresetBankCapabilities;
+import com.smartdevicelink.proxy.rpc.RadioControlCapabilities;
+import com.smartdevicelink.proxy.rpc.RadioControlData;
+import com.smartdevicelink.proxy.rpc.RdsData;
+import com.smartdevicelink.proxy.rpc.RemoteControlCapabilities;
+import com.smartdevicelink.proxy.rpc.Rectangle;
import com.smartdevicelink.proxy.rpc.ScreenParams;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.SingleTireStatus;
@@ -40,6 +53,7 @@ import com.smartdevicelink.proxy.rpc.SoftButton;
import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
import com.smartdevicelink.proxy.rpc.StartTime;
import com.smartdevicelink.proxy.rpc.TTSChunk;
+import com.smartdevicelink.proxy.rpc.Temperature;
import com.smartdevicelink.proxy.rpc.TextField;
import com.smartdevicelink.proxy.rpc.TireStatus;
import com.smartdevicelink.proxy.rpc.TouchCoord;
@@ -48,9 +62,15 @@ import com.smartdevicelink.proxy.rpc.TouchEventCapabilities;
import com.smartdevicelink.proxy.rpc.Turn;
import com.smartdevicelink.proxy.rpc.VehicleDataResult;
import com.smartdevicelink.proxy.rpc.VehicleType;
+import com.smartdevicelink.proxy.rpc.VideoStreamingCapability;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
import com.smartdevicelink.proxy.rpc.VrHelpItem;
+import com.smartdevicelink.proxy.rpc.enums.DefrostZone;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+import com.smartdevicelink.proxy.rpc.enums.VentilationMode;
+import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
public class Validator{
@@ -298,6 +318,99 @@ public class Validator{
return true;
}
+ public static boolean validateCoordinate(Coordinate c1, Coordinate c2){
+ if(c1 == null){
+ return ( c2 == null );
+ }
+ if(c2 == null){
+ return ( c1 == null );
+ }
+
+ if(c1.getLatitudeDegrees() != c2.getLatitudeDegrees()){
+ return false;
+ }
+
+ if(c1.getLongitudeDegrees() != c2.getLongitudeDegrees()){
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateRectangle(Rectangle c1, Rectangle c2){
+ if(c1 == null){
+ return ( c2 == null );
+ }
+ if(c2 == null){
+ return ( c1 == null );
+ }
+
+ if(c1.getX() != c2.getX()){
+ return false;
+ }
+
+ if(c1.getY() != c2.getY()){
+ return false;
+ }
+
+ if(c1.getWidth() != c2.getWidth()){
+ return false;
+ }
+
+ if(c1.getHeight() != c2.getHeight()){
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateOasisAddress(OasisAddress a1, OasisAddress a2){
+ if(a1 == null){
+ return ( a2 == null );
+ }
+ if(a2 == null){
+ return ( a1 == null );
+ }
+
+ if(!a1.getAdministrativeArea().equals(a2.getAdministrativeArea())){
+ return false;
+ }
+
+ if(!a1.getCountryCode().equals(a2.getCountryCode())){
+ return false;
+ }
+
+ if(!a1.getCountryName().equals(a2.getCountryName())){
+ return false;
+ }
+
+ if(!a1.getLocality().equals(a2.getLocality())){
+ return false;
+ }
+
+ if(!a1.getSubLocality().equals(a2.getSubLocality())){
+ return false;
+ }
+
+ if(!a1.getSubAdministrativeArea().equals(a2.getSubAdministrativeArea())){
+ return false;
+ }
+
+ if(!a1.getPostalCode().equals(a2.getPostalCode())){
+ return false;
+ }
+
+ if(!a1.getThoroughfare().equals(a2.getThoroughfare())){
+ return false;
+ }
+
+ if(!a1.getSubThoroughfare().equals(a2.getSubThoroughfare())){
+ return false;
+ }
+
+ return true;
+ }
+
public static boolean validateTtsChunks(List<TTSChunk> list1, List<TTSChunk> list2){
if(list1 == null){
return ( list2 == null );
@@ -425,6 +538,342 @@ public class Validator{
return true;
}
+ public static boolean validateTemperature(Temperature temperature1, Temperature temperature2){
+ if(temperature1 == null){
+ return ( temperature2 == null );
+ }
+ if(temperature2 == null){
+ return ( temperature1 == null );
+ }
+
+ if((float) temperature1.getValue() != (float) temperature2.getValue()){
+ log("validateTemperature",
+ "Value " + temperature1.getValue() + " didn't match value " + temperature2.getValue()
+ + ".");
+ return false;
+ }
+
+ if(temperature1.getUnit() != temperature2.getUnit()){
+ log("validateTemperature",
+ "Unit " + temperature1.getUnit() + " didn't match unit " + temperature2.getUnit() + ".");
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateRdsData(RdsData rdsData1, RdsData rdsData2){
+ if(rdsData1 == null){
+ return ( rdsData2 == null );
+ }
+ if(rdsData2 == null){
+ return ( rdsData1 == null );
+ }
+
+ if(rdsData1.getProgramService() != rdsData2.getProgramService()){
+ log("validateRdsData",
+ "Ps " + rdsData1.getProgramService() + " didn't match Ps " + rdsData2.getProgramService()
+ + ".");
+ return false;
+ }
+
+ if(rdsData1.getRadioText() != rdsData2.getRadioText()){
+ log("validateRdsData",
+ "Rt " + rdsData1.getRadioText() + " didn't match Rt " + rdsData2.getRadioText()
+ + ".");
+ return false;
+ }
+
+ if(rdsData1.getClockText() != rdsData2.getClockText()){
+ log("validateRdsData",
+ "Ct " + rdsData1.getClockText() + " didn't match Ct " + rdsData2.getClockText()
+ + ".");
+ return false;
+ }
+
+ if(rdsData1.getProgramIdentification() != rdsData2.getProgramIdentification()){
+ log("validateRdsData",
+ "Pi " + rdsData1.getProgramIdentification() + " didn't match Pi " + rdsData2.getProgramIdentification()
+ + ".");
+ return false;
+ }
+
+ if(rdsData1.getRegion() != rdsData2.getRegion()){
+ log("validateRdsData",
+ "Reg " + rdsData1.getRegion() + " didn't match Reg " + rdsData2.getRegion()
+ + ".");
+ return false;
+ }
+
+ if(rdsData1.getTrafficProgram() != rdsData2.getTrafficProgram()){
+ log("validateRdsData",
+ "Tp " + rdsData1.getTrafficProgram() + " didn't match Tp " + rdsData2.getTrafficProgram()
+ + ".");
+ return false;
+ }
+
+ if(rdsData1.getTrafficAnnouncement() != rdsData2.getTrafficAnnouncement()){
+ log("validateRdsData",
+ "Ta " + rdsData1.getTrafficAnnouncement() + " didn't match Ta " + rdsData2.getTrafficAnnouncement()
+ + ".");
+ return false;
+ }
+
+ if(rdsData1.getProgramType() != rdsData2.getProgramType()){
+ log("validateRdsData",
+ "Pty " + rdsData1.getProgramType() + " didn't match Pty " + rdsData2.getProgramType()
+ + ".");
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateClimateControlData(ClimateControlData climateControlData1, ClimateControlData climateControlData2){
+ if(climateControlData1 == null){
+ return ( climateControlData2 == null );
+ }
+ if(climateControlData2 == null){
+ return ( climateControlData1 == null );
+ }
+
+ if(climateControlData1.getFanSpeed() != climateControlData2.getFanSpeed()){
+ log("validateClimateControlData",
+ "FanSpeed " + climateControlData1.getFanSpeed() + " didn't match fanSpeed " + climateControlData2.getFanSpeed()
+ + ".");
+ return false;
+ }
+
+ if(!( validateTemperature(climateControlData1.getCurrentTemperature(), climateControlData2.getCurrentTemperature()) )){
+ return false;
+ }
+
+ if(!( validateTemperature(climateControlData1.getDesiredTemperature(), climateControlData2.getDesiredTemperature()) )){
+ return false;
+ }
+
+ if(climateControlData1.getAcEnable() != climateControlData2.getAcEnable()){
+ log("validateClimateControlData",
+ "AcEnable " + climateControlData1.getAcEnable() + " didn't match AcEnable " + climateControlData2.getAcEnable()
+ + ".");
+ return false;
+ }
+
+ if(climateControlData1.getCirculateAirEnable() != climateControlData2.getCirculateAirEnable()){
+ log("validateClimateControlData",
+ "CirculateAirEnable " + climateControlData1.getCirculateAirEnable() + " didn't match CirculateAirEnable " + climateControlData2.getCirculateAirEnable()
+ + ".");
+ return false;
+ }
+
+ if(climateControlData1.getAutoModeEnable() != climateControlData2.getAutoModeEnable()){
+ log("validateClimateControlData",
+ "AutoModeEnable " + climateControlData1.getAutoModeEnable() + " didn't match AutoModeEnable " + climateControlData2.getAutoModeEnable()
+ + ".");
+ return false;
+ }
+
+ if(climateControlData1.getDefrostZone() != climateControlData2.getDefrostZone()){
+ log("validateClimateControlData",
+ "DefrostZone " + climateControlData1.getDefrostZone() + " didn't match DefrostZone " + climateControlData2.getDefrostZone()
+ + ".");
+ return false;
+ }
+
+ if(climateControlData1.getDualModeEnable() != climateControlData2.getDualModeEnable()){
+ log("validateClimateControlData",
+ "DualModeEnable " + climateControlData1.getDualModeEnable() + " didn't match DualModeEnable " + climateControlData2.getDualModeEnable()
+ + ".");
+ return false;
+ }
+
+ if(climateControlData1.getAcMaxEnable() != climateControlData2.getAcMaxEnable()){
+ log("validateClimateControlData",
+ "AcMaxEnable " + climateControlData1.getAcMaxEnable() + " didn't match AcMaxEnable " + climateControlData2.getAcMaxEnable()
+ + ".");
+ return false;
+ }
+
+ if(climateControlData1.getVentilationMode() != climateControlData2.getVentilationMode()){
+ log("validateClimateControlData",
+ "VentilationMode " + climateControlData1.getVentilationMode() + " didn't match VentilationMode " + climateControlData2.getVentilationMode()
+ + ".");
+ return false;
+ }
+
+
+ return true;
+ }
+
+ public static boolean validateModuleData(ModuleData moduleData1, ModuleData moduleData2){
+ if(moduleData1 == null){
+ return ( moduleData2 == null );
+ }
+ if(moduleData2 == null){
+ return ( moduleData1 == null );
+ }
+
+ if(moduleData1.getModuleType() != moduleData2.getModuleType()){
+ log("validateModuleData",
+ "ModuleType " + moduleData1.getModuleType() + " didn't match ModuleType " + moduleData2.getModuleType()
+ + ".");
+ return false;
+ }
+
+ if(!( validateRadioControlData(moduleData1.getRadioControlData(), moduleData2.getRadioControlData()) )){
+ return false;
+ }
+
+ if(!( validateClimateControlData(moduleData1.getClimateControlData(), moduleData2.getClimateControlData()) )){
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateRemoteControlCapabilities(RemoteControlCapabilities remoteControlCapabilities1, RemoteControlCapabilities remoteControlCapabilities2){
+ if(remoteControlCapabilities1 == null){
+ return ( remoteControlCapabilities2 == null );
+ }
+ if(remoteControlCapabilities2 == null){
+ return ( remoteControlCapabilities1 == null );
+ }
+
+ if(!( validateButtonCapabilities(remoteControlCapabilities1.getButtonCapabilities(), remoteControlCapabilities2.getButtonCapabilities()) )){
+ return false;
+ }
+
+ if(!( validateRadioControlCapabilities(remoteControlCapabilities1.getRadioControlCapabilities(), remoteControlCapabilities2.getRadioControlCapabilities()) )){
+ return false;
+ }
+
+ if(!( validateClimateControlCapabilities(remoteControlCapabilities1.getClimateControlCapabilities(), remoteControlCapabilities2.getClimateControlCapabilities()) )){
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateRadioControlData(RadioControlData radioControlData1, RadioControlData radioControlData2){
+ if(radioControlData1 == null){
+ return ( radioControlData2 == null );
+ }
+ if(radioControlData2 == null){
+ return ( radioControlData1 == null );
+ }
+
+ if(radioControlData1.getFrequencyInteger() != radioControlData2.getFrequencyInteger()){
+ log("validateRadioControlData",
+ "FrequencyInteger " + radioControlData1.getFrequencyInteger() + " didn't match FrequencyInteger " + radioControlData2.getFrequencyInteger()
+ + ".");
+ return false;
+ }
+
+ if(radioControlData1.getFrequencyFraction() != radioControlData2.getFrequencyFraction()){
+ log("validateRadioControlData",
+ "FrequencyFraction " + radioControlData1.getFrequencyFraction() + " didn't match FrequencyFraction " + radioControlData2.getFrequencyFraction()
+ + ".");
+ return false;
+ }
+
+ if(radioControlData1.getBand() != radioControlData2.getBand()){
+ log("validateRadioControlData",
+ "Band " + radioControlData1.getBand() + " didn't match Band " + radioControlData2.getBand()
+ + ".");
+ return false;
+ }
+
+ if(!( validateRdsData(radioControlData1.getRdsData(), radioControlData2.getRdsData()) )){
+ return false;
+ }
+
+ if(radioControlData1.getAvailableHDs() != radioControlData2.getAvailableHDs()){
+ log("validateRadioControlData",
+ "AvailableHDs " + radioControlData1.getAvailableHDs() + " didn't match AvailableHDs " + radioControlData2.getAvailableHDs()
+ + ".");
+ return false;
+ }
+
+ if(radioControlData1.getHdChannel() != radioControlData2.getHdChannel()){
+ log("validateRadioControlData",
+ "HdChannel " + radioControlData1.getHdChannel() + " didn't match HdChannel " + radioControlData2.getHdChannel()
+ + ".");
+ return false;
+ }
+
+ if(radioControlData1.getSignalStrength() != radioControlData2.getSignalStrength()){
+ log("validateRadioControlData",
+ "SignalStrength " + radioControlData1.getSignalStrength() + " didn't match SignalStrength " + radioControlData2.getSignalStrength()
+ + ".");
+ return false;
+ }
+
+ if(radioControlData1.getSignalChangeThreshold() != radioControlData2.getSignalChangeThreshold()){
+ log("validateRadioControlData",
+ "SignalChangeThreshold " + radioControlData1.getSignalChangeThreshold() + " didn't match SignalChangeThreshold " + radioControlData2.getSignalChangeThreshold()
+ + ".");
+ return false;
+ }
+
+ if(radioControlData1.getRadioEnable() != radioControlData2.getRadioEnable()){
+ log("validateRadioControlData",
+ "RadioEnable " + radioControlData1.getRadioEnable() + " didn't match RadioEnable " + radioControlData2.getRadioEnable()
+ + ".");
+ return false;
+ }
+
+ if(radioControlData1.getState() != radioControlData2.getState()){
+ log("validateRadioControlData",
+ "State " + radioControlData1.getState() + " didn't match State " + radioControlData2.getState()
+ + ".");
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateNavigationCapability(NavigationCapability navigationCapability1, NavigationCapability navigationCapability2){
+ if(navigationCapability1 == null){
+ return ( navigationCapability2 == null );
+ }
+ if(navigationCapability2 == null){
+ return ( navigationCapability1 == null );
+ }
+
+ if(navigationCapability1.getSendLocationEnabled() != navigationCapability2.getSendLocationEnabled()){
+ log("validateNavigationCapability",
+ "SendLocationEnabled " + navigationCapability1.getSendLocationEnabled() + " didn't match SendLocationEnabled " + navigationCapability2.getSendLocationEnabled()
+ + ".");
+ return false;
+ }
+
+ if(navigationCapability1.getWayPointsEnabled() != navigationCapability2.getWayPointsEnabled()){
+ log("validateNavigationCapability",
+ "WayPointsEnabled " + navigationCapability1.getWayPointsEnabled() + " didn't match WayPointsEnabled " + navigationCapability2.getWayPointsEnabled() + ".");
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validatePhoneCapability(PhoneCapability phoneCapability1, PhoneCapability phoneCapability2){
+ if(phoneCapability1 == null){
+ return ( phoneCapability2 == null );
+ }
+ if(phoneCapability2 == null){
+ return ( phoneCapability1 == null );
+ }
+
+ if(phoneCapability1.getDialNumberEnabled() != phoneCapability2.getDialNumberEnabled()){
+ log("validatePhoneCapability",
+ "DialNumberEnabled " + phoneCapability1.getDialNumberEnabled() + " didn't match DialNumberEnabled " + phoneCapability1.getDialNumberEnabled()
+ + ".");
+ return false;
+ }
+
+ return true;
+ }
+
public static boolean validateTouchEventCapabilities(TouchEventCapabilities item1, TouchEventCapabilities item2){
if(item1 == null){
return ( item2 == null );
@@ -1104,6 +1553,18 @@ public class Validator{
return true;
}
+
+ public static boolean validateSupportedFormats (VideoStreamingFormat vsf1, VideoStreamingFormat vsf2) {
+ if(vsf1.getProtocol() != vsf2.getProtocol()){
+ return false;
+ }
+
+ if(vsf1.getCodec() != vsf2.getCodec()){
+ return false;
+ }
+
+ return true;
+ }
public static boolean validateDisplayCapabilities (DisplayCapabilities item1, DisplayCapabilities item2) {
if (item1 == null) {
@@ -1256,7 +1717,154 @@ public class Validator{
return true;
}
-
+
+ public static boolean validateRadioControlCapabilities (List<RadioControlCapabilities> item1, List<RadioControlCapabilities> item2) {
+ if (item1 == null) {
+ return ( item2 == null );
+ }
+ if (item2 == null) {
+ return ( item1 == null );
+ }
+
+ if (item1.size() != item2.size()) {
+ return false;
+ }
+
+ for (int i = 0; i < item1.size(); i++) {
+ if (item1.get(i).getModuleName() != item2.get(i).getModuleName()) {
+ return false;
+ }
+ if (item1.get(i).getRadioEnableAvailable() != item2.get(i).getRadioEnableAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getRadioBandAvailable() != item2.get(i).getRadioBandAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getRadioFrequencyAvailable() != item2.get(i).getRadioFrequencyAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getHdChannelAvailable() != item2.get(i).getHdChannelAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getRdsDataAvailable() != item2.get(i).getRdsDataAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getAvailableHDsAvailable() != item2.get(i).getAvailableHDsAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getStateAvailable() != item2.get(i).getStateAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getSignalStrengthAvailable() != item2.get(i).getSignalStrengthAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getSignalChangeThresholdAvailable() != item2.get(i).getSignalChangeThresholdAvailable()) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static boolean validateClimateControlCapabilities (List<ClimateControlCapabilities> item1, List<ClimateControlCapabilities> item2) {
+ if (item1 == null) {
+ return ( item2 == null );
+ }
+ if (item2 == null) {
+ return ( item1 == null );
+ }
+
+ if (item1.size() != item2.size()) {
+ return false;
+ }
+
+ for (int i = 0; i < item1.size(); i++) {
+ if (item1.get(i).getModuleName() != item2.get(i).getModuleName()) {
+ return false;
+ }
+ if (item1.get(i).getFanSpeedAvailable() != item2.get(i).getFanSpeedAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getDesiredTemperatureAvailable() != item2.get(i).getDesiredTemperatureAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getAcEnableAvailable() != item2.get(i).getAcEnableAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getAcMaxEnableAvailable() != item2.get(i).getAcMaxEnableAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getCirculateAirEnableAvailable() != item2.get(i).getCirculateAirEnableAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getAutoModeEnableAvailable() != item2.get(i).getAutoModeEnableAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getDualModeEnableAvailable() != item2.get(i).getDualModeEnableAvailable()) {
+ return false;
+ }
+ if (item1.get(i).getDefrostZoneAvailable() != item2.get(i).getDefrostZoneAvailable()) {
+ return false;
+ }
+
+ if(! (validateDefrostZones(item1.get(i).getDefrostZone(), item2.get(i).getDefrostZone()) )){
+ return false;
+ }
+
+ if (item1.get(i).getVentilationModeAvailable() != item2.get(i).getVentilationModeAvailable()) {
+ return false;
+ }
+
+ if(! (validateVentilationModes(item1.get(i).getVentilationMode(), item2.get(i).getVentilationMode()) )){
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static boolean validateDefrostZones (List<DefrostZone> item1, List<DefrostZone> item2) {
+ if (item1 == null) {
+ return ( item2 == null );
+ }
+ if (item2 == null) {
+ return ( item1 == null );
+ }
+
+ if (item1.size() != item2.size()) {
+ return false;
+ }
+
+ for (int i = 0; i < item1.size(); i++) {
+ if (item1.get(i) != item2.get(i)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static boolean validateVentilationModes (List<VentilationMode> item1, List<VentilationMode> item2) {
+ if (item1 == null) {
+ return ( item2 == null );
+ }
+ if (item2 == null) {
+ return ( item1 == null );
+ }
+
+ if (item1.size() != item2.size()) {
+ return false;
+ }
+
+ for (int i = 0; i < item1.size(); i++) {
+ if (item1.get(i) != item2.get(i)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
public static boolean validateTurnList (List<Turn> item1, List<Turn> item2) {
if (item1 == null) {
return (item2 == null);
@@ -1497,4 +2105,68 @@ public class Validator{
return true;
}
+
+ public static boolean validateHMICapabilities(HMICapabilities hmiA, HMICapabilities hmiB){
+ if(hmiA.isPhoneCallAvailable() != hmiB.isPhoneCallAvailable()){
+ return false;
+ }
+
+ if(hmiA.isVideoStreamingAvailable() != hmiB.isVideoStreamingAvailable()){
+ return false;
+ }
+
+ if(hmiA.isNavigationAvailable() != hmiB.isNavigationAvailable()){
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateHMIZoneCapabilities(List<HmiZoneCapabilities> hmizA, List<HmiZoneCapabilities> hmizB){
+ for(int i = 0; i < hmizA.size(); i++){
+ if(!hmizA.get(i).equals(hmizB.get(i))){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean validateSpeechCapabilities(List<SpeechCapabilities> spA, List<SpeechCapabilities> spB){
+ for(int i = 0; i < spA.size(); i++){
+ if(!spA.get(i).equals(spB.get(i))){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean validateVideoStreamingFormat(VideoStreamingFormat a, VideoStreamingFormat b){
+ if(!a.getCodec().equals(b.getCodec())){
+ return false;
+ }
+
+ if(!a.getProtocol().equals(b.getProtocol())){
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean validateVideoStreamingCapability(VideoStreamingCapability a, VideoStreamingCapability b){
+ if(!validateImageResolution(a.getPreferredResolution(), b.getPreferredResolution())){
+ return false;
+ }
+
+ if(!a.getMaxBitrate().equals(b.getMaxBitrate())){
+ return false;
+ }
+
+ for(int i = 0; i < a.getSupportedFormats().size(); i++){
+ if(!validateVideoStreamingFormat(a.getSupportedFormats().get(i), b.getSupportedFormats().get(i))){
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/encoder/EncoderUtilsTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/encoder/EncoderUtilsTest.java
new file mode 100644
index 000000000..083a5dd3f
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/encoder/EncoderUtilsTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.test.encoder;
+
+import android.annotation.TargetApi;
+import android.media.MediaFormat;
+import android.os.Build;
+
+import com.smartdevicelink.encoder.EncoderUtils;
+
+import junit.framework.TestCase;
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.encoder.EncoderUtils}
+ */
+@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
+public class EncoderUtilsTest extends TestCase {
+ public void testGetCodecSpecificDataWithNull() {
+ byte[] result = EncoderUtils.getCodecSpecificData(null);
+ assertNull(result);
+ }
+
+ public void testGetCodecSpecificDataForAVC() {
+ // example of SPS NAL unit with 4-byte start code
+ byte[] sps = new byte[] {
+ 0x00, 0x00, 0x00, 0x01,
+ 0x67, 0x42, (byte)0xC0, 0x0A, (byte)0xA6, 0x11, 0x11, (byte)0xE8,
+ 0x40, 0x00, 0x00, (byte)0xFA, 0x40, 0x00, 0x3A, (byte)0x98,
+ 0x23, (byte)0xC4, (byte)0x89, (byte)0x84, 0x60
+ };
+ // example of PPS NAL unit with 4-byte start code
+ byte[] pps = new byte[] {
+ 0x00, 0x00, 0x00, 0x01,
+ 0x68, (byte)0xC8, 0x42, 0x0F, 0x13, 0x20
+ };
+
+ ByteBuffer spsByteBuffer = ByteBuffer.allocate(sps.length);
+ spsByteBuffer.put(sps);
+ spsByteBuffer.flip();
+
+ ByteBuffer ppsByteBuffer = ByteBuffer.allocate(pps.length);
+ ppsByteBuffer.put(pps);
+ ppsByteBuffer.flip();
+
+ MediaFormat format = MediaFormat.createVideoFormat("video/avc", 16, 16);
+ format.setByteBuffer("csd-0", spsByteBuffer);
+ format.setByteBuffer("csd-1", ppsByteBuffer);
+
+ byte[] result = EncoderUtils.getCodecSpecificData(format);
+ assertNotNull(result);
+
+ byte[] expected = new byte[sps.length + pps.length];
+ System.arraycopy(sps, 0, expected, 0, sps.length);
+ System.arraycopy(pps, 0, expected, sps.length, pps.length);
+ assertTrue("Output codec specific data doesn't match", Arrays.equals(expected, result));
+ }
+
+ public void testGetCodecSpecificDataWithInvalidAVCData() {
+ // testing an error case when the encoder emits SPS only (which should not happen)
+ byte[] sps = new byte[] {
+ 0x00, 0x00, 0x00, 0x01,
+ 0x67, 0x42, (byte)0xC0, 0x0A, (byte)0xA6, 0x11, 0x11, (byte)0xE8,
+ 0x40, 0x00, 0x00, (byte)0xFA, 0x40, 0x00, 0x3A, (byte)0x98,
+ 0x23, (byte)0xC4, (byte)0x89, (byte)0x84, 0x60
+ };
+
+ ByteBuffer spsByteBuffer = ByteBuffer.allocate(sps.length);
+ spsByteBuffer.put(sps);
+ spsByteBuffer.flip();
+
+ MediaFormat format = MediaFormat.createVideoFormat("video/avc", 16, 16);
+ format.setByteBuffer("csd-0", spsByteBuffer);
+ // no PPS
+
+ byte[] result = EncoderUtils.getCodecSpecificData(format);
+ assertNull(result);
+ }
+
+ public void testGetCodecSpecificDataForUnknownCodec() {
+ MediaFormat format = MediaFormat.createVideoFormat("video/raw", 16, 16);
+ byte[] result = EncoderUtils.getCodecSpecificData(format);
+ assertNull("For unsupported codec, getCodecSpecificData should return null", result);
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCMessageTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCMessageTests.java
new file mode 100644
index 000000000..51727bb66
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCMessageTests.java
@@ -0,0 +1,141 @@
+package com.smartdevicelink.test.proxy;
+
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.Alert;
+import com.smartdevicelink.proxy.rpc.ChangeRegistration;
+import com.smartdevicelink.proxy.rpc.Choice;
+import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
+import com.smartdevicelink.proxy.rpc.GetDTCsResponse;
+import com.smartdevicelink.proxy.rpc.Image;
+import com.smartdevicelink.proxy.rpc.TTSChunk;
+import com.smartdevicelink.proxy.rpc.enums.Language;
+import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Created by austinkirk on 6/8/17.
+ */
+
+public class RPCMessageTests extends TestCase {
+ RPCMessage testMessage = new RPCMessage("TestFunction");
+
+ private static final String TAG = "RPC Struct Tests";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testGeneralGettersAndSetters(){
+ String testKey = Test.GENERAL_STRING;
+ Integer testInt = Test.GENERAL_INT;
+
+ testMessage.setParameters(testKey, testInt);
+ assertEquals(Test.MATCH, testInt, testMessage.getParameters(testKey));
+
+ testMessage.setParameters(testKey, null);
+ assertNull(testMessage.getParameters(testKey));
+ }
+
+ public void testCommonObjectGetters(){
+ String stringKey = "String";
+ String testString = Test.GENERAL_STRING;
+ testMessage.setParameters(stringKey, testString);
+
+ assertEquals(Test.MATCH, testMessage.getString(stringKey), testString);
+
+ String intKey = "Integer";
+ Integer testInt = Test.GENERAL_INT;
+ testMessage.setParameters(intKey, testInt);
+
+ assertEquals(Test.MATCH, testMessage.getInteger(intKey), testInt);
+
+ String doubleKey = "Double";
+ Double testDouble = Test.GENERAL_DOUBLE;
+ testMessage.setParameters(doubleKey, testDouble);
+
+ assertEquals(Test.MATCH, testMessage.getDouble(doubleKey), testDouble);
+
+ String booleanKey = "Boolean";
+ Boolean testBoolean = Test.GENERAL_BOOLEAN;
+ testMessage.setParameters(booleanKey, testBoolean);
+
+ assertEquals(Test.MATCH, testMessage.getBoolean(booleanKey), testBoolean);
+
+ String longKey = "Long";
+ Long testLong = Test.GENERAL_LONG;
+ testMessage.setParameters(longKey, testLong);
+
+ assertEquals(Test.MATCH, testMessage.getLong(longKey), testLong);
+
+ testMessage.setParameters(longKey, testInt);
+
+ assertEquals(Test.MATCH, testMessage.getLong(longKey), new Long(testInt.longValue()));
+
+ testMessage.setParameters(longKey, testDouble);
+ assertNull(testMessage.getLong(longKey));
+ }
+
+ public void testGetObject(){
+ String keyIsEmpty = "EMPTY";
+ assertNull(testMessage.getObject(Integer.class, keyIsEmpty));
+
+ String keyLanguage = ChangeRegistration.KEY_LANGUAGE;
+ Language language = Test.GENERAL_LANGUAGE;
+ testMessage.setParameters(keyLanguage, language);
+ assertEquals(Test.MATCH, language, testMessage.getObject(Language.class, keyLanguage));
+
+ String languageString = language.toString();
+ testMessage.setParameters(keyLanguage, languageString);
+ assertEquals(Test.MATCH, language, testMessage.getObject(Language.class, keyLanguage));
+
+ String keyImage = Choice.KEY_IMAGE;
+ Image testImage = Test.GENERAL_IMAGE;
+ testMessage.setParameters(keyImage, testImage.getStore());
+ assertTrue(Validator.validateImage(testImage, (Image) testMessage.getObject(Image.class, keyImage)));
+
+ String keyDTCs = GetDTCsResponse.KEY_DTC;
+ List<String> testDTCs = Test.GENERAL_STRING_LIST;
+ testMessage.setParameters(keyDTCs, testDTCs);
+ assertEquals(Test.MATCH, testDTCs, testMessage.getObject(String.class, keyDTCs));
+
+ String keyTTSchunks = Alert.KEY_TTS_CHUNKS;
+ List<TTSChunk> testTTSchunks = Test.GENERAL_TTSCHUNK_LIST;
+ testMessage.setParameters(keyTTSchunks, testTTSchunks);
+ assertEquals(Test.MATCH, testTTSchunks, testMessage.getObject(TTSChunk.class, keyTTSchunks));
+
+ List<Hashtable<String, Object>> testListTTSchunks = new ArrayList<>();
+ for(TTSChunk ttsChunk : testTTSchunks){
+ testListTTSchunks.add(ttsChunk.getStore());
+ }
+ testMessage.setParameters(keyTTSchunks, testListTTSchunks);
+ List<TTSChunk> underTest = (List<TTSChunk>) testMessage.getObject(TTSChunk.class, keyTTSchunks);
+ assertTrue(Validator.validateTtsChunks(testTTSchunks, underTest));
+
+ String keyMediaClockFormats = DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS;
+ List<MediaClockFormat> testMediaClockFormats = Test.GENERAL_MEDIACLOCKFORMAT_LIST;
+ testMessage.setParameters(keyMediaClockFormats, testMediaClockFormats);
+ assertEquals(Test.MATCH, testMediaClockFormats, testMessage.getObject(MediaClockFormat.class, keyMediaClockFormats));
+
+ List<String> testListMediaClockFormats = new ArrayList<>();
+ for(MediaClockFormat mcFormat : testMediaClockFormats){
+ testListMediaClockFormats.add(mcFormat.toString());
+ }
+ testMessage.setParameters(keyMediaClockFormats, testListMediaClockFormats);
+ assertEquals(Test.MATCH, testMediaClockFormats, testMessage.getObject(MediaClockFormat.class, keyMediaClockFormats));
+
+ assertNull(testMessage.getObject(Image.class, keyLanguage)); // Test incorrect class
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java
index b334058ea..e31aedbe7 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestFactoryTests.java
@@ -80,7 +80,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testInt, testBSR.getCorrelationID());
testBSR = RPCRequestFactory.buildSystemRequest(testData, null);
- assertNull(Test.NULL, testBSR.getCorrelationID());
+ assertNotNull(Test.NULL, testBSR.getCorrelationID());
testBSR = RPCRequestFactory.buildSystemRequest(null, testInt);
assertNull(Test.NULL, testBSR);
@@ -95,7 +95,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testInt, testBSR.getCorrelationID());
testBSR = RPCRequestFactory.buildSystemRequestLegacy(testVData, null);
- assertNull(Test.NULL, testBSR.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testBSR.getCorrelationID());
testBSR = RPCRequestFactory.buildSystemRequestLegacy(null, testInt);
assertNull(Test.NULL, testBSR);
@@ -145,7 +145,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testBAC.getMenuParams());
assertNull(Test.NULL, testBAC.getVrCommands());
assertNull(Test.NULL, testBAC.getCmdIcon());
- assertNull(Test.NULL, testBAC.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testBAC.getCorrelationID());
// Test -- buildAddCommand(Integer commandID, String menuText, Integer parentID, Integer position, Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
testIconValue = "icon";
@@ -167,7 +167,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testBAC.getMenuParams());
assertNull(Test.NULL, testBAC.getVrCommands());
assertNull(Test.NULL, testBAC.getCmdIcon());
- assertNull(Test.NULL, testBAC.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testBAC.getCorrelationID());
// Test -- buildAddCommand(Integer commandID, String menuText, Integer parentID, Integer position, Vector<String> vrCommands, Integer correlationID)
testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testParentID, testPosition, testVrCommands, testCorrelationID);
@@ -182,7 +182,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testBAC.getCmdID());
assertNull(Test.NULL, testBAC.getMenuParams());
assertNull(Test.NULL, testBAC.getVrCommands());
- assertNull(Test.NULL, testBAC.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testBAC.getCorrelationID());
// Test -- buildAddCommand(Integer commandID, String menuText, Vector<String> vrCommands, Integer correlationID)
testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testMenuText, testVrCommands, testCorrelationID);
@@ -195,7 +195,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testBAC.getCmdID());
assertNull(Test.NULL, testBAC.getMenuParams());
assertNull(Test.NULL, testBAC.getVrCommands());
- assertNull(Test.NULL, testBAC.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testBAC.getCorrelationID());
// Test -- buildAddCommand(Integer commandID, Vector<String> vrCommands, Integer correlationID)
testBAC = RPCRequestFactory.buildAddCommand(testCommandID, testVrCommands, testCorrelationID);
@@ -206,7 +206,7 @@ public class RPCRequestFactoryTests extends TestCase {
testBAC = RPCRequestFactory.buildAddCommand(null, null, null);
assertNull(Test.NULL, testBAC.getCmdID());
assertNull(Test.NULL, testBAC.getVrCommands());
- assertNull(Test.NULL, testBAC.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testBAC.getCorrelationID());
}
public void testBuildAddSubMenu () {
@@ -232,7 +232,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testBASM.getMenuID());
assertNull(Test.NULL, testBASM.getMenuName());
assertNull(Test.NULL, testBASM.getPosition());
- assertNull(Test.NULL, testBASM.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testBASM.getCorrelationID());
}
public void testBuildAlert () {
@@ -294,7 +294,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testAlert.getPlayTone());
assertNull(Test.NULL, testAlert.getDuration());
assertNull(Test.NULL, testAlert.getSoftButtons());
- assertNull(Test.NULL, testAlert.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testAlert.getCorrelationID());
// Test -- buildAlert(String ttsText, Boolean playTone, Integer correlationID)
// ^ Calls another build method.
@@ -323,7 +323,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testAlert.getAlertText2());
assertNull(Test.NULL, testAlert.getPlayTone());
assertNull(Test.NULL, testAlert.getDuration());
- assertNull(Test.NULL, testAlert.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testAlert.getCorrelationID());
}
public void testBuildCreateInteractionChoiceSet () {
@@ -346,7 +346,7 @@ public class RPCRequestFactoryTests extends TestCase {
testBCICS = RPCRequestFactory.buildCreateInteractionChoiceSet(null, null, null);
assertNull(Test.NULL, testBCICS.getChoiceSet());
assertNull(Test.NULL, testBCICS.getInteractionChoiceSetID());
- assertNull(Test.NULL, testBCICS.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testBCICS.getCorrelationID());
}
public void testBuildDeleteCommand () {
@@ -363,7 +363,7 @@ public class RPCRequestFactoryTests extends TestCase {
testDC = RPCRequestFactory.buildDeleteCommand(null, null);
assertNull(Test.NULL, testDC.getCmdID());
- assertNull(Test.NULL, testDC.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testDC.getCorrelationID());
}
@@ -381,7 +381,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testFileName, testDF.getSdlFileName());
testDF = RPCRequestFactory.buildDeleteFile(null, null);
- assertNull(Test.NULL, testDF.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testDF.getCorrelationID());
assertNull(Test.NULL, testDF.getSdlFileName());
}
@@ -400,7 +400,7 @@ public class RPCRequestFactoryTests extends TestCase {
testDICS = RPCRequestFactory.buildDeleteInteractionChoiceSet(null, null);
assertNull(Test.NULL, testDICS.getInteractionChoiceSetID());
- assertNull(Test.NULL, testDICS.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testDICS.getCorrelationID());
}
public void testBuildDeleteSubMenu () {
@@ -417,7 +417,7 @@ public class RPCRequestFactoryTests extends TestCase {
testDSM = RPCRequestFactory.buildDeleteSubMenu(null, null);
assertNull(Test.NULL, testDSM.getMenuID());
- assertNull(Test.NULL, testDSM.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testDSM.getCorrelationID());
}
public void testBuildListFiles () {
@@ -430,7 +430,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testCorrelationID, testLF.getCorrelationID());
testLF = RPCRequestFactory.buildListFiles(null);
- assertNull(Test.NULL, testLF.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testLF.getCorrelationID());
}
@SuppressWarnings("deprecation")
@@ -480,7 +480,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testPI.getInteractionMode());
assertNull(Test.NULL, testPI.getTimeout());
assertNull(Test.NULL, testPI.getVrHelp());
- assertNull(Test.NULL, testPI.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testPI.getCorrelationID());
// Test -- buildPerformInteraction(String initPrompt, String displayText, Vector<Integer> interactionChoiceSetIDList, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp, Integer correlationID)
// ^ Calls another build method.
@@ -510,7 +510,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testPI.getTimeoutPrompt());
assertNull(Test.NULL, testPI.getInteractionMode());
assertNull(Test.NULL, testPI.getTimeout());
- assertNull(Test.NULL, testPI.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testPI.getCorrelationID());
// Test -- buildPerformInteraction(String initPrompt, String displayText, Vector<Integer> interactionChoiceSetIDList, String helpPrompt, String timeoutPrompt, InteractionMode interactionMode, Integer timeout, Integer correlationID)
// ^ Calls another build method.
@@ -538,7 +538,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testPI.getHelpPrompt());
assertNull(Test.NULL, testPI.getInteractionMode());
assertNull(Test.NULL, testPI.getTimeout());
- assertNull(Test.NULL, testPI.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testPI.getCorrelationID());
// Test -- buildPerformInteraction(String initPrompt, String displayText, Vector<Integer> interactionChoiceSetIDList, String helpPrompt, InteractionMode interactionMode, Integer timeout, Integer correlationID)
// ^ Calls another build method.
@@ -567,7 +567,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testPF.getFileType());
assertNull(Test.NULL, testPF.getPersistentFile());
assertNull(Test.NULL, testPF.getFileData());
- assertNull(Test.NULL, testPF.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testPF.getCorrelationID());
// Test -- buildPutFile(String sdlFileName, Integer iOffset, Integer iLength)
testPF = RPCRequestFactory.buildPutFile(testFileName, testOffset, testLength);
@@ -665,7 +665,7 @@ public class RPCRequestFactoryTests extends TestCase {
testSAI = RPCRequestFactory.buildSetAppIcon(null, null);
assertNull(Test.NULL, testSAI.getSdlFileName());
- assertNull(Test.NULL, testSAI.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSAI.getCorrelationID());
}
@@ -698,7 +698,7 @@ public class RPCRequestFactoryTests extends TestCase {
testSBP = RPCRequestFactory.buildSetGlobalProperties((Vector<TTSChunk>) null, null, null);
assertNull(Test.NULL, testSBP.getHelpPrompt());
assertNull(Test.NULL, testSBP.getTimeoutPrompt());
- assertNull(Test.NULL, testSBP.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSBP.getCorrelationID());
// Test -- buildSetGlobalProperties(String helpPrompt, String timeoutPrompt, String vrHelpTitle, Vector<VrHelpItem> vrHelp, Integer correlationID)
// ^ Calls another build method.
@@ -716,7 +716,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testSBP.getTimeoutPrompt());
assertNull(Test.NULL, testSBP.getVrHelpTitle());
assertNull(Test.NULL, testSBP.getVrHelp());
- assertNull(Test.NULL, testSBP.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSBP.getCorrelationID());
}
public void testBuildSetMediaClockTimer () {
@@ -736,7 +736,7 @@ public class RPCRequestFactoryTests extends TestCase {
testSMCT = RPCRequestFactory.buildSetMediaClockTimer(null, null, null, null, null);
assertNull(Test.NULL, testSMCT.getStartTime());
assertNull(Test.NULL, testSMCT.getUpdateMode());
- assertNull(Test.NULL, testSMCT.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSMCT.getCorrelationID());
// Test -- buildSetMediaClockTimer(UpdateMode updateMode, Integer correlationID)
// ^ Calls another build method.
@@ -784,7 +784,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testShow.getSoftButtons());
assertNull(Test.NULL, testShow.getCustomPresets());
assertNull(Test.NULL, testShow.getAlignment());
- assertNull(Test.NULL, testShow.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testShow.getCorrelationID());
// Test -- buildShow(String mainText1, String mainText2, String mainText3, String mainText4, TextAlignment alignment, Integer correlationID)
// ^ Calls another build method.
@@ -805,7 +805,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testShow.getMediaClock());
assertNull(Test.NULL, testShow.getMediaTrack());
assertNull(Test.NULL, testShow.getAlignment());
- assertNull(Test.NULL, testShow.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testShow.getCorrelationID());
// Test -- buildShow(String mainText1, String mainText2, TextAlignment alignment, Integer correlationID)
// ^ Calls another build method.
@@ -825,7 +825,7 @@ public class RPCRequestFactoryTests extends TestCase {
testSpeak = RPCRequestFactory.buildSpeak((String) null, null);
assertNull(Test.NULL, testSpeak.getTtsChunks());
- assertNull(Test.NULL, testSpeak.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSpeak.getCorrelationID());
// Test -- buildSpeak(Vector<TTSChunk> ttsChunks, Integer correlationID)
testSpeak = RPCRequestFactory.buildSpeak(testTTSChunks, testCorrelationID);
@@ -834,7 +834,7 @@ public class RPCRequestFactoryTests extends TestCase {
testSpeak = RPCRequestFactory.buildSpeak((Vector<TTSChunk>) null, null);
assertNull(Test.NULL, testSpeak.getTtsChunks());
- assertNull(Test.NULL, testSpeak.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSpeak.getCorrelationID());
}
public void testBuildSubscribeButton () {
@@ -850,7 +850,7 @@ public class RPCRequestFactoryTests extends TestCase {
testSB = RPCRequestFactory.buildSubscribeButton(null, null);
assertNull(Test.NULL, testSB.getButtonName());
- assertNull(Test.NULL, testSB.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSB.getCorrelationID());
}
@@ -864,7 +864,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testCorrelationID, testUAI.getCorrelationID());
testUAI = RPCRequestFactory.buildUnregisterAppInterface(null);
- assertNull(Test.NULL, testUAI.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testUAI.getCorrelationID());
}
public void testBuildUnsubscribeButton () {
@@ -880,7 +880,7 @@ public class RPCRequestFactoryTests extends TestCase {
testUB = RPCRequestFactory.buildUnsubscribeButton(null, null);
assertNull(Test.NULL, testUB.getButtonName());
- assertNull(Test.NULL, testUB.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testUB.getCorrelationID());
}
@@ -909,7 +909,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testCorrelationID, testSVD.getCorrelationID());
testSVD = RPCRequestFactory.BuildSubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null);
- assertNull(Test.NULL, testSVD.getCorrelationID());
+ assertNotNull(Test.NULL, testSVD.getCorrelationID());
}
public void testBuildUnsubscribeVehicleData () {
@@ -937,7 +937,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testCorrelationID, testUVD.getCorrelationID());
testUVD = RPCRequestFactory.BuildUnsubscribeVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null);
- assertNull(Test.NULL, testUVD.getCorrelationID());
+ assertNotNull(Test.NULL, testUVD.getCorrelationID());
}
public void testBuildGetVehicleData () {
@@ -966,7 +966,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testCorrelationID, testGVD.getCorrelationID());
testGVD = RPCRequestFactory.BuildGetVehicleData(testGPS, testSpeed, testRPM, testFuelLevel, testFuelLevelState, testInstantFuelConsumption, testExternalTemperature, testVIN, testPRNDL, testTirePressure, testOdometer, testBeltStatus, testBodyInformation, testDeviceStatus, testDriverBraking, null);
- assertNull(Test.NULL, testGVD.getCorrelationID());
+ assertNotNull(Test.NULL, testGVD.getCorrelationID());
}
public void testBuildScrollableMessage () {
@@ -988,7 +988,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testSM.getScrollableMessageBody());
assertNull(Test.NULL, testSM.getTimeout());
assertNull(Test.NULL, testSM.getSoftButtons());
- assertNull(Test.NULL, testSM.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSM.getCorrelationID());
}
public void testBuildSlider () {
@@ -1013,7 +1013,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testSlider.getSliderHeader());
assertNull(Test.NULL, testSlider.getSliderFooter());
assertNull(Test.NULL, testSlider.getTimeout());
- assertNull(Test.NULL, testSlider.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSlider.getCorrelationID());
}
public void testBuildChangeRegistration () {
@@ -1031,7 +1031,7 @@ public class RPCRequestFactoryTests extends TestCase {
testCR = RPCRequestFactory.BuildChangeRegistration(null, null, null);
assertNull(Test.NULL, testCR.getLanguage());
assertNull(Test.NULL, testCR.getHmiDisplayLanguage());
- assertNull(Test.NULL, testCR.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testCR.getCorrelationID());
}
public void testBuildSetDisplayLayout () {
@@ -1047,7 +1047,7 @@ public class RPCRequestFactoryTests extends TestCase {
testSDL = RPCRequestFactory.BuildSetDisplayLayout(null, null);
assertNull(Test.NULL, testSDL.getDisplayLayout());
- assertNull(Test.NULL, testSDL.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testSDL.getCorrelationID());
}
public void testBuildPerformAudioPassThru () {
@@ -1085,7 +1085,7 @@ public class RPCRequestFactoryTests extends TestCase {
assertNull(Test.NULL, testPAPT.getBitsPerSample());
assertNull(Test.NULL, testPAPT.getAudioType());
assertNull(Test.NULL, testPAPT.getMuteAudio());
- assertNull(Test.NULL, testPAPT.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testPAPT.getCorrelationID());
}
public void testBuildEndAudioPassThru () {
@@ -1098,6 +1098,6 @@ public class RPCRequestFactoryTests extends TestCase {
assertEquals(Test.MATCH, testCorrelationID, testEAPT.getCorrelationID());
testEAPT = RPCRequestFactory.BuildEndAudioPassThru(null);
- assertNull(Test.NULL, testEAPT.getCorrelationID());
+ assertNotNull(Test.NOT_NULL, testEAPT.getCorrelationID());
}
} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestTest.java
new file mode 100644
index 000000000..5c1b9436d
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCRequestTest.java
@@ -0,0 +1,48 @@
+package com.smartdevicelink.test.proxy;
+
+import android.test.AndroidTestCase;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.RPCResponse;
+import com.smartdevicelink.proxy.rpc.GetSystemCapability;
+import com.smartdevicelink.test.Config;
+import com.smartdevicelink.test.JsonUtils;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+public class RPCRequestTest extends AndroidTestCase {
+
+ public static final int SDL_VERSION_UNDER_TEST = Config.SDL_VERSION_UNDER_TEST;
+
+ private static final int CORR_ID = 402;
+
+ protected RPCRequest msg;
+
+ @Override
+ public void setUp(){
+ this.msg = new GetSystemCapability();
+
+ }
+
+ public void testCreation(){
+ assertNotNull("Object creation failed.", msg);
+ }
+
+ public void testGetCorrelationId(){
+ assertNotNull(this.msg.getCorrelationID());
+ }
+ public void testSettingCorrelationId(){
+ assertNotNull(this.msg.getCorrelationID());
+ msg.setCorrelationID(CORR_ID);
+ assertEquals("Correlation ID doesn't match expected ID.", CORR_ID, (int)msg.getCorrelationID());
+
+ }
+
+
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java
new file mode 100644
index 000000000..370d30979
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/RPCStructTests.java
@@ -0,0 +1,158 @@
+package com.smartdevicelink.test.proxy;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.AirbagStatus;
+import com.smartdevicelink.proxy.rpc.Choice;
+import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
+import com.smartdevicelink.proxy.rpc.Image;
+import com.smartdevicelink.proxy.rpc.ImageField;
+import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Created by austinkirk on 6/8/17.
+ */
+
+public class RPCStructTests extends TestCase {
+ RPCStruct testStruct = new RPCStruct();
+
+ private static final String TAG = "RPC Struct Tests";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testGeneralGettersAndSetters(){
+ String testKey = Test.GENERAL_STRING;
+ Integer testInt = Test.GENERAL_INT;
+
+ testStruct.setValue(testKey, testInt);
+ assertEquals(Test.MATCH, testInt, testStruct.getValue(testKey));
+
+ testStruct.setValue(testKey, null);
+ assertNull(testStruct.getValue(testKey));
+ }
+
+ public void testCommonObjectGetters(){
+ String stringKey = "String";
+ String testString = Test.GENERAL_STRING;
+ testStruct.setValue(stringKey, testString);
+
+ assertEquals(Test.MATCH, testStruct.getString(stringKey), testString);
+
+ String intKey = "Integer";
+ Integer testInt = Test.GENERAL_INT;
+ testStruct.setValue(intKey, testInt);
+
+ assertEquals(Test.MATCH, testStruct.getInteger(intKey), testInt);
+
+ String doubleKey = "Double";
+ Double testDouble = Test.GENERAL_DOUBLE;
+ testStruct.setValue(doubleKey, testDouble);
+
+ assertEquals(Test.MATCH, testStruct.getDouble(doubleKey), testDouble);
+
+ String booleanKey = "Boolean";
+ Boolean testBoolean = Test.GENERAL_BOOLEAN;
+ testStruct.setValue(booleanKey, testBoolean);
+
+ assertEquals(Test.MATCH, testStruct.getBoolean(booleanKey), testBoolean);
+
+ String longKey = "Long";
+ Long testLong = Test.GENERAL_LONG;
+ testStruct.setValue(longKey, testLong);
+
+ assertEquals(Test.MATCH, testStruct.getLong(longKey), testLong);
+
+ testStruct.setValue(longKey, testInt);
+
+ assertEquals(Test.MATCH, testStruct.getLong(longKey), new Long(testInt.longValue()));
+
+ testStruct.setValue(longKey, testDouble);
+
+ assertNull(testStruct.getLong(longKey));
+ }
+
+ public void testGetObject(){
+ String keyIsEmpty = "EMPTY";
+ assertNull(testStruct.getObject(Integer.class, keyIsEmpty));
+
+ String keyAirbag = AirbagStatus.KEY_DRIVER_AIRBAG_DEPLOYED;
+ VehicleDataEventStatus eventStatus = VehicleDataEventStatus.FAULT;
+ testStruct.setValue(keyAirbag, eventStatus);
+ assertEquals(Test.MATCH, eventStatus, testStruct.getObject(VehicleDataEventStatus.class, keyAirbag));
+
+ String eventStatusString = VehicleDataEventStatus.FAULT.toString();
+ testStruct.setValue(keyAirbag, eventStatusString);
+ assertEquals(Test.MATCH, eventStatus, testStruct.getObject(VehicleDataEventStatus.class, keyAirbag));
+
+ String keyImage = Choice.KEY_IMAGE;
+ Image testImage = Test.GENERAL_IMAGE;
+ testStruct.setValue(keyImage, testImage.getStore());
+ assertTrue(Validator.validateImage(testImage, (Image) testStruct.getObject(Image.class, keyImage)));
+
+ String keyVrCommand = Choice.KEY_VR_COMMANDS;
+ List<String> testCommands = Test.GENERAL_STRING_LIST;
+ testStruct.setValue(keyVrCommand, testCommands);
+ assertEquals(Test.MATCH, testCommands, testStruct.getObject(String.class, keyVrCommand));
+
+ String keyImageFields = DisplayCapabilities.KEY_IMAGE_FIELDS;
+ List<ImageField> testImageFields = Test.GENERAL_IMAGEFIELD_LIST;
+ testStruct.setValue(keyImageFields, testImageFields);
+ assertEquals(Test.MATCH, testImageFields, testStruct.getObject(ImageField.class, keyImageFields));
+
+ List<Hashtable<String, Object>> testListImageFields = new ArrayList<>();
+ for(ImageField imgField : testImageFields){
+ testListImageFields.add(imgField.getStore());
+ }
+ testStruct.setValue(keyImageFields, testListImageFields);
+ List<ImageField> underTest = (List<ImageField>) testStruct.getObject(ImageField.class, keyImageFields);
+ int index = 0;
+ for(ImageField imgField : testImageFields){
+ assertTrue(Validator.validateImageFields(imgField, underTest.get(index++)));
+ }
+
+ String keyMediaClockFormats = DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS;
+ List<MediaClockFormat> testMediaClockFormats = Test.GENERAL_MEDIACLOCKFORMAT_LIST;
+ testStruct.setValue(keyMediaClockFormats, testMediaClockFormats);
+ assertEquals(Test.MATCH, testMediaClockFormats, testStruct.getObject(MediaClockFormat.class, keyMediaClockFormats));
+
+ List<String> testListMediaClockFormats = new ArrayList<>();
+ for(MediaClockFormat mcFormat : testMediaClockFormats){
+ testListMediaClockFormats.add(mcFormat.toString());
+ }
+ testStruct.setValue(keyMediaClockFormats, testListMediaClockFormats);
+ assertEquals(Test.MATCH, testMediaClockFormats, testStruct.getObject(MediaClockFormat.class, keyMediaClockFormats));
+
+ assertNull(testStruct.getObject(Image.class, keyAirbag)); // Test incorrect class
+ }
+
+ public void testGetObjectExceptions(){
+ String invalidKey = "invalid";
+ testStruct.setValue(invalidKey, new Hashtable<>());
+ assertNull(testStruct.getObject(Integer.class, invalidKey));
+
+ List<Hashtable<String, Object>> list = new ArrayList<>();
+ list.add(new Hashtable<String, Object>());
+ testStruct.setValue(invalidKey, list);
+ assertNull(testStruct.getObject(Integer.class, invalidKey));
+
+ testStruct.setValue(invalidKey, Test.GENERAL_STRING);
+ assertNull(testStruct.getObject(Integer.class, invalidKey));
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java
new file mode 100644
index 000000000..fdc52f9b7
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SdlProxyBaseTests.java
@@ -0,0 +1,507 @@
+package com.smartdevicelink.test.proxy;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.telephony.TelephonyManager;
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+import com.smartdevicelink.exception.SdlException;
+import com.smartdevicelink.exception.SdlExceptionCause;
+import com.smartdevicelink.proxy.SdlProxyALM;
+import com.smartdevicelink.proxy.SdlProxyBuilder;
+import com.smartdevicelink.proxy.SdlProxyConfigurationResources;
+import com.smartdevicelink.proxy.callbacks.OnServiceEnded;
+import com.smartdevicelink.proxy.callbacks.OnServiceNACKed;
+import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
+import com.smartdevicelink.proxy.rpc.AddCommandResponse;
+import com.smartdevicelink.proxy.rpc.AddSubMenuResponse;
+import com.smartdevicelink.proxy.rpc.AlertManeuverResponse;
+import com.smartdevicelink.proxy.rpc.AlertResponse;
+import com.smartdevicelink.proxy.rpc.ButtonPressResponse;
+import com.smartdevicelink.proxy.rpc.ChangeRegistrationResponse;
+import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSetResponse;
+import com.smartdevicelink.proxy.rpc.DeleteCommandResponse;
+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;
+import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse;
+import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.GetWayPointsResponse;
+import com.smartdevicelink.proxy.rpc.ListFilesResponse;
+import com.smartdevicelink.proxy.rpc.OnAudioPassThru;
+import com.smartdevicelink.proxy.rpc.OnButtonEvent;
+import com.smartdevicelink.proxy.rpc.OnButtonPress;
+import com.smartdevicelink.proxy.rpc.OnCommand;
+import com.smartdevicelink.proxy.rpc.OnDriverDistraction;
+import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.OnHashChange;
+import com.smartdevicelink.proxy.rpc.OnInteriorVehicleData;
+import com.smartdevicelink.proxy.rpc.OnKeyboardInput;
+import com.smartdevicelink.proxy.rpc.OnLanguageChange;
+import com.smartdevicelink.proxy.rpc.OnLockScreenStatus;
+import com.smartdevicelink.proxy.rpc.OnPermissionsChange;
+import com.smartdevicelink.proxy.rpc.OnStreamRPC;
+import com.smartdevicelink.proxy.rpc.OnSystemRequest;
+import com.smartdevicelink.proxy.rpc.OnTBTClientState;
+import com.smartdevicelink.proxy.rpc.OnTouchEvent;
+import com.smartdevicelink.proxy.rpc.OnVehicleData;
+import com.smartdevicelink.proxy.rpc.OnWayPointChange;
+import com.smartdevicelink.proxy.rpc.PerformAudioPassThruResponse;
+import com.smartdevicelink.proxy.rpc.PerformInteractionResponse;
+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.SendHapticDataResponse;
+import com.smartdevicelink.proxy.rpc.SendLocationResponse;
+import com.smartdevicelink.proxy.rpc.SetAppIconResponse;
+import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
+import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse;
+import com.smartdevicelink.proxy.rpc.SetInteriorVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.SetMediaClockTimerResponse;
+import com.smartdevicelink.proxy.rpc.ShowConstantTbtResponse;
+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.SubscribeWayPointsResponse;
+import com.smartdevicelink.proxy.rpc.SystemRequestResponse;
+import com.smartdevicelink.proxy.rpc.UnsubscribeButtonResponse;
+import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.UnsubscribeWayPointsResponse;
+import com.smartdevicelink.proxy.rpc.UpdateTurnListResponse;
+import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
+import com.smartdevicelink.streaming.video.SdlRemoteDisplay;
+import com.smartdevicelink.streaming.video.VideoStreamingParameters;
+import com.smartdevicelink.test.streaming.video.SdlRemoteDisplayTest;
+
+import junit.framework.Assert;
+
+import java.lang.reflect.Method;
+
+
+public class SdlProxyBaseTests extends AndroidTestCase{
+ public static final String TAG = "SdlProxyBaseTests";
+
+ @Override
+ protected void setUp() throws Exception{
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ //Nothing here for now
+ }
+
+ /**
+ * Test SdlProxyBase for handling null SdlProxyConfigurationResources
+ */
+ public void testNullSdlProxyConfigurationResources() {
+ SdlProxyALM proxy = null;
+ SdlProxyBuilder.Builder builder = new SdlProxyBuilder.Builder(new ProxyListenerTest(), "appId", "appName", true, getContext());
+ SdlProxyConfigurationResources config = new SdlProxyConfigurationResources("path", (TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE));
+ //Construct with a non-null SdlProxyConfigurationResources
+ builder.setSdlProxyConfigurationResources(config);
+ try {
+ proxy = builder.build();
+ } catch (Exception e) {
+ Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing non null SdlProxyConfigurationResources");
+ if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) {
+ Assert.fail("Exception in testNullSdlProxyConfigurationResources");
+ }
+ }
+
+ //Construct with a null SdlProxyConfigurationResources
+ builder.setSdlProxyConfigurationResources(null);
+ try {
+ proxy = builder.build();
+ } catch (Exception e) {
+ Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing null SdlProxyConfigurationResources");
+ if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) {
+ Assert.fail("Exception in testNullSdlProxyConfigurationResources, testing null SdlProxyConfigurationResources");
+ }
+ }
+
+ //Construct with a non-null SdlProxyConfigurationResources and a null TelephonyManager
+ config.setTelephonyManager(null);
+ builder.setSdlProxyConfigurationResources(config);
+ try {
+ proxy = builder.build();
+ } catch (Exception e) {
+ Log.v(TAG, "Exception in testNullSdlProxyConfigurationResources, testing null TelephonyManager");
+ if (!(e instanceof SdlException) || !((SdlException) e).getSdlExceptionCause().equals(SdlExceptionCause.BLUETOOTH_ADAPTER_NULL)) {
+ Assert.fail("Exception in testNullSdlProxyConfigurationResources, testing null TelephonyManager");
+ }
+ }
+ }
+
+ public void testRemoteDisplayStreaming(){
+ SdlProxyALM proxy = null;
+ SdlProxyBuilder.Builder builder = new SdlProxyBuilder.Builder(new ProxyListenerTest(), "appId", "appName", true, getContext());
+ try{
+ proxy = builder.build();
+ // public void startRemoteDisplayStream(Context context, final Class<? extends SdlRemoteDisplay> remoteDisplay, final VideoStreamingParameters parameters, final boolean encrypted){
+ Method m = SdlProxyALM.class.getDeclaredMethod("startRemoteDisplayStream", Context.class, SdlRemoteDisplay.class, VideoStreamingParameters.class, boolean.class);
+ assertNotNull(m);
+ m.setAccessible(true);
+ m.invoke(proxy,getContext(), SdlRemoteDisplayTest.MockRemoteDisplay.class, (VideoStreamingParameters)null, false);
+ assert true;
+
+ }catch (Exception e){
+ assert false;
+ }
+ }
+
+ public class ProxyListenerTest implements IProxyListenerALM {
+
+ @Override
+ public void onProxyClosed(String s, Exception e, SdlDisconnectedReason reason) {
+
+ }
+
+ @Override
+ public void onOnHMIStatus(OnHMIStatus status) {
+
+ }
+
+ @Override
+ public void onListFilesResponse(ListFilesResponse response) {
+ }
+
+ @Override
+ public void onPutFileResponse(PutFileResponse response) {
+ }
+
+ @Override
+ public void onOnLockScreenNotification(OnLockScreenStatus notification) {
+ }
+
+ @Override
+ public void onOnCommand(OnCommand notification){
+ }
+
+ /**
+ * Callback method that runs when the add command response is received from SDL.
+ */
+ @Override
+ public void onAddCommandResponse(AddCommandResponse response) {
+ }
+
+ @Override
+ public void onOnPermissionsChange(OnPermissionsChange notification) {
+
+ }
+
+ @Override
+ public void onSubscribeVehicleDataResponse(SubscribeVehicleDataResponse response) {
+ }
+
+ @Override
+ public void onOnVehicleData(OnVehicleData notification) {
+ }
+
+ /**
+ * Rest of the SDL callbacks from the head unit
+ */
+
+ @Override
+ public void onAddSubMenuResponse(AddSubMenuResponse response) {
+ }
+
+ @Override
+ public void onCreateInteractionChoiceSetResponse(CreateInteractionChoiceSetResponse response) {
+ }
+
+ @Override
+ public void onAlertResponse(AlertResponse response) {
+ }
+
+ @Override
+ public void onDeleteCommandResponse(DeleteCommandResponse response) {
+ }
+
+ @Override
+ public void onDeleteInteractionChoiceSetResponse(DeleteInteractionChoiceSetResponse response) {
+ }
+
+ @Override
+ public void onDeleteSubMenuResponse(DeleteSubMenuResponse response) {
+ }
+
+ @Override
+ public void onPerformInteractionResponse(PerformInteractionResponse response) {
+ }
+
+ @Override
+ public void onResetGlobalPropertiesResponse(
+ ResetGlobalPropertiesResponse response) {
+ }
+
+ @Override
+ public void onSetGlobalPropertiesResponse(SetGlobalPropertiesResponse response) {
+ }
+
+ @Override
+ public void onSetMediaClockTimerResponse(SetMediaClockTimerResponse response) {
+ }
+
+ @Override
+ public void onShowResponse(ShowResponse response) {
+ }
+
+ @Override
+ public void onSpeakResponse(SpeakResponse response) {
+ Log.i(TAG, "SpeakCommand response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+ }
+
+ @Override
+ public void onOnButtonEvent(OnButtonEvent notification) {
+ }
+
+ @Override
+ public void onOnButtonPress(OnButtonPress notification) {
+ }
+
+ @Override
+ public void onSubscribeButtonResponse(SubscribeButtonResponse response) {
+ }
+
+ @Override
+ public void onUnsubscribeButtonResponse(UnsubscribeButtonResponse response) {
+ }
+
+
+ @Override
+ public void onOnTBTClientState(OnTBTClientState notification) {
+ }
+
+ @Override
+ public void onUnsubscribeVehicleDataResponse(
+ UnsubscribeVehicleDataResponse response) {
+
+ }
+
+ @Override
+ public void onGetVehicleDataResponse(GetVehicleDataResponse response) {
+
+ }
+
+ @Override
+ public void onReadDIDResponse(ReadDIDResponse response) {
+
+ }
+
+ @Override
+ public void onGetDTCsResponse(GetDTCsResponse response) {
+
+ }
+
+
+ @Override
+ public void onPerformAudioPassThruResponse(PerformAudioPassThruResponse response) {
+
+ }
+
+ @Override
+ public void onEndAudioPassThruResponse(EndAudioPassThruResponse response) {
+
+ }
+
+ @Override
+ public void onOnAudioPassThru(OnAudioPassThru notification) {
+
+ }
+
+ @Override
+ public void onDeleteFileResponse(DeleteFileResponse response) {
+
+ }
+
+ @Override
+ public void onSetAppIconResponse(SetAppIconResponse response) {
+
+ }
+
+ @Override
+ public void onScrollableMessageResponse(ScrollableMessageResponse response) {
+
+ }
+
+ @Override
+ public void onChangeRegistrationResponse(ChangeRegistrationResponse response) {
+
+ }
+
+ @Override
+ public void onSetDisplayLayoutResponse(SetDisplayLayoutResponse response) {
+
+ }
+
+ @Override
+ public void onOnLanguageChange(OnLanguageChange notification) {
+
+ }
+
+ @Override
+ public void onSliderResponse(SliderResponse response) {
+
+ }
+
+
+ @Override
+ public void onOnHashChange(OnHashChange notification) {
+
+ }
+
+ @Override
+ public void onOnSystemRequest(OnSystemRequest notification) {
+ }
+
+ @Override
+ public void onSystemRequestResponse(SystemRequestResponse response) {
+
+ }
+
+ @Override
+ public void onOnKeyboardInput(OnKeyboardInput notification) {
+
+ }
+
+ @Override
+ public void onOnTouchEvent(OnTouchEvent notification) {
+
+ }
+
+ @Override
+ public void onDiagnosticMessageResponse(DiagnosticMessageResponse response) {
+
+ }
+
+ @Override
+ public void onOnStreamRPC(OnStreamRPC notification) {
+
+ }
+
+ @Override
+ public void onStreamRPCResponse(StreamRPCResponse response) {
+
+ }
+
+ @Override
+ public void onDialNumberResponse(DialNumberResponse response) {
+
+ }
+
+ @Override
+ public void onSendLocationResponse(SendLocationResponse response) {
+ Log.i(TAG, "SendLocation response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+
+ }
+
+ @Override
+ public void onServiceEnded(OnServiceEnded serviceEnded) {
+
+ }
+
+ @Override
+ public void onServiceNACKed(OnServiceNACKed serviceNACKed) {
+
+ }
+
+ @Override
+ public void onShowConstantTbtResponse(ShowConstantTbtResponse response) {
+ Log.i(TAG, "ShowConstantTbt response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+
+ }
+
+ @Override
+ public void onAlertManeuverResponse(AlertManeuverResponse response) {
+ Log.i(TAG, "AlertManeuver response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+
+ }
+
+ @Override
+ public void onUpdateTurnListResponse(UpdateTurnListResponse response) {
+ Log.i(TAG, "UpdateTurnList response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+
+ }
+
+ @Override
+ public void onServiceDataACK(int dataSize) {
+ }
+
+ @Override
+ public void onGetWayPointsResponse(GetWayPointsResponse response) {
+ Log.i(TAG, "GetWayPoints response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+ }
+
+ @Override
+ public void onSubscribeWayPointsResponse(SubscribeWayPointsResponse response) {
+ Log.i(TAG, "SubscribeWayPoints response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+ }
+
+ @Override
+ public void onUnsubscribeWayPointsResponse(UnsubscribeWayPointsResponse response) {
+ Log.i(TAG, "UnsubscribeWayPoints response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+ }
+
+ @Override
+ public void onOnWayPointChange(OnWayPointChange notification) {
+ Log.i(TAG, "OnWayPointChange notification from SDL: " + notification);
+ }
+
+ @Override
+ public void onGetSystemCapabilityResponse(GetSystemCapabilityResponse response) {
+ Log.i(TAG, "GetSystemCapability response from SDL: " + response);
+ }
+
+ @Override
+ public void onGetInteriorVehicleDataResponse(GetInteriorVehicleDataResponse response) {
+ Log.i(TAG, "GetInteriorVehicleData response from SDL: " + response);
+ }
+
+ @Override
+ public void onButtonPressResponse(ButtonPressResponse response) {
+ Log.i(TAG, "ButtonPress response from SDL: " + response);
+ }
+
+ @Override
+ public void onSetInteriorVehicleDataResponse(SetInteriorVehicleDataResponse response) {
+ Log.i(TAG, "SetInteriorVehicleData response from SDL: " + response);
+ }
+
+ @Override
+ public void onOnInteriorVehicleData(OnInteriorVehicleData notification) {
+
+ }
+
+ @Override
+ public void onOnDriverDistraction(OnDriverDistraction notification) {
+ // Some RPCs (depending on region) cannot be sent when driver distraction is active.
+ }
+
+ @Override
+ public void onError(String info, Exception e) {
+ }
+
+ @Override
+ public void onGenericResponse(GenericResponse response) {
+ Log.i(TAG, "Generic response from SDL: " + response.getResultCode().name() + " Info: " + response.getInfo());
+ }
+
+ @Override
+ public void onSendHapticDataResponse(SendHapticDataResponse response) {
+ Log.i(TAG, "SendHapticDataResponse response from SDL: " + response);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java
new file mode 100644
index 000000000..8d2ef8d20
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java
@@ -0,0 +1,173 @@
+package com.smartdevicelink.test.proxy;
+
+import android.test.AndroidTestCase;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.SystemCapabilityManager;
+import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
+import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener;
+import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities;
+import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
+import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
+import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse;
+import com.smartdevicelink.proxy.rpc.HMICapabilities;
+import com.smartdevicelink.proxy.rpc.PresetBankCapabilities;
+import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
+import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
+import com.smartdevicelink.proxy.rpc.SystemCapability;
+import com.smartdevicelink.proxy.rpc.VideoStreamingCapability;
+import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.streaming.video.VideoStreamingParameters;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+import com.smartdevicelink.util.CorrelationIdGenerator;
+
+import java.util.List;
+
+public class SystemCapabilityManagerTests extends AndroidTestCase {
+ public static final String TAG = "SystemCapabilityManagerTests";
+ public static SystemCapabilityManager systemCapabilityManager;
+
+ @Override
+ protected void setUp() throws Exception{
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public SystemCapabilityManager createSampleManager(){
+ SystemCapabilityManager systemCapabilityManager = new SystemCapabilityManager(new InternalSDLInterface());
+
+ RegisterAppInterfaceResponse raiResponse = new RegisterAppInterfaceResponse();
+
+ raiResponse.setHmiCapabilities(Test.GENERAL_HMICAPABILITIES);
+ raiResponse.setDisplayCapabilities(Test.GENERAL_DISPLAYCAPABILITIES);
+ raiResponse.setAudioPassThruCapabilities(Test.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST);
+ raiResponse.setButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST);
+ raiResponse.setHmiZoneCapabilities(Test.GENERAL_HMIZONECAPABILITIES_LIST);
+ raiResponse.setPresetBankCapabilities(Test.GENERAL_PRESETBANKCAPABILITIES);
+ raiResponse.setSoftButtonCapabilities(Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST);
+ raiResponse.setSpeechCapabilities(Test.GENERAL_SPEECHCAPABILITIES_LIST);
+ raiResponse.setSuccess(true);
+
+ systemCapabilityManager.parseRAIResponse(raiResponse);
+ return systemCapabilityManager;
+ }
+
+ public void testParseRAI() {
+ systemCapabilityManager = createSampleManager();
+
+ assertTrue(Test.TRUE,
+ Validator.validateHMICapabilities(Test.GENERAL_HMICAPABILITIES, (HMICapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.HMI)));
+ assertTrue(Test.TRUE,
+ Validator.validateDisplayCapabilities(Test.GENERAL_DISPLAYCAPABILITIES, (DisplayCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY)));
+ assertTrue(Test.TRUE,
+ Validator.validateAudioPassThruCapabilities(Test.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST, (List<AudioPassThruCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.AUDIO_PASSTHROUGH)));
+ assertTrue(Test.TRUE,
+ Validator.validateButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST, (List<ButtonCapabilities> )systemCapabilityManager.getCapability(SystemCapabilityType.BUTTON)));
+ assertTrue(Test.TRUE,
+ Validator.validateHMIZoneCapabilities(Test.GENERAL_HMIZONECAPABILITIES_LIST, (List<HmiZoneCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.HMI_ZONE)));
+ assertTrue(Test.TRUE,
+ Validator.validatePresetBankCapabilities(Test.GENERAL_PRESETBANKCAPABILITIES, (PresetBankCapabilities) systemCapabilityManager.getCapability(SystemCapabilityType.PRESET_BANK)));
+ assertTrue(Test.TRUE,
+ Validator.validateSoftButtonCapabilities(Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST, (List<SoftButtonCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON)));
+ assertTrue(Test.TRUE,
+ Validator.validateSpeechCapabilities(Test.GENERAL_SPEECHCAPABILITIES_LIST, (List<SpeechCapabilities>) systemCapabilityManager.getCapability(SystemCapabilityType.SPEECH)));
+ }
+
+ public void testGetVSCapability(){
+ VideoStreamingCapability vsCapability = new VideoStreamingCapability();
+ vsCapability.setMaxBitrate(Test.GENERAL_INT);
+ vsCapability.setPreferredResolution(Test.GENERAL_IMAGERESOLUTION);
+ vsCapability.setSupportedFormats(Test.GENERAL_VIDEOSTREAMINGFORMAT_LIST);
+
+ SystemCapability cap = new SystemCapability();
+ cap.setSystemCapabilityType(SystemCapabilityType.VIDEO_STREAMING);
+ cap.setCapabilityForType(SystemCapabilityType.VIDEO_STREAMING, vsCapability);
+
+ final SystemCapability referenceCapability = cap;
+
+ systemCapabilityManager = new SystemCapabilityManager(new InternalSDLInterface() {
+ @Override
+ public void sendRPCRequest(RPCRequest message) {
+ GetSystemCapabilityResponse response = new GetSystemCapabilityResponse();
+ response.setSystemCapability(referenceCapability);
+ response.setSuccess(true);
+ message.getOnRPCResponseListener().onResponse(CorrelationIdGenerator.generateId(), response);
+ }
+ });
+
+ systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING, new OnSystemCapabilityListener() {
+ @Override
+ public void onCapabilityRetrieved(Object capability) {
+ assertTrue(Test.TRUE,
+ Validator.validateVideoStreamingCapability(
+ (VideoStreamingCapability) referenceCapability.getCapabilityForType(SystemCapabilityType.VIDEO_STREAMING),
+ (VideoStreamingCapability) capability));
+ }
+
+ @Override
+ public void onError(String info) {
+ assertTrue(false);
+ }
+ });
+ }
+
+ public void testListConversion(){
+ SystemCapabilityManager systemCapabilityManager = createSampleManager();
+ Object capability = systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON);
+ assertNotNull(capability);
+ List<SoftButtonCapabilities> list = SystemCapabilityManager.convertToList(capability, SoftButtonCapabilities.class);
+ assertNotNull(list);
+
+ }
+
+ private class InternalSDLInterface implements ISdl{
+ @Override
+ public void start(){}
+
+ @Override
+ public void stop() {}
+
+ @Override
+ public boolean isConnected() {return false; }
+
+ @Override
+ public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) {}
+
+ @Override
+ public void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) {}
+
+ @Override
+ public void startVideoService(VideoStreamingParameters parameters, boolean encrypted) { }
+
+ @Override
+ public void stopVideoService() {}
+
+ @Override
+ public void startAudioService(boolean encrypted) {}
+
+ @Override
+ public void stopAudioService() {}
+
+ @Override
+ public void sendRPCRequest(RPCRequest message) {}
+
+ @Override
+ public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {}
+
+ @Override
+ public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {return false;}
+ }
+
+
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ClimateControlCapabilitiesTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ClimateControlCapabilitiesTests.java
new file mode 100644
index 000000000..33f9d2631
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ClimateControlCapabilitiesTests.java
@@ -0,0 +1,160 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.ClimateControlCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.DefrostZone;
+import com.smartdevicelink.proxy.rpc.enums.VentilationMode;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ClimateControlCapabilities}
+ */
+public class ClimateControlCapabilitiesTests extends TestCase{
+
+ private ClimateControlCapabilities msg;
+
+ @Override
+ public void setUp(){
+ msg = new ClimateControlCapabilities();
+
+ msg.setModuleName(Test.GENERAL_STRING);
+ msg.setFanSpeedAvailable(Test.GENERAL_BOOLEAN);
+ msg.setDesiredTemperatureAvailable(Test.GENERAL_BOOLEAN);
+ msg.setAcEnableAvailable(Test.GENERAL_BOOLEAN);
+ msg.setAcMaxEnableAvailable(Test.GENERAL_BOOLEAN);
+ msg.setCirculateAirEnableAvailable(Test.GENERAL_BOOLEAN);
+ msg.setAutoModeEnableAvailable(Test.GENERAL_BOOLEAN);
+ msg.setDualModeEnableAvailable(Test.GENERAL_BOOLEAN);
+ msg.setDefrostZoneAvailable(Test.GENERAL_BOOLEAN);
+ msg.setDefrostZone(Test.GENERAL_DEFROSTZONE_LIST);
+ msg.setVentilationModeAvailable(Test.GENERAL_BOOLEAN);
+ msg.setVentilationMode(Test.GENERAL_VENTILATIONMODE_LIST);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String moduleName = msg.getModuleName();
+ boolean fanSpeedAvailable = msg.getFanSpeedAvailable();
+ boolean desiredTemperatureAvailable = msg.getDesiredTemperatureAvailable();
+ boolean acEnableAvailable = msg.getAcEnableAvailable();
+ boolean acMaxEnableAvailable = msg.getAcMaxEnableAvailable();
+ boolean circulateAirEnableAvailable = msg.getCirculateAirEnableAvailable();
+ boolean autoModeEnableAvailable = msg.getAutoModeEnableAvailable();
+ boolean dualModeEnableAvailable = msg.getDualModeEnableAvailable();
+ boolean defrostZoneAvailable = msg.getDefrostZoneAvailable();
+ List<DefrostZone> defrostZone = msg.getDefrostZone();
+ boolean ventilationModeAvailable = msg.getVentilationModeAvailable();
+ List<VentilationMode> ventilationMode = msg.getVentilationMode();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, moduleName);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, fanSpeedAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, desiredTemperatureAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, acEnableAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, acMaxEnableAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, circulateAirEnableAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, autoModeEnableAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, dualModeEnableAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, defrostZoneAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, ventilationModeAvailable);
+
+ assertEquals(Test.MATCH, Test.GENERAL_DEFROSTZONE_LIST.size(), defrostZone.size());
+ assertEquals(Test.MATCH, Test.GENERAL_VENTILATIONMODE_LIST.size(), ventilationMode.size());
+
+ for(int i = 0; i < Test.GENERAL_DEFROSTZONE_LIST.size(); i++){
+ assertEquals(Test.MATCH, Test.GENERAL_DEFROSTZONE_LIST.get(i), defrostZone.get(i));
+ }
+ for(int i = 0; i < Test.GENERAL_VENTILATIONMODE_LIST.size(); i++){
+ assertEquals(Test.MATCH, Test.GENERAL_VENTILATIONMODE_LIST.get(i), ventilationMode.get(i));
+ }
+
+ // Invalid/Null Tests
+ ClimateControlCapabilities msg = new ClimateControlCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getModuleName());
+ assertNull(Test.NULL, msg.getFanSpeedAvailable());
+ assertNull(Test.NULL, msg.getDesiredTemperatureAvailable());
+ assertNull(Test.NULL, msg.getAcEnableAvailable());
+ assertNull(Test.NULL, msg.getAcMaxEnableAvailable());
+ assertNull(Test.NULL, msg.getAutoModeEnableAvailable());
+ assertNull(Test.NULL, msg.getDualModeEnableAvailable());
+ assertNull(Test.NULL, msg.getDefrostZoneAvailable());
+ assertNull(Test.NULL, msg.getDefrostZone());
+ assertNull(Test.NULL, msg.getVentilationModeAvailable());
+ assertNull(Test.NULL, msg.getVentilationMode());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(ClimateControlCapabilities.KEY_MODULE_NAME, Test.GENERAL_STRING);
+ reference.put(ClimateControlCapabilities.KEY_FAN_SPEED_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_DESIRED_TEMPERATURE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_AC_ENABLE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_AC_MAX_ENABLE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_CIRCULATE_AIR_ENABLE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_AUTO_MODE_ENABLE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_DUAL_MODE_ENABLE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_DEFROST_ZONE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_VENTILATION_MODE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlCapabilities.KEY_DEFROST_ZONE, JsonUtils.createJsonArray(Test.GENERAL_DEFROSTZONE_LIST));
+ reference.put(ClimateControlCapabilities.KEY_VENTILATION_MODE, JsonUtils.createJsonArray(Test.GENERAL_VENTILATIONMODE_LIST));
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ if(key.equals(ClimateControlCapabilities.KEY_DEFROST_ZONE)) {
+ JSONArray defrostZoneArrayReference = JsonUtils.readJsonArrayFromJsonObject(reference, key);
+ JSONArray defrostZoneArrayTest = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
+ List<DefrostZone> defrostZoneListReference = new ArrayList<DefrostZone>();
+ List<DefrostZone> defrostZoneListTest = new ArrayList<DefrostZone>();
+
+ assertEquals(Test.MATCH, defrostZoneArrayReference.length(), defrostZoneArrayTest.length());
+
+ for (int index = 0 ; index < defrostZoneArrayReference.length(); index++) {
+ defrostZoneListReference.add( (DefrostZone)defrostZoneArrayReference.get(index) );
+ defrostZoneListTest.add( (DefrostZone)defrostZoneArrayTest.get(index) );
+ }
+ assertTrue(Test.TRUE, defrostZoneListReference.containsAll(defrostZoneListTest) && defrostZoneListTest.containsAll(defrostZoneListReference));
+ } else if(key.equals(ClimateControlCapabilities.KEY_VENTILATION_MODE)) {
+ JSONArray ventilationModeArrayReference = JsonUtils.readJsonArrayFromJsonObject(reference, key);
+ JSONArray ventilationModeArrayTest = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
+ List<VentilationMode> ventilationModeListReference = new ArrayList<VentilationMode>();
+ List<VentilationMode> ventilationModeListTest = new ArrayList<VentilationMode>();
+
+ assertEquals(Test.MATCH, ventilationModeArrayReference.length(), ventilationModeArrayTest.length());
+
+ for (int index = 0 ; index < ventilationModeArrayReference.length(); index++) {
+ ventilationModeListReference.add( (VentilationMode)ventilationModeArrayReference.get(index) );
+ ventilationModeListTest.add( (VentilationMode)ventilationModeArrayTest.get(index) );
+ }
+ assertTrue(Test.TRUE, ventilationModeListReference.containsAll(ventilationModeListTest) && ventilationModeListTest.containsAll(ventilationModeListReference));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ClimateControlDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ClimateControlDataTests.java
new file mode 100644
index 000000000..5b0eefa9f
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ClimateControlDataTests.java
@@ -0,0 +1,130 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.proxy.rpc.ClimateControlData;
+import com.smartdevicelink.proxy.rpc.Temperature;
+import com.smartdevicelink.proxy.rpc.enums.DefrostZone;
+import com.smartdevicelink.proxy.rpc.enums.VentilationMode;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ClimateControlData}
+ */
+public class ClimateControlDataTests extends TestCase{
+
+ private ClimateControlData msg;
+
+ @Override
+ public void setUp(){
+ msg = new ClimateControlData();
+
+ msg.setFanSpeed(Test.GENERAL_INT);
+ msg.setCurrentTemperature(Test.GENERAL_TEMPERATURE);
+ msg.setDesiredTemperature(Test.GENERAL_TEMPERATURE);
+ msg.setAcEnable(Test.GENERAL_BOOLEAN);
+ msg.setCirculateAirEnable(Test.GENERAL_BOOLEAN);
+ msg.setAutoModeEnable(Test.GENERAL_BOOLEAN);
+ msg.setDefrostZone(Test.GENERAL_DEFROSTZONE);
+ msg.setDualModeEnable(Test.GENERAL_BOOLEAN);
+ msg.setAcMaxEnable(Test.GENERAL_BOOLEAN);
+ msg.setVentilationMode(Test.GENERAL_VENTILATIONMODE);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ int fanSpeed = msg.getFanSpeed();
+ Temperature currentTemperature = msg.getCurrentTemperature();
+ Temperature desiredTemperature = msg.getDesiredTemperature();
+ boolean acEnable = msg.getAcEnable();
+ boolean circulateAirEnable = msg.getCirculateAirEnable();
+ boolean autoModeEnable = msg.getAutoModeEnable();
+ DefrostZone defrostZone = msg.getDefrostZone();
+ boolean dualModeEnable = msg.getDualModeEnable();
+ boolean acMaxEnable = msg.getAcMaxEnable();
+ VentilationMode ventilationMode = msg.getVentilationMode();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_INT, fanSpeed);
+ assertTrue(Test.TRUE, Validator.validateTemperature(Test.GENERAL_TEMPERATURE, currentTemperature));
+ assertTrue(Test.TRUE, Validator.validateTemperature(Test.GENERAL_TEMPERATURE, desiredTemperature));
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, acEnable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, circulateAirEnable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, autoModeEnable);
+ assertEquals(Test.MATCH, Test.GENERAL_DEFROSTZONE, defrostZone);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, dualModeEnable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, acMaxEnable);
+ assertEquals(Test.MATCH, Test.GENERAL_VENTILATIONMODE, ventilationMode);
+
+ // Invalid/Null Tests
+ ClimateControlData msg = new ClimateControlData();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getFanSpeed());
+ assertNull(Test.NULL, msg.getCurrentTemperature());
+ assertNull(Test.NULL, msg.getDesiredTemperature());
+ assertNull(Test.NULL, msg.getAcEnable());
+ assertNull(Test.NULL, msg.getCirculateAirEnable());
+ assertNull(Test.NULL, msg.getAutoModeEnable());
+ assertNull(Test.NULL, msg.getDefrostZone());
+ assertNull(Test.NULL, msg.getDualModeEnable());
+ assertNull(Test.NULL, msg.getAcMaxEnable());
+ assertNull(Test.NULL, msg.getVentilationMode());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(ClimateControlData.KEY_FAN_SPEED, Test.GENERAL_INT);
+ reference.put(ClimateControlData.KEY_CURRENT_TEMPERATURE, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_TEMPERATURE.getStore()));
+ reference.put(ClimateControlData.KEY_DESIRED_TEMPERATURE, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_TEMPERATURE.getStore()));
+ reference.put(ClimateControlData.KEY_AC_ENABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlData.KEY_CIRCULATE_AIR_ENABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlData.KEY_AUTO_MODE_ENABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlData.KEY_DUAL_MODE_ENABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlData.KEY_AC_MAX_ENABLE, Test.GENERAL_BOOLEAN);
+ reference.put(ClimateControlData.KEY_DEFROST_ZONE, Test.GENERAL_DEFROSTZONE);
+ reference.put(ClimateControlData.KEY_VENTILATION_MODE, Test.GENERAL_VENTILATIONMODE);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ if(key.equals(ClimateControlData.KEY_CURRENT_TEMPERATURE)){
+ JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validateTemperature( new Temperature(hashReference), new Temperature(hashTest)));
+ } else if(key.equals(ClimateControlData.KEY_DESIRED_TEMPERATURE)){
+ JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validateTemperature( new Temperature(hashReference), new Temperature(hashTest)));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/CoordinateTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/CoordinateTests.java
new file mode 100644
index 000000000..5f8a8327f
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/CoordinateTests.java
@@ -0,0 +1,73 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.Coordinate;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * Created by austinkirk on 6/6/17.
+ */
+
+public class CoordinateTests extends TestCase {
+
+ private Coordinate msg;
+
+ @Override
+ public void setUp(){
+ msg = new Coordinate();
+
+ msg.setLatitudeDegrees(Test.GENERAL_FLOAT);
+ msg.setLongitudeDegrees(Test.GENERAL_FLOAT);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ float floatLat = msg.getLatitudeDegrees();
+ float floatLong = msg.getLongitudeDegrees();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_FLOAT, floatLat);
+ assertEquals(Test.MATCH, Test.GENERAL_FLOAT, floatLong);
+ // Invalid/Null Tests
+ Coordinate msg = new Coordinate();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getLatitudeDegrees());
+ assertNull(Test.NULL, msg.getLongitudeDegrees());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(Coordinate.KEY_LATITUDE_DEGREES, (Float) Test.GENERAL_FLOAT);
+ reference.put(Coordinate.KEY_LONGITUDE_DEGREES, (Float) Test.GENERAL_FLOAT);
+
+ JSONObject underTest = msg.serializeJSON();
+
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ Object a = JsonUtils.readObjectFromJsonObject(reference, key);
+ Object b = JsonUtils.readObjectFromJsonObject(underTest, key);
+
+ assertEquals(Test.MATCH, a, b);
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DateTimeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DateTimeTests.java
new file mode 100644
index 000000000..2cf38b68f
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/DateTimeTests.java
@@ -0,0 +1,109 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.DateTime;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * Created by austinkirk on 6/6/17.
+ */
+
+public class DateTimeTests extends TestCase {
+
+ private DateTime msg;
+
+ @Override
+ public void setUp(){
+ msg = new DateTime();
+
+ msg.setYear(Test.GENERAL_INT);
+ msg.setMonth(Test.GENERAL_INT);
+ msg.setDay(Test.GENERAL_INT);
+ msg.setHour(Test.GENERAL_INT);
+ msg.setMinute(Test.GENERAL_INT);
+ msg.setSecond(Test.GENERAL_INT);
+ msg.setMilliSecond(Test.GENERAL_INT);
+ msg.setTzHour(Test.GENERAL_INT);
+ msg.setTzMinute(Test.GENERAL_INT);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Integer year = msg.getYear();
+ Integer month = msg.getMonth();
+ Integer day = msg.getDay();
+ Integer hour = msg.getHour();
+ Integer min = msg.getMinute();
+ Integer sec = msg.getSecond();
+ Integer ms = msg.getMilliSecond();
+ Integer tzHour = msg.getTzHour();
+ Integer tzMin = msg.getTzMinute();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, year);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, month);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, day);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, hour);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, min);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, sec);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, ms);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, tzHour);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, tzMin);
+
+ // Invalid/Null Tests
+ DateTime msg = new DateTime();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getYear());
+ assertNull(Test.NULL, msg.getMonth());
+ assertNull(Test.NULL, msg.getDay());
+ assertNull(Test.NULL, msg.getHour());
+ assertNull(Test.NULL, msg.getMinute());
+ assertNull(Test.NULL, msg.getSecond());
+ assertNull(Test.NULL, msg.getMilliSecond());
+ assertNull(Test.NULL, msg.getTzHour());
+ assertNull(Test.NULL, msg.getTzMinute());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(DateTime.KEY_YEAR, (Integer) Test.GENERAL_INT);
+ reference.put(DateTime.KEY_MONTH, (Integer) Test.GENERAL_INT);
+ reference.put(DateTime.KEY_DAY, (Integer) Test.GENERAL_INT);
+ reference.put(DateTime.KEY_HOUR, (Integer) Test.GENERAL_INT);
+ reference.put(DateTime.KEY_MINUTE, (Integer) Test.GENERAL_INT);
+ reference.put(DateTime.KEY_SECOND, (Integer) Test.GENERAL_INT);
+ reference.put(DateTime.KEY_MILLISECOND, (Integer) Test.GENERAL_INT);
+ reference.put(DateTime.KEY_TZ_HOUR, (Integer) Test.GENERAL_INT);
+ reference.put(DateTime.KEY_TZ_MINUTE, (Integer) Test.GENERAL_INT);
+
+ JSONObject underTest = msg.serializeJSON();
+
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ Object a = JsonUtils.readObjectFromJsonObject(reference, key);
+ Object b = JsonUtils.readObjectFromJsonObject(underTest, key);
+
+ assertEquals(Test.MATCH, a, b);
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HMICapabilitiesTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HMICapabilitiesTests.java
new file mode 100644
index 000000000..cc4813caa
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HMICapabilitiesTests.java
@@ -0,0 +1,74 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.HMICapabilities;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import static com.smartdevicelink.proxy.rpc.HMICapabilities.KEY_NAVIGATION;
+import static com.smartdevicelink.proxy.rpc.HMICapabilities.KEY_PHONE_CALL;
+import static com.smartdevicelink.proxy.rpc.HMICapabilities.KEY_VIDEO_STREAMING;
+
+public class HMICapabilitiesTests extends TestCase {
+ private HMICapabilities msg;
+
+ @Override
+ public void setUp(){
+ msg = new HMICapabilities();
+
+ msg.setNavigationAvilable(Test.GENERAL_BOOLEAN);
+ msg.setPhoneCallAvilable(Test.GENERAL_BOOLEAN);
+ msg.setVideoStreamingAvailable(Test.GENERAL_BOOLEAN);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Boolean navAvail = msg.isNavigationAvailable();
+ Boolean phoneAvail = msg.isPhoneCallAvailable();
+ Boolean vidStreamAvail = msg.isVideoStreamingAvailable();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, navAvail);
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, phoneAvail);
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, vidStreamAvail);
+
+ // Invalid/Null Tests
+ HMICapabilities msg = new HMICapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertFalse(msg.isNavigationAvailable());
+ assertFalse(msg.isPhoneCallAvailable());
+ assertFalse(msg.isVideoStreamingAvailable());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(KEY_NAVIGATION, Test.GENERAL_BOOLEAN);
+ reference.put(HMICapabilities.KEY_PHONE_CALL, Test.GENERAL_BOOLEAN);
+ reference.put(HMICapabilities.KEY_VIDEO_STREAMING, Test.GENERAL_BOOLEAN);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ assertEquals(Test.MATCH, JsonUtils.readStringListFromJsonObject(reference, KEY_NAVIGATION),
+ JsonUtils.readStringListFromJsonObject(underTest, KEY_NAVIGATION));
+
+ assertEquals(Test.MATCH, JsonUtils.readStringListFromJsonObject(reference, KEY_PHONE_CALL),
+ JsonUtils.readStringListFromJsonObject(underTest, KEY_PHONE_CALL));
+
+ assertEquals(Test.MATCH, JsonUtils.readStringListFromJsonObject(reference, KEY_VIDEO_STREAMING),
+ JsonUtils.readStringListFromJsonObject(underTest, KEY_VIDEO_STREAMING));
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java
new file mode 100644
index 000000000..c72204640
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/HapticRectTests.java
@@ -0,0 +1,73 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.proxy.rpc.HapticRect;
+import com.smartdevicelink.proxy.rpc.Rectangle;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * Created by brettywhite on 8/24/17.
+ */
+
+public class HapticRectTests extends TestCase {
+
+ private HapticRect msg;
+
+ @Override
+ public void setUp() {
+ msg = new HapticRect();
+
+ msg.setId(Test.GENERAL_INTEGER);
+ msg.setRect(Test.GENERAL_RECTANGLE);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Integer id = msg.getId();
+ Rectangle rect = msg.getRect();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_INTEGER, id);
+ assertEquals(Test.MATCH, Test.GENERAL_RECTANGLE, rect);
+
+ // Invalid/Null Tests
+ HapticRect msg = new HapticRect();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getId());
+ assertNull(Test.NULL, msg.getRect());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(HapticRect.KEY_ID, Test.GENERAL_INTEGER);
+ reference.put(HapticRect.KEY_RECT, Test.GENERAL_RECTANGLE);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(reference, HapticRect.KEY_ID),
+ JsonUtils.readIntegerFromJsonObject(underTest, HapticRect.KEY_ID));
+
+ assertTrue(Validator.validateRectangle(
+ (Rectangle) JsonUtils.readObjectFromJsonObject(reference, HapticRect.KEY_RECT),
+ new Rectangle(JsonRPCMarshaller.deserializeJSONObject( (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, HapticRect.KEY_RECT))))
+ );
+
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/LocationDetailsTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/LocationDetailsTests.java
new file mode 100644
index 000000000..18da17eac
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/LocationDetailsTests.java
@@ -0,0 +1,113 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.proxy.rpc.Coordinate;
+import com.smartdevicelink.proxy.rpc.Image;
+import com.smartdevicelink.proxy.rpc.LocationDetails;
+import com.smartdevicelink.proxy.rpc.OasisAddress;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.List;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class LocationDetailsTests extends TestCase {
+ private LocationDetails msg;
+
+ @Override
+ public void setUp(){
+ msg = Test.GENERAL_LOCATIONDETAILS;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ List<String> field1 = msg.getAddressLines();
+ String field2 = msg.getLocationDescription();
+ String field3 = msg.getLocationName();
+ String field4 = msg.getPhoneNumber();
+ Coordinate field5 = msg.getCoordinate();
+ Image field6 = msg.getLocationImage();
+ OasisAddress field7 = msg.getSearchAddress();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST, field1);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, field2);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, field3);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, field4);
+ assertEquals(Test.MATCH, Test.GENERAL_COORDINATE, field5);
+ assertEquals(Test.MATCH, Test.GENERAL_IMAGE, field6);
+ assertEquals(Test.MATCH, Test.GENERAL_OASISADDRESS, field7);
+
+ // Invalid/Null Tests
+ LocationDetails msg = new LocationDetails();
+ assertNotNull(Test.NOT_NULL, msg);
+
+
+ assertNull(msg.getAddressLines());
+ assertNull(msg.getLocationDescription());
+ assertNull(msg.getLocationName());
+ assertNull(msg.getPhoneNumber());
+ assertNull(msg.getCoordinate());
+ assertNull(msg.getLocationImage());
+ assertNull(msg.getSearchAddress());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(LocationDetails.KEY_ADDRESS_LINES, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST));
+ reference.put(LocationDetails.KEY_LOCATION_DESCRIPTION, Test.GENERAL_STRING);
+ reference.put(LocationDetails.KEY_LOCATION_NAME, Test.GENERAL_STRING);
+ reference.put(LocationDetails.KEY_PHONE_NUMBER, Test.GENERAL_STRING);
+ reference.put(LocationDetails.KEY_COORDINATE, Test.GENERAL_COORDINATE);
+ reference.put(LocationDetails.KEY_LOCATION_IMAGE, Test.GENERAL_IMAGE);
+ reference.put(LocationDetails.KEY_SEARCH_ADDRESS, Test.GENERAL_OASISADDRESS);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, LocationDetails.KEY_ADDRESS_LINES),
+ JsonUtils.readObjectFromJsonObject(underTest, LocationDetails.KEY_ADDRESS_LINES));
+
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(reference, LocationDetails.KEY_LOCATION_DESCRIPTION),
+ JsonUtils.readStringFromJsonObject(underTest, LocationDetails.KEY_LOCATION_DESCRIPTION));
+
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(reference, LocationDetails.KEY_LOCATION_NAME),
+ JsonUtils.readStringFromJsonObject(underTest, LocationDetails.KEY_LOCATION_NAME));
+
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(reference, LocationDetails.KEY_PHONE_NUMBER),
+ JsonUtils.readStringFromJsonObject(underTest, LocationDetails.KEY_PHONE_NUMBER));
+
+ assertTrue(Validator.validateCoordinate(
+ (Coordinate) JsonUtils.readObjectFromJsonObject(reference, LocationDetails.KEY_COORDINATE),
+ new Coordinate(JsonRPCMarshaller.deserializeJSONObject( (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, LocationDetails.KEY_COORDINATE))))
+ );
+
+ assertTrue(Validator.validateImage(
+ (Image) JsonUtils.readObjectFromJsonObject(reference, LocationDetails.KEY_LOCATION_IMAGE),
+ new Image(JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(underTest, LocationDetails.KEY_LOCATION_IMAGE)))
+ ));
+
+ assertTrue(Validator.validateOasisAddress(
+ (OasisAddress) JsonUtils.readObjectFromJsonObject(reference, LocationDetails.KEY_SEARCH_ADDRESS),
+ new OasisAddress(JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(underTest, LocationDetails.KEY_SEARCH_ADDRESS)))
+ ));
+
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/MetadataTagsTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/MetadataTagsTests.java
new file mode 100644
index 000000000..5f27cc132
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/MetadataTagsTests.java
@@ -0,0 +1,110 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.MetadataTags;
+import com.smartdevicelink.proxy.rpc.enums.MetadataType;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class:
+ * {@link MetadataTags}
+ */
+
+public class MetadataTagsTests extends TestCase {
+
+ private MetadataTags msg;
+ private MetadataTags msg2;
+ private List<MetadataType> exampleList;
+
+ @Override
+ public void setUp() {
+ // Create List for Testing
+ exampleList = new ArrayList<>();
+ exampleList.add(0, MetadataType.CURRENT_TEMPERATURE);
+ exampleList.add(1, MetadataType.MEDIA_ALBUM);
+ exampleList.add(2, MetadataType.MEDIA_ARTIST);
+
+ msg = new MetadataTags();
+ msg.setMainField1(exampleList);
+ msg.setMainField2(exampleList);
+ msg.setMainField3(exampleList);
+ msg.setMainField4(exampleList);
+
+ // Setup without a list
+ msg2 = new MetadataTags();
+ msg2.setMainField1(MetadataType.CURRENT_TEMPERATURE);
+ msg2.setMainField2(MetadataType.HUMIDITY);
+ msg2.setMainField3(MetadataType.MAXIMUM_TEMPERATURE);
+ msg2.setMainField4(MetadataType.MEDIA_ALBUM);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ List<MetadataType> mainField1Types = msg.getMainField1();
+ List<MetadataType> mainField2Types = msg.getMainField2();
+ List<MetadataType> mainField3Types = msg.getMainField3();
+ List<MetadataType> mainField4Types = msg.getMainField4();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, exampleList, mainField1Types);
+ assertEquals(Test.MATCH, exampleList, mainField2Types);
+ assertEquals(Test.MATCH, exampleList, mainField3Types);
+ assertEquals(Test.MATCH, exampleList, mainField4Types);
+
+ // Test metadata set without a list
+ mainField1Types = msg2.getMainField1();
+ mainField2Types = msg2.getMainField2();
+ mainField3Types = msg2.getMainField3();
+ mainField4Types = msg2.getMainField4();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, MetadataType.CURRENT_TEMPERATURE, mainField1Types.get(0));
+ assertEquals(Test.MATCH, MetadataType.HUMIDITY, mainField2Types.get(0));
+ assertEquals(Test.MATCH, MetadataType.MAXIMUM_TEMPERATURE, mainField3Types.get(0));
+ assertEquals(Test.MATCH, MetadataType.MEDIA_ALBUM, mainField4Types.get(0));
+
+ // Invalid/Null Tests
+ MetadataTags msg = new MetadataTags();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getMainField1());
+ assertNull(Test.NULL, msg.getMainField2());
+ assertNull(Test.NULL, msg.getMainField3());
+ assertNull(Test.NULL, msg.getMainField4());
+ }
+
+ public void testJson() {
+ JSONObject reference = new JSONObject();
+
+ try {
+ reference.put(MetadataTags.KEY_MAIN_FIELD_1_TYPE, Test.JSON_TEXTFIELDTYPES);
+ reference.put(MetadataTags.KEY_MAIN_FIELD_2_TYPE, Test.JSON_TEXTFIELDTYPES);
+ reference.put(MetadataTags.KEY_MAIN_FIELD_3_TYPE, Test.JSON_TEXTFIELDTYPES);
+ reference.put(MetadataTags.KEY_MAIN_FIELD_4_TYPE, Test.JSON_TEXTFIELDTYPES);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ModuleDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ModuleDataTests.java
new file mode 100644
index 000000000..ea71dfc8a
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/ModuleDataTests.java
@@ -0,0 +1,95 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.proxy.rpc.ClimateControlData;
+import com.smartdevicelink.proxy.rpc.ModuleData;
+import com.smartdevicelink.proxy.rpc.RadioControlData;
+import com.smartdevicelink.proxy.rpc.enums.ModuleType;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ModuleData}
+ */
+public class ModuleDataTests extends TestCase{
+
+ private ModuleData msg;
+
+ @Override
+ public void setUp(){
+ msg = new ModuleData();
+
+ msg.setModuleType(Test.GENERAL_MODULETYPE);
+ msg.setRadioControlData(Test.GENERAL_RADIOCONTROLDATA);
+ msg.setClimateControlData(Test.GENERAL_CLIMATECONTROLDATA);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ModuleType moduleType = msg.getModuleType();
+ RadioControlData radioControlData = msg.getRadioControlData();
+ ClimateControlData climateControlData = msg.getClimateControlData();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_MODULETYPE, moduleType);
+ assertTrue(Test.TRUE, Validator.validateRadioControlData(Test.GENERAL_RADIOCONTROLDATA, radioControlData));
+ assertTrue(Test.TRUE, Validator.validateClimateControlData(Test.GENERAL_CLIMATECONTROLDATA, climateControlData));
+
+ // Invalid/Null Tests
+ ModuleData msg = new ModuleData();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getModuleType());
+ assertNull(Test.NULL, msg.getRadioControlData());
+ assertNull(Test.NULL, msg.getClimateControlData());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(ModuleData.KEY_MODULE_TYPE, Test.GENERAL_MODULETYPE);
+ reference.put(ModuleData.KEY_RADIO_CONTROL_DATA, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_RADIOCONTROLDATA.getStore()));
+ reference.put(ModuleData.KEY_CLIMATE_CONTROL_DATA, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_CLIMATECONTROLDATA.getStore()));
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ if(key.equals(ModuleData.KEY_RADIO_CONTROL_DATA)){
+ JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validateRadioControlData( new RadioControlData(hashReference), new RadioControlData(hashTest)));
+ } else if(key.equals(ModuleData.KEY_CLIMATE_CONTROL_DATA)){
+ JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validateClimateControlData( new ClimateControlData(hashReference), new ClimateControlData(hashTest)));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/NavigationCapabilityTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/NavigationCapabilityTests.java
new file mode 100644
index 000000000..efbf7e30d
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/NavigationCapabilityTests.java
@@ -0,0 +1,69 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.NavigationCapability;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.NavigationCapability}
+ */
+public class NavigationCapabilityTests extends TestCase{
+
+ private NavigationCapability msg;
+
+ @Override
+ public void setUp(){
+ msg = new NavigationCapability();
+
+ msg.setSendLocationEnabled(Test.GENERAL_BOOLEAN);
+ msg.setWayPointsEnabled(Test.GENERAL_BOOLEAN);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean sendLocationEnabled = msg.getSendLocationEnabled();
+ boolean getWayPointsEnabled = msg.getWayPointsEnabled();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, sendLocationEnabled);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, getWayPointsEnabled);
+
+ // Invalid/Null Tests
+ NavigationCapability msg = new NavigationCapability();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getSendLocationEnabled());
+ assertNull(Test.NULL, msg.getWayPointsEnabled());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(NavigationCapability.KEY_GETWAYPOINTS_ENABLED, Test.GENERAL_BOOLEAN);
+ reference.put(NavigationCapability.KEY_LOCATION_ENABLED, Test.GENERAL_BOOLEAN);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/OasisAddressTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/OasisAddressTests.java
new file mode 100644
index 000000000..cf39a3c18
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/OasisAddressTests.java
@@ -0,0 +1,95 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.OasisAddress;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class OasisAddressTests extends TestCase {
+ private OasisAddress msg;
+
+ @Override
+ public void setUp(){
+ msg = Test.GENERAL_OASISADDRESS;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String f1 = msg.getAdministrativeArea();
+ String f2 = msg.getSubAdministrativeArea();
+ String f3 = msg.getCountryCode();
+ String f4 = msg.getCountryName();
+ String f5 = msg.getLocality();
+ String f6 = msg.getSubLocality();
+ String f7 = msg.getPostalCode();
+ String f8 = msg.getThoroughfare();
+ String f9 = msg.getSubThoroughfare();
+
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f1);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f2);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f3);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f4);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f5);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f6);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f7);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f8);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, f9);
+
+ // Invalid/Null Tests
+ OasisAddress msg = new OasisAddress();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(msg.getAdministrativeArea());
+ assertNull(msg.getSubAdministrativeArea());
+ assertNull(msg.getCountryCode());
+ assertNull(msg.getCountryName());
+ assertNull(msg.getLocality());
+ assertNull(msg.getSubLocality());
+ assertNull(msg.getPostalCode());
+ assertNull(msg.getThoroughfare());
+ assertNull(msg.getSubThoroughfare());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(OasisAddress.KEY_ADMINISTRATIVE_AREA, Test.GENERAL_STRING);
+ reference.put(OasisAddress.KEY_SUB_ADMINISTRATIVE_AREA, Test.GENERAL_STRING);
+ reference.put(OasisAddress.KEY_COUNTRY_CODE, Test.GENERAL_STRING);
+ reference.put(OasisAddress.KEY_COUNTRY_NAME, Test.GENERAL_STRING);
+ reference.put(OasisAddress.KEY_LOCALITY, Test.GENERAL_STRING);
+ reference.put(OasisAddress.KEY_SUB_LOCALITY, Test.GENERAL_STRING);
+ reference.put(OasisAddress.KEY_POSTAL_CODE, Test.GENERAL_STRING);
+ reference.put(OasisAddress.KEY_THOROUGH_FARE, Test.GENERAL_STRING);
+ reference.put(OasisAddress.KEY_SUB_THOROUGH_FARE, Test.GENERAL_STRING);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ assertEquals(Test.MATCH, reference.get(key),
+ underTest.get(key));
+ }
+
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PhoneCapabilityTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PhoneCapabilityTests.java
new file mode 100644
index 000000000..2614db0fd
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/PhoneCapabilityTests.java
@@ -0,0 +1,64 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.PhoneCapability;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.PhoneCapability}
+ */
+public class PhoneCapabilityTests extends TestCase{
+
+ private PhoneCapability msg;
+
+ @Override
+ public void setUp(){
+ msg = new PhoneCapability();
+
+ msg.setDialNumberEnabled(Test.GENERAL_BOOLEAN);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean dialNumberEnabled = msg.getDialNumberEnabled();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, dialNumberEnabled);
+
+ // Invalid/Null Tests
+ PhoneCapability msg = new PhoneCapability();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getDialNumberEnabled());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(PhoneCapability.KEY_DIALNUMBER_ENABLED, Test.GENERAL_BOOLEAN);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RadioControlCapabilitiesTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RadioControlCapabilitiesTests.java
new file mode 100644
index 000000000..28c1d2c5b
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RadioControlCapabilitiesTests.java
@@ -0,0 +1,112 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.RadioControlCapabilities;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.RadioControlCapabilities}
+ */
+public class RadioControlCapabilitiesTests extends TestCase{
+
+ private RadioControlCapabilities msg;
+
+ @Override
+ public void setUp(){
+ msg = new RadioControlCapabilities();
+
+ msg.setModuleName(Test.GENERAL_STRING);
+ msg.setRadioEnableAvailable(Test.GENERAL_BOOLEAN);
+ msg.setRadioBandAvailable(Test.GENERAL_BOOLEAN);
+ msg.setRadioFrequencyAvailable(Test.GENERAL_BOOLEAN);
+ msg.setHdChannelAvailable(Test.GENERAL_BOOLEAN);
+ msg.setRdsDataAvailable(Test.GENERAL_BOOLEAN);
+ msg.setAvailableHDsAvailable(Test.GENERAL_BOOLEAN);
+ msg.setStateAvailable(Test.GENERAL_BOOLEAN);
+ msg.setSignalStrengthAvailable(Test.GENERAL_BOOLEAN);
+ msg.setSignalChangeThresholdAvailable(Test.GENERAL_BOOLEAN);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String moduleName = msg.getModuleName();
+ boolean radioEnableAvailable = msg.getRadioEnableAvailable();
+ boolean radioBandAvailable = msg.getRadioBandAvailable();
+ boolean radioFrequencyAvailable = msg.getRadioFrequencyAvailable();
+ boolean hdChannelAvailable = msg.getHdChannelAvailable();
+ boolean rdsDataAvailable = msg.getRdsDataAvailable();
+ boolean availableHDsAvailable = msg.getAvailableHDsAvailable();
+ boolean stateAvailable = msg.getStateAvailable();
+ boolean signalStrengthAvailable = msg.getSignalStrengthAvailable();
+ boolean signalChangeThresholdAvailable = msg.getSignalChangeThresholdAvailable();
+
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, moduleName);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, radioEnableAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, radioBandAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, radioFrequencyAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, hdChannelAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, rdsDataAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, availableHDsAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, stateAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, signalStrengthAvailable);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, signalChangeThresholdAvailable);
+
+ // Invalid/Null Tests
+ RadioControlCapabilities msg = new RadioControlCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getModuleName());
+ assertNull(Test.NULL, msg.getRadioEnableAvailable());
+ assertNull(Test.NULL, msg.getRadioBandAvailable());
+ assertNull(Test.NULL, msg.getRadioFrequencyAvailable());
+ assertNull(Test.NULL, msg.getHdChannelAvailable());
+ assertNull(Test.NULL, msg.getRdsDataAvailable());
+ assertNull(Test.NULL, msg.getAvailableHDsAvailable());
+ assertNull(Test.NULL, msg.getStateAvailable());
+ assertNull(Test.NULL, msg.getSignalStrengthAvailable());
+ assertNull(Test.NULL, msg.getSignalChangeThresholdAvailable());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(RadioControlCapabilities.KEY_MODULE_NAME, Test.GENERAL_STRING);
+ reference.put(RadioControlCapabilities.KEY_RADIO_ENABLE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlCapabilities.KEY_RADIO_BAND_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlCapabilities.KEY_RADIO_FREQUENCY_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlCapabilities.KEY_HD_CHANNEL_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlCapabilities.KEY_RDS_DATA_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlCapabilities.KEY_AVAILABLE_HDS_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlCapabilities.KEY_STATE_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlCapabilities.KEY_SIGNAL_STRENGTH_AVAILABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlCapabilities.KEY_SIGNAL_CHANGE_THRESHOLD_AVAILABLE, Test.GENERAL_BOOLEAN);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RadioControlDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RadioControlDataTests.java
new file mode 100644
index 000000000..b42145e8f
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RadioControlDataTests.java
@@ -0,0 +1,124 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.proxy.rpc.RadioControlData;
+import com.smartdevicelink.proxy.rpc.RdsData;
+import com.smartdevicelink.proxy.rpc.enums.RadioBand;
+import com.smartdevicelink.proxy.rpc.enums.RadioState;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.RadioControlData}
+ */
+public class RadioControlDataTests extends TestCase{
+
+ private RadioControlData msg;
+
+ @Override
+ public void setUp(){
+ msg = new RadioControlData();
+
+ msg.setFrequencyInteger(Test.GENERAL_INT);
+ msg.setFrequencyFraction(Test.GENERAL_INT);
+ msg.setBand(Test.GENERAL_RADIOBAND);
+ msg.setRdsData(Test.GENERAL_RDSDATA);
+ msg.setAvailableHDs(Test.GENERAL_INT);
+ msg.setHdChannel(Test.GENERAL_INT);
+ msg.setSignalStrength(Test.GENERAL_INT);
+ msg.setSignalChangeThreshold(Test.GENERAL_INT);
+ msg.setRadioEnable(Test.GENERAL_BOOLEAN);
+ msg.setState(Test.GENERAL_RADIOSTATE);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ int frequencyInteger = msg.getFrequencyInteger();
+ int frequencyFraction = msg.getFrequencyFraction();
+ RadioBand band = msg.getBand();
+ RdsData rdsData = msg.getRdsData();
+ int availableHDs = msg.getAvailableHDs();
+ int hdChannel = msg.getHdChannel();
+ int signalStrength = msg.getSignalStrength();
+ int signalChangeThreshold = msg.getSignalChangeThreshold();
+ boolean radioEnable = msg.getRadioEnable();
+ RadioState state = msg.getState();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_INT, frequencyInteger);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, frequencyFraction);
+ assertEquals(Test.MATCH, Test.GENERAL_RADIOBAND, band);
+ assertTrue(Test.TRUE, Validator.validateRdsData(Test.GENERAL_RDSDATA, rdsData));
+ assertEquals(Test.MATCH, Test.GENERAL_INT, availableHDs);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, hdChannel);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, signalStrength);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, signalChangeThreshold);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, radioEnable);
+ assertEquals(Test.MATCH, Test.GENERAL_RADIOSTATE, state);
+
+ // Invalid/Null Tests
+ RadioControlData msg = new RadioControlData();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getFrequencyInteger());
+ assertNull(Test.NULL, msg.getFrequencyFraction());
+ assertNull(Test.NULL, msg.getBand());
+ assertNull(Test.NULL, msg.getRdsData());
+ assertNull(Test.NULL, msg.getAvailableHDs());
+ assertNull(Test.NULL, msg.getHdChannel());
+ assertNull(Test.NULL, msg.getSignalStrength());
+ assertNull(Test.NULL, msg.getSignalChangeThreshold());
+ assertNull(Test.NULL, msg.getRadioEnable());
+ assertNull(Test.NULL, msg.getState());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(RadioControlData.KEY_FREQUENCY_INTEGER, Test.GENERAL_INT);
+ reference.put(RadioControlData.KEY_FREQUENCY_FRACTION, Test.GENERAL_INT);
+ reference.put(RadioControlData.KEY_BAND, Test.GENERAL_RADIOBAND);
+ reference.put(RadioControlData.KEY_RDS_DATA, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_RDSDATA.getStore()));
+ reference.put(RadioControlData.KEY_AVAILABLE_HDS, Test.GENERAL_INT);
+ reference.put(RadioControlData.KEY_HD_CHANNEL, Test.GENERAL_INT);
+ reference.put(RadioControlData.KEY_SIGNAL_STRENGTH, Test.GENERAL_INT);
+ reference.put(RadioControlData.KEY_SIGNAL_CHANGE_THRESHOLD, Test.GENERAL_INT);
+ reference.put(RadioControlData.KEY_RADIO_ENABLE, Test.GENERAL_BOOLEAN);
+ reference.put(RadioControlData.KEY_STATE, Test.GENERAL_RADIOSTATE);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ if(key.equals(RadioControlData.KEY_RDS_DATA)){
+ JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validateRadioControlData( new RadioControlData(hashReference), new RadioControlData(hashTest)));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RdsDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RdsDataTests.java
new file mode 100644
index 000000000..7414304b0
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RdsDataTests.java
@@ -0,0 +1,101 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.RdsData;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.RdsData}
+ */
+public class RdsDataTests extends TestCase{
+
+ private RdsData msg;
+
+ @Override
+ public void setUp(){
+ msg = new RdsData();
+
+ msg.setProgramService(Test.GENERAL_STRING);
+ msg.setRadioText(Test.GENERAL_STRING);
+ msg.setClockText(Test.GENERAL_STRING);
+ msg.setProgramIdentification(Test.GENERAL_STRING);
+ msg.setRegion(Test.GENERAL_STRING);
+ msg.setTrafficProgram(Test.GENERAL_BOOLEAN);
+ msg.setTrafficAnnouncement(Test.GENERAL_BOOLEAN);
+ msg.setProgramType(Test.GENERAL_INT);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String ps = msg.getProgramService();
+ String rt = msg.getRadioText();
+ String ct = msg.getClockText();
+ String pi = msg.getProgramIdentification();
+ int pty = msg.getProgramType();
+ boolean tp = msg.getTrafficProgram();
+ boolean ta = msg.getTrafficAnnouncement();
+ String reg = msg.getRegion();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, ps);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, rt);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, ct);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, pi);
+ assertEquals(Test.MATCH, Test.GENERAL_INT, pty);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, tp);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, ta);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, reg);
+
+ // Invalid/Null Tests
+ RdsData msg = new RdsData();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getProgramService());
+ assertNull(Test.NULL, msg.getRadioText());
+ assertNull(Test.NULL, msg.getClockText());
+ assertNull(Test.NULL, msg.getProgramIdentification());
+ assertNull(Test.NULL, msg.getRegion());
+ assertNull(Test.NULL, msg.getTrafficProgram());
+ assertNull(Test.NULL, msg.getTrafficAnnouncement());
+ assertNull(Test.NULL, msg.getProgramType());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(RdsData.KEY_PS, Test.GENERAL_STRING);
+ reference.put(RdsData.KEY_RT, Test.GENERAL_STRING);
+ reference.put(RdsData.KEY_CT, Test.GENERAL_STRING);
+ reference.put(RdsData.KEY_PI, Test.GENERAL_STRING);
+ reference.put(RdsData.KEY_PTY, Test.GENERAL_INT);
+ reference.put(RdsData.KEY_TP, Test.GENERAL_BOOLEAN);
+ reference.put(RdsData.KEY_TA, Test.GENERAL_BOOLEAN);
+ reference.put(RdsData.KEY_REG, Test.GENERAL_STRING);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RectangleTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RectangleTests.java
new file mode 100644
index 000000000..569a4db83
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RectangleTests.java
@@ -0,0 +1,79 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.Rectangle;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link Rectangle}
+ */
+public class RectangleTests extends TestCase {
+
+ private Rectangle msg;
+
+ @Override
+ public void setUp() {
+ msg = new Rectangle();
+
+ msg.setX(Test.GENERAL_FLOAT);
+ msg.setY(Test.GENERAL_FLOAT);
+ msg.setWidth(Test.GENERAL_FLOAT);
+ msg.setHeight(Test.GENERAL_FLOAT);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Float x = msg.getX();
+ Float y = msg.getY();
+ Float width = msg.getWidth();
+ Float height = msg.getHeight();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_FLOAT, x);
+ assertEquals(Test.MATCH, Test.GENERAL_FLOAT, y);
+ assertEquals(Test.MATCH, Test.GENERAL_FLOAT, width);
+ assertEquals(Test.MATCH, Test.GENERAL_FLOAT, height);
+
+ // Invalid/Null Tests
+ Rectangle msg = new Rectangle();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getX());
+ assertNull(Test.NULL, msg.getY());
+ assertNull(Test.NULL, msg.getWidth());
+ assertNull(Test.NULL, msg.getHeight());
+ }
+
+ public void testJson() {
+ JSONObject reference = new JSONObject();
+
+ try {
+ reference.put(Rectangle.KEY_X, (Test.GENERAL_FLOAT));
+ reference.put(Rectangle.KEY_Y, (Test.GENERAL_FLOAT));
+ reference.put(Rectangle.KEY_WIDTH, (Test.GENERAL_FLOAT));
+ reference.put(Rectangle.KEY_HEIGHT, (Test.GENERAL_FLOAT));
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RemoteControlCapabilitiesTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RemoteControlCapabilitiesTests.java
new file mode 100644
index 000000000..a15179b8f
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/RemoteControlCapabilitiesTests.java
@@ -0,0 +1,131 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
+import com.smartdevicelink.proxy.rpc.ClimateControlCapabilities;
+import com.smartdevicelink.proxy.rpc.RadioControlCapabilities;
+import com.smartdevicelink.proxy.rpc.RemoteControlCapabilities;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.RemoteControlCapabilities}
+ */
+public class RemoteControlCapabilitiesTests extends TestCase{
+
+ private RemoteControlCapabilities msg;
+
+ @Override
+ public void setUp(){
+ msg = new RemoteControlCapabilities();
+
+ msg.setButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST);
+ msg.setRadioControlCapabilities(Test.GENERAL_RADIOCONTROLCAPABILITIES_LIST);
+ msg.setClimateControlCapabilities(Test.GENERAL_CLIMATECONTROLCAPABILITIES_LIST);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ List<ButtonCapabilities> buttonCapabilities = msg.getButtonCapabilities();
+ List<RadioControlCapabilities> radioControlCapabilities = msg.getRadioControlCapabilities();
+ List<ClimateControlCapabilities> climateControlCapabilities = msg.getClimateControlCapabilities();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BUTTONCAPABILITIES_LIST.size(), buttonCapabilities.size());
+ assertEquals(Test.MATCH, Test.GENERAL_RADIOCONTROLCAPABILITIES_LIST.size(), radioControlCapabilities.size());
+ assertEquals(Test.MATCH, Test.GENERAL_CLIMATECONTROLCAPABILITIES_LIST.size(), climateControlCapabilities.size());
+
+ assertTrue(Test.TRUE, Validator.validateButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST, buttonCapabilities));
+ assertTrue(Test.TRUE, Validator.validateRadioControlCapabilities(Test.GENERAL_RADIOCONTROLCAPABILITIES_LIST, radioControlCapabilities));
+ assertTrue(Test.TRUE, Validator.validateClimateControlCapabilities(Test.GENERAL_CLIMATECONTROLCAPABILITIES_LIST, climateControlCapabilities));
+
+ // Invalid/Null Tests
+ RemoteControlCapabilities msg = new RemoteControlCapabilities();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getButtonCapabilities());
+ assertNull(Test.NULL, msg.getRadioControlCapabilities());
+ assertNull(Test.NULL, msg.getClimateControlCapabilities());
+
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(RemoteControlCapabilities.KEY_BUTTON_CAPABILITIES, Test.JSON_BUTTONCAPABILITIES);
+ reference.put(RemoteControlCapabilities.KEY_RADIO_CONTROL_CAPABILITIES, Test.JSON_RADIOCONTROLCAPABILITIES);
+ reference.put(RemoteControlCapabilities.KEY_CLIMATE_CONTROL_CAPABILITIES, Test.JSON_CLIMATECONTROLCAPABILITIES);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ if(key.equals(RemoteControlCapabilities.KEY_BUTTON_CAPABILITIES)){
+ JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key);
+ JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
+ assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length());
+
+ List<ButtonCapabilities> referenceList = new ArrayList<ButtonCapabilities>();
+ List<ButtonCapabilities> testList = new ArrayList<ButtonCapabilities>();
+ for(int i = 0; i < referenceArray.length(); i++){
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(referenceArray.getJSONObject(i));
+ referenceList.add(new ButtonCapabilities(hashReference));
+ Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray.getJSONObject(i));
+ testList.add(new ButtonCapabilities(hashTest));
+ }
+ assertTrue(Test.TRUE, Validator.validateButtonCapabilities(referenceList, testList));
+ } else if(key.equals(RemoteControlCapabilities.KEY_RADIO_CONTROL_CAPABILITIES)){
+ JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key);
+ JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
+ assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length());
+
+ List<RadioControlCapabilities> referenceList = new ArrayList<RadioControlCapabilities>();
+ List<RadioControlCapabilities> testList = new ArrayList<RadioControlCapabilities>();
+ for(int i = 0; i < referenceArray.length(); i++){
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(referenceArray.getJSONObject(i));
+ referenceList.add(new RadioControlCapabilities(hashReference));
+ Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray.getJSONObject(i));
+ testList.add(new RadioControlCapabilities(hashTest));
+ }
+ assertTrue(Test.TRUE, Validator.validateRadioControlCapabilities(referenceList, testList));
+ } else if(key.equals(RemoteControlCapabilities.KEY_CLIMATE_CONTROL_CAPABILITIES)){
+ JSONArray referenceArray = JsonUtils.readJsonArrayFromJsonObject(reference, key);
+ JSONArray underTestArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
+ assertEquals(Test.MATCH, referenceArray.length(), underTestArray.length());
+
+ List<ClimateControlCapabilities> referenceList = new ArrayList<ClimateControlCapabilities>();
+ List<ClimateControlCapabilities> testList = new ArrayList<ClimateControlCapabilities>();
+ for(int i = 0; i < referenceArray.length(); i++){
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(referenceArray.getJSONObject(i));
+ referenceList.add(new ClimateControlCapabilities(hashReference));
+ Hashtable<String, Object> hashTest= JsonRPCMarshaller.deserializeJSONObject(underTestArray.getJSONObject(i));
+ testList.add(new ClimateControlCapabilities(hashTest));
+ }
+ assertTrue(Test.TRUE, Validator.validateClimateControlCapabilities(referenceList, testList));
+ }
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java
index c94afc643..645652ea0 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SdlMsgVersionTest.java
@@ -25,6 +25,7 @@ public class SdlMsgVersionTest extends TestCase {
msg.setMajorVersion(Test.GENERAL_INT);
msg.setMinorVersion(Test.GENERAL_INT);
+ msg.setPatchVersion(Test.GENERAL_INT);
}
/**
@@ -34,17 +35,20 @@ public class SdlMsgVersionTest extends TestCase {
// Test Values
Integer major = msg.getMajorVersion();
Integer minor = msg.getMinorVersion();
-
+ Integer patch = msg.getPatchVersion();
+
// Valid Tests
assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, major);
assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, minor);
-
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, patch);
+
// Invalid/Null Tests
SdlMsgVersion msg = new SdlMsgVersion();
assertNotNull(Test.NOT_NULL, msg);
assertNull(Test.NULL, msg.getMajorVersion());
assertNull(Test.NULL, msg.getMinorVersion());
+ assertNull(Test.NULL, msg.getPatchVersion());
}
public void testJson() {
@@ -53,6 +57,7 @@ public class SdlMsgVersionTest extends TestCase {
try {
reference.put(SdlMsgVersion.KEY_MAJOR_VERSION, Test.GENERAL_INT);
reference.put(SdlMsgVersion.KEY_MINOR_VERSION, Test.GENERAL_INT);
+ reference.put(SdlMsgVersion.KEY_PATCH_VERSION, Test.GENERAL_INT);
JSONObject underTest = msg.serializeJSON();
assertEquals(Test.MATCH, reference.length(), underTest.length());
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SystemCapabilityTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SystemCapabilityTests.java
new file mode 100644
index 000000000..aa0d75c07
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/SystemCapabilityTests.java
@@ -0,0 +1,108 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.proxy.rpc.NavigationCapability;
+import com.smartdevicelink.proxy.rpc.PhoneCapability;
+import com.smartdevicelink.proxy.rpc.RemoteControlCapabilities;
+import com.smartdevicelink.proxy.rpc.SystemCapability;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.SystemCapability}
+ */
+public class SystemCapabilityTests extends TestCase {
+
+ private SystemCapability msg;
+
+ @Override
+ public void setUp() {
+ msg = new SystemCapability();
+
+ msg.setSystemCapabilityType(Test.GENERAL_SYSTEMCAPABILITYTYPE);
+ msg.setCapabilityForType(SystemCapabilityType.NAVIGATION, Test.GENERAL_NAVIGATIONCAPABILITY);
+ msg.setCapabilityForType(SystemCapabilityType.PHONE_CALL, Test.GENERAL_PHONECAPABILITY);
+ msg.setCapabilityForType(SystemCapabilityType.REMOTE_CONTROL, Test.GENERAL_REMOTECONTROLCAPABILITIES);
+
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ SystemCapabilityType testType = msg.getSystemCapabilityType();
+ NavigationCapability testNavigationCapability = (NavigationCapability) msg.getCapabilityForType(SystemCapabilityType.NAVIGATION);
+ PhoneCapability testPhoneCapability = (PhoneCapability) msg.getCapabilityForType(SystemCapabilityType.PHONE_CALL);
+ RemoteControlCapabilities testRemoteControlCapabilities = (RemoteControlCapabilities) msg.getCapabilityForType(SystemCapabilityType.REMOTE_CONTROL);
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_SYSTEMCAPABILITYTYPE, testType);
+ assertTrue(Test.TRUE, Validator.validateNavigationCapability(Test.GENERAL_NAVIGATIONCAPABILITY, testNavigationCapability));
+ assertTrue(Test.TRUE, Validator.validatePhoneCapability(Test.GENERAL_PHONECAPABILITY, testPhoneCapability));
+ assertTrue(Test.TRUE, Validator.validateRemoteControlCapabilities(Test.GENERAL_REMOTECONTROLCAPABILITIES, testRemoteControlCapabilities));
+
+ // Invalid/Null Tests
+ SystemCapability msg = new SystemCapability();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getSystemCapabilityType());
+ assertNull(Test.NULL, msg.getCapabilityForType(SystemCapabilityType.NAVIGATION));
+ assertNull(Test.NULL, msg.getCapabilityForType(SystemCapabilityType.PHONE_CALL));
+ assertNull(Test.NULL, msg.getCapabilityForType(SystemCapabilityType.REMOTE_CONTROL));
+ }
+
+ public void testJson() {
+ JSONObject reference = new JSONObject();
+
+ try {
+ reference.put(SystemCapability.KEY_SYSTEM_CAPABILITY_TYPE, Test.GENERAL_SYSTEMCAPABILITYTYPE);
+ reference.put(SystemCapability.KEY_NAVIGATION_CAPABILITY, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_NAVIGATIONCAPABILITY.getStore()));
+ reference.put(SystemCapability.KEY_PHONE_CAPABILITY, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_PHONECAPABILITY.getStore()));
+ reference.put(SystemCapability.KEY_REMOTE_CONTROL_CAPABILITY, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_REMOTECONTROLCAPABILITIES.getStore()));
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+
+ if(key.equals(SystemCapability.KEY_NAVIGATION_CAPABILITY)){
+ JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validateNavigationCapability( new NavigationCapability(hashReference), new NavigationCapability(hashTest)));
+ } else if(key.equals(SystemCapability.KEY_PHONE_CAPABILITY)){
+ JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validatePhoneCapability( new PhoneCapability(hashReference), new PhoneCapability(hashTest)));
+ } else if(key.equals(SystemCapability.KEY_REMOTE_CONTROL_CAPABILITY)){
+ JSONObject objectEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONObject testEquals = (JSONObject) JsonUtils.readObjectFromJsonObject(underTest, key);
+ Hashtable<String, Object> hashReference = JsonRPCMarshaller.deserializeJSONObject(objectEquals);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(testEquals);
+ assertTrue(Test.TRUE, Validator.validateRemoteControlCapabilities( new RemoteControlCapabilities(hashReference), new RemoteControlCapabilities(hashTest)));
+ } else{
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ }
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/TemperatureTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/TemperatureTests.java
new file mode 100644
index 000000000..090f5a235
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/TemperatureTests.java
@@ -0,0 +1,72 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.Temperature;
+import com.smartdevicelink.proxy.rpc.enums.TemperatureUnit;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.Temperature}
+ */
+public class TemperatureTests extends TestCase{
+
+ private Temperature msg;
+
+ @Override
+ public void setUp(){
+ msg = new Temperature();
+
+ msg.setUnit(Test.GENERAL_TEMPERATUREUNIT);
+ msg.setValue(Test.GENERAL_FLOAT);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ TemperatureUnit unit = msg.getUnit();
+ float value = msg.getValue();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_FLOAT, value);
+ assertEquals(Test.MATCH, Test.GENERAL_TEMPERATUREUNIT, unit);
+
+ // Invalid/Null Tests
+ Temperature msg = new Temperature();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getUnit());
+ assertNull(Test.NULL, msg.getValue());
+ }
+
+ public void testJson(){
+ JSONObject reference = new JSONObject();
+
+ try{
+ reference.put(Temperature.KEY_VALUE, (Float) Test.GENERAL_FLOAT);
+ reference.put(Temperature.KEY_UNIT, Test.GENERAL_TEMPERATUREUNIT);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while(iterator.hasNext()){
+ String key = (String) iterator.next();
+
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+
+ }
+ } catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingCapabilityTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingCapabilityTests.java
new file mode 100644
index 000000000..54cfc1a22
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingCapabilityTests.java
@@ -0,0 +1,96 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.proxy.rpc.ImageResolution;
+import com.smartdevicelink.proxy.rpc.VideoStreamingCapability;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import junit.framework.TestCase;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+
+public class VideoStreamingCapabilityTests extends TestCase {
+
+ private VideoStreamingCapability msg;
+
+ @Override
+ public void setUp() {
+ msg = new VideoStreamingCapability();
+ msg.setSupportedFormats(Test.GENERAL_VIDEOSTREAMINGFORMAT_LIST);
+ msg.setPreferredResolution(Test.GENERAL_IMAGERESOLUTION);
+ msg.setMaxBitrate(Test.GENERAL_INT);
+ msg.setIsHapticSpatialDataSupported(Test.GENERAL_BOOLEAN);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ List<VideoStreamingFormat> format = msg.getSupportedFormats();
+ ImageResolution res = msg.getPreferredResolution();
+ Integer maxBitrate = msg.getMaxBitrate();
+ Boolean isHapticSpatialDataSupported = msg.getIsHapticSpatialDataSupported();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, (List<VideoStreamingFormat>) Test.GENERAL_VIDEOSTREAMINGFORMAT_LIST, format);
+ assertEquals(Test.MATCH, (ImageResolution) Test.GENERAL_IMAGERESOLUTION, res);
+ assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, maxBitrate);
+ assertEquals(Test.MATCH, (Boolean) Test.GENERAL_BOOLEAN, isHapticSpatialDataSupported);
+
+ // Invalid/Null Tests
+ VideoStreamingCapability msg = new VideoStreamingCapability();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getMaxBitrate());
+ assertNull(Test.NULL, msg.getPreferredResolution());
+ assertNull(Test.NULL, msg.getSupportedFormats());
+ assertNull(Test.NULL, msg.getIsHapticSpatialDataSupported());
+ }
+
+ public void testJson() {
+ JSONObject reference = new JSONObject();
+
+ try {
+ reference.put(VideoStreamingCapability.KEY_MAX_BITRATE, Test.GENERAL_INT);
+ reference.put(VideoStreamingCapability.KEY_PREFERRED_RESOLUTION, Test.GENERAL_IMAGERESOLUTION);
+ reference.put(VideoStreamingCapability.KEY_SUPPORTED_FORMATS, Test.GENERAL_VIDEOSTREAMINGFORMAT_LIST);
+ reference.put(VideoStreamingCapability.KEY_HAPTIC_SPATIAL_DATA_SUPPORTED, Test.GENERAL_BOOLEAN);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+
+ if (key.equals(VideoStreamingCapability.KEY_MAX_BITRATE) || key.equals(VideoStreamingCapability.KEY_HAPTIC_SPATIAL_DATA_SUPPORTED)) {
+ assertTrue(Test.TRUE, JsonUtils.readIntegerFromJsonObject(reference, key) == JsonUtils.readIntegerFromJsonObject(underTest, key));
+ } else if (key.equals(VideoStreamingCapability.KEY_PREFERRED_RESOLUTION)) {
+ ImageResolution irReference = (ImageResolution) JsonUtils.readObjectFromJsonObject(reference, key);
+ Hashtable<String, Object> hashTest = JsonRPCMarshaller.deserializeJSONObject(JsonUtils.readJsonObjectFromJsonObject(underTest, key));
+ assertTrue(Validator.validateImageResolution(irReference, new ImageResolution(hashTest)));
+ } else if (key.equals(VideoStreamingCapability.KEY_SUPPORTED_FORMATS)){
+ List<VideoStreamingFormat> vsfReference = (List<VideoStreamingFormat>) JsonUtils.readObjectFromJsonObject(reference, key);
+ JSONArray vsfArray = JsonUtils.readJsonArrayFromJsonObject(underTest, key);
+ int i = 0;
+ for(VideoStreamingFormat vsf : vsfReference){
+ assertTrue(Validator.validateSupportedFormats(vsf, new VideoStreamingFormat(JsonRPCMarshaller.deserializeJSONObject(vsfArray.getJSONObject(i++)))));
+ }
+ }
+ }
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingFormatTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingFormatTests.java
new file mode 100644
index 000000000..ff7cb2719
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/VideoStreamingFormatTests.java
@@ -0,0 +1,70 @@
+package com.smartdevicelink.test.rpc.datatypes;
+
+import com.smartdevicelink.proxy.rpc.ImageResolution;
+import com.smartdevicelink.proxy.rpc.VideoStreamingCapability;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+
+import junit.framework.TestCase;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Iterator;
+
+public class VideoStreamingFormatTests extends TestCase {
+
+ private VideoStreamingFormat msg;
+
+ @Override
+ public void setUp() {
+ msg = new VideoStreamingFormat();
+ msg.setProtocol(Test.GENERAL_VIDEOSTREAMINGPROTOCOL);
+ msg.setCodec(Test.GENERAL_VIDEOSTREAMINGCODEC);
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ VideoStreamingProtocol protocol = msg.getProtocol();
+ VideoStreamingCodec codec = msg.getCodec();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, (VideoStreamingProtocol) Test.GENERAL_VIDEOSTREAMINGPROTOCOL, protocol);
+ assertEquals(Test.MATCH, (VideoStreamingCodec) Test.GENERAL_VIDEOSTREAMINGCODEC, codec);
+
+ // Invalid/Null Tests
+ VideoStreamingFormat msg = new VideoStreamingFormat();
+ assertNotNull(Test.NOT_NULL, msg);
+
+ assertNull(Test.NULL, msg.getProtocol());
+ assertNull(Test.NULL, msg.getCodec());
+ }
+
+ public void testJson() {
+ JSONObject reference = new JSONObject();
+
+ try {
+ reference.put(VideoStreamingFormat.KEY_PROTOCOL, Test.GENERAL_VIDEOSTREAMINGPROTOCOL);
+ reference.put(VideoStreamingFormat.KEY_CODEC, Test.GENERAL_VIDEOSTREAMINGCODEC);
+
+ JSONObject underTest = msg.serializeJSON();
+ assertEquals(Test.MATCH, reference.length(), underTest.length());
+
+ Iterator<?> iterator = reference.keys();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key));
+ }
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
+
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java
index 76d203901..6446cb914 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppHmiTypeTests.java
@@ -10,7 +10,7 @@ import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.enums.AppHmiType}
+ * {@link com.smartdevicelink.proxy.rpc.enums.AppHMIType}
*/
public class AppHmiTypeTests extends TestCase {
@@ -34,10 +34,14 @@ public class AppHmiTypeTests extends TestCase {
AppHMIType enumSocial = AppHMIType.valueForString(example);
example = "BACKGROUND_PROCESS";
AppHMIType enumBackgroundProcess = AppHMIType.valueForString(example);
+ example = "PROJECTION";
+ AppHMIType enumProjection = AppHMIType.valueForString(example);
example = "TESTING";
AppHMIType enumTesting = AppHMIType.valueForString(example);
example = "SYSTEM";
AppHMIType enumSystem = AppHMIType.valueForString(example);
+ example = "REMOTE_CONTROL";
+ AppHMIType enumRemoteControl = AppHMIType.valueForString(example);
assertNotNull("DEFAULT returned null", enumDefault);
assertNotNull("COMMUNICATION returned null", enumCommunication);
@@ -47,8 +51,10 @@ public class AppHmiTypeTests extends TestCase {
assertNotNull("INFORMATION returned null", enumInformation);
assertNotNull("SOCIAL returned null", enumSocial);
assertNotNull("BACKGROUND_PROCESS returned null", enumBackgroundProcess);
+ assertNotNull("PROJECTION returned null", enumProjection);
assertNotNull("TESTING returned null", enumTesting);
assertNotNull("SYSTEM returned null", enumSystem);
+ assertNotNull("REMOTE_CONTROL returned null", enumRemoteControl);
}
/**
@@ -93,9 +99,11 @@ public class AppHmiTypeTests extends TestCase {
enumTestList.add(AppHMIType.NAVIGATION);
enumTestList.add(AppHMIType.INFORMATION);
enumTestList.add(AppHMIType.SOCIAL);
- enumTestList.add(AppHMIType.BACKGROUND_PROCESS);
+ enumTestList.add(AppHMIType.BACKGROUND_PROCESS);
+ enumTestList.add(AppHMIType.PROJECTION);
enumTestList.add(AppHMIType.TESTING);
- enumTestList.add(AppHMIType.SYSTEM);
+ enumTestList.add(AppHMIType.SYSTEM);
+ enumTestList.add(AppHMIType.REMOTE_CONTROL);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ButtonNameTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ButtonNameTests.java
index 1db7c4580..e37eb2fd1 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ButtonNameTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ButtonNameTests.java
@@ -52,7 +52,44 @@ public class ButtonNameTests extends TestCase {
ButtonName enumCustomButton = ButtonName.valueForString(example);
example = "SEARCH";
ButtonName enumSearch = ButtonName.valueForString(example);
-
+ example = "AC_MAX";
+ ButtonName enumAcMax = ButtonName.valueForString(example);
+ example = "AC";
+ ButtonName enumAc = ButtonName.valueForString(example);
+ example = "RECIRCULATE";
+ ButtonName enumRecirculate = ButtonName.valueForString(example);
+ example = "FAN_UP";
+ ButtonName enumFanUp = ButtonName.valueForString(example);
+ example = "FAN_DOWN";
+ ButtonName enumFanDown = ButtonName.valueForString(example);
+ example = "TEMP_UP";
+ ButtonName enumTempUp = ButtonName.valueForString(example);
+ example = "TEMP_DOWN";
+ ButtonName enumTempDown = ButtonName.valueForString(example);
+ example = "DEFROST_MAX";
+ ButtonName enumDefrostMax = ButtonName.valueForString(example);
+ example = "DEFROST";
+ ButtonName enumDefrost = ButtonName.valueForString(example);
+ example = "DEFROST_REAR";
+ ButtonName enumDefrostRear = ButtonName.valueForString(example);
+ example = "UPPER_VENT";
+ ButtonName enumUpperVent = ButtonName.valueForString(example);
+ example = "LOWER_VENT";
+ ButtonName enumLowerVent = ButtonName.valueForString(example);
+ example = "VOLUME_UP";
+ ButtonName enumVolumeUp = ButtonName.valueForString(example);
+ example = "VOLUME_DOWN";
+ ButtonName enumVolumeDown = ButtonName.valueForString(example);
+ example = "EJECT";
+ ButtonName enumEject = ButtonName.valueForString(example);
+ example = "SOURCE";
+ ButtonName enumSource = ButtonName.valueForString(example);
+ example = "SHUFFLE";
+ ButtonName enumShuffle = ButtonName.valueForString(example);
+ example = "REPEAT";
+ ButtonName enumRepeat = ButtonName.valueForString(example);
+
+
assertNotNull("OK returned null", enumOk);
assertNotNull("SEEKLEFT returned null", enumSeekLeft);
@@ -71,6 +108,24 @@ public class ButtonNameTests extends TestCase {
assertNotNull("PRESET_9 returned null", enumPreset9);
assertNotNull("CUSTOM_BUTTON returned null", enumCustomButton);
assertNotNull("SEARCH returned null", enumSearch);
+ assertNotNull("AC_MAX returned null", enumAcMax);
+ assertNotNull("AC returned null", enumAc);
+ assertNotNull("RECIRCULATE returned null", enumRecirculate);
+ assertNotNull("FAN_UP returned null", enumFanUp);
+ assertNotNull("FAN_DOWN returned null", enumFanDown);
+ assertNotNull("TEMP_UP returned null", enumTempUp);
+ assertNotNull("TEMP_DOWN returned null", enumTempDown);
+ assertNotNull("DEFROST_MAX returned null", enumDefrostMax);
+ assertNotNull("DEFROST returned null", enumDefrost);
+ assertNotNull("DEFROST_REAR returned null", enumDefrostRear);
+ assertNotNull("UPPER_VENT returned null", enumUpperVent);
+ assertNotNull("LOWER_VENT returned null", enumLowerVent);
+ assertNotNull("VOLUME_UP returned null", enumVolumeUp);
+ assertNotNull("VOLUME_DOWN returned null", enumVolumeDown);
+ assertNotNull("EJECT returned null", enumEject);
+ assertNotNull("SOURCE returned null", enumSource);
+ assertNotNull("SHUFFLE returned null", enumShuffle);
+ assertNotNull("REPEAT returned null", enumRepeat);
}
/**
@@ -125,7 +180,25 @@ public class ButtonNameTests extends TestCase {
enumTestList.add(ButtonName.PRESET_8);
enumTestList.add(ButtonName.PRESET_9);
enumTestList.add(ButtonName.CUSTOM_BUTTON);
- enumTestList.add(ButtonName.SEARCH);
+ enumTestList.add(ButtonName.SEARCH);
+ enumTestList.add(ButtonName.AC_MAX);
+ enumTestList.add(ButtonName.AC);
+ enumTestList.add(ButtonName.RECIRCULATE);
+ enumTestList.add(ButtonName.FAN_UP);
+ enumTestList.add(ButtonName.FAN_DOWN);
+ enumTestList.add(ButtonName.TEMP_UP);
+ enumTestList.add(ButtonName.TEMP_DOWN);
+ enumTestList.add(ButtonName.DEFROST_MAX);
+ enumTestList.add(ButtonName.DEFROST);
+ enumTestList.add(ButtonName.DEFROST_REAR);
+ enumTestList.add(ButtonName.UPPER_VENT);
+ enumTestList.add(ButtonName.LOWER_VENT);
+ enumTestList.add(ButtonName.VOLUME_UP);
+ enumTestList.add(ButtonName.VOLUME_DOWN);
+ enumTestList.add(ButtonName.EJECT);
+ enumTestList.add(ButtonName.SOURCE);
+ enumTestList.add(ButtonName.SHUFFLE);
+ enumTestList.add(ButtonName.REPEAT);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DefrostZoneTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DefrostZoneTests.java
new file mode 100644
index 000000000..f1f375623
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DefrostZoneTests.java
@@ -0,0 +1,79 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.DefrostZone;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.enums.DefrostZone}
+ */
+public class DefrostZoneTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "FRONT";
+ DefrostZone enumFront = DefrostZone.valueForString(example);
+ example = "REAR";
+ DefrostZone enumRear = DefrostZone.valueForString(example);
+ example = "ALL";
+ DefrostZone enumAll = DefrostZone.valueForString(example);
+ example = "NONE";
+ DefrostZone enumNone = DefrostZone.valueForString(example);
+
+ assertNotNull("FRONT returned null", enumFront);
+ assertNotNull("REAR returned null", enumRear);
+ assertNotNull("ALL returned null", enumAll);
+ assertNotNull("NONE returned null", enumNone);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "fRONT";
+ try {
+ DefrostZone temp = DefrostZone.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ DefrostZone temp = DefrostZone.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+ /**
+ * Verifies the possible enum values of DefrostZone.
+ */
+ public void testListEnum() {
+ List<DefrostZone> enumValueList = Arrays.asList(DefrostZone.values());
+
+ List<DefrostZone> enumTestList = new ArrayList<DefrostZone>();
+ enumTestList.add(DefrostZone.FRONT);
+ enumTestList.add(DefrostZone.REAR);
+ enumTestList.add(DefrostZone.ALL);
+ enumTestList.add(DefrostZone.NONE);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DisplayTypeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DisplayTypeTests.java
index 83af2561e..560bdf025 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DisplayTypeTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/DisplayTypeTests.java
@@ -9,15 +9,15 @@ import junit.framework.TestCase;
import com.smartdevicelink.proxy.rpc.enums.DisplayType;
/**
- * This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.enums.DisplayType}
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.proxy.rpc.enums.DisplayType}
*/
public class DisplayTypeTests extends TestCase {
/**
* Verifies that the enum values are not null upon valid assignment.
*/
- public void testValidEnums () {
+ public void testValidEnums () {
String example = "CID";
DisplayType enumCid = DisplayType.valueForString(example);
example = "TYPE2";
@@ -38,6 +38,8 @@ public class DisplayTypeTests extends TestCase {
DisplayType enumMfd5 = DisplayType.valueForString(example);
example = "GEN3_8-INCH";
DisplayType enumGen3_8Inch = DisplayType.valueForString(example);
+ example = "SDL_GENERIC";
+ DisplayType enumGeneric = DisplayType.valueForString(example);
assertNotNull("CID returned null", enumCid);
assertNotNull("TYPE2 returned null", enumType2);
@@ -49,6 +51,7 @@ public class DisplayTypeTests extends TestCase {
assertNotNull("MFD4 returned null", enumMfd4);
assertNotNull("MFD5 returned null", enumMfd5);
assertNotNull("GEN3_8-INCH returned null", enumGen3_8Inch);
+ assertNotNull("SDL_GENERIC returned null", enumGeneric);
}
/**
@@ -57,11 +60,11 @@ public class DisplayTypeTests extends TestCase {
public void testInvalidEnum () {
String example = "cId";
try {
- DisplayType temp = DisplayType.valueForString(example);
- assertNull("Result of valueForString should be null.", temp);
+ DisplayType temp = DisplayType.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
}
catch (IllegalArgumentException exception) {
- fail("Invalid enum throws IllegalArgumentException.");
+ fail("Invalid enum throws IllegalArgumentException.");
}
}
@@ -71,19 +74,19 @@ public class DisplayTypeTests extends TestCase {
public void testNullEnum () {
String example = null;
try {
- DisplayType temp = DisplayType.valueForString(example);
- assertNull("Result of valueForString should be null.", temp);
+ DisplayType temp = DisplayType.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
}
catch (NullPointerException exception) {
- fail("Null string throws NullPointerException.");
+ fail("Null string throws NullPointerException.");
}
}
-
+
/**
* Verifies the possible enum values of DisplayType.
*/
public void testListEnum() {
- List<DisplayType> enumValueList = Arrays.asList(DisplayType.values());
+ List<DisplayType> enumValueList = Arrays.asList(DisplayType.values());
List<DisplayType> enumTestList = new ArrayList<DisplayType>();
enumTestList.add(DisplayType.CID);
@@ -91,13 +94,14 @@ public class DisplayTypeTests extends TestCase {
enumTestList.add(DisplayType.TYPE5);
enumTestList.add(DisplayType.NGN);
enumTestList.add(DisplayType.GEN2_8_DMA);
- enumTestList.add(DisplayType.GEN2_6_DMA);
+ enumTestList.add(DisplayType.GEN2_6_DMA);
enumTestList.add(DisplayType.MFD3);
- enumTestList.add(DisplayType.MFD4);
+ enumTestList.add(DisplayType.MFD4);
enumTestList.add(DisplayType.MFD5);
- enumTestList.add(DisplayType.GEN3_8_INCH);
+ enumTestList.add(DisplayType.GEN3_8_INCH);
+ enumTestList.add(DisplayType.SDL_GENERIC);
- assertTrue("Enum value list does not match enum class list",
+ assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
- }
+ }
} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/LanguageTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/LanguageTests.java
index 3679a9ffc..6b87c5d26 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/LanguageTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/LanguageTests.java
@@ -10,7 +10,7 @@ import com.smartdevicelink.proxy.rpc.enums.Language;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.enums.Language}
+ * {@link com.smartdevicelink.proxy.rpc.enums.Language}
*/
public class LanguageTests extends TestCase {
@@ -20,6 +20,32 @@ public class LanguageTests extends TestCase {
public void testValidEnums () {
String example = "EN-US";
Language enumEnUs = Language.valueForString(example);
+ example = "EN-SA";
+ Language enumEnSa = Language.valueForString(example);
+ example = "HE-IL";
+ Language enumHeIl = Language.valueForString(example);
+ example = "RO-RO";
+ Language enumRoRo = Language.valueForString(example);
+ example = "UK-UA";
+ Language enumUkUa = Language.valueForString(example);
+ example = "ID-ID";
+ Language enumIdId = Language.valueForString(example);
+ example = "VI-VN";
+ Language enumViVn = Language.valueForString(example);
+ example = "MS-MY";
+ Language enumMsMy = Language.valueForString(example);
+ example = "HI-IN";
+ Language enumHiIn = Language.valueForString(example);
+ example = "NL-BE";
+ Language enumNlBe = Language.valueForString(example);
+ example = "EL-GR";
+ Language enumElGr = Language.valueForString(example);
+ example = "HU-HU";
+ Language enumHuHu = Language.valueForString(example);
+ example = "FI-FI";
+ Language enumFiFi = Language.valueForString(example);
+ example = "SK-SK";
+ Language enumSkSk = Language.valueForString(example);
example = "ES-MX";
Language enumEsMx = Language.valueForString(example);
example = "FR-CA";
@@ -66,8 +92,25 @@ public class LanguageTests extends TestCase {
Language enumDaDk = Language.valueForString(example);
example = "NO-NO";
Language enumNoNo = Language.valueForString(example);
+ example = "EN-IN";
+ Language enumEnIn = Language.valueForString(example);
+ example = "TH-TH";
+ Language enumThTh = Language.valueForString(example);
assertNotNull("EN-US returned null", enumEnUs);
+ assertNotNull("EN-SA returned null", enumEnSa);
+ assertNotNull("HE-IL returned null", enumHeIl);
+ assertNotNull("RO-RO returned null", enumRoRo);
+ assertNotNull("UK-UA returned null", enumUkUa);
+ assertNotNull("ID-ID returned null", enumIdId);
+ assertNotNull("VI-VN returned null", enumViVn);
+ assertNotNull("MS-MY returned null", enumMsMy);
+ assertNotNull("HI-IN returned null", enumHiIn);
+ assertNotNull("NL-BE returned null", enumNlBe);
+ assertNotNull("EL-GR returned null", enumElGr);
+ assertNotNull("HU-HU returned null", enumHuHu);
+ assertNotNull("FI-FI returned null", enumFiFi);
+ assertNotNull("SK-SK returned null", enumSkSk);
assertNotNull("ES-MX returned null", enumEsMx);
assertNotNull("FR-CA returned null", enumFrCa);
assertNotNull("DE-DE returned null", enumDeDe);
@@ -91,6 +134,8 @@ public class LanguageTests extends TestCase {
assertNotNull("CS-CZ returned null", enumCsCz);
assertNotNull("DA-DK returned null", enumDaDk);
assertNotNull("NO-NO returned null", enumNoNo);
+ assertNotNull("EN-IN returned null", enumEnIn);
+ assertNotNull("TH-TH returned null", enumThTh);
}
/**
@@ -130,6 +175,19 @@ public class LanguageTests extends TestCase {
List<Language> enumTestList = new ArrayList<Language>();
enumTestList.add(Language.EN_US);
+ enumTestList.add(Language.EN_SA);
+ enumTestList.add(Language.HE_IL);
+ enumTestList.add(Language.RO_RO);
+ enumTestList.add(Language.UK_UA);
+ enumTestList.add(Language.ID_ID);
+ enumTestList.add(Language.VI_VN);
+ enumTestList.add(Language.MS_MY);
+ enumTestList.add(Language.HI_IN);
+ enumTestList.add(Language.NL_BE);
+ enumTestList.add(Language.EL_GR);
+ enumTestList.add(Language.HU_HU);
+ enumTestList.add(Language.FI_FI);
+ enumTestList.add(Language.SK_SK);
enumTestList.add(Language.ES_MX);
enumTestList.add(Language.FR_CA);
enumTestList.add(Language.DE_DE);
@@ -153,6 +211,8 @@ public class LanguageTests extends TestCase {
enumTestList.add(Language.CS_CZ);
enumTestList.add(Language.DA_DK);
enumTestList.add(Language.NO_NO);
+ enumTestList.add(Language.EN_IN);
+ enumTestList.add(Language.TH_TH);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MetadataTypeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MetadataTypeTests.java
new file mode 100644
index 000000000..c1aff1bdd
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MetadataTypeTests.java
@@ -0,0 +1,114 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.MetadataType;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.proxy.rpc.MetadataTags}
+ */
+
+public class MetadataTypeTests extends TestCase{
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "mediaTitle";
+ MetadataType enumMediaTitle = MetadataType.valueForString(example);
+ example = "mediaArtist";
+ MetadataType enumMediaArtist = MetadataType.valueForString(example);
+ example = "mediaAlbum";
+ MetadataType enumMediaAlbum = MetadataType.valueForString(example);
+ example = "mediaYear";
+ MetadataType enumMediaYear = MetadataType.valueForString(example);
+ example = "mediaGenre";
+ MetadataType enumMediaGenre = MetadataType.valueForString(example);
+ example = "mediaStation";
+ MetadataType enumMediaStation = MetadataType.valueForString(example);
+ example = "rating";
+ MetadataType enumRating = MetadataType.valueForString(example);
+ example = "currentTemperature";
+ MetadataType enumCurrentTemperature = MetadataType.valueForString(example);
+ example = "maximumTemperature";
+ MetadataType enumMaximumTemperature = MetadataType.valueForString(example);
+ example = "minimumTemperature";
+ MetadataType enumMinimumTemperature = MetadataType.valueForString(example);
+ example = "weatherTerm";
+ MetadataType enumWeatherTerm = MetadataType.valueForString(example);
+ example = "humidity";
+ MetadataType enumHumidity = MetadataType.valueForString(example);
+
+
+ assertNotNull("mediaTitle returned null", enumMediaTitle);
+ assertNotNull("mediaArtist returned null", enumMediaArtist);
+ assertNotNull("mediaAlbum returned null", enumMediaAlbum);
+ assertNotNull("mediaYear returned null", enumMediaYear);
+ assertNotNull("mediaGenre returned null", enumMediaGenre);
+ assertNotNull("mediaStation returned null", enumMediaStation);
+ assertNotNull("rating returned null", enumRating);
+ assertNotNull("currentTemperature returned null", enumCurrentTemperature);
+ assertNotNull("maximumTemperature returned null", enumMaximumTemperature);
+ assertNotNull("minimumTemperature returned null", enumMinimumTemperature);
+ assertNotNull("weatherTerm returned null", enumWeatherTerm);
+ assertNotNull("humidity returned null", enumHumidity);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "MEDIA_TITLEZ";
+ try {
+ MetadataType temp = MetadataType.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ MetadataType temp = MetadataType.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+ /**
+ * Verifies the possible enum values of MetadataType.
+ */
+ public void testListEnum() {
+ List<MetadataType> enumValueList = Arrays.asList(MetadataType.values());
+
+ List<MetadataType> enumTestList = new ArrayList<MetadataType>();
+ enumTestList.add(MetadataType.MEDIA_TITLE);
+ enumTestList.add(MetadataType.MEDIA_ARTIST);
+ enumTestList.add(MetadataType.MEDIA_ALBUM);
+ enumTestList.add(MetadataType.MEDIA_YEAR);
+ enumTestList.add(MetadataType.MEDIA_GENRE);
+ enumTestList.add(MetadataType.MEDIA_STATION);
+ enumTestList.add(MetadataType.RATING);
+ enumTestList.add(MetadataType.CURRENT_TEMPERATURE);
+ enumTestList.add(MetadataType.MAXIMUM_TEMPERATURE);
+ enumTestList.add(MetadataType.MINIMUM_TEMPERATURE);
+ enumTestList.add(MetadataType.WEATHER_TERM);
+ enumTestList.add(MetadataType.HUMIDITY);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ModuleTypeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ModuleTypeTests.java
new file mode 100644
index 000000000..18a47b79d
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ModuleTypeTests.java
@@ -0,0 +1,71 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.ModuleType;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.enums.ModuleType}
+ */
+public class ModuleTypeTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "CLIMATE";
+ ModuleType enumClimate = ModuleType.valueForString(example);
+ example = "RADIO";
+ ModuleType enumRadio = ModuleType.valueForString(example);
+
+ assertNotNull("CLIMATE returned null", enumClimate);
+ assertNotNull("RADIO returned null", enumRadio);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "cLIMATE";
+ try {
+ ModuleType temp = ModuleType.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ ModuleType temp = ModuleType.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+ /**
+ * Verifies the possible enum values of ModuleType.
+ */
+ public void testListEnum() {
+ List<ModuleType> enumValueList = Arrays.asList(ModuleType.values());
+
+ List<ModuleType> enumTestList = new ArrayList<ModuleType>();
+ enumTestList.add(ModuleType.CLIMATE);
+ enumTestList.add(ModuleType.RADIO);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/RadioBandTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/RadioBandTests.java
new file mode 100644
index 000000000..cc5d5b700
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/RadioBandTests.java
@@ -0,0 +1,75 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.RadioBand;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.enums.RadioBand}
+ */
+public class RadioBandTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "AM";
+ RadioBand enumAm = RadioBand.valueForString(example);
+ example = "FM";
+ RadioBand enumFm = RadioBand.valueForString(example);
+ example = "XM";
+ RadioBand enumXm = RadioBand.valueForString(example);
+
+ assertNotNull("AM returned null", enumAm);
+ assertNotNull("FM returned null", enumFm);
+ assertNotNull("XM returned null", enumXm);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "aM";
+ try {
+ RadioBand temp = RadioBand.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ RadioBand temp = RadioBand.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+ /**
+ * Verifies the possible enum values of RadioBand.
+ */
+ public void testListEnum() {
+ List<RadioBand> enumValueList = Arrays.asList(RadioBand.values());
+
+ List<RadioBand> enumTestList = new ArrayList<RadioBand>();
+ enumTestList.add(RadioBand.AM);
+ enumTestList.add(RadioBand.FM);
+ enumTestList.add(RadioBand.XM);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/RadioStateTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/RadioStateTests.java
new file mode 100644
index 000000000..d16f00599
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/RadioStateTests.java
@@ -0,0 +1,79 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.RadioState;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.enums.RadioState}
+ */
+public class RadioStateTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "ACQUIRING";
+ RadioState enumAcquiring = RadioState.valueForString(example);
+ example = "ACQUIRED";
+ RadioState enumAcquired = RadioState.valueForString(example);
+ example = "MULTICAST";
+ RadioState enumMultiCast = RadioState.valueForString(example);
+ example = "NOT_FOUND";
+ RadioState enumNotFound = RadioState.valueForString(example);
+
+ assertNotNull("ACQUIRING returned null", enumAcquiring);
+ assertNotNull("ACQUIRED returned null", enumAcquired);
+ assertNotNull("MULTICAST returned null", enumMultiCast);
+ assertNotNull("NOT_FOUND returned null", enumNotFound);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "aCQUIRING";
+ try {
+ RadioState temp = RadioState.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ RadioState temp = RadioState.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+ /**
+ * Verifies the possible enum values of RadioState.
+ */
+ public void testListEnum() {
+ List<RadioState> enumValueList = Arrays.asList(RadioState.values());
+
+ List<RadioState> enumTestList = new ArrayList<RadioState>();
+ enumTestList.add(RadioState.ACQUIRING);
+ enumTestList.add(RadioState.ACQUIRED);
+ enumTestList.add(RadioState.MULTICAST);
+ enumTestList.add(RadioState.NOT_FOUND);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java
index 3eaae9937..5156c4f44 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java
@@ -82,6 +82,10 @@ public class ResultTests extends TestCase {
Result enumExpiredCert = Result.valueForString(example);
example = "RESUME_FAILED";
Result enumResumeFailed = Result.valueForString(example);
+ example = "DATA_NOT_AVAILABLE";
+ Result enumDataNotAvailable = Result.valueForString(example);
+ example = "READ_ONLY";
+ Result enumReadOnly = Result.valueForString(example);
assertNotNull("SUCCESS returned null", enumSuccess);
assertNotNull("INVALID_DATA returned null", enumInvalidData);
@@ -115,6 +119,8 @@ public class ResultTests extends TestCase {
assertNotNull("INVALID_CERT returned null", enumInvalidCert);
assertNotNull("EXPIRED_CERT returned null", enumExpiredCert);
assertNotNull("RESUME_FAILED returned null", enumResumeFailed);
+ assertNotNull("DATA_NOT_AVAILABLE returned null", enumDataNotAvailable);
+ assertNotNull("READ_ONLY returned null", enumReadOnly);
}
/**
@@ -183,7 +189,9 @@ public class ResultTests extends TestCase {
enumTestList.add(Result.SAVED);
enumTestList.add(Result.INVALID_CERT);
enumTestList.add(Result.EXPIRED_CERT);
- enumTestList.add(Result.RESUME_FAILED);
+ enumTestList.add(Result.RESUME_FAILED);
+ enumTestList.add(Result.DATA_NOT_AVAILABLE);
+ enumTestList.add(Result.READ_ONLY);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java
new file mode 100644
index 000000000..f17f3cbd3
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/SystemCapabilityTypeTests.java
@@ -0,0 +1,115 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.enums.SystemCapabilityType}
+ */
+public class SystemCapabilityTypeTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "NAVIGATION";
+ SystemCapabilityType enumNavigation = SystemCapabilityType.valueForString(example);
+ example = "PHONE_CALL";
+ SystemCapabilityType enumPhoneCall = SystemCapabilityType.valueForString(example);
+ example = "VIDEO_STREAMING";
+ SystemCapabilityType enumVideoStreaming = SystemCapabilityType.valueForString(example);
+ example = "REMOTE_CONTROL";
+ SystemCapabilityType enumRemoteControl = SystemCapabilityType.valueForString(example);
+ example = "HMI";
+ SystemCapabilityType enumHmi = SystemCapabilityType.valueForString(example);
+ example = "DISPLAY";
+ SystemCapabilityType enumDisplay = SystemCapabilityType.valueForString(example);
+ example = "AUDIO_PASSTHROUGH";
+ SystemCapabilityType enumAudioPassThrough = SystemCapabilityType.valueForString(example);
+ example = "BUTTON";
+ SystemCapabilityType enumButton = SystemCapabilityType.valueForString(example);
+ example = "HMI_ZONE";
+ SystemCapabilityType enumHmiZone = SystemCapabilityType.valueForString(example);
+ example = "PRESET_BANK";
+ SystemCapabilityType enumPresetBank = SystemCapabilityType.valueForString(example);
+ example = "SOFTBUTTON";
+ SystemCapabilityType enumSoftButton = SystemCapabilityType.valueForString(example);
+ example = "SPEECH";
+ SystemCapabilityType enumSpeech = SystemCapabilityType.valueForString(example);
+ example = "VOICE_RECOGNITION";
+ SystemCapabilityType enumVoiceRecognition = SystemCapabilityType.valueForString(example);
+
+ assertNotNull("NAVIGATION returned null", enumNavigation);
+ assertNotNull("PHONE_CALL returned null", enumPhoneCall);
+ assertNotNull("VIDEO_STREAMING returned null", enumVideoStreaming);
+ assertNotNull("REMOTE_CONTROL returned null", enumRemoteControl);
+ assertNotNull("HMI returned null", enumHmi);
+ assertNotNull("DISPLAY returned null", enumDisplay);
+ assertNotNull("AUDIO_PASSTHROUGH returned null", enumAudioPassThrough);
+ assertNotNull("BUTTON returned null", enumButton);
+ assertNotNull("HMI_ZONE returned null", enumHmiZone);
+ assertNotNull("PRESET_BANK returned null", enumPresetBank);
+ assertNotNull("SOFTBUTTON returned null", enumSoftButton);
+ assertNotNull("SPEECH returned null", enumSpeech);
+ assertNotNull("VOICE_RECOGNITION returned null", enumVoiceRecognition);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "nAVIGATION";
+ try {
+ SystemCapabilityType temp = SystemCapabilityType.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ SystemCapabilityType temp = SystemCapabilityType.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+ /**
+ * Verifies the possible enum values of SystemCapabilityType.
+ */
+ public void testListEnum() {
+ List<SystemCapabilityType> enumValueList = Arrays.asList(SystemCapabilityType.values());
+
+ List<SystemCapabilityType> enumTestList = new ArrayList<SystemCapabilityType>();
+ enumTestList.add(SystemCapabilityType.NAVIGATION);
+ enumTestList.add(SystemCapabilityType.PHONE_CALL);
+ enumTestList.add(SystemCapabilityType.VIDEO_STREAMING);
+ enumTestList.add(SystemCapabilityType.REMOTE_CONTROL);
+ enumTestList.add(SystemCapabilityType.HMI);
+ enumTestList.add(SystemCapabilityType.DISPLAY);
+ enumTestList.add(SystemCapabilityType.AUDIO_PASSTHROUGH);
+ enumTestList.add(SystemCapabilityType.BUTTON);
+ enumTestList.add(SystemCapabilityType.HMI_ZONE);
+ enumTestList.add(SystemCapabilityType.PRESET_BANK);
+ enumTestList.add(SystemCapabilityType.SOFTBUTTON);
+ enumTestList.add(SystemCapabilityType.SPEECH);
+ enumTestList.add(SystemCapabilityType.VOICE_RECOGNITION);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TouchTypeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TouchTypeTests.java
index 06636a045..db9c417ef 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TouchTypeTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TouchTypeTests.java
@@ -1,16 +1,16 @@
package com.smartdevicelink.test.rpc.enums;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import com.smartdevicelink.proxy.rpc.enums.TouchType;
import junit.framework.TestCase;
-import com.smartdevicelink.proxy.rpc.enums.TouchType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.enums.TouchType}
+ * {@link com.smartdevicelink.proxy.rpc.enums.TouchType}
*/
public class TouchTypeTests extends TestCase {
@@ -24,10 +24,14 @@ public class TouchTypeTests extends TestCase {
TouchType enumMove = TouchType.valueForString(example);
example = "END";
TouchType enumEnd = TouchType.valueForString(example);
-
+ example = "CANCEL";
+ TouchType enumCancel = TouchType.valueForString(example);
+
+
assertNotNull("BEGIN returned null", enumBegin);
assertNotNull("MOVE returned null", enumMove);
assertNotNull("END returned null", enumEnd);
+ assertNotNull("CANCEL returned null", enumCancel);
}
/**
@@ -69,6 +73,7 @@ public class TouchTypeTests extends TestCase {
enumTestList.add(TouchType.BEGIN);
enumTestList.add(TouchType.MOVE);
enumTestList.add(TouchType.END);
+ enumTestList.add(TouchType.CANCEL);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VentilationModeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VentilationModeTests.java
new file mode 100644
index 000000000..561e66a77
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VentilationModeTests.java
@@ -0,0 +1,79 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.VentilationMode;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.enums.VentilationMode}
+ */
+public class VentilationModeTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "UPPER";
+ VentilationMode enumUpper = VentilationMode.valueForString(example);
+ example = "LOWER";
+ VentilationMode enumLower = VentilationMode.valueForString(example);
+ example = "BOTH";
+ VentilationMode enumBoth = VentilationMode.valueForString(example);
+ example = "NONE";
+ VentilationMode enumNone = VentilationMode.valueForString(example);
+
+ assertNotNull("UPPER returned null", enumUpper);
+ assertNotNull("LOWER returned null", enumLower);
+ assertNotNull("BOTH returned null", enumBoth);
+ assertNotNull("NONE returned null", enumNone);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "uPPER";
+ try {
+ VentilationMode temp = VentilationMode.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ VentilationMode temp = VentilationMode.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+ /**
+ * Verifies the possible enum values of VentilationMode.
+ */
+ public void testListEnum() {
+ List<VentilationMode> enumValueList = Arrays.asList(VentilationMode.values());
+
+ List<VentilationMode> enumTestList = new ArrayList<VentilationMode>();
+ enumTestList.add(VentilationMode.UPPER);
+ enumTestList.add(VentilationMode.LOWER);
+ enumTestList.add(VentilationMode.BOTH);
+ enumTestList.add(VentilationMode.NONE);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VideoStreamingCodecTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VideoStreamingCodecTests.java
new file mode 100644
index 000000000..b4aa8fd97
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VideoStreamingCodecTests.java
@@ -0,0 +1,79 @@
+package com.smartdevicelink.test.rpc.enums;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class VideoStreamingCodecTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "H264";
+ VideoStreamingCodec enumH264 = VideoStreamingCodec.valueForString(example);
+ example = "H265";
+ VideoStreamingCodec enumH265 = VideoStreamingCodec.valueForString(example);
+ example = "Theora";
+ VideoStreamingCodec enumTheora = VideoStreamingCodec.valueForString(example);
+ example = "VP8";
+ VideoStreamingCodec enumVP8 = VideoStreamingCodec.valueForString(example);
+ example = "VP9";
+ VideoStreamingCodec enumVP9 = VideoStreamingCodec.valueForString(example);
+
+ assertNotNull("H264 returned null", enumH264);
+ assertNotNull("H265 returned null", enumH265);
+ assertNotNull("Theora returned null", enumTheora);
+ assertNotNull("VP8 returned null", enumVP8);
+ assertNotNull("VP9 returned null", enumVP9);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "H234";
+ try {
+ VideoStreamingCodec temp = VideoStreamingCodec.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ VideoStreamingCodec temp = VideoStreamingCodec.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+
+ /**
+ * Verifies the possible enum values of TouchType.
+ */
+ public void testListEnum() {
+ List<VideoStreamingCodec> enumValueList = Arrays.asList(VideoStreamingCodec.values());
+
+ List<VideoStreamingCodec> enumTestList = new ArrayList<VideoStreamingCodec>();
+ enumTestList.add(VideoStreamingCodec.H264);
+ enumTestList.add(VideoStreamingCodec.H265);
+ enumTestList.add(VideoStreamingCodec.Theora);
+ enumTestList.add(VideoStreamingCodec.VP8);
+ enumTestList.add(VideoStreamingCodec.VP9);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VideoStreamingProtocolTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VideoStreamingProtocolTests.java
new file mode 100644
index 000000000..be50d2c30
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VideoStreamingProtocolTests.java
@@ -0,0 +1,82 @@
+package com.smartdevicelink.test.rpc.enums;
+
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class VideoStreamingProtocolTests extends TestCase {
+
+ /**
+ * Verifies that the enum values are not null upon valid assignment.
+ */
+ public void testValidEnums () {
+ String example = "RAW";
+ VideoStreamingProtocol enumRAW = VideoStreamingProtocol.valueForString(example);
+ example = "RTP";
+ VideoStreamingProtocol enumRTP = VideoStreamingProtocol.valueForString(example);
+ example = "RTSP";
+ VideoStreamingProtocol enumRTSP = VideoStreamingProtocol.valueForString(example);
+ example = "RTMP";
+ VideoStreamingProtocol enumRTMP = VideoStreamingProtocol.valueForString(example);
+ example = "WEBM";
+ VideoStreamingProtocol enumWEBM = VideoStreamingProtocol.valueForString(example);
+
+ assertNotNull("RAW returned null", enumRAW);
+ assertNotNull("RTP returned null", enumRTP);
+ assertNotNull("RTSP returned null", enumRTSP);
+ assertNotNull("RTMP returned null", enumRTMP);
+ assertNotNull("WEBM returned null", enumWEBM);
+ }
+
+ /**
+ * Verifies that an invalid assignment is null.
+ */
+ public void testInvalidEnum () {
+ String example = "RAAW";
+ try {
+ VideoStreamingProtocol temp = VideoStreamingProtocol.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (IllegalArgumentException exception) {
+ fail("Invalid enum throws IllegalArgumentException.");
+ }
+ }
+
+ /**
+ * Verifies that a null assignment is invalid.
+ */
+ public void testNullEnum () {
+ String example = null;
+ try {
+ VideoStreamingProtocol temp = VideoStreamingProtocol.valueForString(example);
+ assertNull("Result of valueForString should be null.", temp);
+ }
+ catch (NullPointerException exception) {
+ fail("Null string throws NullPointerException.");
+ }
+ }
+
+
+ /**
+ * Verifies the possible enum values of TouchType.
+ */
+ public void testListEnum() {
+ List<VideoStreamingProtocol> enumValueList = Arrays.asList(VideoStreamingProtocol.values());
+
+ List<VideoStreamingProtocol> enumTestList = new ArrayList<VideoStreamingProtocol>();
+ enumTestList.add(VideoStreamingProtocol.RAW);
+ enumTestList.add(VideoStreamingProtocol.RTP);
+ enumTestList.add(VideoStreamingProtocol.RTSP);
+ enumTestList.add(VideoStreamingProtocol.RTMP);
+ enumTestList.add(VideoStreamingProtocol.WEBM);
+
+ assertTrue("Enum value list does not match enum class list",
+ enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
+ }
+}
+
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnInteriorVehicleDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnInteriorVehicleDataTests.java
new file mode 100644
index 000000000..4fded53fe
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnInteriorVehicleDataTests.java
@@ -0,0 +1,69 @@
+package com.smartdevicelink.test.rpc.notifications;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.ModuleData;
+import com.smartdevicelink.proxy.rpc.OnInteriorVehicleData;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.OnInteriorVehicleData}
+ */
+public class OnInteriorVehicleDataTests extends BaseRpcTests{
+
+ @Override
+ protected RPCMessage createMessage(){
+ OnInteriorVehicleData msg = new OnInteriorVehicleData();
+ msg.setModuleData(Test.GENERAL_MODULEDATA);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_NOTIFICATION;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.ON_INTERIOR_VEHICLE_DATA.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(OnInteriorVehicleData.KEY_MODULE_DATA, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_MODULEDATA.getStore()));
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ModuleData moduleData = ( (OnInteriorVehicleData) msg ).getModuleData();
+
+ // Valid Tests
+ assertTrue(Test.TRUE, Validator.validateModuleData(Test.GENERAL_MODULEDATA, moduleData));
+
+ // Invalid/Null Tests
+ OnInteriorVehicleData msg = new OnInteriorVehicleData();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getModuleData());
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSdlChoiceChosenTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSdlChoiceChosenTests.java
index 2725f4eae..77d2cdb21 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSdlChoiceChosenTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnSdlChoiceChosenTests.java
@@ -14,14 +14,16 @@ import com.smartdevicelink.test.Validator;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.OnSdlChoiceChosen}
+ * {@link com.smartdevicelink.proxy.rpc.OnSdlChoiceChosen}
*/
public class OnSdlChoiceChosenTests extends BaseRpcTests{
+ SdlChoice sdlChoice;
+
@Override
protected RPCMessage createMessage(){
OnSdlChoiceChosen msg = new OnSdlChoiceChosen();
- SdlChoice sdlChoice = msg.new SdlChoice(Test.GENERAL_CHOICE);
+ sdlChoice = msg.new SdlChoice(Test.GENERAL_CHOICE);
msg.setTriggerSource(Test.GENERAL_TRIGGERSOURCE);
msg.setSdlChoice(sdlChoice);
@@ -45,7 +47,7 @@ public class OnSdlChoiceChosenTests extends BaseRpcTests{
try{
result.put(OnSdlChoiceChosen.KEY_TRIGGER_SOURCE, Test.GENERAL_TRIGGERSOURCE);
- result.put(OnSdlChoiceChosen.KEY_SDL_CHOICE, Test.JSON_CHOICE);
+ result.put(OnSdlChoiceChosen.KEY_SDL_CHOICE, sdlChoice);
}catch(JSONException e){
fail(Test.JSON_FAIL);
}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnStreamRPCTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnStreamRPCTests.java
new file mode 100644
index 000000000..58db7d8eb
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnStreamRPCTests.java
@@ -0,0 +1,76 @@
+package com.smartdevicelink.test.rpc.notifications;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.OnStreamRPC;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.Test;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class OnStreamRPCTests extends BaseRpcTests {
+ @Override
+ protected RPCMessage createMessage(){
+ OnStreamRPC msg = new OnStreamRPC();
+
+ msg.setBytesComplete(Test.GENERAL_LONG);
+ msg.setFileName(Test.GENERAL_STRING);
+ msg.setFileSize(Test.GENERAL_LONG);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_NOTIFICATION;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.ON_STREAM_RPC.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(OnStreamRPC.KEY_BYTESCOMPLETE, Test.GENERAL_LONG);
+ result.put(OnStreamRPC.KEY_FILENAME, Test.GENERAL_STRING);
+ result.put(OnStreamRPC.KEY_FILESIZE, Test.GENERAL_LONG);
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ Long bytes = ((OnStreamRPC) msg).getBytesComplete();
+ String fileName = ((OnStreamRPC) msg).getFileName();
+ Long fileSize = ((OnStreamRPC) msg).getFileSize();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_LONG, bytes);
+ assertEquals(Test.MATCH, Test.GENERAL_STRING, fileName);
+ assertEquals(Test.MATCH, Test.GENERAL_LONG, fileSize);
+
+ // Invalid/Null Tests
+ OnStreamRPC msg = new OnStreamRPC();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getBytesComplete());
+ assertNull(Test.NULL, msg.getFileName());
+ assertNull(Test.NULL, msg.getFileSize());
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnWayPointChangeTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnWayPointChangeTests.java
new file mode 100644
index 000000000..dcc02dafd
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnWayPointChangeTests.java
@@ -0,0 +1,86 @@
+package com.smartdevicelink.test.rpc.notifications;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.GetWayPointsResponse;
+import com.smartdevicelink.proxy.rpc.LocationDetails;
+import com.smartdevicelink.proxy.rpc.OnWayPointChange;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.Test;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class OnWayPointChangeTests extends BaseRpcTests {
+ @Override
+ protected RPCMessage createMessage(){
+ OnWayPointChange msg = new OnWayPointChange();
+
+ List<LocationDetails> list = new ArrayList<>();
+ list.add(Test.GENERAL_LOCATIONDETAILS);
+ list.add(Test.GENERAL_LOCATIONDETAILS);
+
+ msg.setWayPoints(list);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_NOTIFICATION;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.ON_WAY_POINT_CHANGE.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ JSONArray jsonArray = new JSONArray();
+ try {
+ jsonArray.put(JsonRPCMarshaller.serializeHashtable(Test.GENERAL_LOCATIONDETAILS.getStore()));
+ jsonArray.put(JsonRPCMarshaller.serializeHashtable(Test.GENERAL_LOCATIONDETAILS.getStore()));
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ result.put(GetWayPointsResponse.KEY_WAY_POINTS, jsonArray);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ List<LocationDetails> list = ((OnWayPointChange) msg).getWayPoints();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_LOCATIONDETAILS, list.get(0));
+ assertEquals(Test.MATCH, Test.GENERAL_LOCATIONDETAILS, list.get(1));
+
+ // Invalid/Null Tests
+ OnWayPointChange msg = new OnWayPointChange();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getWayPoints());
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ButtonPressTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ButtonPressTests.java
new file mode 100644
index 000000000..f16a3a87c
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ButtonPressTests.java
@@ -0,0 +1,113 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.ButtonPress;
+import com.smartdevicelink.proxy.rpc.enums.ButtonName;
+import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode;
+import com.smartdevicelink.proxy.rpc.enums.ModuleType;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ButtonPress}
+ */
+public class ButtonPressTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage(){
+ ButtonPress msg = new ButtonPress();
+
+ msg.setModuleType(Test.GENERAL_MODULETYPE);
+ msg.setButtonPressMode(Test.GENERAL_BUTTONPRESSMODE);
+ msg.setButtonName(Test.GENERAL_BUTTONNAME);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.BUTTON_PRESS.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(ButtonPress.KEY_MODULE_TYPE, Test.GENERAL_MODULETYPE);
+ result.put(ButtonPress.KEY_BUTTON_NAME, Test.GENERAL_BUTTONNAME);
+ result.put(ButtonPress.KEY_BUTTON_PRESS_MODE, Test.GENERAL_BUTTONPRESSMODE);
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ModuleType testModuleType = ( (ButtonPress) msg ).getModuleType();
+ ButtonName testButtonName = ( (ButtonPress) msg ).getButtonName();
+ ButtonPressMode testButtonPressMode = ( (ButtonPress) msg ).getButtonPressMode();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_MODULETYPE, testModuleType);
+ assertEquals(Test.MATCH, Test.GENERAL_BUTTONNAME, testButtonName);
+ assertEquals(Test.MATCH, Test.GENERAL_BUTTONPRESSMODE, testButtonPressMode);
+
+ // Invalid/Null Tests
+ ButtonPress msg = new ButtonPress();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getModuleType());
+ assertNull(Test.NULL, msg.getButtonName());
+ assertNull(Test.NULL, msg.getButtonPressMode());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ ButtonPress cmd = new ButtonPress(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, ButtonPress.KEY_MODULE_TYPE).toString(), cmd.getModuleType().toString());
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, ButtonPress.KEY_BUTTON_NAME).toString(), cmd.getButtonName().toString());
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, ButtonPress.KEY_BUTTON_PRESS_MODE).toString(), cmd.getButtonPressMode().toString());
+ }catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java
new file mode 100644
index 000000000..40a8d432f
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/DialNumberTests.java
@@ -0,0 +1,97 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.DialNumber;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * Created by austinkirk on 6/6/17.
+ */
+
+public class DialNumberTests extends BaseRpcTests {
+
+ private final String TEST_NUMBER = "5558675309";
+
+ @Override
+ protected RPCMessage createMessage(){
+ DialNumber msg = new DialNumber();
+
+ msg.setNumber(TEST_NUMBER);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.DIAL_NUMBER.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(DialNumber.KEY_NUMBER, TEST_NUMBER);
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ String testNumber = ((DialNumber) msg).getNumber();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, TEST_NUMBER, testNumber);
+ // Invalid/Null Tests
+ DialNumber msg = new DialNumber();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getNumber());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ DialNumber cmd = new DialNumber(hash);
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, DialNumber.KEY_NUMBER), cmd.getNumber());
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java
new file mode 100644
index 000000000..5a08d4266
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetInteriorVehicleDataTests.java
@@ -0,0 +1,105 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.GetInteriorVehicleData;
+import com.smartdevicelink.proxy.rpc.enums.ModuleType;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.GetInteriorVehicleData}
+ */
+public class GetInteriorVehicleDataTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage(){
+ GetInteriorVehicleData msg = new GetInteriorVehicleData();
+
+ msg.setModuleType(Test.GENERAL_MODULETYPE);
+ msg.setSubscribe(Test.GENERAL_BOOLEAN);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.GET_INTERIOR_VEHICLE_DATA.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(GetInteriorVehicleData.KEY_MODULE_TYPE, Test.GENERAL_MODULETYPE);
+ result.put(GetInteriorVehicleData.KEY_SUBSCRIBE, Test.GENERAL_BOOLEAN);
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ModuleType testModuleType = ( (GetInteriorVehicleData) msg ).getModuleType();
+ boolean testSubscribed = ( (GetInteriorVehicleData) msg ).getSubscribe();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_MODULETYPE, testModuleType);
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, testSubscribed);
+
+ // Invalid/Null Tests
+ GetInteriorVehicleData msg = new GetInteriorVehicleData();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getModuleType());
+ assertNull(Test.NULL, msg.getSubscribe());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ GetInteriorVehicleData cmd = new GetInteriorVehicleData(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, GetInteriorVehicleData.KEY_MODULE_TYPE).toString(), cmd.getModuleType().toString());
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, GetInteriorVehicleData.KEY_SUBSCRIBE), cmd.getSubscribe());
+ }catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java
new file mode 100644
index 000000000..78d4507da
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetSystemCapabilityTests.java
@@ -0,0 +1,95 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.GetSystemCapability;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+public class GetSystemCapabilityTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage(){
+ GetSystemCapability msg = new GetSystemCapability();
+
+ msg.setSystemCapabilityType(Test.GENERAL_SYSTEMCAPABILITYTYPE);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.GET_SYSTEM_CAPABILITY.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(GetSystemCapability.KEY_SYSTEM_CAPABILITY_TYPE, Test.GENERAL_SYSTEMCAPABILITYTYPE);
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ SystemCapabilityType testType = ( (GetSystemCapability) msg ).getSystemCapabilityType();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_SYSTEMCAPABILITYTYPE, testType);
+
+ // Invalid/Null Tests
+ GetSystemCapability msg = new GetSystemCapability();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getSystemCapabilityType());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ GetSystemCapability cmd = new GetSystemCapability(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, GetSystemCapability.KEY_SYSTEM_CAPABILITY_TYPE).toString(), cmd.getSystemCapabilityType().toString());
+ }catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java
new file mode 100644
index 000000000..bf0531685
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetWayPointsTests.java
@@ -0,0 +1,96 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.GetWayPoints;
+import com.smartdevicelink.proxy.rpc.enums.WayPointType;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * Created by austinkirk on 6/6/17.
+ */
+
+public class GetWayPointsTests extends BaseRpcTests {
+ @Override
+ protected RPCMessage createMessage(){
+ GetWayPoints msg = new GetWayPoints();
+
+ msg.setWayPointType(WayPointType.DESTINATION);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.GET_WAY_POINTS.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(GetWayPoints.KEY_WAY_POINT_TYPE, WayPointType.DESTINATION);
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ WayPointType testType = ( (GetWayPoints) msg ).getWayPointType();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, WayPointType.DESTINATION, testType);
+
+ // Invalid/Null Tests
+ GetWayPoints msg = new GetWayPoints();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getWayPointType());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ GetWayPoints cmd = new GetWayPoints(hash);
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+ assertEquals(Test.MATCH, WayPointType.valueForString(JsonUtils.readStringFromJsonObject(parameters, GetWayPoints.KEY_WAY_POINT_TYPE)), cmd.getWayPointType());
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java
new file mode 100644
index 000000000..7c3b0ed90
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SendHapticDataTests.java
@@ -0,0 +1,86 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.HapticRect;
+import com.smartdevicelink.proxy.rpc.SendHapticData;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.Test;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by brettywhite on 8/9/17.
+ */
+
+public class SendHapticDataTests extends BaseRpcTests {
+
+ private SendHapticData msg;
+
+ @Override
+ protected RPCMessage createMessage(){
+ msg = new SendHapticData();
+
+ List<HapticRect> list = new ArrayList<>();
+ list.add(Test.GENERAL_HAPTIC_RECT);
+
+ msg.setHapticRectData(list);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.SEND_HAPTIC_DATA.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ JSONArray jsonArray = new JSONArray();
+ try {
+ jsonArray.put(JsonRPCMarshaller.serializeHashtable(Test.GENERAL_HAPTIC_RECT.getStore()));
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ result.put(SendHapticData.KEY_HAPTIC_RECT_DATA, jsonArray);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ List<HapticRect> list = msg.getHapticRectData();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_HAPTIC_RECT, list.get(0));
+
+ // Invalid/Null Tests
+ SendHapticData msg = new SendHapticData();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getHapticRectData());
+ }
+
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java
new file mode 100644
index 000000000..f5ecb0d06
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SetInteriorVehicleDataTests.java
@@ -0,0 +1,102 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.ModuleData;
+import com.smartdevicelink.proxy.rpc.SetInteriorVehicleData;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.SetInteriorVehicleData}
+ */
+public class SetInteriorVehicleDataTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage(){
+ SetInteriorVehicleData msg = new SetInteriorVehicleData();
+
+ msg.setModuleData(Test.GENERAL_MODULEDATA);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.SET_INTERIOR_VEHICLE_DATA.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(SetInteriorVehicleData.KEY_MODULE_DATA, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_MODULEDATA.getStore()));
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ModuleData testModuleData = ( (SetInteriorVehicleData) msg ).getModuleData();
+
+ // Valid Tests
+ assertTrue(Test.TRUE, Validator.validateModuleData(Test.GENERAL_MODULEDATA, testModuleData));
+
+ // Invalid/Null Tests
+ SetInteriorVehicleData msg = new SetInteriorVehicleData();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getModuleData());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ SetInteriorVehicleData cmd = new SetInteriorVehicleData(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ ModuleData referenceModuleData = new ModuleData(JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(parameters, SetInteriorVehicleData.KEY_MODULE_DATA)));
+
+ assertTrue(Test.TRUE, Validator.validateModuleData(referenceModuleData, cmd.getModuleData()));
+ }catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java
index 5899d9015..9c7a681df 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/ShowTests.java
@@ -12,6 +12,7 @@ import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.rpc.Image;
+import com.smartdevicelink.proxy.rpc.MetadataTags;
import com.smartdevicelink.proxy.rpc.Show;
import com.smartdevicelink.proxy.rpc.SoftButton;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
@@ -23,12 +24,12 @@ import com.smartdevicelink.test.json.rpc.JsonFileReader;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.Show}
+ * {@link com.smartdevicelink.proxy.rpc.Show}
*/
public class ShowTests extends BaseRpcTests {
@Override
- protected RPCMessage createMessage() {
+ protected RPCMessage createMessage() {
Show msg = new Show();
msg.setMainField1(Test.GENERAL_STRING);
@@ -42,6 +43,7 @@ public class ShowTests extends BaseRpcTests {
msg.setSecondaryGraphic(Test.GENERAL_IMAGE);
msg.setCustomPresets(Test.GENERAL_STRING_LIST);
msg.setSoftButtons(Test.GENERAL_SOFTBUTTON_LIST);
+ msg.setMetadataTags(Test.GENERAL_METADATASTRUCT);
return msg;
}
@@ -66,12 +68,13 @@ public class ShowTests extends BaseRpcTests {
result.put(Show.KEY_MAIN_FIELD_3, Test.GENERAL_STRING);
result.put(Show.KEY_MAIN_FIELD_4, Test.GENERAL_STRING);
result.put(Show.KEY_STATUS_BAR, Test.GENERAL_STRING);
- result.put(Show.KEY_MEDIA_TRACK, Test.GENERAL_STRING);
+ result.put(Show.KEY_MEDIA_TRACK, Test.GENERAL_STRING);
result.put(Show.KEY_GRAPHIC, Test.JSON_IMAGE);
result.put(Show.KEY_SECONDARY_GRAPHIC, Test.JSON_IMAGE);
result.put(Show.KEY_ALIGNMENT, Test.GENERAL_TEXTALIGNMENT);
- result.put(Show.KEY_CUSTOM_PRESETS, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST));
+ result.put(Show.KEY_CUSTOM_PRESETS, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST));
result.put(Show.KEY_SOFT_BUTTONS, Test.JSON_SOFTBUTTONS);
+ result.put(Show.KEY_METADATA_TAGS, Test.GENERAL_METADATASTRUCT.serializeJSON());
} catch (JSONException e) {
fail(Test.JSON_FAIL);
}
@@ -92,6 +95,7 @@ public class ShowTests extends BaseRpcTests {
TextAlignment testAlignment = ( (Show) msg ).getAlignment();
List<SoftButton> testSoftButtons = ( (Show) msg ).getSoftButtons();
List<String> testCustomPresets = ( (Show) msg ).getCustomPresets();
+ MetadataTags testMetadata = ( (Show) msg ).getMetadataTags();
// Valid Tests
assertEquals(Test.MATCH, Test.GENERAL_STRING, testTrack);
@@ -102,6 +106,7 @@ public class ShowTests extends BaseRpcTests {
assertEquals(Test.MATCH, Test.GENERAL_STRING, testText3);
assertEquals(Test.MATCH, Test.GENERAL_STRING, testText4);
assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.size(), testCustomPresets.size());
+ assertEquals(Test.MATCH, Test.GENERAL_METADATASTRUCT, testMetadata);
assertTrue(Test.TRUE, Validator.validateSoftButtons(Test.GENERAL_SOFTBUTTON_LIST, testSoftButtons));
assertTrue(Test.TRUE, Validator.validateImage(Test.GENERAL_IMAGE, testGraphic2));
assertTrue(Test.TRUE, Validator.validateImage(Test.GENERAL_IMAGE, testGraphic1));
@@ -121,7 +126,8 @@ public class ShowTests extends BaseRpcTests {
assertNull(Test.NULL, msg.getSecondaryGraphic());
assertNull(Test.NULL, msg.getCustomPresets());
assertNull(Test.NULL, msg.getMediaTrack());
- assertNull(Test.NULL, msg.getSoftButtons());
+ assertNull(Test.NULL, msg.getSoftButtons());
+ assertNull(Test.NULL, msg.getMetadataTags());
}
/**
@@ -130,24 +136,24 @@ public class ShowTests extends BaseRpcTests {
public void testJsonConstructor () {
JSONObject commandJson = JsonFileReader.readId(this.mContext,getCommandType(), getMessageType());
assertNotNull(Test.NOT_NULL, commandJson);
-
+
try {
Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
Show cmd = new Show(hash);
-
+
JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
assertNotNull(Test.NOT_NULL, body);
-
+
// Test everything in the json body.
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
-
+
JSONObject graphic = JsonUtils.readJsonObjectFromJsonObject(parameters, Show.KEY_GRAPHIC);
Image referenceGraphic = new Image(JsonRPCMarshaller.deserializeJSONObject(graphic));
assertTrue(Test.TRUE, Validator.validateImage(referenceGraphic, cmd.getGraphic()));
-
+
List<String> customPresetsList = JsonUtils.readStringListFromJsonObject(parameters, Show.KEY_CUSTOM_PRESETS);
List<String> testPresetsList = cmd.getCustomPresets();
assertEquals(Test.MATCH, customPresetsList.size(), testPresetsList.size());
@@ -160,11 +166,12 @@ public class ShowTests extends BaseRpcTests {
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, Show.KEY_STATUS_BAR), cmd.getStatusBar());
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, Show.KEY_ALIGNMENT), cmd.getAlignment().toString());
assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, Show.KEY_MEDIA_TRACK), cmd.getMediaTrack());
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, Show.KEY_METADATA_TAGS), cmd.getMetadataTags());
JSONObject secondaryGraphic = JsonUtils.readJsonObjectFromJsonObject(parameters, Show.KEY_SECONDARY_GRAPHIC);
Image referenceSecondaryGraphic = new Image(JsonRPCMarshaller.deserializeJSONObject(secondaryGraphic));
assertTrue(Test.TRUE, Validator.validateImage(referenceSecondaryGraphic, cmd.getSecondaryGraphic()));
-
+
JSONArray softButtonArray = JsonUtils.readJsonArrayFromJsonObject(parameters, Show.KEY_SOFT_BUTTONS);
List<SoftButton> softButtonList = new ArrayList<SoftButton>();
for (int index = 0; index < softButtonArray.length(); index++) {
@@ -172,9 +179,9 @@ public class ShowTests extends BaseRpcTests {
softButtonList.add(chunk);
}
assertTrue(Test.TRUE, Validator.validateSoftButtons(softButtonList, cmd.getSoftButtons()));
-
+
} catch (JSONException e) {
fail(Test.JSON_FAIL);
- }
- }
+ }
+ }
} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java
new file mode 100644
index 000000000..06b6ee330
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeWayPointsTests.java
@@ -0,0 +1,73 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.SubscribeWayPoints;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class SubscribeWayPointsTests extends BaseRpcTests {
+ @Override
+ protected RPCMessage createMessage() {
+ return new SubscribeWayPoints();
+ }
+
+ @Override
+ protected String getMessageType() {
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType() {
+ return FunctionID.SUBSCRIBE_WAY_POINTS.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion) {
+ return new JSONObject();
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Invalid/Null Tests
+ SubscribeWayPoints msg = new SubscribeWayPoints();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ SubscribeWayPoints cmd = new SubscribeWayPoints(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java
new file mode 100644
index 000000000..ac4afbbea
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeWayPointsTests.java
@@ -0,0 +1,73 @@
+package com.smartdevicelink.test.rpc.requests;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.UnsubscribeWayPoints;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class UnsubscribeWayPointsTests extends BaseRpcTests {
+ @Override
+ protected RPCMessage createMessage() {
+ return new UnsubscribeWayPoints();
+ }
+
+ @Override
+ protected String getMessageType() {
+ return RPCMessage.KEY_REQUEST;
+ }
+
+ @Override
+ protected String getCommandType() {
+ return FunctionID.UNSUBSCRIBE_WAY_POINTS.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion) {
+ return new JSONObject();
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Invalid/Null Tests
+ UnsubscribeWayPoints msg = new UnsubscribeWayPoints();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ UnsubscribeWayPoints cmd = new UnsubscribeWayPoints(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+ } catch (JSONException e) {
+ fail(Test.JSON_FAIL);
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java
new file mode 100644
index 000000000..64f5b0c75
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ButtonPressResponseTest.java
@@ -0,0 +1,74 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.ButtonPressResponse;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.ButtonPressResponse}
+ */
+public class ButtonPressResponseTest extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage(){
+ return new ButtonPressResponse();
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.BUTTON_PRESS.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ return new JSONObject();
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Invalid/Null Tests
+ ButtonPressResponse msg = new ButtonPressResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ ButtonPressResponse cmd = new ButtonPressResponse(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java
new file mode 100644
index 000000000..bf625f19a
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/DialNumberResponseTests.java
@@ -0,0 +1,74 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.DialNumberResponse;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * Created by austinkirk on 6/6/17.
+ */
+
+public class DialNumberResponseTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage() {
+ return new DialNumberResponse();
+ }
+
+ @Override
+ protected String getMessageType() {
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType() {
+ return FunctionID.DIAL_NUMBER.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion) {
+ return new JSONObject();
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Invalid/Null Tests
+ DialNumberResponse msg = new DialNumberResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ DialNumberResponse cmd = new DialNumberResponse(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java
new file mode 100644
index 000000000..c76388c69
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetInteriorVehicleDataResponseTests.java
@@ -0,0 +1,110 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.ModuleData;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.GetInteriorVehicleDataResponse}
+ */
+public class GetInteriorVehicleDataResponseTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage(){
+
+ GetInteriorVehicleDataResponse msg = new GetInteriorVehicleDataResponse();
+
+ msg.setIsSubscribed(Test.GENERAL_BOOLEAN);
+ msg.setModuleData(Test.GENERAL_MODULEDATA);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.GET_INTERIOR_VEHICLE_DATA.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(GetInteriorVehicleDataResponse.KEY_IS_SUBSCRIBED, Test.GENERAL_BOOLEAN);
+ result.put(GetInteriorVehicleDataResponse.KEY_MODULE_DATA, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_MODULEDATA.getStore()));
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ boolean testIsSubscribed = ( (GetInteriorVehicleDataResponse) msg ).getIsSubscribed();
+ ModuleData testModuleData = ( (GetInteriorVehicleDataResponse) msg ).getModuleData();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_BOOLEAN, testIsSubscribed);
+ assertTrue(Test.TRUE, Validator.validateModuleData(Test.GENERAL_MODULEDATA, testModuleData));
+
+ // Invalid/Null Tests
+ GetInteriorVehicleDataResponse msg = new GetInteriorVehicleDataResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getIsSubscribed());
+ assertNull(Test.NULL, msg.getModuleData());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ GetInteriorVehicleDataResponse cmd = new GetInteriorVehicleDataResponse (hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ ModuleData testModuleData = new ModuleData(JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(parameters, GetInteriorVehicleDataResponse.KEY_MODULE_DATA)));
+ ModuleData cmdModuleData = cmd.getModuleData();
+
+ assertTrue(Test.TRUE, Validator.validateModuleData(testModuleData, cmdModuleData) );
+ assertEquals(Test.MATCH, JsonUtils.readObjectFromJsonObject(parameters, GetInteriorVehicleDataResponse.KEY_IS_SUBSCRIBED), cmd.getIsSubscribed());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java
new file mode 100644
index 000000000..b9fd85a8e
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetSystemCapabilityResponseTests.java
@@ -0,0 +1,97 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse;
+import com.smartdevicelink.proxy.rpc.SystemCapability;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+public class GetSystemCapabilityResponseTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage(){
+ GetSystemCapabilityResponse msg = new GetSystemCapabilityResponse();
+
+ msg.setSystemCapability(Test.GENERAL_SYSTEMCAPABILITY);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.GET_SYSTEM_CAPABILITY.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(GetSystemCapabilityResponse.KEY_SYSTEM_CAPABILITY, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_SYSTEMCAPABILITY.getStore()));
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ SystemCapability testCapability = ( (GetSystemCapabilityResponse) msg ).getSystemCapability();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, Test.GENERAL_SYSTEMCAPABILITY.getSystemCapabilityType(), testCapability.getSystemCapabilityType());
+
+ // Invalid/Null Tests
+ GetSystemCapabilityResponse msg = new GetSystemCapabilityResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getSystemCapability());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ GetSystemCapabilityResponse cmd = new GetSystemCapabilityResponse(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ SystemCapability testCapability = new SystemCapability(JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(parameters, GetSystemCapabilityResponse.KEY_SYSTEM_CAPABILITY)));
+ SystemCapability cmdCapability = cmd.getSystemCapability();
+ assertEquals(Test.MATCH, testCapability.getSystemCapabilityType(), cmdCapability.getSystemCapabilityType());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java
new file mode 100644
index 000000000..57d8499df
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetWayPointsResponseTests.java
@@ -0,0 +1,123 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.GetWayPointsResponse;
+import com.smartdevicelink.proxy.rpc.LocationDetails;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Created by austinkirk on 6/6/17.
+ */
+
+public class GetWayPointsResponseTests extends BaseRpcTests {
+ List<LocationDetails> waypoints = new ArrayList<LocationDetails>();
+
+ @Override
+ protected RPCMessage createMessage() {
+
+ waypoints.add(Test.GENERAL_LOCATIONDETAILS);
+ waypoints.add(Test.GENERAL_LOCATIONDETAILS);
+
+ GetWayPointsResponse getWayPointsResponse = new GetWayPointsResponse();
+ getWayPointsResponse.setWayPoints(waypoints);
+
+ return getWayPointsResponse;
+ }
+
+ @Override
+ protected String getMessageType() {
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType() {
+ return FunctionID.GET_WAY_POINTS.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion) {
+ JSONObject result = new JSONObject();
+
+ JSONArray jsonArray = new JSONArray();
+ try {
+ jsonArray.put(JsonRPCMarshaller.serializeHashtable(Test.GENERAL_LOCATIONDETAILS.getStore()));
+ jsonArray.put(JsonRPCMarshaller.serializeHashtable(Test.GENERAL_LOCATIONDETAILS.getStore()));
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ result.put(GetWayPointsResponse.KEY_WAY_POINTS, jsonArray);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+
+ // Test Values
+ List<LocationDetails> testWPs = ( (GetWayPointsResponse) msg ).getWayPoints();
+
+ // Valid Tests
+ assertEquals(Test.MATCH, waypoints, testWPs);
+
+ // Invalid/Null Tests
+ GetWayPointsResponse msg = new GetWayPointsResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getWayPoints());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ GetWayPointsResponse cmd = new GetWayPointsResponse(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ JSONArray locArray = JsonUtils.readJsonArrayFromJsonObject(parameters, GetWayPointsResponse.KEY_WAY_POINTS);
+ List<LocationDetails> locationList = new ArrayList<LocationDetails>();
+ for (int index = 0; index < locArray.length(); index++) {
+ LocationDetails det = new LocationDetails(JsonRPCMarshaller.deserializeJSONObject( (JSONObject) locArray.get(index)));
+ locationList.add(det);
+ }
+ List<LocationDetails> dets = cmd.getWayPoints();
+ assertEquals(Test.MATCH, locationList.size(), dets.size());
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java
new file mode 100644
index 000000000..c25685157
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SetInteriorVehicleDataResponseTests.java
@@ -0,0 +1,104 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.ModuleData;
+import com.smartdevicelink.proxy.rpc.SetInteriorVehicleDataResponse;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.Validator;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * This is a unit test class for the SmartDeviceLink library project class :
+ * {@link com.smartdevicelink.rpc.SetInteriorVehicleDataResponse}
+ */
+public class SetInteriorVehicleDataResponseTests extends BaseRpcTests {
+
+ @Override
+ protected RPCMessage createMessage(){
+
+ SetInteriorVehicleDataResponse msg = new SetInteriorVehicleDataResponse();
+
+ msg.setModuleData(Test.GENERAL_MODULEDATA);
+
+ return msg;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.SET_INTERIOR_VEHICLE_DATA.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try{
+ result.put(SetInteriorVehicleDataResponse.KEY_MODULE_DATA, JsonRPCMarshaller.serializeHashtable(Test.GENERAL_MODULEDATA.getStore()));
+ }catch(JSONException e){
+ fail(Test.JSON_FAIL);
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Test Values
+ ModuleData testModuleData = ( (SetInteriorVehicleDataResponse) msg ).getModuleData();
+
+ // Valid Tests
+ assertTrue(Test.TRUE, Validator.validateModuleData(Test.GENERAL_MODULEDATA, testModuleData));
+
+ // Invalid/Null Tests
+ SetInteriorVehicleDataResponse msg = new SetInteriorVehicleDataResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+
+ assertNull(Test.NULL, msg.getModuleData());
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ SetInteriorVehicleDataResponse cmd = new SetInteriorVehicleDataResponse (hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+
+ ModuleData testModuleData = new ModuleData(JsonRPCMarshaller.deserializeJSONObject((JSONObject) JsonUtils.readObjectFromJsonObject(parameters, SetInteriorVehicleDataResponse.KEY_MODULE_DATA)));
+ ModuleData cmdModuleData = cmd.getModuleData();
+
+ assertTrue(Test.TRUE, Validator.validateModuleData(testModuleData, cmdModuleData) );
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java
index b012d1944..301e330e7 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java
@@ -16,7 +16,7 @@ import com.smartdevicelink.test.json.rpc.JsonFileReader;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.rpc.ShowResponse}
+ * {@link com.smartdevicelink.proxy.rpc.ShowResponse}
*/
public class ShowResponseTest extends BaseRpcTests {
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/StreamRPCResponseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/StreamRPCResponseTests.java
new file mode 100644
index 000000000..47801ea90
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/StreamRPCResponseTests.java
@@ -0,0 +1,89 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.StreamRPCResponse;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class StreamRPCResponseTests extends BaseRpcTests {
+ @Override
+ protected RPCMessage createMessage(){
+ StreamRPCResponse response = new StreamRPCResponse();
+ response.setFileSize((Long) Test.GENERAL_LONG);
+ response.setFileName(Test.GENERAL_STRING);
+ return response;
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.STREAM_RPC.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ JSONObject result = new JSONObject();
+
+ try {
+ result.put(StreamRPCResponse.KEY_FILESIZE, (Long) Test.GENERAL_LONG);
+ result.put(StreamRPCResponse.KEY_FILENAME, Test.GENERAL_STRING);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Invalid/Null Tests
+ StreamRPCResponse msg = new StreamRPCResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ StreamRPCResponse cmd = new StreamRPCResponse(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+
+ JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS);
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, StreamRPCResponse.KEY_FILENAME), cmd.getFileName());
+ assertEquals(Test.MATCH, JsonUtils.readLongFromJsonObject(parameters, StreamRPCResponse.KEY_FILESIZE), cmd.getFileSize());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java
new file mode 100644
index 000000000..a43220dce
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeWaypointsResponseTests.java
@@ -0,0 +1,73 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.SubscribeWayPointsResponse;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class SubscribeWaypointsResponseTests extends BaseRpcTests {
+ @Override
+ protected RPCMessage createMessage(){
+ return new SubscribeWayPointsResponse();
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.SUBSCRIBE_WAY_POINTS.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ return new JSONObject();
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Invalid/Null Tests
+ SubscribeWayPointsResponse msg = new SubscribeWayPointsResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ SubscribeWayPointsResponse cmd = new SubscribeWayPointsResponse(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java
new file mode 100644
index 000000000..b8b69be60
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeWayPointsResponseTests.java
@@ -0,0 +1,73 @@
+package com.smartdevicelink.test.rpc.responses;
+
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCMessage;
+import com.smartdevicelink.proxy.rpc.UnsubscribeWayPointsResponse;
+import com.smartdevicelink.test.BaseRpcTests;
+import com.smartdevicelink.test.JsonUtils;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.test.json.rpc.JsonFileReader;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+
+/**
+ * Created by austinkirk on 6/7/17.
+ */
+
+public class UnsubscribeWayPointsResponseTests extends BaseRpcTests{
+ @Override
+ protected RPCMessage createMessage(){
+ return new UnsubscribeWayPointsResponse();
+ }
+
+ @Override
+ protected String getMessageType(){
+ return RPCMessage.KEY_RESPONSE;
+ }
+
+ @Override
+ protected String getCommandType(){
+ return FunctionID.UNSUBSCRIBE_WAY_POINTS.toString();
+ }
+
+ @Override
+ protected JSONObject getExpectedParameters(int sdlVersion){
+ return new JSONObject();
+ }
+
+ /**
+ * Tests the expected values of the RPC message.
+ */
+ public void testRpcValues () {
+ // Invalid/Null Tests
+ UnsubscribeWayPointsResponse msg = new UnsubscribeWayPointsResponse();
+ assertNotNull(Test.NOT_NULL, msg);
+ testNullBase(msg);
+ }
+
+ /**
+ * Tests a valid JSON construction of this RPC message.
+ */
+ public void testJsonConstructor () {
+ JSONObject commandJson = JsonFileReader.readId(this.mContext, getCommandType(), getMessageType());
+ assertNotNull(Test.NOT_NULL, commandJson);
+
+ try {
+ Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson);
+ UnsubscribeWayPointsResponse cmd = new UnsubscribeWayPointsResponse(hash);
+
+ JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType());
+ assertNotNull(Test.NOT_NULL, body);
+
+ // Test everything in the json body.
+ assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName());
+ assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID());
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java
index 56a482804..2bf6136fa 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/security/SdlSecurityBaseTest.java
@@ -74,7 +74,7 @@ public class SdlSecurityBaseTest extends AndroidTestCase {
}
@Override
public void onProtocolSessionStartedNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
+ byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
}
@Override
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java
index 6c5f663ba..c74e8ab84 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/AbstractPacketizerTests.java
@@ -1,10 +1,12 @@
package com.smartdevicelink.test.streaming;
import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
+import java.util.List;
import junit.framework.TestCase;
@@ -42,30 +44,27 @@ public class AbstractPacketizerTests extends TestCase {
MockPacketizer testPacketizer1 = null;
MockPacketizer testPacketizer2 = null;
MockPacketizer testPacketizer3 = null;
- MockPacketizer testPacketizer4 = null;
IStreamListener testListener = new MockStreamListener();
-
try {
-
- URL url = new URL("ftp://mirror.csclub.uwaterloo.ca/index.html");
- URLConnection urlConnection = url.openConnection();
- testInputStream = new BufferedInputStream(urlConnection.getInputStream());
-
+ testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes()));
MockInterfaceBroker _interfaceBroker = new MockInterfaceBroker();
BaseTransportConfig _transportConfig = new BTTransportConfig(true);
-
testSdlSession = SdlSession.createSession(testWiproVersion,_interfaceBroker, _transportConfig);
-
testPacketizer1 = new MockPacketizer(testListener, testInputStream, testSessionType, testSessionId, testSdlSession);
testPacketizer2 = new MockPacketizer(null, null, null, testSessionId, testSdlSession);
testPacketizer3 = new MockPacketizer(testListener, testInputStream, testRpcRequest, testSessionType, testSessionId, testWiproVersion, testSdlSession);
- testPacketizer4 = new MockPacketizer(null, null, null, null, testSessionId, testWiproVersion, null);
+ try {
+ new MockPacketizer(null, null, null, null, testSessionId, testWiproVersion, null);
+ fail("Exception should be thrown");
+ }catch(Exception e) {
+ assertTrue(e instanceof IllegalArgumentException);
+ }
+
// Valid Tests
assertNotNull(Test.NOT_NULL, testPacketizer1);
assertNotNull(Test.NOT_NULL, testPacketizer2);
assertNotNull(Test.NOT_NULL, testPacketizer3);
- assertNotNull(Test.NOT_NULL, testPacketizer4);
assertEquals(Test.MATCH, testListener, testPacketizer1.getListener());
assertEquals(Test.MATCH, testInputStream, testPacketizer1.getInputStream());
@@ -83,100 +82,11 @@ public class AbstractPacketizerTests extends TestCase {
assertNull(Test.NULL, testPacketizer2.getListener());
assertNull(Test.NULL, testPacketizer2.getInputStream());
assertNull(Test.NULL, testPacketizer2.getSessionType());
- assertNull(Test.NULL, testPacketizer4.getListener());
- assertNull(Test.NULL, testPacketizer4.getInputStream());
- assertNull(Test.NULL, testPacketizer4.getSessionType());
- assertNull(Test.NULL, testPacketizer4.getRPCRequest());
- assertNull(Test.NULL, testPacketizer4.getSdlSession());
} catch (IOException e) {
+ e.printStackTrace();
fail("IOException was thrown.");
}
}
}
-/**
- * This is a mock class for testing the following :
- * {@link com.smartdevicelink.streaming.AbstractPacketizer}
- */
-class MockStreamListener implements IStreamListener {
- public MockStreamListener () { }
- @Override public void sendStreamPacket(ProtocolMessage pm) { }
-}
-
-/**
- * This is a mock class for testing the following :
- * {@link com.smartdevicelink.streaming.AbstractPacketizer}
- */
-class MockInterfaceBroker implements ISdlConnectionListener {
- public MockInterfaceBroker () { }
- @Override
- public void onTransportDisconnected(String info) {
-
- }
- @Override
- public void onTransportError(String info, Exception e) {
-
- }
- @Override
- public void onProtocolMessageReceived(ProtocolMessage msg) {
-
- }
- @Override
- public void onProtocolSessionStartedNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
-
- }
- @Override
- public void onProtocolSessionStarted(SessionType sessionType,
- byte sessionID, byte version, String correlationID, int hashID,
- boolean isEncrypted) {
-
- }
- @Override
- public void onProtocolSessionEnded(SessionType sessionType, byte sessionID,
- String correlationID) {
-
- }
- @Override
- public void onProtocolSessionEndedNACKed(SessionType sessionType,
- byte sessionID, String correlationID) {
-
- }
- @Override
- public void onProtocolError(String info, Exception e) {
-
- }
- @Override
- public void onHeartbeatTimedOut(byte sessionID) {
-
- }
- @Override
- public void onProtocolServiceDataACK(SessionType sessionType, int dataSize,
- byte sessionID) {
-
- }
-}
-
-/**
- * This is a mock class for testing the following :
- * {@link com.smartdevicelink.streaming.AbstractPacketizer}
- */
-class MockPacketizer extends AbstractPacketizer {
- public MockPacketizer (IStreamListener l, InputStream i, SessionType s, byte sid, SdlSession sdlsession) throws IOException { super (l, i, s, sid, sdlsession); }
- public MockPacketizer (IStreamListener l, InputStream i, RPCRequest r, SessionType s, byte sid, byte w, SdlSession sdlsession) throws IOException { super (l, i, r, s, sid, w, sdlsession); }
-
- @Override public void start() throws IOException { }
- @Override public void stop() { }
-
- public IStreamListener getListener () { return _streamListener; }
- public InputStream getInputStream () { return is; }
- public SessionType getSessionType () { return _serviceType; }
- public SdlSession getSdlSession () { return _session; }
- public byte getSessionId () { return _rpcSessionID; }
- public RPCRequest getRPCRequest () { return _request; }
- public byte getWiproVersion () { return _wiproVersion; }
-
- @Override public void pause() { }
- @Override public void resume() { }
-} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java
new file mode 100644
index 000000000..86dbd7b81
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockInterfaceBroker.java
@@ -0,0 +1,61 @@
+package com.smartdevicelink.test.streaming;
+
+import com.smartdevicelink.SdlConnection.ISdlConnectionListener;
+import com.smartdevicelink.protocol.ProtocolMessage;
+import com.smartdevicelink.protocol.enums.SessionType;
+
+import java.util.List;
+
+/**
+ * This is a mock class for testing the following :
+ * {@link com.smartdevicelink.streaming.AbstractPacketizer}
+ */
+public class MockInterfaceBroker implements ISdlConnectionListener {
+ public MockInterfaceBroker () { }
+ @Override
+ public void onTransportDisconnected(String info) {
+
+ }
+ @Override
+ public void onTransportError(String info, Exception e) {
+
+ }
+ @Override
+ public void onProtocolMessageReceived(ProtocolMessage msg) {
+
+ }
+ @Override
+ public void onProtocolSessionStartedNACKed(SessionType sessionType,
+ byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
+
+ }
+ @Override
+ public void onProtocolSessionStarted(SessionType sessionType,
+ byte sessionID, byte version, String correlationID, int hashID,
+ boolean isEncrypted) {
+
+ }
+ @Override
+ public void onProtocolSessionEnded(SessionType sessionType, byte sessionID,
+ String correlationID) {
+
+ }
+ @Override
+ public void onProtocolSessionEndedNACKed(SessionType sessionType,
+ byte sessionID, String correlationID) {
+
+ }
+ @Override
+ public void onProtocolError(String info, Exception e) {
+
+ }
+ @Override
+ public void onHeartbeatTimedOut(byte sessionID) {
+
+ }
+ @Override
+ public void onProtocolServiceDataACK(SessionType sessionType, int dataSize,
+ byte sessionID) {
+
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java
new file mode 100644
index 000000000..d32a204a6
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockPacketizer.java
@@ -0,0 +1,33 @@
+package com.smartdevicelink.test.streaming;
+
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.streaming.AbstractPacketizer;
+import com.smartdevicelink.streaming.IStreamListener;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This is a mock class for testing the following :
+ * {@link com.smartdevicelink.streaming.AbstractPacketizer}
+ */
+public class MockPacketizer extends AbstractPacketizer {
+ public MockPacketizer (IStreamListener l, InputStream i, SessionType s, byte sid, SdlSession sdlsession) throws IOException { super (l, i, s, sid, sdlsession); }
+ public MockPacketizer (IStreamListener l, InputStream i, RPCRequest r, SessionType s, byte sid, byte w, SdlSession sdlsession) throws IOException { super (l, i, r, s, sid, w, sdlsession); }
+
+ @Override public void start() throws IOException { }
+ @Override public void stop() { }
+
+ public IStreamListener getListener () { return _streamListener; }
+ public InputStream getInputStream () { return is; }
+ public SessionType getSessionType () { return _serviceType; }
+ public SdlSession getSdlSession () { return _session; }
+ public byte getSessionId () { return _rpcSessionID; }
+ public RPCRequest getRPCRequest () { return _request; }
+ public byte getWiproVersion () { return _wiproVersion; }
+
+ @Override public void pause() { }
+ @Override public void resume() { }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockStreamListener.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockStreamListener.java
new file mode 100644
index 000000000..0081c65ea
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/MockStreamListener.java
@@ -0,0 +1,13 @@
+package com.smartdevicelink.test.streaming;
+
+import com.smartdevicelink.protocol.ProtocolMessage;
+import com.smartdevicelink.streaming.IStreamListener;
+
+/**
+ * This is a mock class for testing the following :
+ * {@link com.smartdevicelink.streaming.AbstractPacketizer}
+ */
+public class MockStreamListener implements IStreamListener {
+ public MockStreamListener () { }
+ @Override public void sendStreamPacket(ProtocolMessage pm) { }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java
index 2f4661aa8..5f5bd6d2b 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamPacketizerTests.java
@@ -1,13 +1,19 @@
package com.smartdevicelink.test.streaming;
import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
import com.smartdevicelink.streaming.IStreamListener;
import com.smartdevicelink.streaming.StreamPacketizer;
import com.smartdevicelink.test.Test;
@@ -21,7 +27,96 @@ import junit.framework.TestCase;
* {@link com.smartdevicelink.streaming.StreamPacketizer}
*/
public class StreamPacketizerTests extends TestCase {
-
+
+ private static final byte WIPRO_VERSION = 0x0B;
+ private static final byte SESSION_ID = 0x0A;
+
+ private final byte[][] SAMPLE_H264_VIDEO_STREAM = {
+ // one byte array represents a frame
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x67, 0x42, (byte)0xC0, 0x0A, (byte)0xA6, 0x11, 0x11, (byte)0xE8,
+ 0x40, 0x00, 0x00, (byte)0xFA, 0x40, 0x00, 0x3A, (byte)0x98,
+ 0x23, (byte)0xC4, (byte)0x89, (byte)0x84, 0x60,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x68, (byte)0xC8, 0x42, 0x0F, 0x13, 0x20,
+ 0x00, 0x00, 0x01,
+ 0x65, (byte)0x88, (byte)0x82, 0x07, 0x67, 0x39, 0x31, 0x40,
+ 0x00, 0x5E, 0x0A, (byte)0xFB, (byte)0xEF, (byte)0xAE, (byte)0xBA, (byte)0xEB,
+ (byte)0xAE, (byte)0xBA, (byte)0xEB, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x1C, 0x0E, (byte)0xCE, 0x71, (byte)0xB0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x2A, 0x03, (byte)0xB3, (byte)0x9C, 0x6C},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x3B, 0x03, (byte)0xB3, (byte)0x9C, 0x6C},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x49, 0x00, (byte)0xEC, (byte)0xE7, 0x1B},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x59, 0x40, (byte)0xEC, (byte)0xE7, 0x1B},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x69, (byte)0x80, (byte)0xEC, (byte)0xE7, 0x1B},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x79, (byte)0xC0, (byte)0xEC, (byte)0xE7, 0x1B},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, (byte)0x88, (byte)0x80, 0x3B, 0x39, (byte)0xC6, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, (byte)0x98, (byte)0x90, 0x3B, 0x39, (byte)0xC6, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, (byte)0xA8, (byte)0xA0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, (byte)0xB8, (byte)0xB0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, (byte)0xC8, (byte)0xC0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, (byte)0xD8, (byte)0xD0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, (byte)0xE8, (byte)0xE0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, (byte)0xF8, (byte)0xF0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, 0x00, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, 0x10, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, 0x20, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, 0x30, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, 0x40, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, 0x50, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, 0x60, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, 0x70, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, (byte)0x80, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, (byte)0x90, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, (byte)0xA0, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, (byte)0xB0, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, (byte)0xC0, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9B, (byte)0xD0, 0x1D, (byte)0x9C, (byte)0xE3, 0x60},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x67, 0x42, (byte)0xC0, 0x0A, (byte)0xA6, 0x11, 0x11, (byte)0xE8,
+ 0x40, 0x00, 0x00, (byte)0xFA, 0x40, 0x00, 0x3A, (byte)0x98,
+ 0x23, (byte)0xC4, (byte)0x89, (byte)0x84, 0x60,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x68, (byte)0xC8, 0x42, 0x0F, 0x13, 0x20,
+ 0x00, 0x00, 0x01,
+ 0x65, (byte)0x88, (byte)0x81, 0x00, (byte)0x8E, 0x73, (byte)0x93, 0x14,
+ 0x00, 0x06, (byte)0xA4, 0x2F, (byte)0xBE, (byte)0xFA, (byte)0xEB, (byte)0xAE,
+ (byte)0xBA, (byte)0xEB, (byte)0xAE, (byte)0xBC},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x1C, 0x0D, (byte)0xCE, 0x71, (byte)0xB0},
+ new byte[]{0x00, 0x00, 0x00, 0x01,
+ 0x41, (byte)0x9A, 0x2A, 0x03, 0x33, (byte)0x9C, 0x6C},
+ };
+
/**
* This is a unit test for the following methods :
* {@link com.smartdevicelink.streaming.StreamPacketizer#StreamPacketizer(IStreamListener, InputStream, SessionType, byte)}
@@ -36,14 +131,9 @@ public class StreamPacketizerTests extends TestCase {
IStreamListener testListener = new MockStreamListener();
MockInterfaceBroker _interfaceBroker = new MockInterfaceBroker();
BaseTransportConfig _transportConfig = new BTTransportConfig(true);
-
SdlSession testSdlSession = SdlSession.createSession(testWiproVersion,_interfaceBroker, _transportConfig);
-
- try {
- URL url = new URL("ftp://mirror.csclub.uwaterloo.ca/index.html");
- URLConnection urlConnection = url.openConnection();
- testInputStream = new BufferedInputStream(urlConnection.getInputStream());
-
+ try {
+ testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes()));
StreamPacketizer testStreamPacketizer = new StreamPacketizer(testListener, testInputStream, testSessionType, testSessionId, testSdlSession);
assertNotNull(Test.NOT_NULL, testStreamPacketizer);
@@ -53,4 +143,369 @@ public class StreamPacketizerTests extends TestCase {
fail("IOException was thrown.");
}
}
+
+ /**
+ * Test for {@link com.smartdevicelink.streaming.StreamPacketizer#sendFrame(byte[], int, int, long)}
+ */
+ public void testSendFrameInterfaceWithArray() {
+ StreamReceiver mockReceiver = new StreamReceiver();
+ SdlSession session = createTestSession();
+ StreamPacketizer packetizer = null;
+ try {
+ packetizer = new StreamPacketizer(mockReceiver, null, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithArray(SAMPLE_H264_VIDEO_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertTrue(mockReceiver.verify(SAMPLE_H264_VIDEO_STREAM));
+ }
+
+ /**
+ * Test for {@link com.smartdevicelink.streaming.StreamPacketizer#sendFrame(byte[], int, int, long)}
+ * with offset parameter
+ */
+ public void testSendFrameInterfaceWithArrayOffset() {
+ StreamReceiver mockReceiver = new StreamReceiver();
+ SdlSession session = createTestSession();
+ StreamPacketizer packetizer = null;
+ try {
+ packetizer = new StreamPacketizer(mockReceiver, null, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithArrayOffset(SAMPLE_H264_VIDEO_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertTrue(mockReceiver.verify(SAMPLE_H264_VIDEO_STREAM));
+ }
+
+ /**
+ * Test for {@link com.smartdevicelink.streaming.StreamPacketizer#sendFrame(ByteBuffer, long)}
+ */
+ public void testSendFrameInterfaceWithByteBuffer() {
+ StreamReceiver mockReceiver = new StreamReceiver();
+ SdlSession session = createTestSession();
+ StreamPacketizer packetizer = null;
+ try {
+ packetizer = new StreamPacketizer(mockReceiver, null, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithByteBuffer(SAMPLE_H264_VIDEO_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertTrue(mockReceiver.verify(SAMPLE_H264_VIDEO_STREAM));
+ }
+
+ /**
+ * Test for {@link com.smartdevicelink.streaming.StreamPacketizer#sendFrame(ByteBuffer, long)}
+ * with direct ByteBuffer
+ */
+ public void testSendFrameInterfaceWithDirectByteBuffer() {
+ StreamReceiver mockReceiver = new StreamReceiver();
+ SdlSession session = createTestSession();
+ StreamPacketizer packetizer = null;
+ try {
+ packetizer = new StreamPacketizer(mockReceiver, null, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithDirectByteBuffer(SAMPLE_H264_VIDEO_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertTrue(mockReceiver.verify(SAMPLE_H264_VIDEO_STREAM));
+ }
+
+ /**
+ * Test for {@link com.smartdevicelink.streaming.StreamPacketizer#sendAudio(byte[], int, int, long)}
+ */
+ public void testSendAudioInterfaceWithArray() {
+ // assume 100 data of 16kHz / 16bits audio for 10 msecs
+ int dataCount = 100;
+ byte[][] sampleAudio = new byte[dataCount][];
+ for (int i = 0; i < dataCount; i++) {
+ sampleAudio[i] = new byte[4 * 160];
+ Arrays.fill(sampleAudio[i], (byte)0);
+ }
+
+ StreamReceiver mockReceiver = new StreamReceiver();
+ SdlSession session = createTestSession();
+ StreamPacketizer packetizer = null;
+ try {
+ packetizer = new StreamPacketizer(mockReceiver, null, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithArray(sampleAudio);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertTrue(mockReceiver.verify(sampleAudio));
+ }
+
+ /**
+ * Test for {@link com.smartdevicelink.streaming.StreamPacketizer#sendAudio(byte[], int, int, long)}
+ */
+ public void testSendAudioInterfaceWithArrayOffset() {
+ // assume 100 data of 16kHz / 16bits audio for 10 msecs
+ int dataCount = 100;
+ byte[][] sampleAudio = new byte[dataCount][];
+ for (int i = 0; i < dataCount; i++) {
+ sampleAudio[i] = new byte[4 * 160];
+ Arrays.fill(sampleAudio[i], (byte)0);
+ }
+
+ StreamReceiver mockReceiver = new StreamReceiver();
+ SdlSession session = createTestSession();
+ StreamPacketizer packetizer = null;
+ try {
+ packetizer = new StreamPacketizer(mockReceiver, null, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithArrayOffset(sampleAudio);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertTrue(mockReceiver.verify(sampleAudio));
+ }
+
+ /**
+ * Test for {@link com.smartdevicelink.streaming.StreamPacketizer#sendAudio(ByteBuffer, long)}
+ */
+ public void testSendAudioInterfaceWithByteBuffer() {
+ // assume 100 data of 16kHz / 16bits audio for 10 msecs
+ int dataCount = 100;
+ byte[][] sampleAudio = new byte[dataCount][];
+ for (int i = 0; i < dataCount; i++) {
+ sampleAudio[i] = new byte[4 * 160];
+ Arrays.fill(sampleAudio[i], (byte)0);
+ }
+
+ StreamReceiver mockReceiver = new StreamReceiver();
+ SdlSession session = createTestSession();
+ StreamPacketizer packetizer = null;
+ try {
+ packetizer = new StreamPacketizer(mockReceiver, null, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithByteBuffer(sampleAudio);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertTrue(mockReceiver.verify(sampleAudio));
+ }
+
+ /**
+ * Test for {@link com.smartdevicelink.streaming.StreamPacketizer#sendAudio(ByteBuffer, long)}
+ * with direct ByteBuffer
+ */
+ public void testSendAudioInterfaceWithDirectByteBuffer() {
+ // assume 100 data of 16kHz / 16bits audio for 10 msecs
+ int dataCount = 100;
+ byte[][] sampleAudio = new byte[dataCount][];
+ for (int i = 0; i < dataCount; i++) {
+ sampleAudio[i] = new byte[4 * 160];
+ Arrays.fill(sampleAudio[i], (byte)0);
+ }
+
+ StreamReceiver mockReceiver = new StreamReceiver();
+ SdlSession session = createTestSession();
+ StreamPacketizer packetizer = null;
+ try {
+ packetizer = new StreamPacketizer(mockReceiver, null, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithDirectByteBuffer(sampleAudio);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertTrue(mockReceiver.verify(sampleAudio));
+ }
+
+
+ private SdlSession createTestSession() {
+ return SdlSession.createSession(WIPRO_VERSION, new MockInterfaceBroker(), new BTTransportConfig(true));
+ }
+
+ private class StreamReceiver implements IStreamListener {
+ private ByteArrayOutputStream mReceiveBuffer;
+
+ StreamReceiver() {
+ mReceiveBuffer = new ByteArrayOutputStream();
+ }
+
+ @Override
+ public void sendStreamPacket(ProtocolMessage pm) {
+ try {
+ mReceiveBuffer.write(pm.getData());
+ } catch (IOException e) {
+ fail();
+ }
+ }
+
+ boolean verify(byte[][] expectedStream) {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ for (byte[] frame : expectedStream) {
+ try {
+ buffer.write(frame);
+ } catch (IOException e) {
+ fail();
+ }
+ }
+ boolean result = Arrays.equals(buffer.toByteArray(), mReceiveBuffer.toByteArray());
+ try {
+ buffer.close();
+ } catch (IOException e) {
+ fail();
+ }
+ return result;
+ }
+ }
+
+ private class MockVideoApp {
+ private IVideoStreamListener mListener;
+
+ MockVideoApp(IVideoStreamListener listener) {
+ mListener = listener;
+ }
+
+ void inputByteStreamWithArray(byte[][] stream) {
+ for (byte[] data : stream) {
+ mListener.sendFrame(data, 0, data.length, -1);
+ }
+ }
+
+ void inputByteStreamWithArrayOffset(byte[][] stream) {
+ int dummyOffset = 0;
+ for (byte[] data : stream) {
+ // to test 'offset' param, create a buffer with a dummy offset
+ byte[] buffer = new byte[dummyOffset + data.length];
+ System.arraycopy(data, 0, buffer, dummyOffset, data.length);
+
+ mListener.sendFrame(buffer, dummyOffset, data.length, -1);
+ dummyOffset++;
+ }
+ }
+
+ void inputByteStreamWithByteBuffer(byte[][] stream) {
+ int dummyOffset = 0;
+ for (byte[] data : stream) {
+ // add a dummy offset inside byteBuffer for testing
+ ByteBuffer byteBuffer = ByteBuffer.allocate(dummyOffset + data.length);
+ byteBuffer.position(dummyOffset);
+
+ byteBuffer.put(data);
+ byteBuffer.flip();
+ byteBuffer.position(dummyOffset);
+
+ mListener.sendFrame(byteBuffer, -1);
+ dummyOffset++;
+ }
+ }
+
+ void inputByteStreamWithDirectByteBuffer(byte[][] stream) {
+ int dummyOffset = 0;
+ for (byte[] data : stream) {
+ // add a dummy offset inside byteBuffer for testing
+ ByteBuffer byteBuffer = ByteBuffer.allocateDirect(dummyOffset + data.length);
+ byteBuffer.position(dummyOffset);
+
+ byteBuffer.put(data);
+ byteBuffer.flip();
+ byteBuffer.position(dummyOffset);
+
+ mListener.sendFrame(byteBuffer, -1);
+ dummyOffset++;
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java
index 63fb437f7..0f72eec95 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/StreamRPCPacketizerTests.java
@@ -1,6 +1,7 @@
package com.smartdevicelink.test.streaming;
import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -9,6 +10,7 @@ import java.net.URLConnection;
import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.enums.SessionType;
import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.SdlProxyBase;
import com.smartdevicelink.streaming.IStreamListener;
import com.smartdevicelink.streaming.StreamRPCPacketizer;
import com.smartdevicelink.test.Test;
@@ -19,13 +21,13 @@ import junit.framework.TestCase;
/**
* This is a unit test class for the SmartDeviceLink library project class :
- * {@link com.smartdevicelink.streaming.StreamRpcPacketizer}
+ * {@link com.smartdevicelink.streaming.StreamRPCPacketizer}
*/
public class StreamRPCPacketizerTests extends TestCase {
/**
* This is a unit test for the following methods :
- * {@link com.smartdevicelink.streaming.StreamRPCPacketizer#StreamRPCPacketizer(IStreamListener, InputStream, RPCRequest, SessionType, byte, byte)}
+ * {@link com.smartdevicelink.streaming.StreamRPCPacketizer#StreamRPCPacketizer(SdlProxyBase, IStreamListener, InputStream, RPCRequest, SessionType, byte, byte, long, SdlSession)}
*/
public void testConstructor () {
@@ -41,12 +43,8 @@ public class StreamRPCPacketizerTests extends TestCase {
MockInterfaceBroker _interfaceBroker = new MockInterfaceBroker();
BaseTransportConfig _transportConfig = new BTTransportConfig(true);
SdlSession testSdlSession = SdlSession.createSession(testWiproVersion,_interfaceBroker, _transportConfig);
-
- try {
- URL url = new URL("ftp://mirror.csclub.uwaterloo.ca/index.html");
- URLConnection urlConnection = url.openConnection();
- testInputStream = new BufferedInputStream(urlConnection.getInputStream());
-
+ try {
+ testInputStream = new BufferedInputStream(new ByteArrayInputStream("sdl streaming test".getBytes()));
StreamRPCPacketizer testStreamRpcPacketizer = new StreamRPCPacketizer(null, testListener, testInputStream, testRequest, testSessionType, testSessionId, testWV, testWV, testSdlSession);
assertNotNull(Test.NOT_NULL, testStreamRpcPacketizer);
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java
new file mode 100644
index 000000000..7090ba8e8
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/RTPH264PacketizerTest.java
@@ -0,0 +1,882 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.test.streaming.video;
+
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.protocol.ProtocolMessage;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
+import com.smartdevicelink.streaming.IStreamListener;
+import com.smartdevicelink.streaming.video.RTPH264Packetizer;
+import com.smartdevicelink.test.streaming.MockInterfaceBroker;
+import com.smartdevicelink.transport.BTTransportConfig;
+
+import junit.framework.TestCase;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * This class includes a unit test for {@link RTPH264Packetizer}.
+ *
+ * @author Sho Amano
+ */
+public class RTPH264PacketizerTest extends TestCase {
+
+ private static final int FRAME_LENGTH_LEN = 2;
+ private static final int RTP_HEADER_LEN = 12;
+
+ private static final byte WIPRO_VERSION = 0x0B;
+ private static final byte SESSION_ID = 0x0A;
+
+ private class ByteStreamNALUnit {
+ byte[] startCode;
+ byte[] nalUnit;
+ int frameNum;
+
+ ByteStreamNALUnit(byte[] startCode, byte[] nalUnit, int frameNum) {
+ this.startCode = startCode;
+ this.nalUnit = nalUnit;
+ this.frameNum = frameNum;
+ }
+
+ byte[] createArray() {
+ byte[] array = new byte[startCode.length + nalUnit.length];
+ System.arraycopy(startCode, 0, array, 0, startCode.length);
+ System.arraycopy(nalUnit, 0, array, startCode.length, nalUnit.length);
+ return array;
+ }
+
+ public int getLength() {
+ return startCode.length + nalUnit.length;
+ }
+ }
+
+ private static final byte[] START_CODE_3 = {0x00, 0x00, 0x01};
+ private static final byte[] START_CODE_4 = {0x00, 0x00, 0x00, 0x01};
+
+ /* a sample H.264 stream, including 33 frames of 16px white square */
+ private final ByteStreamNALUnit[] SAMPLE_STREAM = new ByteStreamNALUnit[] {
+ // SPS
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x67, 0x42, (byte)0xC0, 0x0A, (byte)0xA6, 0x11, 0x11, (byte)0xE8,
+ 0x40, 0x00, 0x00, (byte)0xFA, 0x40, 0x00, 0x3A, (byte)0x98,
+ 0x23, (byte)0xC4, (byte)0x89, (byte)0x84, 0x60}, 0),
+ // PPS
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x68, (byte)0xC8, 0x42, 0x0F, 0x13, 0x20}, 0),
+ // I
+ new ByteStreamNALUnit(START_CODE_3, new byte[]{0x65, (byte)0x88, (byte)0x82, 0x07, 0x67, 0x39, 0x31, 0x40,
+ 0x00, 0x5E, 0x0A, (byte)0xFB, (byte)0xEF, (byte)0xAE, (byte)0xBA, (byte)0xEB,
+ (byte)0xAE, (byte)0xBA, (byte)0xEB, (byte)0xC0}, 0),
+ // P
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x1C, 0x0E, (byte)0xCE, 0x71, (byte)0xB0}, 1),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x2A, 0x03, (byte)0xB3, (byte)0x9C, 0x6C}, 2),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x3B, 0x03, (byte)0xB3, (byte)0x9C, 0x6C}, 3),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x49, 0x00, (byte)0xEC, (byte)0xE7, 0x1B}, 4),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x59, 0x40, (byte)0xEC, (byte)0xE7, 0x1B}, 5),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x69, (byte)0x80, (byte)0xEC, (byte)0xE7, 0x1B}, 6),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x79, (byte)0xC0, (byte)0xEC, (byte)0xE7, 0x1B}, 7),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, (byte)0x88, (byte)0x80, 0x3B, 0x39, (byte)0xC6, (byte)0xC0}, 8),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, (byte)0x98, (byte)0x90, 0x3B, 0x39, (byte)0xC6, (byte)0xC0}, 9),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, (byte)0xA8, (byte)0xA0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0}, 10),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, (byte)0xB8, (byte)0xB0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0}, 11),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, (byte)0xC8, (byte)0xC0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0}, 12),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, (byte)0xD8, (byte)0xD0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0}, 13),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, (byte)0xE8, (byte)0xE0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0}, 14),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, (byte)0xF8, (byte)0xF0, 0x3B, 0x39, (byte)0xC6, (byte)0xC0}, 15),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, 0x00, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 16),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, 0x10, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 17),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, 0x20, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 18),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, 0x30, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 19),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, 0x40, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 20),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, 0x50, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 21),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, 0x60, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 22),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, 0x70, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 23),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, (byte)0x80, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 24),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, (byte)0x90, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 25),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, (byte)0xA0, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 26),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, (byte)0xB0, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 27),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, (byte)0xC0, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 28),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9B, (byte)0xD0, 0x1D, (byte)0x9C, (byte)0xE3, 0x60}, 29),
+ // SPS
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x67, 0x42, (byte)0xC0, 0x0A, (byte)0xA6, 0x11, 0x11, (byte)0xE8,
+ 0x40, 0x00, 0x00, (byte)0xFA, 0x40, 0x00, 0x3A, (byte)0x98,
+ 0x23, (byte)0xC4, (byte)0x89, (byte)0x84, 0x60}, 30),
+ // PPS
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x68, (byte)0xC8, 0x42, 0x0F, 0x13, 0x20}, 30),
+ // I
+ new ByteStreamNALUnit(START_CODE_3, new byte[]{0x65, (byte)0x88, (byte)0x81, 0x00, (byte)0x8E, 0x73, (byte)0x93, 0x14,
+ 0x00, 0x06, (byte)0xA4, 0x2F, (byte)0xBE, (byte)0xFA, (byte)0xEB, (byte)0xAE,
+ (byte)0xBA, (byte)0xEB, (byte)0xAE, (byte)0xBC}, 30),
+ // P
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x1C, 0x0D, (byte)0xCE, 0x71, (byte)0xB0}, 31),
+ new ByteStreamNALUnit(START_CODE_4, new byte[]{0x41, (byte)0x9A, 0x2A, 0x03, 0x33, (byte)0x9C, 0x6C}, 32),
+ };
+
+ /**
+ * Test for creating Single Frame RTP packets from H.264 byte stream
+ */
+ public void testSingleFrames() {
+ StreamVerifier verifier = new StreamVerifier(SAMPLE_STREAM);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp encoder = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ encoder.inputByteStreamWithArray(SAMPLE_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(SAMPLE_STREAM.length, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for creating Single Frame RTP packets then splitting into multiple SDL frames
+ */
+ public void testSingleFramesIntoMultipleMessages() {
+ StreamVerifier verifier = new StreamVerifier(SAMPLE_STREAM);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+
+ // try to modify "bufferSize" variable (in AbstractPacketizer)
+ Class packetizerClass = RTPH264Packetizer.class;
+ String fieldName = "bufferSize";
+ java.lang.reflect.Field bufferSizeField = null;
+ while (packetizerClass != null) {
+ try {
+ bufferSizeField = packetizerClass.getDeclaredField(fieldName);
+ break;
+ } catch (NoSuchFieldException e) {
+ packetizerClass = packetizerClass.getSuperclass();
+ }
+ }
+ if (bufferSizeField != null) {
+ try {
+ bufferSizeField.setAccessible(true);
+ // use small MTU and make some RTP packets split into multiple SDL frames
+ bufferSizeField.set(packetizer, FRAME_LENGTH_LEN + RTP_HEADER_LEN + 16);
+ } catch (IllegalAccessException e) {
+ fail("Cannot access to private field \"" + fieldName + "\".");
+ }
+ } else {
+ fail("Cannot find private field \"" + fieldName + "\".");
+ }
+
+ MockVideoApp encoder = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ encoder.inputByteStreamWithArray(SAMPLE_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(SAMPLE_STREAM.length, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for creating Fragmentation Units from H.264 byte stream
+ */
+ public void testFragmentationUnits() {
+ ByteStreamNALUnit[] stream = new ByteStreamNALUnit[] {
+ SAMPLE_STREAM[0], SAMPLE_STREAM[1], null, null, null, SAMPLE_STREAM[5]
+ };
+ byte[] fakeNALUnit1 = new byte[65535 - RTP_HEADER_LEN]; // not fragmented
+ byte[] fakeNALUnit2 = new byte[65536 - RTP_HEADER_LEN]; // will be fragmented
+ byte[] fakeNALUnit3 = new byte[65537 - RTP_HEADER_LEN]; // ditto
+
+ for (int i = 0; i < fakeNALUnit1.length; i++) {
+ fakeNALUnit1[i] = (byte)(i % 256);
+ }
+ for (int i = 0; i < fakeNALUnit2.length; i++) {
+ fakeNALUnit2[i] = (byte)(i % 256);
+ }
+ for (int i = 0; i < fakeNALUnit3.length; i++) {
+ fakeNALUnit3[i] = (byte)(i % 256);
+ }
+
+ stream[2] = new ByteStreamNALUnit(START_CODE_3, fakeNALUnit1, 0);
+ stream[3] = new ByteStreamNALUnit(START_CODE_4, fakeNALUnit2, 1);
+ stream[4] = new ByteStreamNALUnit(START_CODE_4, fakeNALUnit3, 2);
+
+ StreamVerifier verifier = new StreamVerifier(stream);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp encoder = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ encoder.inputByteStreamWithArray(stream);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(stream.length + 2, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for RTP sequence number gets wrap-around correctly
+ */
+ public void testSequenceNumWrapAround() {
+ ByteStreamNALUnit[] stream = new ByteStreamNALUnit[70000];
+ for (int i = 0; i < stream.length; i++) {
+ stream[i] = new ByteStreamNALUnit(START_CODE_4, SAMPLE_STREAM[3].nalUnit, i);
+ }
+
+ StreamVerifier verifier = new StreamVerifier(stream);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp encoder = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ encoder.inputByteStreamWithArray(stream);
+ try {
+ Thread.sleep(2000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(stream.length, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for {@link RTPH264Packetizer#setPayloadType(byte)}
+ */
+ public void testSetPayloadType() {
+ byte pt = (byte)123;
+ StreamVerifier verifier = new StreamVerifier(SAMPLE_STREAM, pt);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ packetizer.setPayloadType(pt);
+ MockVideoApp encoder = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ encoder.inputByteStreamWithArray(SAMPLE_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(SAMPLE_STREAM.length, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for {@link RTPH264Packetizer#setSSRC(int)}
+ */
+ public void testSetSSRC() {
+ int ssrc = 0xFEDCBA98;
+ StreamVerifier verifier = new StreamVerifier(SAMPLE_STREAM);
+ verifier.setExpectedSSRC(ssrc);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ packetizer.setSSRC(ssrc);
+ MockVideoApp encoder = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ encoder.inputByteStreamWithArray(SAMPLE_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(SAMPLE_STREAM.length, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for {@link RTPH264Packetizer#pause()} and
+ * {@link RTPH264Packetizer#resume()}
+ */
+ public void testPauseResume() {
+ int index = 0;
+ // split SAMPLE_STREAM into three parts
+ ByteStreamNALUnit[] inputStream1 = new ByteStreamNALUnit[8];
+ ByteStreamNALUnit[] inputStream2 = new ByteStreamNALUnit[19];
+ ByteStreamNALUnit[] inputStream3 = new ByteStreamNALUnit[10];
+ for (int i = 0; i < inputStream1.length; i++) {
+ inputStream1[i] = SAMPLE_STREAM[index++];
+ }
+ for (int i = 0; i < inputStream2.length; i++) {
+ inputStream2[i] = SAMPLE_STREAM[index++];
+ }
+ for (int i = 0; i < inputStream3.length; i++) {
+ inputStream3[i] = SAMPLE_STREAM[index++];
+ }
+
+ index = 0;
+ // expected output is "all NAL units in inputStream1" plus "I frame and onwards in inputStream3"
+ ByteStreamNALUnit[] expectedStream = new ByteStreamNALUnit[inputStream1.length + 3];
+ for (int i = 0; i < inputStream1.length; i++) {
+ expectedStream[index++] = inputStream1[i];
+ }
+ expectedStream[index++] = SAMPLE_STREAM[34];
+ expectedStream[index++] = SAMPLE_STREAM[35];
+ expectedStream[index] = SAMPLE_STREAM[36];
+
+ StreamVerifier verifier = new StreamVerifier(expectedStream);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp encoder = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ encoder.inputByteStreamWithArray(inputStream1);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.pause();
+
+ // this input stream should be disposed
+ encoder.inputByteStreamWithArray(inputStream2);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.resume();
+
+ // packetizer should resume from a I frame
+ encoder.inputByteStreamWithArray(inputStream3);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(expectedStream.length, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for {@link RTPH264Packetizer#sendFrame(byte[], int, int, long)}
+ */
+ public void testSendFrameInterfaceWithArray() {
+ StreamVerifier verifier = new StreamVerifier(SAMPLE_STREAM);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithArrayOffset(SAMPLE_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(SAMPLE_STREAM.length, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for {@link RTPH264Packetizer#sendFrame(ByteBuffer, long)}
+ */
+ public void testSendFrameInterfaceWithByteBuffer() {
+ StreamVerifier verifier = new StreamVerifier(SAMPLE_STREAM);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithByteBuffer(SAMPLE_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(SAMPLE_STREAM.length, verifier.getPacketCount());
+ }
+
+ /**
+ * Test for {@link RTPH264Packetizer#sendFrame(ByteBuffer, long)}
+ * with direct ByteBuffer
+ */
+ public void testSendFrameInterfaceWithDirectByteBuffer() {
+ StreamVerifier verifier = new StreamVerifier(SAMPLE_STREAM);
+ SdlSession session = createTestSession();
+ RTPH264Packetizer packetizer = null;
+ try {
+ packetizer = new RTPH264Packetizer(verifier, SessionType.NAV, SESSION_ID, session);
+ } catch (IOException e) {
+ fail();
+ }
+ MockVideoApp mockApp = new MockVideoApp(packetizer);
+
+ try {
+ packetizer.start();
+ } catch (IOException e) {
+ fail();
+ }
+
+ mockApp.inputByteStreamWithDirectByteBuffer(SAMPLE_STREAM);
+ try {
+ Thread.sleep(1000, 0);
+ } catch (InterruptedException e) {}
+
+ packetizer.stop();
+ assertEquals(SAMPLE_STREAM.length, verifier.getPacketCount());
+ }
+
+ private SdlSession createTestSession() {
+ return SdlSession.createSession(WIPRO_VERSION, new MockInterfaceBroker(), new BTTransportConfig(true));
+ }
+
+ private class StreamVerifier implements IStreamListener {
+ private static final int STATE_LENGTH = 0;
+ private static final int STATE_PACKET = 1;
+
+ private ByteStreamNALUnit[] mStream;
+ private byte[] mExpectedNALUnit;
+ private ByteBuffer mReceiveBuffer;
+ private int mPacketLen;
+ private int mState;
+ private int mNALCount;
+ private int mTotalPacketCount;
+ private boolean mFragmented;
+ private int mOffsetInNALUnit;
+ private byte mPayloadType;
+ private boolean mVerifySSRC;
+ private int mExpectedSSRC;
+ private boolean mFirstPacketReceived;
+ private short mFirstSequenceNum;
+ private int mFirstTimestamp;
+
+ StreamVerifier(ByteStreamNALUnit[] stream) {
+ this(stream, (byte)96);
+ }
+
+ StreamVerifier(ByteStreamNALUnit[] stream, byte payloadType) {
+ mStream = stream;
+ mReceiveBuffer = ByteBuffer.allocate(256 * 1024);
+ mReceiveBuffer.order(ByteOrder.BIG_ENDIAN);
+ mPacketLen = 0;
+ mState = STATE_LENGTH;
+
+ mNALCount = 0;
+ mTotalPacketCount = 0;
+ mFragmented = false;
+ mOffsetInNALUnit = 1; // Used when verifying FUs. The first byte is skipped.
+
+ mPayloadType = payloadType;
+ mVerifySSRC = false;
+ mExpectedSSRC = 0;
+ mFirstPacketReceived = false;
+ mFirstSequenceNum = 0;
+ mFirstTimestamp = 0;
+ }
+
+ void setExpectedSSRC(int ssrc) {
+ mVerifySSRC = true;
+ mExpectedSSRC = ssrc;
+ }
+
+ int getPacketCount() {
+ return mTotalPacketCount;
+ }
+
+ @Override
+ public void sendStreamPacket(ProtocolMessage pm) {
+ mExpectedNALUnit = mStream[mNALCount].nalUnit;
+ // should be same as MockVideoApp's configuration (29.97 FPS)
+ int expectedPTSDelta = mStream[mNALCount].frameNum * 1001 * 3;
+ boolean isLast = shouldBeLast();
+
+ verifyProtocolMessage(pm, SESSION_ID);
+
+ mReceiveBuffer.put(pm.getData());
+ mReceiveBuffer.flip();
+
+ if (mState == STATE_LENGTH) {
+ if (mReceiveBuffer.remaining() >= 2) {
+ mPacketLen = mReceiveBuffer.getShort() & 0xFFFF;
+ mState = STATE_PACKET;
+ }
+ }
+
+ if (mState == STATE_PACKET) {
+ if (mReceiveBuffer.remaining() >= mPacketLen) {
+ byte[] packet = new byte[mPacketLen];
+ mReceiveBuffer.get(packet);
+
+ verifyRTPPacket(packet, mPayloadType, expectedPTSDelta,
+ mVerifySSRC, mExpectedSSRC, isLast);
+ mFirstPacketReceived = true;
+
+ mState = STATE_LENGTH;
+ mPacketLen = 0;
+ mTotalPacketCount++;
+ }
+ }
+
+ mReceiveBuffer.compact();
+ }
+
+ private void verifyProtocolMessage(ProtocolMessage pm, byte sessionId) {
+ assertEquals(true, pm != null);
+ assertEquals(sessionId, pm.getSessionID());
+ assertEquals(SessionType.NAV, pm.getSessionType());
+ assertEquals(0, pm.getFunctionID());
+ assertEquals(0, pm.getCorrID());
+ assertEquals(false, pm.getPayloadProtected());
+ }
+
+ private void verifyRTPPacket(byte[] packet, byte payloadType, int expectedPTSDelta,
+ boolean verifySSRC, int expectedSSRC, boolean isLast) {
+ assertTrue(packet.length > RTP_HEADER_LEN);
+ verifyRTPHeader(packet, false, isLast, payloadType, (short)(mTotalPacketCount % 65536),
+ expectedPTSDelta, verifySSRC, expectedSSRC);
+
+ byte type = (byte)(packet[RTP_HEADER_LEN] & 0x1F);
+ if (type == 28) { // FU-A frame
+ boolean fuEnd = verifyFUTypeA(packet);
+ if (fuEnd) {
+ mNALCount++;
+ }
+ } else if (type == 29) { // FU-B frame
+ fail("Fragmentation Unit B is not supported by this test");
+ } else if (type == 24 || type == 25 || type == 26 || type == 27) {
+ fail("STAP and MTAP are not supported by this test");
+ } else {
+ // Single Frame
+ verifySingleFrame(packet);
+ mNALCount++;
+ }
+ }
+
+ private void verifyRTPHeader(byte[] packet,
+ boolean hasPadding, boolean isLast, byte payloadType,
+ short seqNumDelta, int ptsDelta, boolean checkSSRC, int ssrc) {
+ int byte0 = packet[0] & 0xFF;
+ assertEquals((byte)2, (byte)((byte0 >> 6) & 3)); // version
+ assertEquals((byte)(hasPadding ? 1 : 0), (byte)((byte0 >> 5) & 1)); // padding
+ assertEquals((byte)0, (byte)((byte0 >> 4) & 1)); // extension
+ assertEquals((byte)0, (byte)(byte0 & 0xF)); // CSRC count
+
+ int byte1 = packet[1] & 0xFF;
+ assertEquals((byte)(isLast ? 1 : 0), (byte)((byte1 >> 7) & 1)); // marker
+ assertEquals(payloadType, (byte)(byte1 & 0x7F)); // Payload Type
+
+ short actualSeq = (short)(((packet[2] & 0xFF) << 8) | (packet[3] & 0xFF));
+ if (!mFirstPacketReceived) {
+ mFirstSequenceNum = actualSeq;
+ } else {
+ assertEquals((short)(mFirstSequenceNum + seqNumDelta), actualSeq);
+ }
+
+ int actualPTS = ((packet[4] & 0xFF) << 24) | ((packet[5] & 0xFF) << 16) |
+ ((packet[6] & 0xFF) << 8) | (packet[7] & 0xFF);
+ if (!mFirstPacketReceived) {
+ mFirstTimestamp = actualPTS;
+ } else {
+ // accept calculation error
+ assertTrue(mFirstTimestamp + ptsDelta - 1 <= actualPTS &&
+ actualPTS <= mFirstTimestamp + ptsDelta + 1);
+ }
+
+ if (checkSSRC) {
+ int actualSSRC = ((packet[8] & 0xFF) << 24) | ((packet[9] & 0xFF) << 16) |
+ ((packet[10] & 0xFF) << 8) | (packet[11] & 0xFF);
+ assertEquals(ssrc, actualSSRC);
+ }
+ }
+
+ private void verifySingleFrame(byte[] packet) {
+ assertEquals(true, arrayCompare(packet, RTP_HEADER_LEN, packet.length - RTP_HEADER_LEN,
+ mExpectedNALUnit, 0, mExpectedNALUnit.length));
+ }
+
+ private boolean verifyFUTypeA(byte[] packet) {
+ int firstByte = mExpectedNALUnit[0] & 0xFF;
+
+ int byte0 = packet[RTP_HEADER_LEN] & 0xFF;
+ assertEquals((byte)((firstByte >> 7) & 1), (byte)((byte0 >> 7) & 1)); // F bit
+ assertEquals((byte)((firstByte >> 5) & 3), (byte)((byte0 >> 5) & 3)); // NRI
+ assertEquals((byte)28, (byte)(byte0 & 0x1F)); // Type
+
+ int byte1 = packet[RTP_HEADER_LEN+1] & 0xFF;
+ boolean isFirstFU = ((byte1 >> 7) & 1) == 1; // Start bit
+ boolean isLastFU = ((byte1 >> 6) & 1) == 1; // End bit
+ assertEquals((byte)0, (byte)((byte1 >> 5) & 1)); // Reserved bit
+ assertEquals((byte)(firstByte & 0x1F), (byte)(byte1 & 0x1F)); // Type
+
+ int len = packet.length - (RTP_HEADER_LEN + 2);
+ assertEquals(true, arrayCompare(packet, RTP_HEADER_LEN + 2, len, mExpectedNALUnit, mOffsetInNALUnit, len));
+ mOffsetInNALUnit += len;
+
+ if (!mFragmented) {
+ // this should be the first fragmentation unit
+ assertEquals(true, isFirstFU);
+ assertEquals(false, isLastFU);
+ mFragmented = true;
+ } else {
+ assertEquals(false, isFirstFU);
+ if (mExpectedNALUnit.length == mOffsetInNALUnit) {
+ // this is the last fragmentation unit
+ assertEquals(true, isLastFU);
+
+ mFragmented = false;
+ mOffsetInNALUnit = 1;
+ return true;
+ } else {
+ assertEquals(false, isLastFU);
+ }
+ }
+ return false;
+ }
+
+ private boolean shouldBeLast() {
+ if (mNALCount + 1 >= mStream.length) {
+ return true;
+ }
+ ByteStreamNALUnit current = mStream[mNALCount];
+ ByteStreamNALUnit next = mStream[mNALCount + 1];
+ if (next.frameNum != current.frameNum) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private boolean arrayCompare(byte[] a1, int start1, int len1, byte[] a2, int start2, int len2) {
+ assertTrue(start1 + len1 <= a1.length);
+ assertTrue(start2 + len2 <= a2.length);
+
+ if (len1 != len2) {
+ return false;
+ }
+
+ for (int i = 0; i < len1; i++) {
+ if (a1[start1 + i] != a2[start2 + i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ private interface IVideoFrameSender {
+ void onVideoFrame(byte[] data, long timestampUs);
+ }
+
+ private class MockVideoApp {
+ private IVideoStreamListener mListener;
+ private int mFPSNum;
+ private int mFPSDen;
+
+ MockVideoApp(IVideoStreamListener listener) {
+ mListener = listener;
+ // 29.97 fps
+ mFPSNum = 30000;
+ mFPSDen = 1001;
+ }
+
+ void inputByteStreamWithArray(ByteStreamNALUnit[] stream) {
+ generateFramesFromStream(stream, new IVideoFrameSender() {
+ @Override
+ public void onVideoFrame(byte[] data, long timestampUs) {
+ byte[] buffer = new byte[data.length];
+ System.arraycopy(data, 0, buffer, 0, data.length);
+ mListener.sendFrame(buffer, 0, data.length, timestampUs);
+ }
+ });
+ }
+
+ void inputByteStreamWithArrayOffset(ByteStreamNALUnit[] stream) {
+ generateFramesFromStream(stream, new IVideoFrameSender() {
+ private int mDummyOffset = 0;
+
+ @Override
+ public void onVideoFrame(byte[] data, long timestampUs) {
+ // to test 'offset' param, create a buffer with a dummy offset
+ byte[] buffer = new byte[mDummyOffset + data.length];
+ System.arraycopy(data, 0, buffer, mDummyOffset, data.length);
+
+ mListener.sendFrame(buffer, mDummyOffset, data.length, timestampUs);
+ mDummyOffset++;
+ }
+ });
+ }
+
+ void inputByteStreamWithByteBuffer(ByteStreamNALUnit[] stream) {
+ generateFramesFromStream(stream, new IVideoFrameSender() {
+ private int mDummyOffset = 0;
+
+ @Override
+ public void onVideoFrame(byte[] data, long timestampUs) {
+ // add a dummy offset inside byteBuffer for testing
+ ByteBuffer byteBuffer = ByteBuffer.allocate(mDummyOffset + data.length);
+ byteBuffer.position(mDummyOffset);
+
+ byteBuffer.put(data);
+ byteBuffer.flip();
+ byteBuffer.position(mDummyOffset);
+
+ mListener.sendFrame(byteBuffer, timestampUs);
+ mDummyOffset++;
+ }
+ });
+ }
+
+ void inputByteStreamWithDirectByteBuffer(ByteStreamNALUnit[] stream) {
+ generateFramesFromStream(stream, new IVideoFrameSender() {
+ private int mDummyOffset = 0;
+
+ @Override
+ public void onVideoFrame(byte[] data, long timestampUs) {
+ // add a dummy offset inside byteBuffer for testing
+ ByteBuffer byteBuffer = ByteBuffer.allocateDirect(mDummyOffset + data.length);
+ byteBuffer.position(mDummyOffset);
+
+ byteBuffer.put(data);
+ byteBuffer.flip();
+ byteBuffer.position(mDummyOffset);
+
+ mListener.sendFrame(byteBuffer, timestampUs);
+ mDummyOffset++;
+ }
+ });
+ }
+
+ private void generateFramesFromStream(ByteStreamNALUnit[] stream, IVideoFrameSender callback) {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+ for (int i = 0; i < stream.length; i++) {
+ ByteStreamNALUnit bs = stream[i];
+ byte[] array = bs.createArray();
+ os.write(array, 0, array.length);
+
+ if (i < stream.length - 1) {
+ ByteStreamNALUnit next = stream[i + 1];
+ if (bs.frameNum == next.frameNum) {
+ // enqueue it and send at once
+ continue;
+ }
+ }
+
+ long timestampUs = bs.frameNum * 1000L * 1000L * mFPSDen / mFPSNum;
+ byte[] data = os.toByteArray();
+ callback.onVideoFrame(data, timestampUs);
+ os.reset();
+ }
+
+ try {
+ os.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java
new file mode 100644
index 000000000..96e6e29cb
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/streaming/video/SdlRemoteDisplayTest.java
@@ -0,0 +1,139 @@
+package com.smartdevicelink.test.streaming.video;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Looper;
+import android.test.AndroidTestCase;
+import android.view.Display;
+import android.view.MotionEvent;
+import android.widget.RelativeLayout;
+
+import com.smartdevicelink.R;
+import com.smartdevicelink.encoder.VirtualDisplayEncoder;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
+import com.smartdevicelink.streaming.video.SdlRemoteDisplay;
+import com.smartdevicelink.streaming.video.VideoStreamingParameters;
+
+import junit.framework.TestCase;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.FutureTask;
+
+
+public class SdlRemoteDisplayTest extends AndroidTestCase {
+
+ MockRemoteDisplayCallback rdCallback = new MockRemoteDisplayCallback();
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ if(Looper.myLooper() == null){
+ Looper.prepare();
+ }
+ }
+
+ public void testCreator(){
+ VirtualDisplayEncoder encoder = createVDE();
+ assertNotNull(encoder);
+
+
+ SdlRemoteDisplay.Creator creator = new SdlRemoteDisplay.Creator(this.getContext(), encoder.getVirtualDisplay(), null, MockRemoteDisplay.class, rdCallback);
+ assertNotNull(creator);
+ FutureTask<Boolean> fTask = new FutureTask<Boolean>(creator);
+ Thread showPresentation = new Thread(fTask);
+ showPresentation.start();
+ assert true;
+ }
+
+ public void testConstructor(){
+ VirtualDisplayEncoder encoder = createVDE();
+ assertNotNull(encoder);
+ MockRemoteDisplay remoteDisplay = new MockRemoteDisplay(getContext(), encoder.getVirtualDisplay());
+ assertNotNull(remoteDisplay);
+
+ encoder.shutDown();
+ }
+
+
+ @TargetApi(19)
+ public void testTouchEvents(){
+ VirtualDisplayEncoder encoder = createVDE();
+ assertNotNull(encoder);
+ MockRemoteDisplay remoteDisplay = new MockRemoteDisplay(getContext(), encoder.getVirtualDisplay());
+ assertNotNull(remoteDisplay);
+ remoteDisplay.show();
+
+ assertNotNull(remoteDisplay.getMainView());
+
+ try{
+ remoteDisplay.handleMotionEvent(MotionEvent.obtain(10, System.currentTimeMillis(), MotionEvent.ACTION_DOWN, 100, 100, 0));
+ }catch (Exception e){
+ assert false;
+ }
+
+ remoteDisplay.dismiss();
+ encoder.shutDown();
+ }
+
+
+ public VirtualDisplayEncoder createVDE(){
+ try{
+ VirtualDisplayEncoder displayEncoder = new VirtualDisplayEncoder();
+ displayEncoder.init(getContext(), new MockVideoStreamListener(), new VideoStreamingParameters());
+ displayEncoder.start();
+ return displayEncoder;
+ }catch (Exception e ){
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+
+ //Mock classes
+
+ public static class MockRemoteDisplay extends SdlRemoteDisplay{
+
+ public MockRemoteDisplay(Context context, Display display) {
+ super(context, display);
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView( new RelativeLayout(getContext()));
+
+ }
+
+
+ }
+
+ class MockVideoStreamListener implements IVideoStreamListener{
+
+ @Override
+ public void sendFrame(byte[] data, int offset, int length, long presentationTimeUs) throws ArrayIndexOutOfBoundsException {
+
+ }
+
+ @Override
+ public void sendFrame(ByteBuffer data, long presentationTimeUs) {
+
+ }
+ }
+
+ class MockRemoteDisplayCallback implements SdlRemoteDisplay.Callback{
+
+ @Override
+ public void onCreated(SdlRemoteDisplay remoteDisplay) {
+
+ }
+
+ @Override
+ public void onInvalidated(SdlRemoteDisplay remoteDisplay) {
+
+ }
+ }
+
+
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/trace/DiagLevelTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/trace/DiagLevelTests.java
index bc1aa6060..ce24ce4e8 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/trace/DiagLevelTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/trace/DiagLevelTests.java
@@ -122,7 +122,7 @@ public class DiagLevelTests extends TestCase {
assertFalse(Test.FALSE, DiagLevel.isValidDetailLevel(testInvalidS));
assertFalse(Test.FALSE, DiagLevel.isValidDetailLevel(null));
assertNull(Test.NULL, DiagLevel.getLevel(null));
- DiagLevel.setLevel(null, null);
+ DiagLevel.setLevel(null, null);
DiagLevel.setAllLevels(null);
} catch (NullPointerException e) {
fail("NullPointerException was thrown when attempting to set null values.");
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java
index ae4bae4ce..cdf83079c 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/transport/MultiplexBluetoothTransportTest.java
@@ -1,12 +1,14 @@
package com.smartdevicelink.test.transport;
-import junit.framework.TestCase;
import android.os.Handler;
+import android.os.Looper;
import android.os.Message;
+import com.smartdevicelink.test.util.DeviceUtil;
import com.smartdevicelink.transport.MultiplexBluetoothTransport;
import com.smartdevicelink.transport.SdlRouterService;
+import junit.framework.TestCase;
public class MultiplexBluetoothTransportTest extends TestCase {
@@ -17,41 +19,50 @@ public class MultiplexBluetoothTransportTest extends TestCase {
boolean didCorrectThing = false, isWaitingForResponse = false;
//Example handler
- Handler stateChangeHandler = new Handler(){
- int stateDesired = MultiplexBluetoothTransport.STATE_LISTEN;
- @Override
- public void handleMessage(Message msg) {
- if(!isWaitingForResponse){
- return;
- }
- switch(msg.what){
- case SdlRouterService.MESSAGE_STATE_CHANGE:
- if(msg.arg1 == stateDesired){
+ Handler stateChangeHandler;
+
+ public void testStateTransitions() {
+ if(Looper.myLooper() == null){
+ Looper.prepare();
+ }
+
+ stateChangeHandler = new Handler(){
+ int stateDesired = MultiplexBluetoothTransport.STATE_LISTEN;
+ @Override
+ public void handleMessage(Message msg) {
+ if(!isWaitingForResponse){
+ return;
+ }
+ switch(msg.what){
+ case SdlRouterService.MESSAGE_STATE_CHANGE:
+ if(msg.arg1 == stateDesired){
didCorrectThing = true;
break;
- }
+ }
default:
didCorrectThing = false;
+ }
+ REQUEST_LOCK.notify();
}
- REQUEST_LOCK.notify();
- }
-
- };
-
- public void testStateTransitions() {
+
+ };
+
//TODO test for more than the two states
bluetooth = MultiplexBluetoothTransport.getBluetoothSerialServerInstance();
assertNull(bluetooth);
bluetooth = MultiplexBluetoothTransport.getBluetoothSerialServerInstance(stateChangeHandler);
assertEquals(bluetooth.getState(), MultiplexBluetoothTransport.STATE_NONE);
-
+
bluetooth.start();
- assertEquals(bluetooth.getState(), MultiplexBluetoothTransport.STATE_LISTEN);
-
+ if(DeviceUtil.isEmulator()){
+ assertEquals(bluetooth.getState(), MultiplexBluetoothTransport.STATE_NONE);
+ }else{
+ assertEquals(bluetooth.getState(), MultiplexBluetoothTransport.STATE_LISTEN);
+ }
+
bluetooth.stop();
assertEquals(bluetooth.getState(), MultiplexBluetoothTransport.STATE_NONE);
-
}
private void notifyResponseReceived(){
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/BitConverterTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/BitConverterTests.java
index a3f0964b4..fb6eed3f9 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/BitConverterTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/BitConverterTests.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.test.util;
-import java.util.Arrays;
+import com.smartdevicelink.test.Test;
+import com.smartdevicelink.util.BitConverter;
import junit.framework.TestCase;
-import com.smartdevicelink.test.Test;
-import com.smartdevicelink.util.BitConverter;
+import java.util.Arrays;
/**
* This is a unit test class for the SmartDeviceLink library project class :
@@ -61,7 +61,7 @@ public class BitConverterTests extends TestCase {
assertTrue(Test.ARRAY, Arrays.equals(expectedBytes, actualBytes));
// Invalid/Null Tests
- assertEquals(Test.MATCH, (int) 0, actualNullBytes);
+ assertEquals(Test.MATCH, (int) -1, actualNullBytes);
}
/**
@@ -83,6 +83,6 @@ public class BitConverterTests extends TestCase {
assertTrue(Test.ARRAY, Arrays.equals(expectedBytes, actualBytes));
// Invalid/Null Tests
- assertEquals(Test.MATCH, (short) 0, actualNullBytes);
+ assertEquals(Test.MATCH, (short) -1, actualNullBytes);
}
} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/DeviceUtil.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/DeviceUtil.java
new file mode 100644
index 000000000..08b5c0840
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/DeviceUtil.java
@@ -0,0 +1,17 @@
+package com.smartdevicelink.test.util;
+
+import android.os.Build;
+
+public class DeviceUtil {
+ public static boolean isEmulator() {
+ return Build.FINGERPRINT.startsWith("generic")
+ || Build.FINGERPRINT.startsWith("unknown")
+ || Build.MODEL.contains("google_sdk")
+ || Build.MODEL.contains("Emulator")
+ || Build.MODEL.contains("Android SDL built for")
+ || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
+ || (Build.BRAND.startsWith("Android") && Build.DEVICE.startsWith("generic"))
+ || (Build.PRODUCT != null && Build.PRODUCT.startsWith("sdk_google_phone"))
+ || "google_sdk".equals(Build.PRODUCT);
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlDataTypeConverterTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlDataTypeConverterTests.java
index a4bdb8ab8..b39c405d5 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlDataTypeConverterTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/SdlDataTypeConverterTests.java
@@ -36,11 +36,11 @@ public class SdlDataTypeConverterTests extends TestCase {
// Valid Tests
assertEquals(Test.MATCH, expectedValue, actualDoubleValue);
assertEquals(Test.MATCH, expectedValue, actualIntegerValue);
+ assertEquals(Test.MATCH, expectedValue, actualFloatValue);
// Null Tests
assertNull(Test.NULL, actualNullValue);
assertNull(Test.NULL, actualLongValue);
assertNull(Test.NULL, actualShortValue);
- assertNull(Test.NULL, actualFloatValue);
}
} \ No newline at end of file
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/VersionTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/VersionTest.java
new file mode 100644
index 000000000..44d25ffe0
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/test/util/VersionTest.java
@@ -0,0 +1,31 @@
+package com.smartdevicelink.test.util;
+
+import android.test.AndroidTestCase;
+
+import com.smartdevicelink.util.Version;
+
+public class VersionTest extends AndroidTestCase {
+
+ private static final String TEST_VERSION = "1.2.3";
+
+ public void testConstructorCorrect(){
+ Version version = new Version(TEST_VERSION);
+ assertEquals(1, version.getMajor());
+ assertEquals(2, version.getMinor());
+ assertEquals(3, version.getPatch());
+ }
+
+ public void testConstructorIncorrect(){
+ try{
+ Version version = new Version("1.2");
+ }catch (Exception e){
+ assert true;
+ }
+ assert false;
+ }
+
+ public void testToString(){
+ Version version = new Version(TEST_VERSION);
+ assertEquals(version.toString(), TEST_VERSION);
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java
index 9f0822a73..901a756a3 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/MultiplexTransportTest.java
@@ -6,6 +6,8 @@ import com.smartdevicelink.transport.enums.TransportType;
import android.test.AndroidTestCase;
+import junit.framework.Assert;
+
public class MultiplexTransportTest extends AndroidTestCase {
private static final int TIMEOUT = 2000;
@@ -69,8 +71,14 @@ public class MultiplexTransportTest extends AndroidTestCase {
trans = new MultiplexTransport(config,transportListener);
assertTrue(trans.brokerThread.isAlive());
-
-
-
+
+ // Send a null config object in the constructor and expect an IllegalArgumentException
+ try {
+ trans = new MultiplexTransport(null, transportListener);
+ } catch (IllegalArgumentException e) {
+ assertEquals("Null transportConfig in MultiplexTransport constructor", e.getMessage());
+ } catch (NullPointerException e) {
+ Assert.fail("NPE in MultiplexTransport constructor");
+ }
}
}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
index 03abbc7f4..e40049afd 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RSVTestCase.java
@@ -1,14 +1,8 @@
package com.smartdevicelink.transport;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
+import android.app.ActivityManager;
+import android.content.ComponentName;
+import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.test.AndroidTestCase;
@@ -17,13 +11,23 @@ import android.util.Log;
import com.smartdevicelink.transport.RouterServiceValidator.TrustedAppStore;
import com.smartdevicelink.util.HttpRequestTask.HttpRequestTaskCallback;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.concurrent.Semaphore;
+
public class RSVTestCase extends AndroidTestCase {
private static final String TAG = "RSVTestCase";
private static final long REFRESH_TRUSTED_APP_LIST_TIME_DAY = 3600000 * 24; // A day in ms
private static final long REFRESH_TRUSTED_APP_LIST_TIME_WEEK = REFRESH_TRUSTED_APP_LIST_TIME_DAY * 7; // A week in ms
private static final long REFRESH_TRUSTED_APP_LIST_TIME_MONTH = REFRESH_TRUSTED_APP_LIST_TIME_DAY * 30; // A ~month in ms
-
+ private static final String TEST = "{\"response\": {\"com.livio.sdl\" : { \"versionBlacklist\":[] }, \"com.lexus.tcapp\" : { \"versionBlacklist\":[] }, \"com.toyota.tcapp\" : { \"versionBlacklist\": [] } , \"com.sdl.router\":{\"versionBlacklist\": [] },\"com.ford.fordpass\" : { \"versionBlacklist\":[] } }}";
RouterServiceValidator rsvp;
/**
* Set this boolean if you want to test the actual validation of router service
@@ -41,6 +45,27 @@ public class RSVTestCase extends AndroidTestCase {
protected void tearDown() throws Exception {
super.tearDown();
}
+
+ private static final Semaphore TRUSTED_LIST_LOCK = new Semaphore(1);
+
+ private void requestTListLock(){
+ try {
+ TRUSTED_LIST_LOCK.acquire();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void releaseTListLock(){
+ TRUSTED_LIST_LOCK.release();
+ }
+
+ private RouterServiceValidator.TrustedListCallback trustedListCallback = new RouterServiceValidator.TrustedListCallback(){
+ @Override
+ public void onListObtained(boolean successful) {
+ releaseTListLock();
+ }
+ };
/*
* These tests are a little strange because they don't test the logic behind the validation of each piece.
@@ -100,6 +125,8 @@ public class RSVTestCase extends AndroidTestCase {
}
public void testHighSecurity(){
+ requestTListLock();
+
RouterServiceValidator rsvp = new RouterServiceValidator(this.mContext); //Use a locally scoped instance
rsvp.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH);
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_INSTALLED_FROM_CHECK);
@@ -108,11 +135,13 @@ public class RSVTestCase extends AndroidTestCase {
assertEquals(RouterServiceValidator.getRefreshRate(), REFRESH_TRUSTED_APP_LIST_TIME_WEEK);
- assertTrue(RouterServiceValidator.createTrustedListRequest(mContext, true, null, null));
+ assertTrue(RouterServiceValidator.createTrustedListRequest(mContext, true, null, trustedListCallback));
}
public void testMediumSecurity(){
+ requestTListLock();
+
RouterServiceValidator rsvp = new RouterServiceValidator(this.mContext); //Use a locally scoped instance
rsvp.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_MED);
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_INSTALLED_FROM_CHECK);
@@ -121,11 +150,13 @@ public class RSVTestCase extends AndroidTestCase {
assertEquals(RouterServiceValidator.getRefreshRate(), REFRESH_TRUSTED_APP_LIST_TIME_WEEK);
- assertTrue(RouterServiceValidator.createTrustedListRequest(mContext, true, null, null));
+ assertTrue(RouterServiceValidator.createTrustedListRequest(mContext, true, null, trustedListCallback));
}
public void testLowSecurity(){
+ requestTListLock();
+
RouterServiceValidator rsvp = new RouterServiceValidator(this.mContext); //Use a locally scoped instance
rsvp.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_LOW);
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_INSTALLED_FROM_CHECK);
@@ -134,11 +165,13 @@ public class RSVTestCase extends AndroidTestCase {
assertEquals(RouterServiceValidator.getRefreshRate(), REFRESH_TRUSTED_APP_LIST_TIME_MONTH);
- assertTrue(RouterServiceValidator.createTrustedListRequest(mContext, true, null, null));
+ assertTrue(RouterServiceValidator.createTrustedListRequest(mContext, true, null, trustedListCallback));
}
public void testNoSecurity(){
+ requestTListLock();
+
RouterServiceValidator rsvp = new RouterServiceValidator(this.mContext); //Use a locally scoped instance
rsvp.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_OFF);
rsvp.setFlags(RouterServiceValidator.FLAG_DEBUG_INSTALLED_FROM_CHECK);
@@ -147,7 +180,7 @@ public class RSVTestCase extends AndroidTestCase {
assertEquals(RouterServiceValidator.getRefreshRate(), REFRESH_TRUSTED_APP_LIST_TIME_WEEK);
- assertFalse(RouterServiceValidator.createTrustedListRequest(mContext, true, null, null));
+ assertFalse(RouterServiceValidator.createTrustedListRequest(mContext, true, null, trustedListCallback));
//This should always return true
assertTrue(rsvp.validate());
@@ -179,51 +212,66 @@ public class RSVTestCase extends AndroidTestCase {
}
public void testInvalidateList(){
+ requestTListLock();
+
assertFalse(RouterServiceValidator.invalidateList(null));
assertTrue(RouterServiceValidator.invalidateList(mContext));
+
+ releaseTListLock();
}
public void testGetTrustedList(){
+ requestTListLock();
+
assertNull(RouterServiceValidator.getTrustedList(null));
assertNotNull(RouterServiceValidator.getTrustedList(mContext));
+
+ releaseTListLock();
}
public void testSetTrustedList(){
+ requestTListLock();
+
assertFalse(RouterServiceValidator.setTrustedList(null,null));
assertFalse(RouterServiceValidator.setTrustedList(mContext,null));
assertFalse(RouterServiceValidator.setTrustedList(null,"test"));
assertTrue(RouterServiceValidator.setTrustedList(mContext,"test"));
- String test = "{\"response\": {\"com.livio.sdl\" : { \"versionBlacklist\":[] }, \"com.lexus.tcapp\" : { \"versionBlacklist\":[] }, \"com.toyota.tcapp\" : { \"versionBlacklist\": [] } , \"com.sdl.router\":{\"versionBlacklist\": [] },\"com.ford.fordpass\" : { \"versionBlacklist\":[] } }}";
- assertTrue(RouterServiceValidator.setTrustedList(mContext,test));
- assertTrue(RouterServiceValidator.setTrustedList(mContext,test+test+test+test+test));
+ assertTrue(RouterServiceValidator.setTrustedList(mContext,TEST));
+ assertTrue(RouterServiceValidator.setTrustedList(mContext,TEST+TEST+TEST+TEST+TEST));
StringBuilder builder = new StringBuilder();
for(int i = 0; i<1000; i++){
- builder.append(test);
+ builder.append(TEST);
}
assertTrue(RouterServiceValidator.setTrustedList(mContext,builder.toString()));
+
+ releaseTListLock();
}
public void testTrustedListSetAndGet(){
- String test = "{\"response\": {\"com.livio.sdl\" : { \"versionBlacklist\":[] }, \"com.lexus.tcapp\" : { \"versionBlacklist\":[] }, \"com.toyota.tcapp\" : { \"versionBlacklist\": [] } , \"com.sdl.router\":{\"versionBlacklist\": [] },\"com.ford.fordpass\" : { \"versionBlacklist\":[] } }}";
- assertTrue(RouterServiceValidator.setTrustedList(mContext,test));
+ requestTListLock();
+
+ assertTrue(RouterServiceValidator.setTrustedList(mContext,TEST));
String retVal = RouterServiceValidator.getTrustedList(mContext);
assertNotNull(retVal);
- assertTrue(test.equals(retVal));
-
- retVal = null;
+ assertTrue(TEST.equals(retVal));
+
StringBuilder builder = new StringBuilder();
for(int i = 0; i<1000; i++){
- builder.append(test);
+ builder.append(TEST);
}
assertTrue(RouterServiceValidator.setTrustedList(mContext,builder.toString()));
retVal = RouterServiceValidator.getTrustedList(mContext);
assertNotNull(retVal);
assertTrue(builder.toString().equals(retVal));
+
+ releaseTListLock();
}
public void testInvalidationSequence(){
+ requestTListLock();
+
assertTrue(RouterServiceValidator.invalidateList(mContext));
- assertTrue(RouterServiceValidator.createTrustedListRequest(mContext,false));
+ assertTrue(RouterServiceValidator.createTrustedListRequest(mContext, false, null, trustedListCallback));
}
public void testAppStorePackages(){
@@ -267,6 +315,8 @@ public class RSVTestCase extends AndroidTestCase {
static boolean didFinish = false;
public void testGetAndCheckList(){
+ requestTListLock();
+
final Object REQUEST_LOCK = new Object();
didFinish = false;
HttpRequestTaskCallback cb = new HttpRequestTaskCallback(){
@@ -279,6 +329,7 @@ public class RSVTestCase extends AndroidTestCase {
didFinish = true;
REQUEST_LOCK.notify();
}
+ releaseTListLock();
}
@Override
public void httpFailure(int statusCode) {
@@ -287,6 +338,7 @@ public class RSVTestCase extends AndroidTestCase {
didFinish = true;
REQUEST_LOCK.notify();
}
+ releaseTListLock();
}
};
@@ -308,12 +360,14 @@ public class RSVTestCase extends AndroidTestCase {
* Test to check that we can save our last request which actually houses all the previous known sdl enabled apps
*/
public void testRequestChange(){
+ requestTListLock();
+
RouterServiceValidator.setLastRequest(mContext, null);
assertNull(RouterServiceValidator.getLastRequest(mContext));
- String test = "{\"response\": {\"com.livio.sdl\" : { \"versionBlacklist\":[] }, \"com.lexus.tcapp\" : { \"versionBlacklist\":[] }, \"com.toyota.tcapp\" : { \"versionBlacklist\": [] } , \"com.sdl.router\":{\"versionBlacklist\": [] },\"com.ford.fordpass\" : { \"versionBlacklist\":[] } }}";
+
JSONObject object = null;
try {
- object = new JSONObject(test);
+ object = new JSONObject(TEST);
} catch (JSONException e) {
e.printStackTrace();
}
@@ -327,7 +381,7 @@ public class RSVTestCase extends AndroidTestCase {
assertTrue(object.toString().equals(oldRequest));
//Now test a new list
- test = "{\"response\": {\"com.livio.sdl\" : { \"versionBlacklist\":[] }, \"com.lexus.tcapp\" : { \"versionBlacklist\":[] }, \"com.test.test\" : { \"versionBlacklist\":[] },\"com.toyota.tcapp\" : { \"versionBlacklist\": [] } , \"com.sdl.router\":{\"versionBlacklist\": [] },\"com.ford.fordpass\" : { \"versionBlacklist\":[] } }}";
+ String test = "{\"response\": {\"com.livio.sdl\" : { \"versionBlacklist\":[] }, \"com.lexus.tcapp\" : { \"versionBlacklist\":[] }, \"com.test.test\" : { \"versionBlacklist\":[] },\"com.toyota.tcapp\" : { \"versionBlacklist\": [] } , \"com.sdl.router\":{\"versionBlacklist\": [] },\"com.ford.fordpass\" : { \"versionBlacklist\":[] } }}";
object = null;
try {
object = new JSONObject(test);
@@ -339,7 +393,40 @@ public class RSVTestCase extends AndroidTestCase {
//Clear it for next test
RouterServiceValidator.setLastRequest(mContext, null);
+ releaseTListLock();
}
-
+
+ /**
+ * Test app's router validation. Validation should fail when the given context and ComponentName object are from different packages and security setting is not OFF
+ * and app is not on trusted list. Validation should pass when the given context and ComponentName object are from the same package.
+ */
+ public void testAppSelfValidation() {
+
+ class RouterServiceValidatorTest extends RouterServiceValidator{
+ public RouterServiceValidatorTest(Context context){
+ super(context);
+ }
+
+ public RouterServiceValidatorTest(Context context, ComponentName service){
+ super(context, service);
+ }
+
+ // Override this method and simply returning true for the purpose of this test
+ protected boolean isServiceRunning(Context context, ComponentName service){
+ return true;
+ }
+ }
+
+ // Fail, different package name for context and service and app security setting is not OFF and app is not on trusted list
+ RouterServiceValidatorTest rsvpFail = new RouterServiceValidatorTest(this.mContext, new ComponentName("anything", mContext.getClass().getSimpleName()));
+ rsvpFail.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH);
+ assertFalse(rsvpFail.validate());
+
+ // Success, same package name for context and service
+ RouterServiceValidatorTest rsvpPass = new RouterServiceValidatorTest(this.mContext, new ComponentName(mContext.getPackageName(), mContext.getClass().getSimpleName()));
+ rsvpPass.setSecurityLevel(MultiplexTransportConfig.FLAG_MULTI_SECURITY_HIGH);
+ assertTrue(rsvpPass.validate());
+ }
+
}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java
index a4d4e1395..4208c1479 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/RegisteredAppTests.java
@@ -18,47 +18,42 @@ public class RegisteredAppTests extends AndroidTestCase {
public void testHandleMessage() {
- // Run Test in Main Thread
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- @Override
- public void run() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
- // Instantiate SdlRouterService and Registered App class
- SdlRouterService router = new SdlRouterService();
- SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger);
+ // Instantiate SdlRouterService and Registered App class
+ SdlRouterService router = new SdlRouterService();
+ SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger);
- // Call Handle Message
- app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_LARGE_PACKET_START,bytes);
+ // Call Handle Message
+ app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_LARGE_PACKET_START,bytes);
+
+ // Insure that the buffer is not null, if it is the test will fail
+ assertNotNull(app.buffer);
- // Insure that the buffer is not null, if it is the test will fail
- assertNotNull(app.buffer);
- }
- });
}
public void testNullBuffer() {
- // Run Test in Main Thread
- new Handler(Looper.getMainLooper()).post(new Runnable() {
- @Override
- public void run() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
- // Instantiate SdlRouterService and Registered App class
- SdlRouterService router = new SdlRouterService();
- SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger);
+ // Instantiate SdlRouterService and Registered App class
+ SdlRouterService router = new SdlRouterService();
+ SdlRouterService.RegisteredApp app = router.new RegisteredApp(APP_ID, messenger);
- // Force Null Buffer
- app.buffer = null;
+ // Force Null Buffer
+ app.buffer = null;
- // Call Handle Message - Making sure it doesn't init buffer
- app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_NONE,bytes);
+ // Call Handle Message - Making sure it doesn't init buffer
+ app.handleMessage(TransportConstants.BYTES_TO_SEND_FLAG_NONE,bytes);
- // Insure that the buffer is null. and no NPE
- assertNull(app.buffer);
+ // Insure that the buffer is null. and no NPE
+ assertNull(app.buffer);
- }
- });
}
}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/SdlRouterServiceTests.java b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/SdlRouterServiceTests.java
new file mode 100644
index 000000000..40fe0e77f
--- /dev/null
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/SdlRouterServiceTests.java
@@ -0,0 +1,132 @@
+package com.smartdevicelink.transport;
+
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+import com.smartdevicelink.protocol.SdlPacket;
+
+import junit.framework.Assert;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public class SdlRouterServiceTests extends AndroidTestCase {
+
+ public static final String TAG = "SdlRouterServiceTests";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ //Nothing here for now
+ }
+
+ /**
+ * Test null bundle handling in AltTransportHandler when handling messages. Only test the case of
+ * msg.what == TransportConstants.ROUTER_RECEIVED_PACKET
+ */
+ public void testAlTransportHandlerHandleNullBundle() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ class AltTransportHandler extends Handler {
+ ClassLoader loader;
+ final WeakReference<SdlRouterService> provider;
+
+ public AltTransportHandler(SdlRouterService provider) {
+ this.provider = new WeakReference<SdlRouterService>(provider);
+ loader = getClass().getClassLoader();
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ SdlRouterService service = this.provider.get();
+ Bundle receivedBundle = msg.getData();
+ switch (msg.what) {
+ case TransportConstants.ROUTER_RECEIVED_PACKET:
+ if (receivedBundle != null) {
+ receivedBundle.setClassLoader(loader);//We do this because loading a custom parceable object isn't possible without it
+ if (receivedBundle.containsKey(TransportConstants.FORMED_PACKET_EXTRA_NAME)) {
+ SdlPacket packet = receivedBundle.getParcelable(TransportConstants.FORMED_PACKET_EXTRA_NAME);
+ if (packet != null && service != null) {
+ service.onPacketRead(packet);
+ } else {
+ Log.w(TAG, "Received null packet from alt transport service");
+ }
+ } else {
+ Log.w(TAG, "Flase positive packet reception");
+ }
+ } else {
+ Log.e(TAG, "Bundle was null while sending packet to router service from alt transport");
+ }
+ break;
+ default:
+ super.handleMessage(msg);
+ }
+
+ }
+ }
+ AltTransportHandler testHandler = new AltTransportHandler(null);
+ Message msg = Message.obtain(null, TransportConstants.ROUTER_RECEIVED_PACKET);
+ //Send a null bundle
+ msg.setData(null);
+ try {
+ testHandler.handleMessage(msg);
+ } catch (Exception e) {
+ Assert.fail("Exception in testAlTransportHandlerHandleNullBundle, " + e);
+ }
+ }
+
+ /**
+ * Test writeBytesToTransport method for handling null byte array in bundle
+ *
+ * @see SdlRouterService#writeBytesToTransport(Bundle)
+ */
+ public void testWriteBytesToTransport() {
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ Method method;
+ Field field = null;
+ Object sdlRouterService = null;
+ try {
+ sdlRouterService = Class.forName("com.smartdevicelink.transport.SdlRouterService").newInstance();
+ //Send a null bundle
+ method = SdlRouterService.class.getDeclaredMethod("writeBytesToTransport", Bundle.class);
+ Bundle bundle = null;
+ method.invoke(sdlRouterService, bundle);
+
+ //Send a non-null bundle with a null bytes array
+ //First, set mSerialService to the correct state so we get to test packet being null
+ MultiplexBluetoothTransport transport = new MultiplexBluetoothTransport(null);
+ transport.setStateManually(MultiplexBluetoothTransport.STATE_CONNECTED);
+ field = SdlRouterService.class.getDeclaredField("mSerialService");
+ field.setAccessible(true);
+ field.set(sdlRouterService, transport);
+ bundle = new Bundle();
+ bundle.putByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME, null);
+ method.invoke(sdlRouterService, bundle);
+ } catch (Exception e) {
+ Assert.fail("Exception in testWriteBytesToTransport, " + e);
+ }
+
+ //Return mSerialService to previous state
+ if (field != null && sdlRouterService != null) {
+ try {
+ field.set(sdlRouterService, null);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
index bbc682fbc..5725b6974 100644
--- a/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
+++ b/sdl_android/src/androidTest/java/com/smartdevicelink/transport/TransportBrokerTest.java
@@ -2,11 +2,13 @@ package com.smartdevicelink.transport;
import android.bluetooth.BluetoothAdapter;
import android.os.Handler;
+import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.test.AndroidTestCase;
import com.smartdevicelink.test.SdlUnitTestContants;
+import com.smartdevicelink.test.util.DeviceUtil;
public class TransportBrokerTest extends AndroidTestCase {
RouterServiceValidator rsvp;
@@ -27,68 +29,92 @@ public class TransportBrokerTest extends AndroidTestCase {
}
public void testStart(){
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID,rsvp.getService());
- assertTrue(broker.start());
+ if(!DeviceUtil.isEmulator()){ // Cannot perform MBT operations in emulator
+ assertTrue(broker.start());
+ }
broker.stop();
+
}
public void testSendPacket(){
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+
TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID,rsvp.getService());
- assertTrue(broker.start());
+
+ if(!DeviceUtil.isEmulator()){ // Cannot perform MBT operations in emulator
+ assertTrue(broker.start());
+ }
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
- assertNotNull(adapter);
- assertTrue(adapter.isEnabled());
-
+ if(!DeviceUtil.isEmulator()){ // Cannot perform BT adapter operations in emulator
+ assertNotNull(adapter);
+ assertTrue(adapter.isEnabled());
+ }
//Not ideal, but not implementing callbacks just for unit tests
int count = 0;
while(broker.routerServiceMessenger == null && count<10){
sleep();
count++;
}
- assertNotNull(broker.routerServiceMessenger);
-
-
+ if(!DeviceUtil.isEmulator()){ // Cannot perform BT adapter operations in emulator
+ assertNotNull(broker.routerServiceMessenger);
+ }
+
//assertFalse(broker.sendPacketToRouterService(null, 0, 0));
//assertFalse(broker.sendPacketToRouterService(new byte[3], -1, 0));
//assertFalse(broker.sendPacketToRouterService(new byte[3], 0, 4));
//assertTrue(broker.sendPacketToRouterService(new byte[3],0, 3));
-
+
broker.stop();
+
}
public void testOnPacketReceived(){
- TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID,rsvp.getService());
- assertTrue(broker.start());
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+ TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID, rsvp.getService());
+ if(!DeviceUtil.isEmulator()){ // Cannot perform MBT operations in emulator
+ assertTrue(broker.start());
+ }
+
}
public void testSendMessageToRouterService(){
- TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID,rsvp.getService());
+ if (Looper.myLooper() == null) {
+ Looper.prepare();
+ }
+
+ TransportBroker broker = new TransportBroker(mContext, SdlUnitTestContants.TEST_APP_ID, rsvp.getService());
Handler handler = new Handler();
- Message message = new Message();
+ Message message = new Message();
broker.routerServiceMessenger = null;
broker.isBound = true;
+
assertFalse(broker.sendMessageToRouterService(message));
-
+
broker.routerServiceMessenger = new Messenger(handler); //So it's not ambiguous
+
broker.isBound = false;
+
assertFalse(broker.sendMessageToRouterService(message));
-
+
broker.isBound = true;
broker.registeredWithRouterService = true;
-
+
message = null;
+
assertFalse(broker.sendMessageToRouterService(message));
-
+
message = new Message();
-
+
assertTrue(broker.sendMessageToRouterService(message));
-
-
-
-
}
-
-
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
index f4b4c43d9..16350da4b 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/ISdlConnectionListener.java
@@ -3,6 +3,8 @@ package com.smartdevicelink.SdlConnection;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
+import java.util.List;
+
public interface ISdlConnectionListener {
public void onTransportDisconnected(String info);
@@ -12,7 +14,7 @@ public interface ISdlConnectionListener {
public void onProtocolMessageReceived(ProtocolMessage msg);
public void onProtocolSessionStartedNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID);
+ byte sessionID, byte version, String correlationID, List<String> rejectedParams);
public void onProtocolSessionStarted(SessionType sessionType,
byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted);
diff --git a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java
index 272c1878d..b346884aa 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java
@@ -1,6 +1,7 @@
package com.smartdevicelink.SdlConnection;
+import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import android.content.ComponentName;
@@ -263,8 +264,9 @@ public class SdlConnection implements IProtocolListener, ITransportListener {
@Override
public void onProtocolSessionNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
- _connectionListener.onProtocolSessionStartedNACKed(sessionType, sessionID, version, correlationID);
+ byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
+ _connectionListener.onProtocolSessionStartedNACKed(sessionType,
+ sessionID, version, correlationID, rejectedParams);
}
@Override
@@ -433,10 +435,11 @@ public class SdlConnection implements IProtocolListener, ITransportListener {
@Override
public void onProtocolSessionStartedNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
+ byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
SdlSession session = findSessionById(sessionID);
if (session != null) {
- session.onProtocolSessionStartedNACKed(sessionType, sessionID, version, correlationID);
+ session.onProtocolSessionStartedNACKed(sessionType,
+ sessionID, version, correlationID, rejectedParams);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
index 1a9d051a6..20bcc0cc8 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java
@@ -5,6 +5,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -15,6 +16,7 @@ import android.util.Log;
import android.view.Surface;
import com.smartdevicelink.encoder.SdlEncoder;
+import com.smartdevicelink.encoder.VirtualDisplayEncoder;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
@@ -22,11 +24,19 @@ import com.smartdevicelink.protocol.heartbeat.IHeartbeatMonitor;
import com.smartdevicelink.protocol.heartbeat.IHeartbeatMonitorListener;
import com.smartdevicelink.proxy.LockScreenManager;
import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.interfaces.IAudioStreamListener;
+import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
import com.smartdevicelink.security.ISecurityInitializedListener;
import com.smartdevicelink.security.SdlSecurityBase;
+import com.smartdevicelink.streaming.AbstractPacketizer;
import com.smartdevicelink.streaming.IStreamListener;
+import com.smartdevicelink.streaming.video.RTPH264Packetizer;
import com.smartdevicelink.streaming.StreamPacketizer;
import com.smartdevicelink.streaming.StreamRPCPacketizer;
+import com.smartdevicelink.streaming.video.VideoStreamingParameters;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.MultiplexTransport;
import com.smartdevicelink.transport.enums.TransportType;
@@ -46,11 +56,15 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
private LockScreenManager lockScreenMan = new LockScreenManager();
private SdlSecurityBase sdlSecurity = null;
StreamRPCPacketizer mRPCPacketizer = null;
- StreamPacketizer mVideoPacketizer = null;
+ AbstractPacketizer mVideoPacketizer = null;
StreamPacketizer mAudioPacketizer = null;
SdlEncoder mSdlEncoder = null;
+ VirtualDisplayEncoder virtualDisplayEncoder = null;
private final static int BUFF_READ_SIZE = 1024;
private int sessionHashId = 0;
+ private HashMap<SessionType, CopyOnWriteArrayList<ISdlServiceListener>> serviceListeners;
+ private VideoStreamingParameters desiredVideoParams = null;
+ private VideoStreamingParameters acceptedVideoParams = null;
public static SdlSession createSession(byte wiproVersion, ISdlConnectionListener listener, BaseTransportConfig btConfig) {
@@ -113,6 +127,14 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
}
}
+ public long getMtu(SessionType type) {
+ if (this._sdlConnection != null) {
+ return this._sdlConnection.getWiProProtocol().getMtu(type);
+ } else {
+ return 0;
+ }
+ }
+
public void close() {
if (sdlSecurity != null)
{
@@ -134,8 +156,10 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
public void startStream(InputStream is, SessionType sType, byte rpcSessionID) throws IOException {
if (sType.equals(SessionType.NAV))
{
- mVideoPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID, this);
- mVideoPacketizer.sdlConnection = this.getSdlConnection();
+ // protocol is fixed to RAW
+ StreamPacketizer packetizer = new StreamPacketizer(this, is, sType, rpcSessionID, this);
+ packetizer.sdlConnection = this.getSdlConnection();
+ mVideoPacketizer = packetizer;
mVideoPacketizer.start();
}
else if (sType.equals(SessionType.PCM))
@@ -157,8 +181,10 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
}
if (sType.equals(SessionType.NAV))
{
- mVideoPacketizer = new StreamPacketizer(this, is, sType, rpcSessionID, this);
- mVideoPacketizer.sdlConnection = this.getSdlConnection();
+ // protocol is fixed to RAW
+ StreamPacketizer packetizer = new StreamPacketizer(this, is, sType, rpcSessionID, this);
+ packetizer.sdlConnection = this.getSdlConnection();
+ mVideoPacketizer = packetizer;
mVideoPacketizer.start();
}
else if (sType.equals(SessionType.PCM))
@@ -175,7 +201,47 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
}
return os;
}
-
+
+ public IVideoStreamListener startVideoStream() {
+ byte rpcSessionID = getSessionId();
+ VideoStreamingProtocol protocol = getAcceptedProtocol();
+ try {
+ switch (protocol) {
+ case RAW: {
+ StreamPacketizer packetizer = new StreamPacketizer(this, null, SessionType.NAV, rpcSessionID, this);
+ packetizer.sdlConnection = this.getSdlConnection();
+ mVideoPacketizer = packetizer;
+ mVideoPacketizer.start();
+ return packetizer;
+ }
+ case RTP: {
+ RTPH264Packetizer packetizer = new RTPH264Packetizer(this, SessionType.NAV, rpcSessionID, this);
+ mVideoPacketizer = packetizer;
+ mVideoPacketizer.start();
+ return packetizer;
+ }
+ default:
+ Log.e(TAG, "Protocol " + protocol + " is not supported.");
+ return null;
+ }
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ public IAudioStreamListener startAudioStream() {
+ byte rpcSessionID = getSessionId();
+ try {
+ StreamPacketizer packetizer = new StreamPacketizer(this, null, SessionType.PCM, rpcSessionID, this);
+ packetizer.sdlConnection = this.getSdlConnection();
+ mAudioPacketizer = packetizer;
+ mAudioPacketizer.start();
+ return packetizer;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
public void startRPCStream(InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion) {
try {
mRPCPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0, this);
@@ -284,19 +350,18 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
public Surface createOpenGLInputSurface(int frameRate, int iFrameInterval, int width,
int height, int bitrate, SessionType sType, byte rpcSessionID) {
- try {
- PipedOutputStream stream = (PipedOutputStream) startStream(sType, rpcSessionID);
- if (stream == null) return null;
- mSdlEncoder = new SdlEncoder();
- mSdlEncoder.setFrameRate(frameRate);
- mSdlEncoder.setFrameInterval(iFrameInterval);
- mSdlEncoder.setFrameWidth(width);
- mSdlEncoder.setFrameHeight(height);
- mSdlEncoder.setBitrate(bitrate);
- mSdlEncoder.setOutputStream(stream);
- } catch (IOException e) {
+ IVideoStreamListener encoderListener = startVideoStream();
+ if (encoderListener == null) {
return null;
}
+
+ mSdlEncoder = new SdlEncoder();
+ mSdlEncoder.setFrameRate(frameRate);
+ mSdlEncoder.setFrameInterval(iFrameInterval);
+ mSdlEncoder.setFrameWidth(width);
+ mSdlEncoder.setFrameHeight(height);
+ mSdlEncoder.setBitrate(bitrate);
+ mSdlEncoder.setOutputListener(encoderListener);
return mSdlEncoder.prepareEncoder();
}
@@ -482,6 +547,12 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
if (isEncrypted)
encryptedServices.addIfAbsent(sessionType);
this.sessionListener.onProtocolSessionStarted(sessionType, sessionID, version, correlationID, hashID, isEncrypted);
+ if(serviceListeners != null && serviceListeners.containsKey(sessionType)){
+ CopyOnWriteArrayList<ISdlServiceListener> listeners = serviceListeners.get(sessionType);
+ for(ISdlServiceListener listener:listeners){
+ listener.onServiceStarted(this, sessionType, isEncrypted);
+ }
+ }
//if (version == 3)
initialiseSession();
if (sessionType.eq(SessionType.RPC)){
@@ -493,6 +564,12 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
public void onProtocolSessionEnded(SessionType sessionType, byte sessionID,
String correlationID) {
this.sessionListener.onProtocolSessionEnded(sessionType, sessionID, correlationID);
+ if(serviceListeners != null && serviceListeners.containsKey(sessionType)){
+ CopyOnWriteArrayList<ISdlServiceListener> listeners = serviceListeners.get(sessionType);
+ for(ISdlServiceListener listener:listeners){
+ listener.onServiceEnded(this, sessionType);
+ }
+ }
encryptedServices.remove(sessionType);
}
@@ -533,15 +610,27 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
@Override
public void onProtocolSessionStartedNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
- this.sessionListener.onProtocolSessionStartedNACKed(sessionType, sessionID, version, correlationID);
+ byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
+ this.sessionListener.onProtocolSessionStartedNACKed(sessionType,
+ sessionID, version, correlationID, rejectedParams);
+ if(serviceListeners != null && serviceListeners.containsKey(sessionType)){
+ CopyOnWriteArrayList<ISdlServiceListener> listeners = serviceListeners.get(sessionType);
+ for(ISdlServiceListener listener:listeners){
+ listener.onServiceError(this, sessionType, "Start "+ sessionType.toString() +" Service NACK'ed");
+ }
+ }
}
@Override
public void onProtocolSessionEndedNACKed(SessionType sessionType,
byte sessionID, String correlationID) {
this.sessionListener.onProtocolSessionEndedNACKed(sessionType, sessionID, correlationID);
-
+ if(serviceListeners != null && serviceListeners.containsKey(sessionType)){
+ CopyOnWriteArrayList<ISdlServiceListener> listeners = serviceListeners.get(sessionType);
+ for(ISdlServiceListener listener:listeners){
+ listener.onServiceError(this, sessionType, "End "+ sessionType.toString() +" Service NACK'ed");
+ }
+ }
}
@Override
@@ -596,4 +685,66 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
public static boolean removeConnection(SdlConnection connection){
return shareConnections.remove(connection);
}
+
+ public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener){
+ if(serviceListeners == null){
+ serviceListeners = new HashMap<>();
+ }
+ if(serviceType != null && sdlServiceListener != null){
+ if(!serviceListeners.containsKey(serviceType)){
+ serviceListeners.put(serviceType,new CopyOnWriteArrayList<ISdlServiceListener>());
+ }
+ serviceListeners.get(serviceType).add(sdlServiceListener);
+ }
+ }
+
+ public boolean removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener){
+ if(serviceListeners!= null && serviceType != null && sdlServiceListener != null && serviceListeners.containsKey(serviceType)){
+ return serviceListeners.get(serviceType).remove(sdlServiceListener);
+ }
+ return false;
+ }
+
+
+ public HashMap<SessionType, CopyOnWriteArrayList<ISdlServiceListener>> getServiceListeners(){
+ return serviceListeners;
+ }
+
+ public void setDesiredVideoParams(VideoStreamingParameters params){
+ this.desiredVideoParams = params;
+ }
+
+ /**
+ * Returns the currently set desired video streaming parameters. If there haven't been any set,
+ * the default options will be returned and set for this instance.
+ * @return
+ */
+ public VideoStreamingParameters getDesiredVideoParams(){
+ if(desiredVideoParams == null){
+ desiredVideoParams = new VideoStreamingParameters();
+ }
+ return desiredVideoParams;
+ }
+
+ public void setAcceptedVideoParams(VideoStreamingParameters params){
+ this.acceptedVideoParams = params;
+ }
+
+ public VideoStreamingParameters getAcceptedVideoParams(){
+ return acceptedVideoParams;
+ }
+
+ private VideoStreamingProtocol getAcceptedProtocol() {
+ // acquire default protocol (RAW)
+ VideoStreamingProtocol protocol = new VideoStreamingParameters().getFormat().getProtocol();
+
+ if (acceptedVideoParams != null) {
+ VideoStreamingFormat format = acceptedVideoParams.getFormat();
+ if (format != null && format.getProtocol() != null) {
+ protocol = format.getProtocol();
+ }
+ }
+
+ return protocol;
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java b/sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java
new file mode 100644
index 000000000..362564da8
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.encoder;
+
+import android.annotation.TargetApi;
+import android.media.MediaFormat;
+import android.os.Build;
+import android.util.Log;
+
+import java.nio.ByteBuffer;
+
+@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
+public final class EncoderUtils {
+ private final static String TAG = "EncoderUtils";
+
+ /**
+ * Extracts codec-specific data from MediaFormat instance
+ *
+ * Currently, only AVC is supported.
+ *
+ * @param format MediaFormat instance retrieved from MediaCodec
+ * @return byte array containing codec-specific data, or null if an error occurred
+ */
+ public static byte[] getCodecSpecificData(MediaFormat format) {
+ if (format == null) {
+ return null;
+ }
+
+ String name = format.getString(MediaFormat.KEY_MIME);
+ if (name == null) {
+ return null;
+ }
+
+ // same as MediaFormat.MIMETYPE_VIDEO_AVC but it requires API level 21
+ if (name.equals("video/avc")) {
+ return getAVCCodecSpecificData(format);
+ } else {
+ Log.w(TAG, "Retrieving codec-specific data for " + name + " is not supported");
+ return null;
+ }
+ }
+
+ /**
+ * Extracts H.264 codec-specific data (SPS and PPS) from MediaFormat instance
+ *
+ * The codec-specific data is in byte-stream format; 4-byte start codes (0x00 0x00 0x00 0x01)
+ * are added in front of SPS and PPS NAL units.
+ *
+ * @param format MediaFormat instance retrieved from MediaCodec
+ * @return byte array containing codec-specific data, or null if an error occurred
+ */
+ private static byte[] getAVCCodecSpecificData(MediaFormat format) {
+ // For H.264, "csd-0" contains SPS and "csd-1" contains PPS. Refer to the documentation
+ // of MediaCodec.
+ if (!(format.containsKey("csd-0") && format.containsKey("csd-1"))) {
+ Log.w(TAG, "H264 codec specific data not found");
+ return null;
+ }
+
+ ByteBuffer sps = format.getByteBuffer("csd-0");
+ int spsLen = sps.remaining();
+ ByteBuffer pps = format.getByteBuffer("csd-1");
+ int ppsLen = pps.remaining();
+
+ byte[] output = new byte[spsLen + ppsLen];
+ try {
+ sps.get(output, 0, spsLen);
+ pps.get(output, spsLen, ppsLen);
+ } catch (Exception e) {
+ // should not happen
+ Log.w(TAG, "Error while copying H264 codec specific data: " + e);
+ return null;
+ }
+
+ return output;
+ }
+
+ private EncoderUtils() {}
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java b/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java
index 81e344840..bd1e0c364 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java
@@ -9,11 +9,16 @@ import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.os.Build;
+import android.util.Log;
import android.view.Surface;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public class SdlEncoder {
-
+
+ private static final String TAG = "SdlEncoder";
+
// parameters for the encoder
private static final String _MIME_TYPE = "video/avc"; // H.264/AVC video
// private static final String MIME_TYPE = "video/mp4v-es"; //MPEG4 video
@@ -26,10 +31,13 @@ public class SdlEncoder {
// encoder state
private MediaCodec mEncoder;
private PipedOutputStream mOutputStream;
+ private IVideoStreamListener mOutputListener;
// allocate one of these up front so we don't need to do it every time
private MediaCodec.BufferInfo mBufferInfo;
-
+
+ // Codec-specific data (SPS and PPS)
+ private byte[] mH264CodecSpecificData = null;
public SdlEncoder () {
}
@@ -51,6 +59,9 @@ public class SdlEncoder {
public void setOutputStream(PipedOutputStream mStream){
mOutputStream = mStream;
}
+ public void setOutputListener(IVideoStreamListener listener) {
+ mOutputListener = listener;
+ }
public Surface prepareEncoder () {
mBufferInfo = new MediaCodec.BufferInfo();
@@ -114,6 +125,7 @@ public class SdlEncoder {
}
mOutputStream = null;
}
+ mH264CodecSpecificData = null;
}
/**
@@ -127,7 +139,7 @@ public class SdlEncoder {
public void drainEncoder(boolean endOfStream) {
final int TIMEOUT_USEC = 10000;
- if(mEncoder == null || mOutputStream == null) {
+ if(mEncoder == null || (mOutputStream == null && mOutputListener == null)) {
return;
}
if (endOfStream) {
@@ -147,15 +159,52 @@ public class SdlEncoder {
// not expected for an encoder
encoderOutputBuffers = mEncoder.getOutputBuffers();
} else if (encoderStatus == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
+ if (mH264CodecSpecificData == null) {
+ MediaFormat format = mEncoder.getOutputFormat();
+ mH264CodecSpecificData = EncoderUtils.getCodecSpecificData(format);
+ } else {
+ Log.w(TAG, "Output format change notified more than once, ignoring.");
+ }
} else if (encoderStatus < 0) {
} else {
+ if ((mBufferInfo.flags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG) != 0) {
+ // If we already retrieve codec specific data via OUTPUT_FORMAT_CHANGED event,
+ // we do not need this data.
+ if (mH264CodecSpecificData != null) {
+ mBufferInfo.size = 0;
+ } else {
+ Log.i(TAG, "H264 codec specific data not retrieved yet.");
+ }
+ }
+
if (mBufferInfo.size != 0) {
- byte[] dataToWrite = new byte[mBufferInfo.size];
- encoderOutputBuffers[encoderStatus].get(dataToWrite,
- mBufferInfo.offset, mBufferInfo.size);
+ ByteBuffer encoderOutputBuffer = encoderOutputBuffers[encoderStatus];
+ byte[] dataToWrite = null;
+ int dataOffset = 0;
+
+ // append SPS and PPS in front of every IDR NAL unit
+ if ((mBufferInfo.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) != 0
+ && mH264CodecSpecificData != null) {
+ dataToWrite = new byte[mH264CodecSpecificData.length + mBufferInfo.size];
+ System.arraycopy(mH264CodecSpecificData, 0,
+ dataToWrite, 0, mH264CodecSpecificData.length);
+ dataOffset = mH264CodecSpecificData.length;
+ } else {
+ dataToWrite = new byte[mBufferInfo.size];
+ }
try {
- mOutputStream.write(dataToWrite, 0, mBufferInfo.size);
+ encoderOutputBuffer.position(mBufferInfo.offset);
+ encoderOutputBuffer.limit(mBufferInfo.offset + mBufferInfo.size);
+
+ encoderOutputBuffer.get(dataToWrite, dataOffset, mBufferInfo.size);
+
+ if (mOutputStream != null) {
+ mOutputStream.write(dataToWrite, 0, mBufferInfo.size);
+ } else if (mOutputListener != null) {
+ mOutputListener.sendFrame(
+ dataToWrite, 0, dataToWrite.length, mBufferInfo.presentationTimeUs);
+ }
} catch (Exception e) {}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java b/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java
new file mode 100644
index 000000000..0fe303c71
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java
@@ -0,0 +1,400 @@
+/*
+ * Copyright (c) 2017 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.encoder;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.hardware.display.DisplayManager;
+import android.hardware.display.VirtualDisplay;
+import android.media.MediaCodec;
+import android.media.MediaCodecInfo;
+import android.media.MediaFormat;
+import android.os.Build;
+import android.util.Log;
+import android.view.Display;
+import android.view.Surface;
+
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
+import com.smartdevicelink.proxy.rpc.ImageResolution;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.streaming.video.VideoStreamingParameters;
+
+import java.nio.ByteBuffer;
+
+@TargetApi(19)
+@SuppressWarnings("NullableProblems")
+public class VirtualDisplayEncoder {
+ private static final String TAG = "VirtualDisplayEncoder";
+ private VideoStreamingParameters streamingParams = new VideoStreamingParameters();
+ private DisplayManager mDisplayManager;
+ private volatile MediaCodec mVideoEncoder = null;
+ private volatile MediaCodec.BufferInfo mVideoBufferInfo = null;
+ private volatile Surface inputSurface = null;
+ private volatile VirtualDisplay virtualDisplay = null;
+ private IVideoStreamListener mOutputListener;
+ private Boolean initPassed = false;
+ private final Object STREAMING_LOCK = new Object();
+
+ // Codec-specific data (SPS and PPS)
+ private byte[] mH264CodecSpecificData = null;
+
+ //For older (<21) OS versions
+ private Thread encoderThread;
+
+
+ /**
+ * Initialization method for VirtualDisplayEncoder object. MUST be called before start() or shutdown()
+ * Will overwrite previously set videoWeight and videoHeight
+ * @param context to create the virtual display
+ * @param outputListener the listener that the video frames will be sent through
+ * @param streamingParams parameters to create the virtual display and encoder
+ * @throws Exception if the API level is <19 or supplied parameters were null
+ */
+ public void init(Context context, IVideoStreamListener outputListener, VideoStreamingParameters streamingParams) throws Exception {
+ if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
+ Log.e(TAG, "API level of 19 required for VirtualDisplayEncoder");
+ throw new Exception("API level of 19 required");
+ }
+
+ if (context == null || outputListener == null || streamingParams == null || streamingParams.getResolution() == null || streamingParams.getFormat() == null) {
+ Log.e(TAG, "init parameters cannot be null for VirtualDisplayEncoder");
+ throw new Exception("init parameters cannot be null");
+ }
+
+ this.mDisplayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
+
+ this.streamingParams.update(streamingParams);
+
+ mOutputListener = outputListener;
+
+ initPassed = true;
+ }
+
+ @SuppressWarnings("unused")
+ public VideoStreamingParameters getStreamingParams(){
+ return this.streamingParams;
+ }
+
+ @SuppressWarnings("unused")
+ public void setStreamingParams(int displayDensity, ImageResolution resolution, int frameRate, int bitrate, int interval, VideoStreamingFormat format) {
+ this.streamingParams = new VideoStreamingParameters(displayDensity, frameRate, bitrate, interval, resolution, format);
+ }
+
+ @SuppressWarnings("unused")
+ public void setStreamingParams(VideoStreamingParameters streamingParams) {
+ this.streamingParams = streamingParams;
+ }
+
+ /**
+ * NOTE: Must call init() without error before calling this method.
+ * Prepares the encoder and virtual display.
+ */
+ public void start() throws Exception {
+ if (!initPassed) {
+ Log.e(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method.");
+ return;
+ }
+ if (streamingParams == null || streamingParams.getResolution() == null || streamingParams.getFormat() == null) {
+ return;
+ }
+
+ synchronized (STREAMING_LOCK) {
+
+ try {
+ inputSurface = prepareVideoEncoder();
+
+ // Create a virtual display that will output to our encoder.
+ virtualDisplay = mDisplayManager.createVirtualDisplay(TAG,
+ streamingParams.getResolution().getResolutionWidth(), streamingParams.getResolution().getResolutionHeight(),
+ streamingParams.getDisplayDensity(), inputSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);
+
+ startEncoder();
+
+ } catch (Exception ex) {
+ Log.e(TAG, "Unable to create Virtual Display.");
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+
+ public void shutDown() {
+ if (!initPassed) {
+ Log.e(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method.");
+ return;
+ }
+ try {
+ if (encoderThread != null) {
+ encoderThread.interrupt();
+ encoderThread = null;
+ }
+
+ if (mVideoEncoder != null) {
+ mVideoEncoder.stop();
+ mVideoEncoder.release();
+ mVideoEncoder = null;
+ }
+
+ if (virtualDisplay != null) {
+ virtualDisplay.release();
+ virtualDisplay = null;
+ }
+
+ if (inputSurface != null) {
+ inputSurface.release();
+ inputSurface = null;
+ }
+ } catch (Exception ex) {
+ Log.e(TAG, "shutDown() failed");
+ }
+ }
+
+ private Surface prepareVideoEncoder() {
+
+ if (streamingParams == null || streamingParams.getResolution() == null || streamingParams.getFormat() == null) {
+ return null;
+ }
+
+ if (mVideoBufferInfo == null) {
+ mVideoBufferInfo = new MediaCodec.BufferInfo();
+ }
+
+ String videoMimeType = getMimeForFormat(streamingParams.getFormat());
+
+ MediaFormat format = MediaFormat.createVideoFormat(videoMimeType, streamingParams.getResolution().getResolutionWidth(), streamingParams.getResolution().getResolutionHeight());
+
+ // Set some required properties. The media codec may fail if these aren't defined.
+ format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
+ format.setInteger(MediaFormat.KEY_BIT_RATE, streamingParams.getBitrate());
+ format.setInteger(MediaFormat.KEY_FRAME_RATE, streamingParams.getFrameRate());
+ format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, streamingParams.getInterval()); // seconds between I-frames
+
+
+ // Create a MediaCodec encoder and configure it. Get a Surface we can use for recording into.
+ try {
+ mVideoEncoder = MediaCodec.createEncoderByType(videoMimeType);
+ mVideoEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
+ Surface surface = mVideoEncoder.createInputSurface(); //prepared
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ mVideoEncoder.setCallback(new MediaCodec.Callback() {
+ @Override
+ public void onInputBufferAvailable(MediaCodec codec, int index) {
+ // nothing to do here
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ @Override
+ public void onOutputBufferAvailable(MediaCodec codec, int index, MediaCodec.BufferInfo info) {
+ try {
+ ByteBuffer encodedData = codec.getOutputBuffer(index);
+ if (encodedData != null) {
+ if (info.size != 0) {
+ byte[] dataToWrite;// = new byte[info.size];
+ int dataOffset = 0;
+
+ // append SPS and PPS in front of every IDR NAL unit
+ if ((info.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) != 0 && mH264CodecSpecificData != null) {
+ dataToWrite = new byte[mH264CodecSpecificData.length + info.size];
+ System.arraycopy(mH264CodecSpecificData, 0, dataToWrite, 0, mH264CodecSpecificData.length);
+ dataOffset = mH264CodecSpecificData.length;
+ } else {
+ dataToWrite = new byte[info.size];
+ }
+
+ encodedData.position(info.offset);
+ encodedData.limit(info.offset + info.size);
+
+ encodedData.get(dataToWrite, dataOffset, info.size);
+ if (mOutputListener != null) {
+ mOutputListener.sendFrame(dataToWrite, 0, dataToWrite.length, info.presentationTimeUs);
+ }
+ }
+
+ codec.releaseOutputBuffer(index, false);
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onError(MediaCodec codec, MediaCodec.CodecException e) {
+ e.printStackTrace();
+ }
+
+ @Override
+ public void onOutputFormatChanged(MediaCodec codec, MediaFormat format) {
+ mH264CodecSpecificData = EncoderUtils.getCodecSpecificData(format);
+ }
+ });
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ //Implied from previous if check that this has to be older than Build.VERSION_CODES.LOLLIPOP
+ encoderThread = new Thread(new EncoderCompat());
+
+ } else {
+ Log.e(TAG, "Unable to start encoder. Android OS version " + Build.VERSION.SDK_INT + "is not supported");
+ }
+
+ return surface;
+
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return null;
+ }
+
+ private void startEncoder() {
+ if (mVideoEncoder != null) {
+ mVideoEncoder.start();
+ }
+ if (encoderThread != null) {
+ encoderThread.start();
+ }
+ }
+
+ public Display getVirtualDisplay() {
+ return virtualDisplay.getDisplay();
+ }
+
+ private String getMimeForFormat(VideoStreamingFormat format) {
+ if (format != null) {
+ VideoStreamingCodec codec = format.getCodec();
+ if (codec != null) {
+ switch (codec) { //MediaFormat constants are only available in Android 21+
+ case VP8:
+ return "video/x-vnd.on2.vp8"; //MediaFormat.MIMETYPE_VIDEO_VP8
+ case VP9:
+ return "video/x-vnd.on2.vp9"; //MediaFormat.MIMETYPE_VIDEO_VP9
+ case H264: //Fall through
+ default:
+ return "video/avc"; // MediaFormat.MIMETYPE_VIDEO_AVC
+ }
+ }
+ }
+ return null;
+ }
+
+ private class EncoderCompat implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ drainEncoder(false);
+ } catch (Exception e) {
+ Log.w(TAG, "Error attempting to drain encoder");
+ } finally {
+ mVideoEncoder.release();
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ void drainEncoder(boolean endOfStream) {
+ if (mVideoEncoder == null || mOutputListener == null) {
+ return;
+ }
+
+ if (endOfStream) {
+ mVideoEncoder.signalEndOfInputStream();
+ }
+
+ ByteBuffer[] encoderOutputBuffers = mVideoEncoder.getOutputBuffers();
+ Thread currentThread = Thread.currentThread();
+ while (!currentThread.isInterrupted()) {
+ int encoderStatus = mVideoEncoder.dequeueOutputBuffer(mVideoBufferInfo, -1);
+ if(encoderStatus < 0){
+ if (encoderStatus == MediaCodec.INFO_TRY_AGAIN_LATER) {
+ // no output available yet
+ if (!endOfStream) {
+ break; // out of while
+ }
+ } else if (encoderStatus == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
+ // not expected for an encoder
+ encoderOutputBuffers = mVideoEncoder.getOutputBuffers();
+ } else if (encoderStatus == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
+ if (mH264CodecSpecificData == null) {
+ MediaFormat format = mVideoEncoder.getOutputFormat();
+ mH264CodecSpecificData = EncoderUtils.getCodecSpecificData(format);
+ } else {
+ Log.w(TAG, "Output format change notified more than once, ignoring.");
+ }
+ }
+ } else {
+ if ((mVideoBufferInfo.flags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG) != 0) {
+ // If we already retrieve codec specific data via OUTPUT_FORMAT_CHANGED event,
+ // we do not need this data.
+ if (mH264CodecSpecificData != null) {
+ mVideoBufferInfo.size = 0;
+ } else {
+ Log.i(TAG, "H264 codec specific data not retrieved yet.");
+ }
+ }
+
+ if (mVideoBufferInfo.size != 0) {
+ ByteBuffer encoderOutputBuffer = encoderOutputBuffers[encoderStatus];
+ byte[] dataToWrite;
+ int dataOffset = 0;
+
+ // append SPS and PPS in front of every IDR NAL unit
+ if ((mVideoBufferInfo.flags & MediaCodec.BUFFER_FLAG_KEY_FRAME) != 0 && mH264CodecSpecificData != null) {
+ dataToWrite = new byte[mH264CodecSpecificData.length + mVideoBufferInfo.size];
+ System.arraycopy(mH264CodecSpecificData, 0, dataToWrite, 0, mH264CodecSpecificData.length);
+ dataOffset = mH264CodecSpecificData.length;
+ } else {
+ dataToWrite = new byte[mVideoBufferInfo.size];
+ }
+
+ try {
+ encoderOutputBuffer.position(mVideoBufferInfo.offset);
+ encoderOutputBuffer.limit(mVideoBufferInfo.offset + mVideoBufferInfo.size);
+
+ encoderOutputBuffer.get(dataToWrite, dataOffset, mVideoBufferInfo.size);
+
+ if (mOutputListener != null) {
+ mOutputListener.sendFrame(dataToWrite, 0, dataToWrite.length, mVideoBufferInfo.presentationTimeUs);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ mVideoEncoder.releaseOutputBuffer(encoderStatus, false);
+
+ if ((mVideoBufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
+ break; // out of while
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/main/java/com/smartdevicelink/haptic/HapticInterfaceManager.java b/sdl_android/src/main/java/com/smartdevicelink/haptic/HapticInterfaceManager.java
new file mode 100644
index 000000000..9a6e44897
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/haptic/HapticInterfaceManager.java
@@ -0,0 +1,131 @@
+/***************************************************************************************************
+ * Copyright © 2017 Xevo Inc.
+ * Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
+ * and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
+ * endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+ * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **************************************************************************************************/
+package com.smartdevicelink.haptic;
+
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.rpc.HapticRect;
+import com.smartdevicelink.proxy.rpc.Rectangle;
+import com.smartdevicelink.proxy.rpc.SendHapticData;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created on 9/22/2017.
+ *
+ * Manages haptic data used to render focusable areas on the HU screen. App developers can
+ * over-ride the default logic used to find focusable Views by passing their own data to
+ * {@link #setHapticData(List)}
+ */
+public class HapticInterfaceManager {
+ private static final String TAG = "Haptic";
+
+ private WeakReference<ISdl> proxyHolder;
+ private List<HapticRect> userHapticData;
+
+ public HapticInterfaceManager(ISdl proxy) {
+ this.proxyHolder = new WeakReference<>(proxy);
+ }
+
+ /**
+ * Sets haptic data and sends update to the HU. To be used by app code instead of letting
+ * Presentation find the Views and automatically send to HU.
+ *
+ * @param hapticData
+ * Rect data indicating "focusable" screen elements or areas
+ */
+ public void setHapticData(List<HapticRect> hapticData) {
+ userHapticData = hapticData;
+ ISdl proxy = proxyHolder.get();
+ if (proxy != null) {
+ SendHapticData msg = new SendHapticData();
+ msg.setHapticRectData(userHapticData);
+ proxy.sendRPCRequest(msg);
+ }
+ }
+
+ /**
+ * Sends haptic data found by searching for focusable and clickable Views in the view heirarchy
+ * to the HU. Should be called by Presentation's OnShowListener.
+ *
+ * @param root
+ * the root or parent View
+ */
+ public void refreshHapticData(View root) {
+ ISdl proxy = proxyHolder.get();
+ if ((userHapticData == null) && (proxy != null)) {
+ List<HapticRect> hapticRects = new ArrayList<>();
+ findHapticRects(root, hapticRects);
+
+ SendHapticData msg = new SendHapticData();
+ msg.setHapticRectData(hapticRects);
+
+ proxy.sendRPCRequest(msg);
+ }
+ }
+
+ private void findHapticRects(View root, final List<HapticRect> hapticRects) {
+ List<View> focusables = new ArrayList<>();
+ getFocusableViews(root, focusables);
+
+ int [] loc = new int[2];
+ int id = 0;
+ for (View view : focusables) {
+ int w = view.getWidth();
+ int h = view.getHeight();
+ view.getLocationOnScreen(loc);
+
+ Rectangle rect = new Rectangle();
+ rect.setWidth((float) w);
+ rect.setHeight((float) h);
+ rect.setX((float) loc[0]);
+ rect.setY((float) loc[1]);
+
+ HapticRect hapticRect = new HapticRect();
+ hapticRect.setId(id++);
+ hapticRect.setRect(rect);
+ hapticRects.add(hapticRect);
+ }
+ }
+
+ private void getFocusableViews(View view, final List<View> focusables) {
+ // Not using addFocusables() or addTouchables() because of concerns with adding ViewGroup
+ // and not getting "clickables."
+
+ if (!(view instanceof ViewGroup) && (view != null) &&
+ (view.isFocusable() || view.isClickable())) {
+ focusables.add(view);
+ }
+
+ if (view instanceof ViewGroup) {
+ ViewGroup parent = (ViewGroup) view;
+
+ for (int i = 0; i < parent.getChildCount(); i++) {
+ getFocusableViews(parent.getChildAt(i), focusables);
+ }
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/AbstractProtocol.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/AbstractProtocol.java
index 8acc709e1..bb8c7fb6c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/AbstractProtocol.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/AbstractProtocol.java
@@ -3,6 +3,8 @@ package com.smartdevicelink.protocol;
import com.smartdevicelink.protocol.WiProProtocol.MessageFrameAssembler;
import com.smartdevicelink.protocol.enums.SessionType;
+import java.util.List;
+
public abstract class AbstractProtocol {
private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
@@ -31,6 +33,7 @@ public abstract class AbstractProtocol {
public abstract void SendMessage(ProtocolMessage msg);
public abstract int getMtu();
+ public abstract long getMtu(SessionType type);
public abstract void handlePacketReceived(SdlPacket packet);
@@ -128,8 +131,8 @@ public abstract class AbstractProtocol {
}
protected void handleProtocolSessionNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
- _protocolListener.onProtocolSessionNACKed(sessionType, sessionID, version, correlationID);
+ byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
+ _protocolListener.onProtocolSessionNACKed(sessionType, sessionID, version, correlationID, rejectedParams);
}
// This method handles protocol errors. A callback is sent to the protocol
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java
index eb8f36831..5848b9f5a 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java
@@ -44,7 +44,7 @@ public class BinaryFrameHeader {
System.arraycopy(binHeader, 12 + _jsonSize, _bulkData, 0, _bulkData.length);
msg.setBulkData(_bulkData);
}
- } catch (OutOfMemoryError e){
+ } catch (OutOfMemoryError|ArrayIndexOutOfBoundsException e){
Log.e(TAG, "Unable to process data to form header");
return null;
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java
index b54ff66c8..04397b935 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/IProtocolListener.java
@@ -2,6 +2,8 @@ package com.smartdevicelink.protocol;
import com.smartdevicelink.protocol.enums.*;
+import java.util.List;
+
public interface IProtocolListener {
// Called to indicate that these bytes are to be sent as part of a message.
// This call includes the part of the message.
@@ -14,7 +16,8 @@ public interface IProtocolListener {
// Called to indicate that a protocol session has been started (from either side)
void onProtocolSessionStarted(SessionType sessionType, byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted);
- void onProtocolSessionNACKed(SessionType sessionType, byte sessionID, byte version, String correlationID);
+ void onProtocolSessionNACKed(SessionType sessionType, byte sessionID, byte version,
+ String correlationID, List<String> rejectedParams);
// Called to indicate that a protocol session has ended (from either side)
void onProtocolSessionEnded(SessionType sessionType, byte sessionID, String correlationID /*, String info, Exception ex*/);
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/ProtocolMessage.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/ProtocolMessage.java
index 99b34aff6..cb5ad3a74 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/ProtocolMessage.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/ProtocolMessage.java
@@ -45,12 +45,16 @@ public class ProtocolMessage {
this._data = data;
this._jsonSize = data.length;
}
-
+
public void setData(byte[] data, int length) {
+ setData(data, 0, length);
+ }
+
+ public void setData(byte[] data, int offset, int length) {
if (this._data != null)
this._data = null;
this._data = new byte[length];
- System.arraycopy(data, 0, this._data, 0, length);
+ System.arraycopy(data, offset, this._data, 0, length);
this._jsonSize = 0;
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
index 9c7a02852..cc14cdac7 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
@@ -1,7 +1,9 @@
package com.smartdevicelink.protocol;
import java.nio.ByteBuffer;
+import java.util.HashMap;
+import com.livio.BSON.BsonEncoder;
import com.smartdevicelink.protocol.enums.FrameType;
import android.os.Parcel;
@@ -65,6 +67,7 @@ public class SdlPacket implements Parcelable{
int messageId;
int priorityCoefficient;
byte[] payload = null;
+ HashMap<String, Object> bsonPayload;
public SdlPacket(int version, boolean encryption, int frameType,
int serviceType, int frameInfo, int sessionId,
@@ -185,7 +188,12 @@ public class SdlPacket implements Parcelable{
return payload;
}
- public byte[] constructPacket(){
+ public byte[] constructPacket() {
+ if (bsonPayload != null && !bsonPayload.isEmpty()) {
+ byte[] bsonBytes = BsonEncoder.encodeToBytes(bsonPayload);
+ payload = bsonBytes;
+ dataSize = bsonBytes.length;
+ }
return constructPacket(version, encryption, frameType,
serviceType, frameInfo, sessionId,
dataSize, messageId, payload);
@@ -219,6 +227,7 @@ public class SdlPacket implements Parcelable{
public static byte[] constructPacket(int version, boolean encryption, int frameType,
int serviceType, int controlFrameInfo, int sessionId,
int dataSize, int messageId, byte[] payload){
+
ByteBuffer builder;
switch(version){
case 1:
@@ -344,6 +353,25 @@ public class SdlPacket implements Parcelable{
}
};
-
-
+
+ public void putTag(String tag, Object data){
+ if(bsonPayload == null){
+ bsonPayload = new HashMap<>();
+ }
+ bsonPayload.put(tag, data);
+ }
+
+ public Object getTag(String tag){
+ if(payload == null){
+ return null;
+ }else if(bsonPayload == null || bsonPayload.isEmpty()){
+ bsonPayload = BsonEncoder.decodeFromBytes(payload);
+ }
+
+ if(bsonPayload == null){
+ return null;
+ }
+
+ return bsonPayload.get(tag);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java
index 7b36b1689..72482d47e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java
@@ -4,27 +4,39 @@ import com.smartdevicelink.SdlConnection.SdlConnection;
import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
+import com.smartdevicelink.protocol.enums.ControlFrameTags;
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.proxy.rpc.ImageResolution;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
import com.smartdevicelink.security.SdlSecurityBase;
+import com.smartdevicelink.streaming.video.VideoStreamingParameters;
import com.smartdevicelink.util.BitConverter;
import com.smartdevicelink.util.DebugTool;
+import com.smartdevicelink.util.Version;
import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
import java.util.Hashtable;
+import java.util.List;
public class WiProProtocol extends AbstractProtocol {
- byte _version = 1;
private final static String FailurePropagating_Msg = "Failure propagating ";
+ //If increasing MAX PROTOCOL VERSION major version, make sure to alter it in SdlPsm
+ public static final Version MAX_PROTOCOL_VERSION = new Version("5.0.0");
+ private Version protocolVersion = new Version("1.0.0");
+ byte _version = 1;
public static final int V1_V2_MTU_SIZE = 1500;
public static final int V3_V4_MTU_SIZE = 131072;
public static final int V1_HEADER_SIZE = 8;
public static final int V2_HEADER_SIZE = 12;
private static int HEADER_SIZE = 8;
- private static int MAX_DATA_SIZE = V1_V2_MTU_SIZE - HEADER_SIZE;
+ private static int TLS_MAX_RECORD_SIZE = 16384;
int hashID = 0;
int messageID = 0;
@@ -38,6 +50,7 @@ public class WiProProtocol extends AbstractProtocol {
Hashtable<Integer, MessageFrameAssembler> _assemblerForMessageID = new Hashtable<Integer, MessageFrameAssembler>();
Hashtable<Byte, Hashtable<Integer, MessageFrameAssembler>> _assemblerForSessionID = new Hashtable<Byte, Hashtable<Integer, MessageFrameAssembler>>();
Hashtable<Byte, Object> _messageLocks = new Hashtable<Byte, Object>();
+ private HashMap<SessionType, Long> mtus = new HashMap<SessionType,Long>();
// Hide no-arg ctor
private WiProProtocol() {
@@ -51,6 +64,7 @@ public class WiProProtocol extends AbstractProtocol {
{
sdlconn = (SdlConnection) protocolListener;
}
+ mtus.put(SessionType.RPC, new Long(V1_V2_MTU_SIZE - HEADER_SIZE));
} // end-ctor
/**
@@ -58,49 +72,95 @@ public class WiProProtocol extends AbstractProtocol {
* @return the max transfer unit
*/
public int getMtu(){
- return MAX_DATA_SIZE;
+ return mtus.get(SessionType.RPC).intValue();
}
-
+
+ public long getMtu(SessionType type){
+ Long mtu = mtus.get(type);
+ if(mtu == null){
+ mtu = mtus.get(SessionType.RPC);
+ }
+ return mtu;
+ }
+
+
+ /**
+ * Use getProtocolVersion() or getMajorVersionByte instead.<br>
+ * Returns the Major version of the currently used protocol version
+ */
+ @Deprecated
public byte getVersion() {
- return this._version;
+ return getMajorVersionByte();
}
-
+
+ public Version getProtocolVersion(){
+ return this.protocolVersion;
+ }
+ public byte getMajorVersionByte(){
+ if(_version == 1){
+ _version = new Integer(this.protocolVersion.getMajor()).byteValue();
+ }
+ return _version;
+
+ }
+
+ /**
+ * This method will set the major protocol version that we should use. It will also set the default MTU based on version.
+ * @param version
+ */
public void setVersion(byte version) {
- if (version > 4) {
- this._version = 4; //protect for future, proxy only supports v4 or lower
+ if (version > 5) {
+ this.protocolVersion = new Version("5.0.0"); //protect for future, proxy only supports v5 or lower
+ HEADER_SIZE = 12;
+ mtus.put(SessionType.RPC,new Long(V3_V4_MTU_SIZE) );
+ } else if (version == 5) {
+ this.protocolVersion = new Version("5.0.0");
HEADER_SIZE = 12;
- MAX_DATA_SIZE = V1_V2_MTU_SIZE - HEADER_SIZE; //default to lowest size since capabilities of this version are unknown
- } else if (version == 4) {
- this._version = version;
+ mtus.put(SessionType.RPC,new Long(V3_V4_MTU_SIZE) );
+ }else if (version == 4) {
+ this.protocolVersion = new Version("4.0.0");
HEADER_SIZE = 12;
- MAX_DATA_SIZE = V3_V4_MTU_SIZE; //versions 4 supports 128k MTU
+ mtus.put(SessionType.RPC,new Long(V3_V4_MTU_SIZE) ); //versions 4 supports 128k MTU
} else if (version == 3) {
- this._version = version;
+ this.protocolVersion = new Version("3.0.0");
HEADER_SIZE = 12;
- MAX_DATA_SIZE = V3_V4_MTU_SIZE; //versions 3 supports 128k MTU
+ mtus.put(SessionType.RPC,new Long(V3_V4_MTU_SIZE) ); //versions 3 supports 128k MTU
} else if (version == 2) {
- this._version = version;
+ this.protocolVersion = new Version("2.0.0");
HEADER_SIZE = 12;
- MAX_DATA_SIZE = V1_V2_MTU_SIZE - HEADER_SIZE;
+ mtus.put(SessionType.RPC,new Long(V1_V2_MTU_SIZE - HEADER_SIZE) );
} else if (version == 1){
- this._version = version;
+ this.protocolVersion = new Version("1.0.0");
HEADER_SIZE = 8;
- MAX_DATA_SIZE = V1_V2_MTU_SIZE - HEADER_SIZE;
+ mtus.put(SessionType.RPC,new Long(V1_V2_MTU_SIZE - HEADER_SIZE) );
}
}
public void StartProtocolSession(SessionType sessionType) {
- SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, _version, (byte) 0x00, false);
+ SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, getMajorVersionByte(), (byte) 0x00, false);
+ if(sessionType.equals(SessionType.RPC)){ // check for RPC session
+ header.putTag(ControlFrameTags.RPC.StartService.PROTOCOL_VERSION, MAX_PROTOCOL_VERSION.toString());
+ }
handlePacketToSend(header);
} // end-method
private void sendStartProtocolSessionACK(SessionType sessionType, byte sessionID) {
- SdlPacket header = SdlPacketFactory.createStartSessionACK(sessionType, sessionID, 0x00, _version);
+ SdlPacket header = SdlPacketFactory.createStartSessionACK(sessionType, sessionID, 0x00, getMajorVersionByte());
handlePacketToSend(header);
} // end-method
public void EndProtocolSession(SessionType sessionType, byte sessionID, int hashId) {
- SdlPacket header = SdlPacketFactory.createEndSession(sessionType, sessionID, hashID, _version, BitConverter.intToByteArray(hashId));
+ SdlPacket header;
+ if (sessionType.equals(SessionType.RPC)) { // check for RPC session
+ if(_version < 5){
+ header = SdlPacketFactory.createEndSession(sessionType, sessionID, hashID, getMajorVersionByte(), BitConverter.intToByteArray(hashID));
+ }else{
+ header = SdlPacketFactory.createEndSession(sessionType, sessionID, hashID, getMajorVersionByte(), new byte[0]);
+ header.putTag(ControlFrameTags.RPC.EndService.HASH_ID, hashID);
+ }
+ }else{ //Any other service type we don't include the hash id
+ header = SdlPacketFactory.createEndSession(sessionType, sessionID, hashID, getMajorVersionByte(), new byte[0]);
+ }
handlePacketToSend(header);
} // end-method
@@ -111,7 +171,7 @@ public class WiProProtocol extends AbstractProtocol {
byte sessionID = protocolMsg.getSessionID();
byte[] data = null;
- if (_version > 1 && sessionType != SessionType.NAV && sessionType != SessionType.PCM) {
+ if (protocolVersion.getMajor() > 1 && sessionType != SessionType.NAV && sessionType != SessionType.PCM) {
if (sessionType.eq(SessionType.CONTROL)) {
final byte[] secureData = protocolMsg.getData().clone();
data = new byte[HEADER_SIZE + secureData.length];
@@ -147,7 +207,7 @@ public class WiProProtocol extends AbstractProtocol {
if (session == null)
return;
- byte[] dataToRead = new byte[4096];
+ byte[] dataToRead = new byte[TLS_MAX_RECORD_SIZE];
SdlSecurityBase sdlSec = session.getSdlSecurity();
if (sdlSec == null)
return;
@@ -171,13 +231,14 @@ public class WiProProtocol extends AbstractProtocol {
}
synchronized(messageLock) {
- if (data.length > MAX_DATA_SIZE) {
-
+ if (data.length > getMtu(sessionType)) {
+
messageID++;
// Assemble first frame.
- int frameCount = data.length / MAX_DATA_SIZE;
- if (data.length % MAX_DATA_SIZE > 0) {
+ Long mtu = getMtu(sessionType);
+ int frameCount = new Long(data.length / mtu).intValue();
+ if (data.length % mtu > 0) {
frameCount++;
}
//byte[] firstFrameData = new byte[HEADER_SIZE];
@@ -187,7 +248,7 @@ public class WiProProtocol extends AbstractProtocol {
// Second four bytes are frame count.
System.arraycopy(BitConverter.intToByteArray(frameCount), 0, firstFrameData, 4, 4);
- SdlPacket firstHeader = SdlPacketFactory.createMultiSendDataFirst(sessionType, sessionID, messageID, _version,firstFrameData,protocolMsg.getPayloadProtected());
+ SdlPacket firstHeader = SdlPacketFactory.createMultiSendDataFirst(sessionType, sessionID, messageID, getMajorVersionByte(),firstFrameData,protocolMsg.getPayloadProtected());
firstHeader.setPriorityCoefficient(1+protocolMsg.priorityCoefficient);
//Send the first frame
handlePacketToSend(firstHeader);
@@ -209,17 +270,17 @@ public class WiProProtocol extends AbstractProtocol {
} // end-if
int bytesToWrite = data.length - currentOffset;
- if (bytesToWrite > MAX_DATA_SIZE) {
- bytesToWrite = MAX_DATA_SIZE;
+ if (bytesToWrite > mtu) {
+ bytesToWrite = mtu.intValue();
}
- SdlPacket consecHeader = SdlPacketFactory.createMultiSendDataRest(sessionType, sessionID, bytesToWrite, frameSequenceNumber , messageID, _version,data, currentOffset, bytesToWrite, protocolMsg.getPayloadProtected());
+ SdlPacket consecHeader = SdlPacketFactory.createMultiSendDataRest(sessionType, sessionID, bytesToWrite, frameSequenceNumber , messageID, getMajorVersionByte(),data, currentOffset, bytesToWrite, protocolMsg.getPayloadProtected());
consecHeader.setPriorityCoefficient(i+2+protocolMsg.priorityCoefficient);
handlePacketToSend(consecHeader);
currentOffset += bytesToWrite;
}
} else {
messageID++;
- SdlPacket header = SdlPacketFactory.createSingleSendData(sessionType, sessionID, data.length, messageID, _version,data, protocolMsg.getPayloadProtected());
+ SdlPacket header = SdlPacketFactory.createSingleSendData(sessionType, sessionID, data.length, messageID, getMajorVersionByte(),data, protocolMsg.getPayloadProtected());
header.setPriorityCoefficient(protocolMsg.priorityCoefficient);
handlePacketToSend(header);
}
@@ -228,7 +289,7 @@ public class WiProProtocol extends AbstractProtocol {
public void handlePacketReceived(SdlPacket packet){
//Check for a version difference
- if (_version == 1) {
+ if (getMajorVersionByte() == 1) {
setVersion((byte)packet.version);
}
@@ -244,7 +305,7 @@ public class WiProProtocol extends AbstractProtocol {
protected MessageFrameAssembler getFrameAssemblerForFrame(SdlPacket packet) {
Integer iSessionId = Integer.valueOf(packet.getSessionId());
Byte bySessionId = iSessionId.byteValue();
-
+
Hashtable<Integer, MessageFrameAssembler> hashSessionID = _assemblerForSessionID.get(bySessionId);
if (hashSessionID == null) {
hashSessionID = new Hashtable<Integer, MessageFrameAssembler>();
@@ -293,13 +354,13 @@ public class WiProProtocol extends AbstractProtocol {
message.setSessionType(SessionType.valueOf((byte)packet.getServiceType()));
message.setSessionID((byte)packet.getSessionId());
//If it is WiPro 2.0 it must have binary header
- if (_version > 1) {
+ if (protocolVersion.getMajor() > 1) {
BinaryFrameHeader binFrameHeader = BinaryFrameHeader.
parseBinaryHeader(accumulator.toByteArray());
if(binFrameHeader == null) {
return;
}
- message.setVersion(_version);
+ message.setVersion(getMajorVersionByte());
message.setRPCType(binFrameHeader.getRPCType());
message.setFunctionID(binFrameHeader.getFunctionID());
message.setCorrID(binFrameHeader.getCorrID());
@@ -399,21 +460,69 @@ public class WiProProtocol extends AbstractProtocol {
messageLock = new Object();
_messageLocks.put((byte)packet.getSessionId(), messageLock);
}
- int hashID = 0;
- if (_version > 1){
- if (packet.payload!= null && packet.dataSize == 4){ //hashid will be 4 bytes in length
- hashID = BitConverter.intFromByteArray(packet.payload, 0);
+ if(packet.version >= 5){
+ String mtuTag = null;
+ if(serviceType.equals(SessionType.RPC)){
+ mtuTag = ControlFrameTags.RPC.StartServiceACK.MTU;
+ }else if(serviceType.equals(SessionType.PCM)){
+ mtuTag = ControlFrameTags.Audio.StartServiceACK.MTU;
+ }else if(serviceType.equals(SessionType.NAV)){
+ mtuTag = ControlFrameTags.Video.StartServiceACK.MTU;
+ }
+ Object mtu = packet.getTag(mtuTag);
+ if(mtu!=null){
+ mtus.put(serviceType,(Long) packet.getTag(mtuTag));
}
- }
- handleProtocolSessionStarted(serviceType,(byte) packet.getSessionId(), _version, "", hashID, packet.isEncrypted());
+ if(serviceType.equals(SessionType.RPC)){
+ hashID = (Integer) packet.getTag(ControlFrameTags.RPC.StartServiceACK.HASH_ID);
+ Object version = packet.getTag(ControlFrameTags.RPC.StartServiceACK.PROTOCOL_VERSION);
+ if(version!=null){
+ //At this point we have confirmed the negotiated version between the module and the proxy
+ protocolVersion = new Version((String)version);
+ }
+ }else if(serviceType.equals(SessionType.NAV)){
+ SdlSession session = sdlconn.findSessionById((byte) packet.sessionId);
+ if(session != null) {
+ ImageResolution acceptedResolution = new ImageResolution();
+ VideoStreamingFormat acceptedFormat = new VideoStreamingFormat();
+ acceptedResolution.setResolutionHeight((Integer) packet.getTag(ControlFrameTags.Video.StartServiceACK.HEIGHT));
+ acceptedResolution.setResolutionWidth((Integer) packet.getTag(ControlFrameTags.Video.StartServiceACK.WIDTH));
+ acceptedFormat.setCodec(VideoStreamingCodec.valueForString((String) packet.getTag(ControlFrameTags.Video.StartServiceACK.VIDEO_CODEC)));
+ acceptedFormat.setProtocol(VideoStreamingProtocol.valueForString((String) packet.getTag(ControlFrameTags.Video.StartServiceACK.VIDEO_PROTOCOL)));
+ VideoStreamingParameters agreedVideoParams = session.getDesiredVideoParams();
+ agreedVideoParams.setResolution(acceptedResolution);
+ agreedVideoParams.setFormat(acceptedFormat);
+ session.setAcceptedVideoParams(agreedVideoParams);
+ }
+ }
+ }else{
+ if (protocolVersion.getMajor() > 1){
+ if (packet.payload!= null && packet.dataSize == 4){ //hashid will be 4 bytes in length
+ hashID = BitConverter.intFromByteArray(packet.payload, 0);
+ }
+ }
+ }
+ handleProtocolSessionStarted(serviceType,(byte) packet.getSessionId(), getMajorVersionByte(), "", hashID, packet.isEncrypted());
} else if (frameInfo == FrameDataControlFrameType.StartSessionNACK.getValue()) {
+ List<String> rejectedParams = null;
+ if(packet.version >= 5){
+ String rejectedTag = null;
+ if(serviceType.equals(SessionType.RPC)){
+ rejectedTag = ControlFrameTags.RPC.StartServiceNAK.REJECTED_PARAMS;
+ }else if(serviceType.equals(SessionType.PCM)){
+ rejectedTag = ControlFrameTags.Audio.StartServiceNAK.REJECTED_PARAMS;
+ }else if(serviceType.equals(SessionType.NAV)){
+ rejectedTag = ControlFrameTags.Video.StartServiceNAK.REJECTED_PARAMS;
+ }
+ rejectedParams = (List<String>) packet.getTag(rejectedTag);
+ }
if (serviceType.eq(SessionType.NAV) || serviceType.eq(SessionType.PCM)) {
- handleProtocolSessionNACKed(serviceType, (byte)packet.getSessionId(), _version, "");
+ handleProtocolSessionNACKed(serviceType, (byte)packet.getSessionId(), getMajorVersionByte(), "", rejectedParams);
} else {
handleProtocolError("Got StartSessionNACK for protocol sessionID=" + packet.getSessionId(), null);
}
} else if (frameInfo == FrameDataControlFrameType.EndSession.getValue()) {
- if (_version > 1) {
+ if (protocolVersion.getMajor() > 1) {
handleProtocolSessionEnded(serviceType, (byte)packet.getSessionId(), "");
} else {
handleProtocolSessionEnded(serviceType, (byte)packet.getSessionId(), "");
@@ -421,6 +530,18 @@ public class WiProProtocol extends AbstractProtocol {
} else if (frameInfo == FrameDataControlFrameType.EndSessionACK.getValue()) {
handleProtocolSessionEnded(serviceType, (byte)packet.getSessionId(), "");
} else if (frameInfo == FrameDataControlFrameType.EndSessionNACK.getValue()) {
+ if(packet.version >= 5){
+ String rejectedTag = null;
+ if(serviceType.equals(SessionType.RPC)){
+ rejectedTag = ControlFrameTags.RPC.EndServiceNAK.REJECTED_PARAMS;
+ }else if(serviceType.equals(SessionType.PCM)){
+ rejectedTag = ControlFrameTags.Audio.EndServiceNAK.REJECTED_PARAMS;
+ }else if(serviceType.equals(SessionType.NAV)){
+ rejectedTag = ControlFrameTags.Video.EndServiceNAK.REJECTED_PARAMS;
+ }
+ List<String> rejectedParams = (List<String>) packet.getTag(rejectedTag);
+ // TODO: Pass these back
+ }
handleProtocolSessionEndedNACK(serviceType, (byte)packet.getSessionId(), "");
} else if (frameInfo == FrameDataControlFrameType.ServiceDataACK.getValue()) {
if (packet.getPayload() != null && packet.getDataSize() == 4) //service data ack will be 4 bytes in length
@@ -445,13 +566,13 @@ public class WiProProtocol extends AbstractProtocol {
message.setSessionID((byte)packet.getSessionId());
//If it is WiPro 2.0 it must have binary header
boolean isControlService = message.getSessionType().equals(SessionType.CONTROL);
- if (_version > 1&& !isControlService) {
+ if (protocolVersion.getMajor() > 1 && !isControlService) {
BinaryFrameHeader binFrameHeader = BinaryFrameHeader.
parseBinaryHeader(packet.payload);
if(binFrameHeader == null) {
return;
}
- message.setVersion(_version);
+ message.setVersion(getMajorVersionByte());
message.setRPCType(binFrameHeader.getRPCType());
message.setFunctionID(binFrameHeader.getFunctionID());
message.setCorrID(binFrameHeader.getCorrID());
@@ -478,9 +599,23 @@ public class WiProProtocol extends AbstractProtocol {
@Override
public void StartProtocolService(SessionType sessionType, byte sessionID, boolean isEncrypted) {
- SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, _version, sessionID, isEncrypted);
+ SdlPacket header = SdlPacketFactory.createStartSession(sessionType, 0x00, getMajorVersionByte(), sessionID, isEncrypted);
+ if(sessionType.equals(SessionType.NAV)){
+ SdlSession videoSession = sdlconn.findSessionById(sessionID);
+ if(videoSession != null){
+ ImageResolution desiredResolution = videoSession.getDesiredVideoParams().getResolution();
+ VideoStreamingFormat desiredFormat = videoSession.getDesiredVideoParams().getFormat();
+ if(desiredResolution != null){
+ header.putTag(ControlFrameTags.Video.StartService.WIDTH, desiredResolution.getResolutionWidth());
+ header.putTag(ControlFrameTags.Video.StartService.HEIGHT, desiredResolution.getResolutionHeight());
+ }
+ if(desiredFormat != null){
+ header.putTag(ControlFrameTags.Video.StartService.VIDEO_CODEC, desiredFormat.getCodec().toString());
+ header.putTag(ControlFrameTags.Video.StartService.VIDEO_PROTOCOL, desiredFormat.getProtocol().toString());
+ }
+ }
+ }
handlePacketToSend(header);
-
}
@Override
@@ -497,21 +632,24 @@ public class WiProProtocol extends AbstractProtocol {
@Override
public void SendHeartBeat(byte sessionID) {
- final SdlPacket heartbeat = SdlPacketFactory.createHeartbeat(SessionType.CONTROL, sessionID, _version);
+ final SdlPacket heartbeat = SdlPacketFactory.createHeartbeat(SessionType.CONTROL, sessionID, getMajorVersionByte());
handlePacketToSend(heartbeat);
}
@Override
public void SendHeartBeatACK(byte sessionID) {
- final SdlPacket heartbeat = SdlPacketFactory.createHeartbeatACK(SessionType.CONTROL, sessionID, _version);
+ final SdlPacket heartbeat = SdlPacketFactory.createHeartbeatACK(SessionType.CONTROL, sessionID, getMajorVersionByte());
handlePacketToSend(heartbeat);
}
@Override
public void EndProtocolService(SessionType serviceType, byte sessionID) {
- SdlPacket header = SdlPacketFactory.createEndSession(serviceType, sessionID, hashID, _version, new byte[4]);
- handlePacketToSend(header);
-
+ if(serviceType.equals(SessionType.RPC)){ //RPC session will close all other sessions so we want to make sure we use the correct EndProtocolSession method
+ EndProtocolSession(serviceType,sessionID,hashID);
+ }else {
+ SdlPacket header = SdlPacketFactory.createEndSession(serviceType, sessionID, hashID, getMajorVersionByte(), new byte[0]);
+ handlePacketToSend(header);
+ }
}
} // end-class
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java
new file mode 100644
index 000000000..74a001edc
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/ControlFrameTags.java
@@ -0,0 +1,85 @@
+package com.smartdevicelink.protocol.enums;
+
+/**
+ * Control frame payload tags that relate to the respective services. Each class represents a different service, RPC, Audio, and Video services.
+ */
+public class ControlFrameTags {
+
+ private static class StartServiceACKBase{
+ /** Max transport unit to be used for this service */
+ public static final String MTU = "mtu";
+ }
+
+ private static class NAKBase{
+ /** An array of rejected parameters related to the corresponding request*/
+ public static final String REJECTED_PARAMS = "rejectedParams";
+ }
+
+ /**
+ * Control frame payloads that relate to the Remote Procedure Call (RPC) service.
+ */
+ public static class RPC {
+ public static class StartService {
+ /** The max version of the protocol supported by client requesting service to start.<br>
+ * Must be in the format "Major.Minor.Patch"
+ */
+ public static final String PROTOCOL_VERSION = "protocolVersion";
+ }
+ public static class StartServiceACK extends StartServiceACKBase{
+ /** The negotiated version of the protocol. Must be in the format "Major.Minor.Patch"*/
+ public static final String PROTOCOL_VERSION = StartService.PROTOCOL_VERSION;
+ /** Hash ID to identify this service and used when sending an EndService control frame*/
+ public static final String HASH_ID = "hashId";
+ }
+ public static class StartServiceNAK extends NAKBase{}
+ public static class EndService {
+ /** Hash ID supplied in the StartServiceACK for this service type*/
+ public static final String HASH_ID = RPC.StartServiceACK.HASH_ID;
+ }
+ public static class EndServiceACK {}
+ public static class EndServiceNAK extends NAKBase{}
+ }
+
+ /**
+ * Control frame payloads that relate to the Audio streaming service. This service has also been referred to as the PCM service.
+ */
+ public static class Audio {
+ public static class StartService {}
+ public static class StartServiceACK extends StartServiceACKBase{}
+ public static class StartServiceNAK extends NAKBase{}
+ public static class EndService {}
+ public static class EndServiceACK {}
+ public static class EndServiceNAK extends NAKBase{}
+ }
+
+ /**
+ * Control frame payloads that relate to the Video streaming service. This service has also been referred to as the .h264 service.
+ */
+ public static class Video {
+ public static class StartService {
+ /** Desired height in pixels from the client requesting the video service to start*/
+ public static final String HEIGHT = "height";
+ /** Desired width in pixels from the client requesting the video service to start*/
+ public static final String WIDTH = "width";
+ /** Desired video protocol to be used*/
+ public static final String VIDEO_PROTOCOL = "videoProtocol";
+ /** Desired video codec to be used*/
+ public static final String VIDEO_CODEC = "videoCodec";
+ }
+ public static class StartServiceACK extends StartServiceACKBase{
+ /** Accepted height in pixels from the client requesting the video service to start*/
+ public static final String HEIGHT = StartService.HEIGHT;
+ /** Accepted width in pixels from the client requesting the video service to start*/
+ public static final String WIDTH = StartService.WIDTH;
+ /** Accepted video protocol to be used*/
+ public static final String VIDEO_PROTOCOL = StartService.VIDEO_PROTOCOL;
+ /** Accepted video codec to be used*/
+ public static final String VIDEO_CODEC = StartService.VIDEO_CODEC;
+ }
+
+ public static class StartServiceNAK extends NAKBase{}
+ public static class EndService {}
+ public static class EndServiceACK {}
+ public static class EndServiceNAK extends NAKBase{}
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
index e427141cf..412d3f857 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
@@ -53,9 +53,16 @@ public enum FunctionID{
SYSTEM_REQUEST(38, "SystemRequest"),
SEND_LOCATION(39, "SendLocation"),
DIAL_NUMBER(40, "DialNumber"),
+
+ BUTTON_PRESS(41, "ButtonPress"),
+ GET_INTERIOR_VEHICLE_DATA(43, "GetInteriorVehicleData"),
+ SET_INTERIOR_VEHICLE_DATA(44, "SetInteriorVehicleData"),
+
GET_WAY_POINTS(45, "GetWayPoints"),
SUBSCRIBE_WAY_POINTS(46, "SubscribeWayPoints"),
UNSUBSCRIBE_WAY_POINTS(47, "UnsubscribeWayPoints"),
+ GET_SYSTEM_CAPABILITY(48, "GetSystemCapability"),
+ SEND_HAPTIC_DATA(49, "SendHapticData"),
// NOTIFICATIONS
ON_HMI_STATUS(32768, "OnHMIStatus"),
@@ -73,6 +80,7 @@ public enum FunctionID{
ON_TOUCH_EVENT(32780, "OnTouchEvent"),
ON_SYSTEM_REQUEST(32781, "OnSystemRequest"),
ON_HASH_CHANGE(32782, "OnHashChange"),
+ ON_INTERIOR_VEHICLE_DATA(32783, "OnInteriorVehicleData"),
ON_WAY_POINT_CHANGE(32784, "OnWayPointChange"),
// MOCKED FUNCTIONS (NOT SENT FROM HEAD-UNIT)
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java
index 1188d28b9..28b1d3dfb 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/LockScreenManager.java
@@ -41,11 +41,15 @@ public class LockScreenManager {
public synchronized void setHMILevel(HMILevel hmiVal)
{
hmiLevel = hmiVal;
-
- if ( (hmiVal.equals(HMILevel.HMI_FULL)) || (hmiVal.equals(HMILevel.HMI_LIMITED)) )
- setUserSelectedStatus(true);
- else if (hmiVal.equals(HMILevel.HMI_NONE))
- setUserSelectedStatus(false);
+
+ if (hmiVal != null) {
+ if ((hmiVal.equals(HMILevel.HMI_FULL)) || (hmiVal.equals(HMILevel.HMI_LIMITED)))
+ setUserSelectedStatus(true);
+ else if (hmiVal.equals(HMILevel.HMI_NONE))
+ setUserSelectedStatus(false);
+ }else{
+ setUserSelectedStatus(false);
+ }
}
public synchronized OnLockScreenStatus getLockObj(/*int SessionID*/)
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java
index 9f3fbfbd9..e55292aad 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCMessage.java
@@ -70,17 +70,60 @@ public class RPCMessage extends RPCStruct {
}
return null;
}
+
+ // Generalized Getters and Setters
- public void setParameters(String functionName, Object value) {
+ public void setParameters(String key, Object value) {
if (value != null) {
- parameters.put(functionName, value);
+ parameters.put(key, value);
} else {
- parameters.remove(functionName);
+ parameters.remove(key);
}
}
-
- public Object getParameters(String functionName) {
- return parameters.get(functionName);
+
+ public Object getParameters(String key) {
+ return parameters.get(key);
+ }
+
+ @Override
+ public Object getObject(Class tClass, String key) {
+ Object obj = parameters.get(key);
+ return formatObject(tClass, obj);
+ }
+
+ // Common Object Getters
+
+ @Override
+ public String getString(String key) {
+ return (String) parameters.get(key);
+ }
+
+ @Override
+ public Integer getInteger(String key) {
+ return (Integer) parameters.get(key);
+ }
+
+ @Override
+ public Float getFloat(String key) {
+ return (Float) parameters.get(key);
+ }
+
+ @Override
+ public Double getDouble(String key) {
+ return (Double) parameters.get(key);
}
+ @Override
+ public Boolean getBoolean(String key) { return (Boolean) parameters.get(key); }
+
+ @Override
+ public Long getLong(String key){
+ Object result = parameters.get(key);
+ if (result instanceof Integer) {
+ return ((Integer) result).longValue();
+ }else if(result instanceof Long){
+ return (Long) result;
+ }
+ return null;
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequest.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequest.java
index 50493870d..370ffe1ec 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequest.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCRequest.java
@@ -6,6 +6,7 @@ package com.smartdevicelink.proxy;
import java.util.Hashtable;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
+import com.smartdevicelink.util.CorrelationIdGenerator;
public class RPCRequest extends RPCMessage {
@@ -21,6 +22,10 @@ public class RPCRequest extends RPCMessage {
}
public Integer getCorrelationID() {
+ //First we check to see if a correlation ID is set. If not, create one.
+ if(!function.containsKey(RPCMessage.KEY_CORRELATION_ID)){
+ setCorrelationID(CorrelationIdGenerator.generateId());
+ }
return (Integer)function.get(RPCMessage.KEY_CORRELATION_ID);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java
index 4aea8e146..116c491df 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/RPCStruct.java
@@ -1,12 +1,17 @@
package com.smartdevicelink.proxy;
-import java.util.Hashtable;
-import java.util.Set;
+import com.smartdevicelink.marshal.JsonRPCMarshaller;
import org.json.JSONException;
import org.json.JSONObject;
-import com.smartdevicelink.marshal.JsonRPCMarshaller;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
public class RPCStruct {
public static final String KEY_BULK_DATA = "bulkData";
@@ -110,4 +115,135 @@ public class RPCStruct {
}
return false;
}
+
+ // Generalized Getters and Setters
+
+ public void setValue(String key, Object value){
+ if (value != null) {
+ store.put(key, value);
+ } else {
+ store.remove(key);
+ }
+ }
+
+ public Object getValue(String key) {
+ return store.get(key);
+ }
+
+ public Object getObject(Class tClass, String key) {
+ Object obj = store.get(key);
+ return formatObject(tClass, obj);
+ }
+
+ // Helper methods
+
+ /**
+ * @param tClass a Class to cast Objects to
+ * @param obj Object returned from a stored hashtable
+ * @return A null object if obj is null or if none of the following is true:
+ * a) obj is an instance of tClass
+ * b) obj is an instance of String and it tClass has a valid `valueForString` method
+ * c) obj is an instance of a Hashtable
+ * d) obj is an instance of a List
+ */
+ protected Object formatObject(Class tClass, Object obj){
+ if(obj == null){
+ return null;
+ } else if (tClass.isInstance(obj)) {
+ return obj;
+ } else if (obj instanceof String) {
+ return getValueForString(tClass, (String) obj);
+ } else if (obj instanceof Hashtable) {
+ try {
+ Constructor constructor = tClass.getConstructor(Hashtable.class);
+ return constructor.newInstance((Hashtable<String, Object>) obj);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else if (obj instanceof List<?>) {
+ List<?> list = (List<?>) obj;
+ if (list != null && list.size() > 0) {
+ Object item = list.get(0);
+ if (tClass.isInstance(item)) {
+ return list;
+ } else if (item instanceof Hashtable) {
+ List<Object> newList = new ArrayList<Object>();
+ for (Object hashObj : list) {
+ try {
+ Constructor constructor = tClass.getConstructor(Hashtable.class);
+ newList.add(constructor.newInstance((Hashtable<String, Object>)hashObj));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ return newList;
+ } else if (item instanceof String){
+ List<Object> newList = new ArrayList<Object>();
+ for (Object hashObj : list) {
+ Object toAdd = getValueForString(tClass, (String) hashObj);
+ if (toAdd != null) {
+ newList.add(toAdd);
+ }
+ }
+ return newList;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param tClass - a Class with a `valueForString(String s)` method that returns an Object for a given String
+ * @param s - a String to be converted to an Object using a `valueForString(String s)` method
+ * @return An Object converted using a `valueForString(String s)` method in the Class passed in, or a null object if such method does not exist
+ */
+ protected Object getValueForString(Class tClass, String s){
+ Method valueForString = null;
+ try {
+ valueForString = tClass.getDeclaredMethod("valueForString", String.class);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ if(valueForString != null){
+ try {
+ Object value = valueForString.invoke(null, (String) s);
+ return value;
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ // Common Object Getters
+ public String getString(String key) {
+ return (String) store.get(key);
+ }
+
+ public Integer getInteger(String key) {
+ return (Integer) store.get(key);
+ }
+
+ public Double getDouble(String key) {
+ return (Double) store.get(key);
+ }
+
+ public Float getFloat(String key) {
+ return (Float) store.get(key);
+ }
+
+ public Boolean getBoolean(String key) { return (Boolean) store.get(key); }
+
+ public Long getLong(String key){
+ Object result = store.get(key);
+ if (result instanceof Integer) {
+ return ((Integer) result).longValue();
+ }else if(result instanceof Long){
+ return (Long) result;
+ }
+ return null;
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java
index 2bdbdf82e..a9cec4f10 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyALM.java
@@ -16,6 +16,7 @@ import com.smartdevicelink.proxy.rpc.HMICapabilities;
import com.smartdevicelink.proxy.rpc.PresetBankCapabilities;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
+import com.smartdevicelink.proxy.rpc.SystemCapability;
import com.smartdevicelink.proxy.rpc.TTSChunk;
import com.smartdevicelink.proxy.rpc.VehicleType;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
@@ -24,334 +25,337 @@ import com.smartdevicelink.proxy.rpc.enums.Language;
import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
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.MultiplexTransportConfig;
+import com.smartdevicelink.transport.BaseTransportConfig;
+import com.smartdevicelink.transport.MultiplexTransportConfig;
import com.smartdevicelink.transport.enums.TransportType;
-
+
+import static com.smartdevicelink.proxy.SystemCapabilityManager.convertToList;
+
public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
-
+
private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
@SuppressWarnings("unused")
- private static final String SDL_LIB_PRIVATE_TOKEN = "{DAE1A88C-6C16-4768-ACA5-6F1247EA01C2}";
+ private static final String SDL_LIB_PRIVATE_TOKEN = "{DAE1A88C-6C16-4768-ACA5-6F1247EA01C2}";
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL
- *
+ *
* Takes advantage of the advanced lifecycle management.
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
* @param isMediaApp - Indicates if the app is a media application.
*/
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
- /*ngn media app*/null,
- /*vr synonyms*/null,
- /*is media app*/isMediaApp,
- /*sdlMsgVersion*/null,
- /*language desired*/languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
- /*callbackToUIThread*/ false,
+ /*TTS Name*/null,
+ /*ngn media app*/null,
+ /*vr synonyms*/null,
+ /*is media app*/isMediaApp,
+ /*sdlMsgVersion*/null,
+ /*language desired*/languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ /*callbackToUIThread*/ false,
new BTTransportConfig());
}
-
+
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL
- *
+ *
* Takes advantage of the advanced lifecycle management.
* @param context - Used to create a multiplexing transport config
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
* @param isMediaApp - Indicates if the app is a media application.
*/
- public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
- /*ngn media app*/null,
- /*vr synonyms*/null,
- /*is media app*/isMediaApp,
- /*sdlMsgVersion*/null,
- /*language desired*/languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
- /*callbackToUIThread*/ false,
+ /*TTS Name*/null,
+ /*ngn media app*/null,
+ /*vr synonyms*/null,
+ /*is media app*/isMediaApp,
+ /*sdlMsgVersion*/null,
+ /*language desired*/languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ /*callbackToUIThread*/ false,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, and isMediaApp.", SDL_LIB_TRACE_KEY);
}
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
- *
- * Takes advantage of the advanced lifecycle management.
- *
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
* @param isMediaApp - Indicates if the app is a media application.
* @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired - Indicates the language desired for the SDL interface.
* @param autoActivateID - ID used to re-register previously registered application.
* @throws SdlException
*/
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
- Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
- String autoActivateID) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
+ Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ String autoActivateID) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
- /*callbackToUIThread*/ false,
+ /*callbackToUIThread*/ false,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " +
"vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
* @param isMediaApp - Indicates if the app is a media application.
* @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired - Indicates the language desired for the SDL interface.
* @param autoActivateID - ID used to re-register previously registered application.
* @throws SdlException
*/
- public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
- Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
- String autoActivateID) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
+ Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ String autoActivateID) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
- /*callbackToUIThread*/ false,
+ /*callbackToUIThread*/ false,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " +
"vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
}
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
- *
- * Takes advantage of the advanced lifecycle management.
- *
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
* @param isMediaApp - Indicates if the app is a media application.
* @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired - Indicates the language desired for the SDL interface.
* @param autoActivateID - ID used to re-register previously registered application.
* @throws SdlException
*/
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms,
- Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired,
- Language hmiDisplayLanguageDesired, String appID, String autoActivateID) throws SdlException {
- super( listener,
- sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms,
+ Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired,
+ Language hmiDisplayLanguageDesired, String appID, String autoActivateID) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
- /*callbackToUIThread*/ false,
+ /*callbackToUIThread*/ false,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
* @param isMediaApp - Indicates if the app is a media application.
* @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired - Indicates the language desired for the SDL interface.
* @param autoActivateID - ID used to re-register previously registered application.
* @throws SdlException
*/
- public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms,
- Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired,
- Language hmiDisplayLanguageDesired, String appID, String autoActivateID) throws SdlException {
- super( listener,
- sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms,
+ Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired,
+ Language hmiDisplayLanguageDesired, String appID, String autoActivateID) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
- /*callbackToUIThread*/ false,
+ /*callbackToUIThread*/ false,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
}
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
- *
- * Takes advantage of the advanced lifecycle management.
- *
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
* @param isMediaApp - Indicates if the app is a media application.
* @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired - Indicates the language desired for the SDL interface.
* @param autoActivateID - ID used to re-register previously registered application.
* @param callbackToUIThread - If true, all callbacks will occur on the UI thread.
* @throws SdlException
*/
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
- Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
- String autoActivateID, boolean callbackToUIThread) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
+ Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ String autoActivateID, boolean callbackToUIThread) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"and callbackToUIThread", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
* @param isMediaApp - Indicates if the app is a media application.
* @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired - Indicates the language desired for the SDL interface.
* @param autoActivateID - ID used to re-register previously registered application.
* @param callbackToUIThread - If true, all callbacks will occur on the UI thread.
* @throws SdlException
*/
- public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
- Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
- String autoActivateID, boolean callbackToUIThread) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
+ Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ String autoActivateID, boolean callbackToUIThread) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"and callbackToUIThread", SDL_LIB_TRACE_KEY);
@@ -359,360 +363,360 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
- *
- * Takes advantage of the advanced lifecycle management.
- *
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
* @param isMediaApp - Indicates if the app is a media application.
* @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired - Indicates the language desired for the SDL interface.
* @param autoActivateID - ID used to re-register previously registered application.
* @param callbackToUIThread - If true, all callbacks will occur on the UI thread.
* @throws SdlException
*/
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID,
- boolean callbackToUIThread) throws SdlException {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID,
+ boolean callbackToUIThread) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"and callbackToUIThread", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
- * @param listener - Reference to the object in the App listening to callbacks from SDL.
- * @param appName - Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
+ * @param listener - Reference to the object in the App listening to callbacks from SDL.
+ * @param appName - Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName - Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms - A vector of strings, all of which can be used as voice commands to
* @param isMediaApp - Indicates if the app is a media application.
* @param sdlMsgVersion - Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired - Indicates the language desired for the SDL interface.
* @param autoActivateID - ID used to re-register previously registered application.
* @param callbackToUIThread - If true, all callbacks will occur on the UI thread.
* @throws SdlException
*/
- public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID,
- boolean callbackToUIThread) throws SdlException {
- super( listener,
+ public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID,
+ boolean callbackToUIThread) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"and callbackToUIThread", SDL_LIB_TRACE_KEY);
}
-
+
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
-
- public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
- super( listener,
+
+ public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
-
+
/********************************************** TRANSPORT SWITCHING SUPPORT *****************************************/
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
+ *
* Takes advantage of the advanced lifecycle management.
- *
- * @param listener Reference to the object in the App listening to callbacks from SDL.
- * @param appName Name of the application displayed on SDL.
+ *
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param appName Name of the application displayed on SDL.
* @param isMediaApp Indicates if the app is a media application.
* @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
- BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
- /*ngn media app*/null,
- /*vr synonyms*/null,
- /*is media app*/isMediaApp,
- /*sdlMsgVersion*/null,
- /*language desired*/languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
- /*callbackToUIThread*/ false,
+ /*TTS Name*/null,
+ /*ngn media app*/null,
+ /*vr synonyms*/null,
+ /*is media app*/isMediaApp,
+ /*sdlMsgVersion*/null,
+ /*language desired*/languageDesired,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ /*callbackToUIThread*/ false,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, appName, and isMediaApp.", SDL_LIB_TRACE_KEY);
}
-
+
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
- * @param listener Reference to the object in the App listening to callbacks from SDL.
- * @param appName Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms A vector of strings, all of which can be used as voice commands to
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param appName Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms A vector of strings, all of which can be used as voice commands to
* @param isMediaApp Indicates if the app is a media application.
* @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired Indicates the language desired for the SDL interface.
* @param autoActivateID ID used to re-register previously registered application.
- * @param transportConfig Initial configuration for transport.
+ * @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
- Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
- String autoActivateID, TransportType transportType, BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
+ Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ String autoActivateID, TransportType transportType, BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
- /*callbackToUIThread*/ false,
+ /*callbackToUIThread*/ false,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " +
"vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
}
-
+
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
- * @param listener Reference to the object in the App listening to callbacks from SDL.
- * @param appName Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms A vector of strings, all of which can be used as voice commands to
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param appName Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms A vector of strings, all of which can be used as voice commands to
* @param isMediaApp Indicates if the app is a media application.
* @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired Indicates the language desired for the SDL interface.
* @param autoActivateID ID used to re-register previously registered application.
- * @param transportConfig Initial configuration for transport.
+ * @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms,
- Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired,
- Language hmiDisplayLanguageDesired, String appID, String autoActivateID,
- BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
- sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms,
+ Boolean isMediaApp, SdlMsgVersion sdlMsgVersion, Language languageDesired,
+ Language hmiDisplayLanguageDesired, String appID, String autoActivateID,
+ BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
+ sdlProxyConfigurationResources,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
- /*callbackToUIThread*/ false,
+ /*callbackToUIThread*/ false,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
}
-
+
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
- * @param listener Reference to the object in the App listening to callbacks from SDL.
- * @param appName Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
- * vehicles. Limited to five characters.
- * @param vrSynonyms A vector of strings, all of which can be used as voice commands to
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param appName Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * vehicles. Limited to five characters.
+ * @param vrSynonyms A vector of strings, all of which can be used as voice commands to
* @param isMediaApp Indicates if the app is a media application.
* @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired Indicates the language desired for the SDL interface.
* @param autoActivateID ID used to re-register previously registered application.
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
- * @param transportConfig Initial configuration for transport.
+ * @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
- Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
- Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
- String autoActivateID, boolean callbackToUIThread,
- BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
- /*sdl proxy configuration resources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, String appName, String ngnMediaScreenAppName,
+ Vector<String> vrSynonyms, Boolean isMediaApp, SdlMsgVersion sdlMsgVersion,
+ Language languageDesired, Language hmiDisplayLanguageDesired, String appID,
+ String autoActivateID, boolean callbackToUIThread,
+ BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
+ /*sdl proxy configuration resources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"and callbackToUIThread", SDL_LIB_TRACE_KEY);
}
-
+
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
- * @param listener Reference to the object in the App listening to callbacks from SDL.
- * @param appName Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
+ * @param listener Reference to the object in the App listening to callbacks from SDL.
+ * @param appName Name of the application displayed on SDL.
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
* @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
- * or equal to the version of SDL SmartDeviceLink running on the vehicle.
+ * or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired Indicates the language desired for the SDL interface.
* @param autoActivateID ID used to re-register previously registered application.
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
- * @param transportConfig Initial configuration for transport.
+ * @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID,
- boolean callbackToUIThread, BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID,
+ boolean callbackToUIThread, BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"and callbackToUIThread", SDL_LIB_TRACE_KEY);
@@ -720,13 +724,13 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
@@ -738,32 +742,32 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param autoActivateID ID used to re-register previously registered application.
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
- * @param transportConfig Initial configuration for transport.
+ * @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister,
- BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister,
+ BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
- /*TTS Name*/null,
+ /*TTS Name*/null,
ngnMediaScreenAppName,
vrSynonyms,
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
@@ -772,9 +776,9 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param appName Name of the application displayed on SDL.
* @param isMediaApp Indicates if the app is a media application.
@@ -784,37 +788,37 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
+ */
@Deprecated
public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, boolean callbackToUIThread, boolean preRegister) throws SdlException
+ String appID, boolean callbackToUIThread, boolean preRegister) throws SdlException
{
- super( listener,
- /*sdlProxyConfigurationResources*/null,
- /*enable advanced lifecycle management*/true,
- appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
- isMediaApp,
- /*sdlMsgVersion*/null,
- languageDesired,
- hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
- callbackToUIThread,
- preRegister,
- new BTTransportConfig());
-
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
+ isMediaApp,
+ /*sdlMsgVersion*/null,
+ languageDesired,
+ hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ callbackToUIThread,
+ preRegister,
+ new BTTransportConfig());
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
- "appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired" + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ "appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired" + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param appName Name of the application displayed on SDL.
@@ -825,99 +829,99 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
+ */
public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, boolean callbackToUIThread, boolean preRegister) throws SdlException
+ String appID, boolean callbackToUIThread, boolean preRegister) throws SdlException
{
- super( listener,
- /*sdlProxyConfigurationResources*/null,
- /*enable advanced lifecycle management*/true,
- appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
- isMediaApp,
- /*sdlMsgVersion*/null,
- languageDesired,
- hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
- callbackToUIThread,
- preRegister,
- new MultiplexTransportConfig(context,appID));
-
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
+ appName,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
+ isMediaApp,
+ /*sdlMsgVersion*/null,
+ languageDesired,
+ hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
+ callbackToUIThread,
+ preRegister,
+ new MultiplexTransportConfig(context,appID));
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
- "appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired" + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ "appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired" + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
-
+
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param appName Name of the application displayed on SDL.
* @param isMediaApp Indicates if the app is a media application.
* @param appID Identifier of the client application.
* @throws SdlException
- */
+ */
@Deprecated
public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID) throws SdlException {
- super( listener,
- /*sdlProxyConfigurationResources*/null,
- /*enable advanced lifecycle management*/true,
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
isMediaApp,
- /*sdlMsgVersion*/null,
- /*languageDesired*/null,
- /*hmiDisplayLanguageDesired*/null,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
false,
false,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
}
-
+
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param appName Name of the application displayed on SDL.
* @param isMediaApp Indicates if the app is a media application.
* @param appID Identifier of the client application.
* @throws SdlException
- */
+ */
public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID) throws SdlException {
- super( listener,
- /*sdlProxyConfigurationResources*/null,
- /*enable advanced lifecycle management*/true,
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
isMediaApp,
- /*sdlMsgVersion*/null,
- /*languageDesired*/null,
- /*hmiDisplayLanguageDesired*/null,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
false,
false,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
}
@@ -925,45 +929,45 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param isMediaApp Indicates if the app is a media application.
* @param appID Identifier of the client application.
* @throws SdlException
- */
+ */
@Deprecated
public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, String appName, Boolean isMediaApp,String appID) throws SdlException {
- super( listener,
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
isMediaApp,
- /*sdlMsgVersion*/null,
- /*languageDesired*/null,
- /*hmiDisplayLanguageDesired*/null,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
false,
false,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"sdlProxyConfigurationResources, appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
@@ -971,49 +975,49 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param isMediaApp Indicates if the app is a media application.
* @param appID Identifier of the client application.
* @throws SdlException
- */
+ */
public SdlProxyALM(Context context, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources, String appName, Boolean isMediaApp,String appID) throws SdlException {
- super( listener,
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
isMediaApp,
- /*sdlMsgVersion*/null,
- /*languageDesired*/null,
- /*hmiDisplayLanguageDesired*/null,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
false,
false,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"sdlProxyConfigurationResources, appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
}
-
+
public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
- /*sdlProxyConfigurationResources*/null,
- /*enable advanced lifecycle management*/true,
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
isMediaApp,
- /*sdlMsgVersion*/null,
- /*languageDesired*/null,
- /*hmiDisplayLanguageDesired*/null,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
false,
false,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
}
@@ -1021,9 +1025,9 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param appName Name of the application displayed on SDL.
* @param isMediaApp Indicates if the app is a media application.
@@ -1031,36 +1035,36 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
+ */
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,
- boolean callbackToUIThread, boolean preRegister) throws SdlException {
- super( listener,
- /*sdlProxyConfigurationResources*/null,
- /*enable advanced lifecycle management*/true,
+ public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,
+ boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
isMediaApp,
- /*sdlMsgVersion*/null,
- /*languageDesired*/null,
- /*hmiDisplayLanguageDesired*/null,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
callbackToUIThread,
preRegister,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"appName, isMediaApp, " + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param appName Name of the application displayed on SDL.
@@ -1069,41 +1073,41 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
- public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,
- boolean callbackToUIThread, boolean preRegister) throws SdlException {
- super( listener,
- /*sdlProxyConfigurationResources*/null,
- /*enable advanced lifecycle management*/true,
+ */
+ public SdlProxyALM(Context context,IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,
+ boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
+ /*sdlProxyConfigurationResources*/null,
+ /*enable advanced lifecycle management*/true,
appName,
- /*ttsName*/null,
- /*ngnMediaScreenAppName*/null,
- /*vrSynonyms*/null,
+ /*ttsName*/null,
+ /*ngnMediaScreenAppName*/null,
+ /*vrSynonyms*/null,
isMediaApp,
- /*sdlMsgVersion*/null,
- /*languageDesired*/null,
- /*hmiDisplayLanguageDesired*/null,
- /*App Type*/null,
- /*App ID*/appID,
- /*autoActivateID*/null,
+ /*sdlMsgVersion*/null,
+ /*languageDesired*/null,
+ /*hmiDisplayLanguageDesired*/null,
+ /*App Type*/null,
+ /*App ID*/appID,
+ /*autoActivateID*/null,
callbackToUIThread,
preRegister,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
"appName, isMediaApp, " + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- * @param appService Reference to the apps service object.
+ *
+ * Takes advantage of the advanced lifecycle management.
+ * @param appService Reference to the apps service object.
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param ttsName TTS name.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
@@ -1116,14 +1120,14 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
- public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
- super( listener,
+ */
+ public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1131,30 +1135,30 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
new MultiplexTransportConfig(appService.getBaseContext(),appID));
-
- this.setAppService(appService);
- this.sendTransportBroadcast();
-
+
+ this.setAppService(appService);
+ this.sendTransportBroadcast();
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
-
-
- public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
+
+
+ public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister, BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1162,35 +1166,35 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
transportConfig);
-
- this.setAppService(appService);
- this.sendTransportBroadcast();
-
+
+ this.setAppService(appService);
+ this.sendTransportBroadcast();
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
-
-
-
+
+
+
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param ttsName TTS name.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
@@ -1203,15 +1207,15 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
+ */
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1219,29 +1223,29 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param ttsName TTS name.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
@@ -1254,14 +1258,14 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
- public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
- super( listener,
+ */
+ public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1269,30 +1273,30 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
-
+
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param ttsName TTS name.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
@@ -1304,17 +1308,17 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param autoActivateID ID used to re-register previously registered application.
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
- * @param transportConfig Initial configuration for transport.
+ * @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
- SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
- String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister,
- BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
+ SdlMsgVersion sdlMsgVersion, Language languageDesired, Language hmiDisplayLanguageDesired,
+ String appID, String autoActivateID, boolean callbackToUIThread, boolean preRegister,
+ BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1322,51 +1326,51 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/null,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/null,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
- }
+ }
/**
* @deprecated
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param ttsName TTS name.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
* @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
* or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired Indicates the language desired for the SDL interface.
- * @param hmiDisplayLanguageDesired Desired language in HMI.
- * @param appType Type of application.
+ * @param hmiDisplayLanguageDesired Desired language in HMI.
+ * @param appType Type of application.
* @param appID Identifier of the client application.
* @param autoActivateID ID used to re-register previously registered application.
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
+ */
@Deprecated
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- 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) throws SdlException {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ 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) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1374,50 +1378,50 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/appType,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/appType,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
new BTTransportConfig());
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
- }
+ }
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param context - Used to create a multiplexing transport config
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param ttsName TTS name.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
* @param sdlMsgVersion Indicates the version of SDL SmartDeviceLink Messages desired. Must be less than
* or equal to the version of SDL SmartDeviceLink running on the vehicle.
* @param languageDesired Indicates the language desired for the SDL interface.
- * @param hmiDisplayLanguageDesired Desired language in HMI.
- * @param appType Type of application.
+ * @param hmiDisplayLanguageDesired Desired language in HMI.
+ * @param appType Type of application.
* @param appID Identifier of the client application.
* @param autoActivateID ID used to re-register previously registered application.
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @throws SdlException
- */
- public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- 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) throws SdlException {
- super( listener,
+ */
+ public SdlProxyALM(Context context,IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ 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) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1425,28 +1429,28 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/appType,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/appType,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
new MultiplexTransportConfig(context,appID));
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
- }
+ }
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param ttsName TTS name.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
@@ -1459,17 +1463,17 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param autoActivateID ID used to re-register previously registered application.
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
- * @param transportConfig Initial configuration for transport.
+ * @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- 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 {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ 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 {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1477,26 +1481,26 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/appType,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/appType,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
- public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- 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 {
- super( listener,
+ public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ 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 {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1504,31 +1508,31 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/appType,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/appType,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
transportConfig);
-
- this.setAppService(appService);
- this.sendTransportBroadcast();
+
+ this.setAppService(appService);
+ this.sendTransportBroadcast();
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
- }
+ }
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
- *
- * Takes advantage of the advanced lifecycle management.
- *
+ *
+ * Takes advantage of the advanced lifecycle management.
+ *
* @param listener Reference to the object in the App listening to callbacks from SDL.
* @param sdlProxyConfigurationResources Proxy configuration resources.
* @param appName Name of the application displayed on SDL.
* @param ttsName TTS name.
- * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
+ * @param ngnMediaScreenAppName Name of the application displayed on SDL for Navigation equipped
* vehicles. Limited to five characters.
* @param vrSynonyms A vector of strings, all of which can be used as voice commands too
* @param isMediaApp Indicates if the app is a media application.
@@ -1542,17 +1546,17 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
* @param callbackToUIThread If true, all callbacks will occur on the UI thread.
* @param preRegister Flag that indicates that client should be pre-registred or not
* @param sHashID HashID used for app resumption
- * @param transportConfig Initial configuration for transport.
+ * @param transportConfig Initial configuration for transport.
* @throws SdlException
*/
- public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- 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,
- BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
+ public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ 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,
+ BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1560,28 +1564,28 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/appType,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/appType,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
- /*sHashID*/sHashID,
+ /*sHashID*/sHashID,
true,
transportConfig);
-
+
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
}
- public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
- 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,
- BaseTransportConfig transportConfig) throws SdlException {
- super( listener,
+ public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
+ 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,
+ BaseTransportConfig transportConfig) throws SdlException {
+ super( listener,
sdlProxyConfigurationResources,
- /*enable advanced lifecycle management*/true,
+ /*enable advanced lifecycle management*/true,
appName,
ttsName,
ngnMediaScreenAppName,
@@ -1589,25 +1593,25 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
isMediaApp,
sdlMsgVersion,
languageDesired,
- /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
- /*App Type*/appType,
- /*App ID*/appID,
+ /*HMI Display Language Desired*/hmiDisplayLanguageDesired,
+ /*App Type*/appType,
+ /*App ID*/appID,
autoActivateID,
callbackToUIThread,
preRegister,
- /*sHashID*/sHashID,
- /*bEnableResume*/true,
+ /*sHashID*/sHashID,
+ /*bEnableResume*/true,
transportConfig);
- this.setAppService(appService);
- this.sendTransportBroadcast();
+ this.setAppService(appService);
+ this.sendTransportBroadcast();
SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
"appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
"callbackToUIThread and version", SDL_LIB_TRACE_KEY);
- }
+ }
/***************************************** END OF TRANSPORT SWITCHING SUPPORT ***************************************/
-
+
// Allow applications using ALM to reset the proxy (dispose and reinstantiate)
/**
* Disconnects the application from SDL, then recreates the transport such that
@@ -1617,69 +1621,76 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
public void resetProxy() throws SdlException {
super.cycleProxy(SdlDisconnectedReason.APPLICATION_REQUESTED_DISCONNECT);
}
-
+
/********* Getters for values returned by RegisterAppInterfaceResponse **********/
-
+
/**
* Gets buttonCapabilities set when application interface is registered.
- *
+ *
* @return buttonCapabilities
* @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
*/
+ @Deprecated
public List<ButtonCapabilities> getButtonCapabilities() throws SdlException{
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
- if (!_appInterfaceRegisterd) {
+
+ // Test SDL availability
+ if (!_appInterfaceRegisterd || _systemCapabilityManager == null) {
throw new SdlException("SDL is unavailable. Unable to get the buttonCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE);
}
- return _buttonCapabilities;
+
+ return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.BUTTON), ButtonCapabilities.class);
}
-
+
/**
* Gets getSoftButtonCapabilities set when application interface is registered.
- *
- * @return softButtonCapabilities
+ *
+ * @return softButtonCapabilities
* @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
*/
+ @Deprecated
public List<SoftButtonCapabilities> getSoftButtonCapabilities() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
- if (!_appInterfaceRegisterd) {
+
+ // Test SDL availability
+ if (!_appInterfaceRegisterd || _systemCapabilityManager == null) {
throw new SdlException("SDL is not connected. Unable to get the softButtonCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE);
}
- return _softButtonCapabilities;
+ return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.SOFTBUTTON),SoftButtonCapabilities.class);
}
-
+
/**
* Gets getPresetBankCapabilities set when application interface is registered.
- *
- * @return presetBankCapabilities
+ *
+ * @return presetBankCapabilities
* @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
*/
+ @Deprecated
public PresetBankCapabilities getPresetBankCapabilities() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
+
+ // Test SDL availability
if (!_appInterfaceRegisterd) {
throw new SdlException("SDL is not connected. Unable to get the presetBankCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE);
}
- return _presetBankCapabilities;
+ return ( PresetBankCapabilities ) _systemCapabilityManager.getCapability(SystemCapabilityType.PRESET_BANK);
}
-
+
/**
* Gets the current version information of the proxy.
- *
+ *
* @return String
* @throws SdlException
*/
@@ -1687,76 +1698,82 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
- }
+ }
if (Version.VERSION != null)
- return Version.VERSION;
-
+ return Version.VERSION;
+
return null;
}
-
-
+
+
/**
* Gets displayCapabilities set when application interface is registered.
- *
+ *
* @return displayCapabilities
* @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
*/
+ @Deprecated
public DisplayCapabilities getDisplayCapabilities() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
- if (!_appInterfaceRegisterd) {
+
+ // Test SDL availability
+ if (!_appInterfaceRegisterd || _systemCapabilityManager == null) {
throw new SdlException("SDL is unavailable. Unable to get the displayCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE);
}
- return _displayCapabilities;
+ return ( DisplayCapabilities ) _systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY);
}
-
+
/**
* Gets hmiZoneCapabilities set when application interface is registered.
- *
+ *
* @return hmiZoneCapabilities
* @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
*/
+ @Deprecated
public List<HmiZoneCapabilities> getHmiZoneCapabilities() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
- if (!_appInterfaceRegisterd) {
+
+ // Test SDL availability
+ if (!_appInterfaceRegisterd || _systemCapabilityManager == null) {
throw new SdlException("SDL is unavailable. Unable to get the hmiZoneCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE);
}
- return _hmiZoneCapabilities;
+ return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.HMI_ZONE), HmiZoneCapabilities.class);
}
-
+
/**
* Gets speechCapabilities set when application interface is registered.
- *
+ *
* @return speechCapabilities
* @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
*/
+ @Deprecated
public List<SpeechCapabilities> getSpeechCapabilities() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
- if (!_appInterfaceRegisterd) {
+
+ // Test SDL availability
+ if (!_appInterfaceRegisterd || _systemCapabilityManager == null) {
throw new SdlException("SDL is unavailable. Unable to get the speechCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE);
}
-
- return _speechCapabilities;
+
+ return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.SPEECH), SpeechCapabilities.class);
}
/**
* Gets PrerecordedSpeech set when application interface is registered.
- *
+ *
* @return PrerecordedSpeech
* @throws SdlException
*/
@@ -1765,17 +1782,17 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
+
+ // Test SDL availability
if (!_appInterfaceRegisterd) {
throw new SdlException("SDL is unavailable. Unable to get the PrerecordedSpeech.", SdlExceptionCause.SDL_UNAVAILABLE);
}
-
+
return _prerecordedSpeech;
}
/**
* Gets sdlLanguage set when application interface is registered.
- *
+ *
* @return sdlLanguage
* @throws SdlException
*/
@@ -1784,18 +1801,18 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
+
+ // Test SDL availability
if (!_appInterfaceRegisterd) {
throw new SdlException("SDL is unavailable. Unable to get the sdlLanguage.", SdlExceptionCause.SDL_UNAVAILABLE);
}
return _sdlLanguage;
}
-
+
/**
* Gets getHmiDisplayLanguage set when application interface is registered.
- *
- * @return hmiDisplayLanguage
+ *
+ * @return hmiDisplayLanguage
* @throws SdlException
*/
public Language getHmiDisplayLanguage() throws SdlException {
@@ -1803,17 +1820,17 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
+
+ // Test SDL availability
if (!_appInterfaceRegisterd) {
throw new SdlException("SDL is not connected. Unable to get the hmiDisplayLanguage.", SdlExceptionCause.SDL_UNAVAILABLE);
}
return _hmiDisplayLanguage;
}
-
+
/**
* Gets sdlMsgVersion set when application interface is registered.
- *
+ *
* @return sdlMsgVersion
* @throws SdlException
*/
@@ -1822,37 +1839,39 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
+
+ // Test SDL availability
if (!_appInterfaceRegisterd) {
throw new SdlException("SDL is unavailable. Unable to get the sdlMsgVersion.", SdlExceptionCause.SDL_UNAVAILABLE);
}
return _sdlMsgVersion;
}
-
+
/**
* Gets vrCapabilities set when application interface is registered.
- *
+ *
* @return vrCapabilities
* @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
*/
+ @Deprecated
public List<VrCapabilities> getVrCapabilities() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
- if (!_appInterfaceRegisterd) {
+
+ // Test SDL availability
+ if (!_appInterfaceRegisterd || _systemCapabilityManager == null) {
throw new SdlException("SDL is unavailable. Unable to get the vrCapabilities.", SdlExceptionCause.SDL_UNAVAILABLE);
}
- return _vrCapabilities;
+ return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.VOICE_RECOGNITION), VrCapabilities.class);
}
-
+
/**
* Gets getVehicleType set when application interface is registered.
- *
- * @return vehicleType
+ *
+ * @return vehicleType
* @throws SdlException
*/
public VehicleType getVehicleType() throws SdlException {
@@ -1860,20 +1879,22 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
+
+ // Test SDL availability
if (!_appInterfaceRegisterd) {
throw new SdlException("SDL is not connected. Unable to get the vehicleType.", SdlExceptionCause.SDL_UNAVAILABLE);
}
return _vehicleType;
}
-
+
/**
- * Gets AudioPassThruCapabilities set when application interface is registered.
- *
- * @return AudioPassThruCapabilities
- * @throws SdlException
- */
+ * Gets AudioPassThruCapabilities set when application interface is registered.
+ *
+ * @return AudioPassThruCapabilities
+ * @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
+ */
+ @Deprecated
public List<AudioPassThruCapabilities> getAudioPassThruCapabilities() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
@@ -1881,10 +1902,10 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
}
// Test SDL availability
- if (!_appInterfaceRegisterd) {
+ if (!_appInterfaceRegisterd || _systemCapabilityManager == null) {
throw new SdlException("SDL is not connected. Unable to get the vehicleType.", SdlExceptionCause.SDL_UNAVAILABLE);
}
- return _audioPassThruCapabilities;
+ return convertToList(_systemCapabilityManager.getCapability(SystemCapabilityType.AUDIO_PASSTHROUGH), AudioPassThruCapabilities.class);
}
public List<Integer> getSupportedDiagModes() throws SdlException {
@@ -1892,14 +1913,22 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
+
+ // Test SDL availability
if (!_appInterfaceRegisterd) {
throw new SdlException("SDL is not connected. Unable to get SupportedDiagModes.", SdlExceptionCause.SDL_UNAVAILABLE);
}
return _diagModes;
- }
-
+ }
+
+ /**
+ * Gets HMICapabilities when application interface is registered.
+ *
+ * @return HMICapabilities
+ * @throws SdlException
+ * @deprecated use {@link SystemCapabilityManager#getCapability(SystemCapabilityType)} instead
+ */
+ @Deprecated
public HMICapabilities getHmiCapabilities() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
@@ -1907,13 +1936,13 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
}
// Test SDL availability
- if (!_appInterfaceRegisterd) {
+ if (!_appInterfaceRegisterd || _systemCapabilityManager == null) {
throw new SdlException("SDL is not connected. Unable to get the HMICapabilities.", SdlExceptionCause.SDL_UNAVAILABLE);
}
- return _hmiCapabilities;
- }
-
-
+ return ( HMICapabilities ) _systemCapabilityManager.getCapability(SystemCapabilityType.HMI);
+ }
+
+
public String getSystemSoftwareVersion() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
@@ -1925,19 +1954,19 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
throw new SdlException("SDL is not connected. Unable to get the SystemSoftwareVersion.", SdlExceptionCause.SDL_UNAVAILABLE);
}
return _systemSoftwareVersion;
- }
-
+ }
+
public boolean isAppResumeSuccess() throws SdlException {
// Test if proxy has been disposed
if (_proxyDisposed) {
throw new SdlException("This object has been disposed, it is no long capable of executing methods.", SdlExceptionCause.SDL_PROXY_DISPOSED);
}
-
- // Test SDL availability
+
+ // Test SDL availability
if (!_appInterfaceRegisterd) {
throw new SdlException("SDL is not connected. Unable to get isResumeSuccess.", SdlExceptionCause.SDL_UNAVAILABLE);
}
return _bResumeSuccess;
- }
-
+ }
+
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
index 7678eaaa6..a27f4a1fb 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -25,15 +25,20 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import android.annotation.TargetApi;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
+import android.os.SystemClock;
import android.telephony.TelephonyManager;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
+import android.view.Display;
+import android.view.MotionEvent;
import android.view.Surface;
import com.smartdevicelink.Dispatcher.IDispatchingStrategy;
@@ -41,8 +46,10 @@ import com.smartdevicelink.Dispatcher.ProxyMessageDispatcher;
import com.smartdevicelink.SdlConnection.ISdlConnectionListener;
import com.smartdevicelink.SdlConnection.SdlConnection;
import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.encoder.VirtualDisplayEncoder;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
+import com.smartdevicelink.haptic.HapticInterfaceManager;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.FunctionID;
@@ -55,9 +62,13 @@ import com.smartdevicelink.proxy.callbacks.OnError;
import com.smartdevicelink.proxy.callbacks.OnProxyClosed;
import com.smartdevicelink.proxy.callbacks.OnServiceEnded;
import com.smartdevicelink.proxy.callbacks.OnServiceNACKed;
-import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
+import com.smartdevicelink.proxy.interfaces.IAudioStreamListener;
import com.smartdevicelink.proxy.interfaces.IProxyListenerBase;
import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener;
+import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.interfaces.ISdlServiceListener;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
+import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener;
import com.smartdevicelink.proxy.rpc.*;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState;
@@ -68,7 +79,6 @@ 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;
@@ -79,16 +89,19 @@ 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.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
+import com.smartdevicelink.proxy.rpc.enums.TouchType;
import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
-import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
import com.smartdevicelink.proxy.rpc.listeners.OnPutFileUpdateListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
import com.smartdevicelink.security.SdlSecurityBase;
+import com.smartdevicelink.streaming.audio.AudioStreamingCodec;
+import com.smartdevicelink.streaming.audio.AudioStreamingParams;
import com.smartdevicelink.streaming.StreamRPCPacketizer;
+import com.smartdevicelink.streaming.video.SdlRemoteDisplay;
+import com.smartdevicelink.streaming.video.VideoStreamingParameters;
import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.trace.TraceDeviceInfo;
import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
@@ -97,13 +110,15 @@ import com.smartdevicelink.transport.SiphonServer;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.util.DebugTool;
+
+@SuppressWarnings({"WeakerAccess", "Convert2Diamond"})
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 static final int RESPONSE_WAIT_TIME = 2000;
-
+
private SdlSession sdlSession = null;
private proxyListenerType _proxyListener = null;
@@ -123,14 +138,17 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
ON_UPDATE_LISTENER_LOCK = new Object(),
ON_NOTIFICATION_LISTENER_LOCK = new Object();
- private Object APP_INTERFACE_REGISTERED_LOCK = new Object();
+ private final Object APP_INTERFACE_REGISTERED_LOCK = new Object();
private int iFileCount = 0;
private boolean navServiceStartResponseReceived = false;
private boolean navServiceStartResponse = false;
+ private List<String> navServiceStartRejectedParams = null;
private boolean pcmServiceStartResponseReceived = false;
private boolean pcmServiceStartResponse = false;
+ @SuppressWarnings("FieldCanBeLocal")
+ private List<String> pcmServiceStartRejectedParams = null;
private boolean navServiceEndResponseReceived = false;
private boolean navServiceEndResponse = false;
private boolean pcmServiceEndResponseReceived = false;
@@ -156,7 +174,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
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 final long instanceDateTime = System.currentTimeMillis();
private String sConnectionDetails = "N/A";
private Vector<TTSChunk> _ttsName = null;
private String _ngnMediaScreenAppName = null;
@@ -165,8 +183,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private Language _hmiDisplayLanguageDesired = null;
private Vector<AppHMIType> _appType = null;
private String _appID = null;
+ @SuppressWarnings({"FieldCanBeLocal", "unused"}) //Need to understand what this is used for
private String _autoActivateIdDesired = null;
- private String _lastHashID = null;
+ private String _lastHashID = null;
private SdlMsgVersion _sdlMsgVersionRequest = null;
private Vector<String> _vrSynonyms = null;
private boolean _bAppResumeEnabled = false;
@@ -182,7 +201,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
// Proxy State Variables
protected Boolean _appInterfaceRegisterd = false;
protected Boolean _preRegisterd = false;
- @SuppressWarnings("unused")
+ @SuppressWarnings({"unused", "FieldCanBeLocal"})
private Boolean _haveReceivedFirstNonNoneHMILevel = false;
protected Boolean _haveReceivedFirstFocusLevel = false;
protected Boolean _haveReceivedFirstFocusLevelFull = false;
@@ -190,42 +209,116 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
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 HMICapabilities _hmiCapabilities = null;
protected String _systemSoftwareVersion = null;
protected List<Integer> _diagModes = null;
protected Boolean firstTimeFull = true;
protected String _proxyVersionInfo = null;
protected Boolean _bResumeSuccess = false;
protected List<Class<? extends SdlSecurityBase>> _secList = null;
+ protected SystemCapabilityManager _systemCapabilityManager;
- private CopyOnWriteArrayList<IPutFileResponseListener> _putFileListenerList = new CopyOnWriteArrayList<IPutFileResponseListener>();
+ private final CopyOnWriteArrayList<IPutFileResponseListener> _putFileListenerList = new CopyOnWriteArrayList<IPutFileResponseListener>();
protected byte _wiproVersion = 1;
protected SparseArray<OnRPCResponseListener> rpcResponseListeners = null;
- protected SparseArray<OnRPCNotificationListener> rpcNotificationListeners = null;
-
+ protected SparseArray<CopyOnWriteArrayList<OnRPCNotificationListener>> rpcNotificationListeners = null;
+
+ protected VideoStreamingManager manager; //Will move to SdlSession once the class becomes public
+
// Interface broker
private SdlInterfaceBroker _interfaceBroker = null;
+ //We create an easily passable anonymous class of the interface so that we don't expose the internal interface to developers
+ private ISdl _internalInterface = new ISdl() {
+ @Override
+ public void start() {
+ try{
+ initializeProxy();
+ }catch (SdlException e){
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void stop() {
+ try{
+ dispose();
+ }catch (SdlException e){
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean isConnected() {
+ return getIsConnected();
+ }
+
+ @Override
+ public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) {
+ SdlProxyBase.this.addServiceListener(serviceType,sdlServiceListener);
+ }
+
+ @Override
+ public void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener) {
+ SdlProxyBase.this.removeServiceListener(serviceType,sdlServiceListener);
+ }
+
+ @Override
+ public void startVideoService(VideoStreamingParameters parameters, boolean encrypted) {
+ if(isConnected()){
+ sdlSession.setDesiredVideoParams(parameters);
+ sdlSession.startService(SessionType.NAV,sdlSession.getSessionId(),encrypted);
+ }
+ }
+
+ @Override
+ public void stopVideoService() {
+ if(isConnected()){
+ sdlSession.endService(SessionType.NAV,sdlSession.getSessionId());
+ }
+ }
+
+ @Override
+ public void startAudioService(boolean encrypted) {
+ if(isConnected()){
+ sdlSession.startService(SessionType.PCM,sdlSession.getSessionId(),encrypted);
+ }
+ }
+
+ @Override
+ public void stopAudioService() {
+ if(isConnected()){
+ sdlSession.endService(SessionType.PCM,sdlSession.getSessionId());
+ }
+ }
+
+ @Override
+ public void sendRPCRequest(RPCRequest message){
+ try {
+ SdlProxyBase.this.sendRPCRequest(message);
+ } catch (SdlException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {
+ SdlProxyBase.this.addOnRPCNotificationListener(notificationId,listener);
+ }
+
+ @Override
+ public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener) {
+ return SdlProxyBase.this.removeOnRPCNotificationListener(notificationId,listener);
+ }
+ };
private void notifyPutFileStreamError(Exception e, String info)
{
@@ -260,12 +353,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
// disconnect has completed
notifyPutFileStreamError(null, info);
- if (_advancedLifecycleManagementEnabled) {
- // If ALM, nothing is required to be done here
- } else {
+ if (!_advancedLifecycleManagementEnabled) {
// 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);
- }
+ }// else If ALM, nothing is required to be done here
+
}
@Override
@@ -326,7 +418,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
sdlSession.setIncomingHeartbeatMonitor(incomingHeartbeatMonitor);
}
- startRPCProtocolSession(sessionID, correlationID);
+ startRPCProtocolSession();
}
else
{
@@ -341,15 +433,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
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
- }
+ startRPCProtocolSession();
+ } //else{} Handle other protocol session types here
+
}
@Override
public void onProtocolSessionStartedNACKed(SessionType sessionType,
- byte sessionID, byte version, String correlationID) {
+ byte sessionID, byte version, String correlationID, List<String> rejectedParams) {
OnServiceNACKed message = new OnServiceNACKed(sessionType);
queueInternalMessage(message);
@@ -361,7 +452,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
updateBroadcastIntent(sendIntent, "COMMENT2", " NACK ServiceType: " + sessionType.getName());
sendBroadcastIntent(sendIntent);
- NavServiceStartedNACK();
+ NavServiceStartedNACK(rejectedParams);
}
else if (sessionType.eq(SessionType.PCM)) {
Intent sendIntent = createBroadcastIntent();
@@ -370,7 +461,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
updateBroadcastIntent(sendIntent, "COMMENT2", " NACK ServiceType: " + sessionType.getName());
sendBroadcastIntent(sendIntent);
- AudioServiceStartedNACK();
+ AudioServiceStartedNACK(rejectedParams);
}
}
@@ -480,7 +571,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if there is an unrecoverable error class might throw an exception.
*/
protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
@@ -493,12 +584,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
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
+ @SuppressWarnings("ConstantConditions")
+ 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);
@@ -565,7 +657,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
// 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());
+ _traceDeviceInterrogator = new TraceDeviceInfo(telephonyManager);
} // end-if
} // end-if
@@ -582,7 +674,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
@Override
public void dispatch(InternalProxyMessage message) {
- dispatchInternalMessage((InternalProxyMessage)message);
+ dispatchInternalMessage(message);
}
@Override
@@ -608,7 +700,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_incomingProxyMessageDispatcher = new ProxyMessageDispatcher<ProtocolMessage>("INCOMING_MESSAGE_DISPATCHER",new IDispatchingStrategy<ProtocolMessage>() {
@Override
public void dispatch(ProtocolMessage message) {
- dispatchIncomingMessage((ProtocolMessage)message);
+ dispatchIncomingMessage(message);
}
@Override
@@ -634,7 +726,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_outgoingProxyMessageDispatcher = new ProxyMessageDispatcher<ProtocolMessage>("OUTGOING_MESSAGE_DISPATCHER",new IDispatchingStrategy<ProtocolMessage>() {
@Override
public void dispatch(ProtocolMessage message) {
- dispatchOutgoingMessage((ProtocolMessage)message);
+ dispatchOutgoingMessage(message);
}
@Override
@@ -650,8 +742,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
rpcResponseListeners = new SparseArray<OnRPCResponseListener>();
- rpcNotificationListeners = new SparseArray<OnRPCNotificationListener>();
-
+ rpcNotificationListeners = new SparseArray<CopyOnWriteArrayList<OnRPCNotificationListener>>();
+
// Initialize the proxy
try {
initializeProxy();
@@ -711,7 +803,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if there is an unrecoverable error class might throw an exception.
*/
protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
boolean enableAdvancedLifecycleManagement, String appName, Vector<TTSChunk> ttsName,
@@ -791,7 +883,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private void sendBroadcastIntent(Intent sendIntent)
{
- Service myService = null;
+ Service myService;
if (_proxyListener != null && _proxyListener instanceof Service)
{
myService = (Service) _proxyListener;
@@ -829,8 +921,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
String sCharSet = "utf-8";
int iContentLength = iContentLen;
- URL url = null;
- HttpURLConnection urlConnection = null;
+ URL url;
+ HttpURLConnection urlConnection;
Intent sendIntent = createBroadcastIntent();
updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "getURLConnection");
@@ -904,7 +996,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
Headers myHeader = msg.getHeader();
- updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "sendOnSystemRequestToUrl");
+ updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "sendOnSystemRequestToUrl");
updateBroadcastIntent(sendIntent, "COMMENT5", "\r\nCloud URL: " + sURLString);
try
@@ -967,9 +1059,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
wr.close();
- long BeforeTime = System.currentTimeMillis();
- @SuppressWarnings("unused")
- String sResponseMsg = urlConnection.getResponseMessage();
+ long BeforeTime = System.currentTimeMillis();
long AfterTime = System.currentTimeMillis();
final long roundtriptime = AfterTime - BeforeTime;
@@ -1006,7 +1096,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
updateBroadcastIntent(sendIntent, "DATA", "Data from cloud response: " + response.toString());
sendRPCRequestPrivate(putFile);
- Log.i("sendOnSystemRequestToUrl", "sent to sdl");
+ Log.i("sendSystemRequestToUrl", "sent to sdl");
updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.PUT_FILE.toString());
updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST);
@@ -1026,20 +1116,20 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (jsonArray.get(i) instanceof String)
{
cloudDataReceived.add(jsonArray.getString(i));
- //Log.i("sendOnSystemRequestToUrl", "jsonArray.getString(i): " + jsonArray.getString(i));
+ //Log.i("sendSystemRequestToUrl", "jsonArray.getString(i): " + jsonArray.getString(i));
}
}
}
else if (jsonResponse.get(dataKey) instanceof String)
{
cloudDataReceived.add(jsonResponse.getString(dataKey));
- //Log.i("sendOnSystemRequestToUrl", "jsonResponse.getString(data): " + jsonResponse.getString("data"));
+ //Log.i("sendSystemRequestToUrl", "jsonResponse.getString(data): " + jsonResponse.getString("data"));
}
}
else
{
- DebugTool.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.");
+ DebugTool.logError("sendSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
+ //Log.i("sendSystemRequestToUrl", "sendSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
return;
}
@@ -1061,10 +1151,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
mySystemRequest = RPCRequestFactory.buildSystemRequest(response.toString(), getPoliciesReservedCorrelationID());
}
- if (getIsConnected())
+ if (getIsConnected())
{
sendRPCRequestPrivate(mySystemRequest);
- Log.i("sendOnSystemRequestToUrl", "sent to sdl");
+ Log.i("sendSystemRequestToUrl", "sent to sdl");
updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString());
updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST);
@@ -1074,45 +1164,45 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
catch (SdlException e)
{
- DebugTool.logError("sendOnSystemRequestToUrl: Could not get data from JSONObject received.", e);
+ DebugTool.logError("sendSystemRequestToUrl: 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);
+ //Log.i("pt", "sendSystemRequestToUrl: Could not get data from JSONObject received."+ e);
}
catch (JSONException e)
{
- DebugTool.logError("sendOnSystemRequestToUrl: JSONException: ", e);
+ DebugTool.logError("sendSystemRequestToUrl: JSONException: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " JSONException encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: JSONException: "+ e);
+ //Log.i("pt", "sendSystemRequestToUrl: JSONException: "+ e);
}
catch (UnsupportedEncodingException e)
{
- DebugTool.logError("sendOnSystemRequestToUrl: Could not encode string.", e);
+ DebugTool.logError("sendSystemRequestToUrl: Could not encode string.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " UnsupportedEncodingException encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: Could not encode string."+ e);
+ //Log.i("pt", "sendSystemRequestToUrl: Could not encode string."+ e);
}
catch (ProtocolException e)
{
- DebugTool.logError("sendOnSystemRequestToUrl: Could not set request method to post.", e);
+ DebugTool.logError("sendSystemRequestToUrl: 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);
+ //Log.i("pt", "sendSystemRequestToUrl: Could not set request method to post."+ e);
}
catch (MalformedURLException e)
{
- DebugTool.logError("sendOnSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e);
+ DebugTool.logError("sendSystemRequestToUrl: 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);
+ //Log.i("pt", "sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server."+ e);
}
catch (IOException e)
{
- DebugTool.logError("sendOnSystemRequestToUrl: IOException: ", e);
+ DebugTool.logError("sendSystemRequestToUrl: IOException: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " IOException while sending to cloud: IOException: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: IOException: "+ e);
+ //Log.i("pt", "sendSystemRequestToUrl: IOException: "+ e);
}
catch (Exception e)
{
- DebugTool.logError("sendOnSystemRequestToUrl: Unexpected Exception: ", e);
+ DebugTool.logError("sendSystemRequestToUrl: Unexpected Exception: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " Exception encountered sendOnSystemRequestToUrl: "+ e);
- //Log.i("pt", "sendOnSystemRequestToUrl: Unexpected Exception: " + e);
+ //Log.i("pt", "sendSystemRequestToUrl: Unexpected Exception: " + e);
}
finally
{
@@ -1137,23 +1227,19 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
// Test correlationID
private boolean isCorrelationIDProtected(Integer correlationID) {
- if (correlationID != null &&
- (HEARTBEAT_CORRELATION_ID == correlationID
+ return 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;
+ || POLICIES_CORRELATION_ID == correlationID);
+
}
// Protected isConnected method to allow legacy proxy to poll isConnected state
public Boolean getIsConnected() {
- if (sdlSession == null) return false;
-
- return sdlSession.getIsConnected();
+ return sdlSession != null && sdlSession.getIsConnected();
}
+
/**
* Returns whether the application is registered in SDL. Note: for testing
@@ -1172,15 +1258,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_haveReceivedFirstNonNoneHMILevel = false;
_haveReceivedFirstFocusLevel = false;
_haveReceivedFirstFocusLevelFull = false;
- if (_preRegisterd)
- _appInterfaceRegisterd = true;
- else
- _appInterfaceRegisterd = false;
+ _appInterfaceRegisterd = _preRegisterd;
_putFileListenerList.clear();
_sdlIntefaceAvailablity = SdlInterfaceAvailability.SDL_INTERFACE_UNAVAILABLE;
-
+
+ //Initialize _systemCapabilityManager here.
+ _systemCapabilityManager = new SystemCapabilityManager(_internalInterface);
// Setup SdlConnection
synchronized(CONNECTION_REFERENCE_LOCK) {
this.sdlSession = SdlSession.createSession(_wiproVersion,_interfaceBroker, _transportConfig);
@@ -1193,8 +1278,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
/**
* This method will fake the multiplex connection event
- * @param action
*/
+ @SuppressWarnings("unused")
public void forceOnConnected(){
synchronized(CONNECTION_REFERENCE_LOCK) {
if (sdlSession != null) {
@@ -1229,6 +1314,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Public method to enable the siphon transport
*/
+ @SuppressWarnings("unused")
public void enableSiphonDebug() {
short enabledPortNumber = SiphonServer.enableSiphonServer();
@@ -1244,6 +1330,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Public method to disable the Siphon Trace Server
*/
+ @SuppressWarnings("unused")
public void disableSiphonDebug() {
short disabledPortNumber = SiphonServer.disableSiphonServer();
@@ -1275,16 +1362,19 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Public method to determine Debug Tool enabled
*/
+ @SuppressWarnings("BooleanMethodIsAlwaysInverted")
public static boolean isDebugEnabled() {
return DebugTool.isDebugEnabled();
}
+ @SuppressWarnings("unused")
@Deprecated
public void close() throws SdlException {
dispose();
}
+ @SuppressWarnings("UnusedParameters")
private void cleanProxy(SdlDisconnectedReason disconnectedReason) throws SdlException {
try {
@@ -1298,7 +1388,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
Boolean waitForInterfaceUnregistered = false;
// Unregister app interface
synchronized(CONNECTION_REFERENCE_LOCK) {
- if (sdlSession != null && sdlSession.getIsConnected() && getAppInterfaceRegistered()) {
+ if (getIsConnected() && getAppInterfaceRegistered()) {
waitForInterfaceUnregistered = true;
unregisterAppInterfacePrivate(UNREGISTER_APP_INTERFACE_CORRELATION_ID);
}
@@ -1320,15 +1410,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
rpcResponseListeners.clear();
}
if(rpcNotificationListeners != null){
- rpcNotificationListeners.clear(); //TODO make sure we want to clear this
+ rpcNotificationListeners.clear();
}
// 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);
}
@@ -1379,15 +1467,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
rpcResponseListeners = 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 final static Object CYCLE_LOCK = new Object();
private boolean _cycling = false;
@@ -1471,17 +1557,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (message.getBulkData() != null) hash.put(RPCStruct.KEY_BULK_DATA, message.getBulkData());
if (message.getPayloadProtected()) hash.put(RPCStruct.KEY_PROTECTED, true);
} else {
- final Hashtable<String, Object> mhash = JsonRPCMarshaller.unmarshall(message.getData());
- hash = mhash;
+ hash = JsonRPCMarshaller.unmarshall(message.getData());
}
handleRPCMessage(hash);
} catch (final Exception excp) {
DebugTool.logError("Failure handling protocol message: " + excp.toString(), excp);
passErrorToProxyListener("Error handing incoming protocol message.", excp);
} // end-catch
- } else {
- // Handle other protocol message types here
- }
+ } //else { Handle other protocol message types here}
} catch (final Exception e) {
// Pass error to application through listener
DebugTool.logError("Error handing proxy event.", e);
@@ -1499,7 +1582,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public String serializeJSON(RPCMessage msg)
{
- String sReturn = null;
+ String sReturn;
try
{
sReturn = msg.serializeJSON(getWiProVersion()).toString(2);
@@ -1532,77 +1615,88 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
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());
- }
- } else if (message.getFunctionName().equals(InternalProxyMessage.OnServiceEnded)) {
- final OnServiceEnded msg = (OnServiceEnded)message;
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onServiceEnded(msg);
- }
- });
- } else {
- _proxyListener.onServiceEnded(msg);
+ switch (message.getFunctionName()) {
+ case 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());
+ }
+ break;
}
- } else if (message.getFunctionName().equals(InternalProxyMessage.OnServiceNACKed)) {
- final OnServiceNACKed msg = (OnServiceNACKed)message;
- if (_callbackToUIThread) {
- // Run in UI thread
- _mainUIHandler.post(new Runnable() {
- @Override
- public void run() {
- _proxyListener.onServiceNACKed(msg);
- }
- });
- } else {
- _proxyListener.onServiceNACKed(msg);
+ case InternalProxyMessage.OnServiceEnded: {
+ final OnServiceEnded msg = (OnServiceEnded) message;
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onServiceEnded(msg);
+ }
+ });
+ } else {
+ _proxyListener.onServiceEnded(msg);
+ }
+ break;
}
+ case InternalProxyMessage.OnServiceNACKed: {
+ final OnServiceNACKed msg = (OnServiceNACKed) message;
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onServiceNACKed(msg);
+ }
+ });
+ } else {
+ _proxyListener.onServiceNACKed(msg);
+ }
- /**************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();
+ /* *************Start Legacy Specific Call-backs************/
+ break;
}
- } 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());
+ case InternalProxyMessage.OnProxyOpened:
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ ((IProxyListener) _proxyListener).onProxyOpened();
+ }
+ });
+ } else {
+ ((IProxyListener) _proxyListener).onProxyOpened();
+ }
+ break;
+ case 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************/
+ break;
}
- /****************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);
- DebugTool.logError("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.");
+ default:
+ // Diagnostics
+ SdlTrace.logProxyEvent("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.", SDL_LIB_TRACE_KEY);
+ DebugTool.logError("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.");
+ break;
}
SdlTrace.logProxyEvent("Proxy fired callback: " + message.getFunctionName(), SDL_LIB_TRACE_KEY);
@@ -1686,10 +1780,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Only call this method for a PutFile response. It will cause a class cast exception if not.
- * @param correlationId
- * @param bytesWritten
- * @param totalSize
+ * @param correlationId correlation id of the packet being updated
+ * @param bytesWritten how many bytes were written
+ * @param totalSize the total size in bytes
*/
+ @SuppressWarnings("unused")
public void onPacketProgress(int correlationId, long bytesWritten, long totalSize){
synchronized(ON_UPDATE_LISTENER_LOCK){
if(rpcResponseListeners !=null
@@ -1703,9 +1798,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Will provide callback to the listener either onFinish or onError depending on the RPCResponses result code,
* <p>Will automatically remove the listener for the list of listeners on completion.
- * @param msg
+ * @param msg The RPCResponse message that was received
* @return if a listener was called or not
*/
+ @SuppressWarnings("UnusedReturnValue")
private boolean onRPCResponseReceived(RPCResponse msg){
synchronized(ON_UPDATE_LISTENER_LOCK){
int correlationId = msg.getCorrelationID();
@@ -1725,9 +1821,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
/**
- *
- * @param listener
- * @param correlationId
+ * Add a listener that will receive the response to the specific RPCRequest sent with the corresponding correlation id
+ * @param listener that will get called back when a response is received
+ * @param correlationId of the RPCRequest that was sent
* @param totalSize only include if this is an OnPutFileUpdateListener. Otherwise it will be ignored.
*/
public void addOnRPCResponseListener(OnRPCResponseListener listener,int correlationId, int totalSize){
@@ -1743,17 +1839,21 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
}
+ @SuppressWarnings("unused")
public SparseArray<OnRPCResponseListener> getResponseListeners(){
synchronized(ON_UPDATE_LISTENER_LOCK){
return this.rpcResponseListeners;
}
}
+ @SuppressWarnings("UnusedReturnValue")
public boolean onRPCNotificationReceived(RPCNotification notification){
synchronized(ON_NOTIFICATION_LISTENER_LOCK){
- OnRPCNotificationListener listener = rpcNotificationListeners.get(FunctionID.getFunctionId(notification.getFunctionName()));
- if(listener!=null){
- listener.onNotified(notification);
+ CopyOnWriteArrayList<OnRPCNotificationListener> listeners = rpcNotificationListeners.get(FunctionID.getFunctionId(notification.getFunctionName()));
+ if(listeners!=null && listeners.size()>0) {
+ for (OnRPCNotificationListener listener : listeners) {
+ listener.onNotified(notification);
+ }
return true;
}
return false;
@@ -1763,20 +1863,45 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* This will ad a listener for the specific type of notification. As of now it will only allow
* a single listener per notification function id
- * @param notification The notification type that this listener is designated for
+ * @param notificationId The notification type that this listener is designated for
* @param listener The listener that will be called when a notification of the provided type is received
*/
- public void addOnRPCNotificationListener(FunctionID notificationId,OnRPCNotificationListener listener){
+ @SuppressWarnings("unused")
+ public void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){
synchronized(ON_NOTIFICATION_LISTENER_LOCK){
- rpcNotificationListeners.put(notificationId.getId(), listener);
+ if(notificationId != null && listener != null){
+ if(rpcNotificationListeners.indexOfKey(notificationId.getId()) < 0 ){
+ rpcNotificationListeners.put(notificationId.getId(),new CopyOnWriteArrayList<OnRPCNotificationListener>());
+ }
+ rpcNotificationListeners.get(notificationId.getId()).add(listener);
+ }
}
}
-
+
+ /**
+ * This method is no longer valid and will not remove the listener for the supplied notificaiton id
+ * @param notificationId n/a
+ * @see #removeOnRPCNotificationListener(FunctionID, OnRPCNotificationListener)
+ */
+ @SuppressWarnings("unused")
+ @Deprecated
public void removeOnRPCNotificationListener(FunctionID notificationId){
synchronized(ON_NOTIFICATION_LISTENER_LOCK){
- rpcNotificationListeners.delete(notificationId.getId());
+ //rpcNotificationListeners.delete(notificationId.getId());
}
}
+
+ public boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener){
+ synchronized(ON_NOTIFICATION_LISTENER_LOCK){
+ if(rpcNotificationListeners!= null
+ && notificationId != null
+ && listener != null
+ && rpcNotificationListeners.indexOfKey(notificationId.getId()) >= 0){
+ return rpcNotificationListeners.get(notificationId.getId()).remove(listener);
+ }
+ }
+ return false;
+ }
private void processRaiResponse(RegisterAppInterfaceResponse rai)
{
@@ -1790,7 +1915,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (_secList == null) return;
- SdlSecurityBase sec = null;
+ SdlSecurityBase sec;
Service svc = getService();
SdlSecurityBase.setAppService(svc);
@@ -1810,16 +1935,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (sec.getMakeList().contains(make))
{
setSdlSecurity(sec);
- if (sec != null)
- {
sec.setAppId(_appID);
if (sdlSession != null)
sec.handleSdlSession(sdlSession);
- }
return;
}
}
- }
+ }
}
private void handleRPCMessage(Hashtable<String, Object> hash) {
@@ -1842,6 +1964,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_appInterfaceRegisterd = true;
}
processRaiResponse(msg);
+
+ //Populate the system capability manager with the RAI response
+ _systemCapabilityManager.parseRAIResponse(msg);
Intent sendIntent = createBroadcastIntent();
updateBroadcastIntent(sendIntent, "RPC_NAME", FunctionID.REGISTER_APP_INTERFACE.toString());
@@ -1855,20 +1980,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
//_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();
- _hmiCapabilities = msg.getHmiCapabilities();
_systemSoftwareVersion = msg.getSystemSoftwareVersion();
_proxyVersionInfo = msg.getProxyVersionInfo();
@@ -1918,8 +2034,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public void run() {
if (_proxyListener instanceof IProxyListener) {
((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
}
onRPCResponseReceived(msg);
}
@@ -1927,8 +2041,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
} else {
if (_proxyListener instanceof IProxyListener) {
((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
}
onRPCResponseReceived(msg);
}
@@ -2008,23 +2120,16 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_appInterfaceRegisterd = true;
}
processRaiResponse(msg);
-
+ //Populate the system capability manager with the RAI response
+ _systemCapabilityManager.parseRAIResponse(msg);
+
//_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();
- _hmiCapabilities = msg.getHmiCapabilities();
_systemSoftwareVersion = msg.getSystemSoftwareVersion();
_proxyVersionInfo = msg.getProxyVersionInfo();
@@ -2069,8 +2174,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public void run() {
if (_proxyListener instanceof IProxyListener) {
((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
}
onRPCResponseReceived(msg);
}
@@ -2078,8 +2181,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
} else {
if (_proxyListener instanceof IProxyListener) {
((IProxyListener)_proxyListener).onRegisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onRegisterAppInterfaceResponse(msg);
}
onRPCResponseReceived(msg);
}
@@ -2127,12 +2228,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onShowResponse((ShowResponse)msg);
+ _proxyListener.onShowResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onShowResponse((ShowResponse)msg);
+ _proxyListener.onShowResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.ADD_COMMAND.toString())) {
@@ -2144,12 +2245,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onAddCommandResponse((AddCommandResponse)msg);
+ _proxyListener.onAddCommandResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onAddCommandResponse((AddCommandResponse)msg);
+ _proxyListener.onAddCommandResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.DELETE_COMMAND.toString())) {
@@ -2161,12 +2262,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onDeleteCommandResponse((DeleteCommandResponse)msg);
+ _proxyListener.onDeleteCommandResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onDeleteCommandResponse((DeleteCommandResponse)msg);
+ _proxyListener.onDeleteCommandResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.ADD_SUB_MENU.toString())) {
@@ -2178,12 +2279,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onAddSubMenuResponse((AddSubMenuResponse)msg);
+ _proxyListener.onAddSubMenuResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onAddSubMenuResponse((AddSubMenuResponse)msg);
+ _proxyListener.onAddSubMenuResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.DELETE_SUB_MENU.toString())) {
@@ -2195,12 +2296,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onDeleteSubMenuResponse((DeleteSubMenuResponse)msg);
+ _proxyListener.onDeleteSubMenuResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onDeleteSubMenuResponse((DeleteSubMenuResponse)msg);
+ _proxyListener.onDeleteSubMenuResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SUBSCRIBE_BUTTON.toString())) {
@@ -2212,12 +2313,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSubscribeButtonResponse((SubscribeButtonResponse)msg);
+ _proxyListener.onSubscribeButtonResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSubscribeButtonResponse((SubscribeButtonResponse)msg);
+ _proxyListener.onSubscribeButtonResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.UNSUBSCRIBE_BUTTON.toString())) {
@@ -2229,12 +2330,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onUnsubscribeButtonResponse((UnsubscribeButtonResponse)msg);
+ _proxyListener.onUnsubscribeButtonResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onUnsubscribeButtonResponse((UnsubscribeButtonResponse)msg);
+ _proxyListener.onUnsubscribeButtonResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SET_MEDIA_CLOCK_TIMER.toString())) {
@@ -2246,12 +2347,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSetMediaClockTimerResponse((SetMediaClockTimerResponse)msg);
+ _proxyListener.onSetMediaClockTimerResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSetMediaClockTimerResponse((SetMediaClockTimerResponse)msg);
+ _proxyListener.onSetMediaClockTimerResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.ENCODED_SYNC_P_DATA.toString())) {
@@ -2289,12 +2390,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onCreateInteractionChoiceSetResponse((CreateInteractionChoiceSetResponse)msg);
+ _proxyListener.onCreateInteractionChoiceSetResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onCreateInteractionChoiceSetResponse((CreateInteractionChoiceSetResponse)msg);
+ _proxyListener.onCreateInteractionChoiceSetResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.DELETE_INTERACTION_CHOICE_SET.toString())) {
@@ -2306,12 +2407,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onDeleteInteractionChoiceSetResponse((DeleteInteractionChoiceSetResponse)msg);
+ _proxyListener.onDeleteInteractionChoiceSetResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onDeleteInteractionChoiceSetResponse((DeleteInteractionChoiceSetResponse)msg);
+ _proxyListener.onDeleteInteractionChoiceSetResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.PERFORM_INTERACTION.toString())) {
@@ -2323,12 +2424,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onPerformInteractionResponse((PerformInteractionResponse)msg);
+ _proxyListener.onPerformInteractionResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onPerformInteractionResponse((PerformInteractionResponse)msg);
+ _proxyListener.onPerformInteractionResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SET_GLOBAL_PROPERTIES.toString())) {
@@ -2340,12 +2441,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSetGlobalPropertiesResponse((SetGlobalPropertiesResponse)msg);
+ _proxyListener.onSetGlobalPropertiesResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSetGlobalPropertiesResponse((SetGlobalPropertiesResponse)msg);
+ _proxyListener.onSetGlobalPropertiesResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.RESET_GLOBAL_PROPERTIES.toString())) {
@@ -2357,12 +2458,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onResetGlobalPropertiesResponse((ResetGlobalPropertiesResponse)msg);
+ _proxyListener.onResetGlobalPropertiesResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onResetGlobalPropertiesResponse((ResetGlobalPropertiesResponse)msg);
+ _proxyListener.onResetGlobalPropertiesResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.UNREGISTER_APP_INTERFACE.toString())) {
@@ -2392,8 +2493,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
public void run() {
if (_proxyListener instanceof IProxyListener) {
((IProxyListener)_proxyListener).onUnregisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onUnregisterAppInterfaceResponse(msg);
}
onRPCResponseReceived(msg);
}
@@ -2401,8 +2500,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
} else {
if (_proxyListener instanceof IProxyListener) {
((IProxyListener)_proxyListener).onUnregisterAppInterfaceResponse(msg);
- } else if (_proxyListener instanceof IProxyListenerALM) {
- //((IProxyListenerALM)_proxyListener).onUnregisterAppInterfaceResponse(msg);
}
onRPCResponseReceived(msg);
}
@@ -2416,12 +2513,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onGenericResponse((GenericResponse)msg);
+ _proxyListener.onGenericResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onGenericResponse((GenericResponse)msg);
+ _proxyListener.onGenericResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SLIDER.toString())) {
@@ -2432,12 +2529,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSliderResponse((SliderResponse)msg);
+ _proxyListener.onSliderResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSliderResponse((SliderResponse)msg);
+ _proxyListener.onSliderResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.PUT_FILE.toString())) {
@@ -2448,13 +2545,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onPutFileResponse((PutFileResponse)msg);
+ _proxyListener.onPutFileResponse(msg);
onRPCResponseReceived(msg);
notifyPutFileStreamResponse(msg);
}
});
} else {
- _proxyListener.onPutFileResponse((PutFileResponse)msg);
+ _proxyListener.onPutFileResponse(msg);
onRPCResponseReceived(msg);
notifyPutFileStreamResponse(msg);
}
@@ -2466,12 +2563,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onDeleteFileResponse((DeleteFileResponse)msg);
+ _proxyListener.onDeleteFileResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onDeleteFileResponse((DeleteFileResponse)msg);
+ _proxyListener.onDeleteFileResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.LIST_FILES.toString())) {
@@ -2482,12 +2579,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onListFilesResponse((ListFilesResponse)msg);
+ _proxyListener.onListFilesResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onListFilesResponse((ListFilesResponse)msg);
+ _proxyListener.onListFilesResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SET_APP_ICON.toString())) {
@@ -2498,12 +2595,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSetAppIconResponse((SetAppIconResponse)msg);
+ _proxyListener.onSetAppIconResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSetAppIconResponse((SetAppIconResponse)msg);
+ _proxyListener.onSetAppIconResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SCROLLABLE_MESSAGE.toString())) {
@@ -2514,12 +2611,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onScrollableMessageResponse((ScrollableMessageResponse)msg);
+ _proxyListener.onScrollableMessageResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onScrollableMessageResponse((ScrollableMessageResponse)msg);
+ _proxyListener.onScrollableMessageResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.CHANGE_REGISTRATION.toString())) {
@@ -2530,12 +2627,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onChangeRegistrationResponse((ChangeRegistrationResponse)msg);
+ _proxyListener.onChangeRegistrationResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onChangeRegistrationResponse((ChangeRegistrationResponse)msg);
+ _proxyListener.onChangeRegistrationResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SET_DISPLAY_LAYOUT.toString())) {
@@ -2543,11 +2640,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
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(msg.getSuccess() && _systemCapabilityManager!=null){
+ _systemCapabilityManager.setCapability(SystemCapabilityType.DISPLAY, msg.getDisplayCapabilities());
+ _systemCapabilityManager.setCapability(SystemCapabilityType.BUTTON, msg.getButtonCapabilities());
+ _systemCapabilityManager.setCapability(SystemCapabilityType.PRESET_BANK, msg.getPresetBankCapabilities());
+ _systemCapabilityManager.setCapability(SystemCapabilityType.SOFTBUTTON, msg.getSoftButtonCapabilities());
}
if (_callbackToUIThread) {
@@ -2555,12 +2652,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSetDisplayLayoutResponse((SetDisplayLayoutResponse)msg);
+ _proxyListener.onSetDisplayLayoutResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSetDisplayLayoutResponse((SetDisplayLayoutResponse)msg);
+ _proxyListener.onSetDisplayLayoutResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.PERFORM_AUDIO_PASS_THRU.toString())) {
@@ -2571,12 +2668,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onPerformAudioPassThruResponse((PerformAudioPassThruResponse)msg);
+ _proxyListener.onPerformAudioPassThruResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onPerformAudioPassThruResponse((PerformAudioPassThruResponse)msg);
+ _proxyListener.onPerformAudioPassThruResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.END_AUDIO_PASS_THRU.toString())) {
@@ -2587,12 +2684,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onEndAudioPassThruResponse((EndAudioPassThruResponse)msg);
+ _proxyListener.onEndAudioPassThruResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onEndAudioPassThruResponse((EndAudioPassThruResponse)msg);
+ _proxyListener.onEndAudioPassThruResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SUBSCRIBE_VEHICLE_DATA.toString())) {
@@ -2603,12 +2700,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSubscribeVehicleDataResponse((SubscribeVehicleDataResponse)msg);
+ _proxyListener.onSubscribeVehicleDataResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSubscribeVehicleDataResponse((SubscribeVehicleDataResponse)msg);
+ _proxyListener.onSubscribeVehicleDataResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.UNSUBSCRIBE_VEHICLE_DATA.toString())) {
@@ -2619,12 +2716,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onUnsubscribeVehicleDataResponse((UnsubscribeVehicleDataResponse)msg);
+ _proxyListener.onUnsubscribeVehicleDataResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onUnsubscribeVehicleDataResponse((UnsubscribeVehicleDataResponse)msg);
+ _proxyListener.onUnsubscribeVehicleDataResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.GET_VEHICLE_DATA.toString())) {
@@ -2635,12 +2732,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onGetVehicleDataResponse((GetVehicleDataResponse)msg);
+ _proxyListener.onGetVehicleDataResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onGetVehicleDataResponse((GetVehicleDataResponse)msg);
+ _proxyListener.onGetVehicleDataResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.SUBSCRIBE_WAY_POINTS.toString())) {
@@ -2651,12 +2748,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSubscribeWayPointsResponse((SubscribeWayPointsResponse)msg);
+ _proxyListener.onSubscribeWayPointsResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSubscribeWayPointsResponse((SubscribeWayPointsResponse)msg);
+ _proxyListener.onSubscribeWayPointsResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.UNSUBSCRIBE_WAY_POINTS.toString())) {
@@ -2667,12 +2764,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onUnsubscribeWayPointsResponse((UnsubscribeWayPointsResponse)msg);
+ _proxyListener.onUnsubscribeWayPointsResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onUnsubscribeWayPointsResponse((UnsubscribeWayPointsResponse)msg);
+ _proxyListener.onUnsubscribeWayPointsResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.GET_WAY_POINTS.toString())) {
@@ -2683,12 +2780,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onGetWayPointsResponse((GetWayPointsResponse)msg);
+ _proxyListener.onGetWayPointsResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onGetWayPointsResponse((GetWayPointsResponse)msg);
+ _proxyListener.onGetWayPointsResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.READ_DID.toString())) {
@@ -2698,12 +2795,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onReadDIDResponse((ReadDIDResponse)msg);
+ _proxyListener.onReadDIDResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onReadDIDResponse((ReadDIDResponse)msg);
+ _proxyListener.onReadDIDResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.GET_DTCS.toString())) {
@@ -2713,12 +2810,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onGetDTCsResponse((GetDTCsResponse)msg);
+ _proxyListener.onGetDTCsResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onGetDTCsResponse((GetDTCsResponse)msg);
+ _proxyListener.onGetDTCsResponse(msg);
onRPCResponseReceived(msg);
}
} else if (functionName.equals(FunctionID.DIAGNOSTIC_MESSAGE.toString())) {
@@ -2728,12 +2825,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onDiagnosticMessageResponse((DiagnosticMessageResponse)msg);
+ _proxyListener.onDiagnosticMessageResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onDiagnosticMessageResponse((DiagnosticMessageResponse)msg);
+ _proxyListener.onDiagnosticMessageResponse(msg);
onRPCResponseReceived(msg);
}
}
@@ -2745,12 +2842,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onSystemRequestResponse((SystemRequestResponse)msg);
+ _proxyListener.onSystemRequestResponse(msg);
onRPCResponseReceived(msg);
}
});
} else {
- _proxyListener.onSystemRequestResponse((SystemRequestResponse)msg);
+ _proxyListener.onSystemRequestResponse(msg);
onRPCResponseReceived(msg);
}
}
@@ -2831,13 +2928,85 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_proxyListener.onUpdateTurnListResponse(msg);
onRPCResponseReceived(msg);
}
+ } else if (functionName.equals(FunctionID.SET_INTERIOR_VEHICLE_DATA.toString())) {
+ final SetInteriorVehicleDataResponse msg = new SetInteriorVehicleDataResponse(hash);
+ if (_callbackToUIThread) {
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSetInteriorVehicleDataResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onSetInteriorVehicleDataResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ } else if (functionName.equals(FunctionID.GET_INTERIOR_VEHICLE_DATA.toString())) {
+ final GetInteriorVehicleDataResponse msg = new GetInteriorVehicleDataResponse(hash);
+ if (_callbackToUIThread) {
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onGetInteriorVehicleDataResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onGetInteriorVehicleDataResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ } else if (functionName.equals(FunctionID.GET_SYSTEM_CAPABILITY.toString())) {
+ // GetSystemCapabilityResponse
+ final GetSystemCapabilityResponse msg = new GetSystemCapabilityResponse(hash);
+ if (_callbackToUIThread) {
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onGetSystemCapabilityResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onGetSystemCapabilityResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ } else if (functionName.equals(FunctionID.BUTTON_PRESS.toString())) {
+ final ButtonPressResponse msg = new ButtonPressResponse(hash);
+ if (_callbackToUIThread) {
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onButtonPressResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onButtonPressResponse(msg);
+ onRPCResponseReceived(msg);
+ }
+ } else if (functionName.equals(FunctionID.SEND_HAPTIC_DATA.toString())) {
+ final SendHapticDataResponse msg = new SendHapticDataResponse(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onSendHapticDataResponse( msg);
+ onRPCResponseReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onSendHapticDataResponse( msg);
+ onRPCResponseReceived(msg);
+ }
}
else {
if (_sdlMsgVersion != null) {
- DebugTool.logError("Unrecognized response Message: " + functionName.toString() +
- "SDL Message Version = " + _sdlMsgVersion);
+ DebugTool.logError("Unrecognized response Message: " + functionName +
+ " SDL Message Version = " + _sdlMsgVersion);
} else {
- DebugTool.logError("Unrecognized response Message: " + functionName.toString());
+ DebugTool.logError("Unrecognized response Message: " + functionName);
}
} // end-if
@@ -2854,22 +3023,25 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
sdlSession.getLockScreenMan().setHMILevel(msg.getHmiLevel());
}
- msg.setFirstRun(Boolean.valueOf(firstTimeFull));
+ msg.setFirstRun(firstTimeFull);
if (msg.getHmiLevel() == HMILevel.HMI_FULL) firstTimeFull = false;
- if (msg.getHmiLevel() != _priorHmiLevel && msg.getAudioStreamingState() != _priorAudioStreamingState) {
+ if (msg.getHmiLevel() != _hmiLevel || msg.getAudioStreamingState() != _audioStreamingState) {
+ _hmiLevel = msg.getHmiLevel();
+ _audioStreamingState = msg.getAudioStreamingState();
+
if (_callbackToUIThread) {
// Run in UI thread
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnHMIStatus((OnHMIStatus)msg);
+ _proxyListener.onOnHMIStatus(msg);
_proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnHMIStatus((OnHMIStatus)msg);
+ _proxyListener.onOnHMIStatus(msg);
_proxyListener.onOnLockScreenNotification(sdlSession.getLockScreenMan().getLockObj());
onRPCNotificationReceived(msg);
}
@@ -2883,12 +3055,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnCommand((OnCommand)msg);
+ _proxyListener.onOnCommand(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnCommand((OnCommand)msg);
+ _proxyListener.onOnCommand(msg);
onRPCNotificationReceived(msg);
}
} else if (functionName.equals(FunctionID.ON_DRIVER_DISTRACTION.toString())) {
@@ -2900,12 +3072,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (sdlSession != null)
{
DriverDistractionState drDist = msg.getState();
- boolean bVal = false;
- if (drDist == DriverDistractionState.DD_ON)
- bVal = true;
- else
- bVal = false;
- sdlSession.getLockScreenMan().setDriverDistStatus(bVal);
+ sdlSession.getLockScreenMan().setDriverDistStatus(drDist == DriverDistractionState.DD_ON);
}
if (_callbackToUIThread) {
@@ -3009,12 +3176,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnButtonPress((OnButtonPress)msg);
+ _proxyListener.onOnButtonPress(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnButtonPress((OnButtonPress)msg);
+ _proxyListener.onOnButtonPress(msg);
onRPCNotificationReceived(msg);
}
} else if (functionName.equals(FunctionID.ON_BUTTON_EVENT.toString())) {
@@ -3026,12 +3193,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnButtonEvent((OnButtonEvent)msg);
+ _proxyListener.onOnButtonEvent(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnButtonEvent((OnButtonEvent)msg);
+ _proxyListener.onOnButtonEvent(msg);
onRPCNotificationReceived(msg);
}
} else if (functionName.equals(FunctionID.ON_LANGUAGE_CHANGE.toString())) {
@@ -3043,12 +3210,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnLanguageChange((OnLanguageChange)msg);
+ _proxyListener.onOnLanguageChange(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnLanguageChange((OnLanguageChange)msg);
+ _proxyListener.onOnLanguageChange(msg);
onRPCNotificationReceived(msg);
}
} else if (functionName.equals(FunctionID.ON_HASH_CHANGE.toString())) {
@@ -3060,7 +3227,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnHashChange((OnHashChange)msg);
+ _proxyListener.onOnHashChange(msg);
onRPCNotificationReceived(msg);
if (_bAppResumeEnabled)
{
@@ -3069,7 +3236,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
});
} else {
- _proxyListener.onOnHashChange((OnHashChange)msg);
+ _proxyListener.onOnHashChange(msg);
onRPCNotificationReceived(msg);
if (_bAppResumeEnabled)
{
@@ -3105,12 +3272,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnSystemRequest((OnSystemRequest)msg);
+ _proxyListener.onOnSystemRequest(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnSystemRequest((OnSystemRequest)msg);
+ _proxyListener.onOnSystemRequest(msg);
onRPCNotificationReceived(msg);
}
} else if (functionName.equals(FunctionID.ON_AUDIO_PASS_THRU.toString())) {
@@ -3121,12 +3288,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnAudioPassThru((OnAudioPassThru)msg);
+ _proxyListener.onOnAudioPassThru(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnAudioPassThru((OnAudioPassThru)msg);
+ _proxyListener.onOnAudioPassThru(msg);
onRPCNotificationReceived(msg);
}
} else if (functionName.equals(FunctionID.ON_VEHICLE_DATA.toString())) {
@@ -3137,12 +3304,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnVehicleData((OnVehicleData)msg);
+ _proxyListener.onOnVehicleData(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnVehicleData((OnVehicleData)msg);
+ _proxyListener.onOnVehicleData(msg);
onRPCNotificationReceived(msg);
}
}
@@ -3189,12 +3356,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnKeyboardInput((OnKeyboardInput)msg);
+ _proxyListener.onOnKeyboardInput(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnKeyboardInput((OnKeyboardInput)msg);
+ _proxyListener.onOnKeyboardInput(msg);
onRPCNotificationReceived(msg);
}
}
@@ -3205,12 +3372,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnTouchEvent((OnTouchEvent)msg);
+ _proxyListener.onOnTouchEvent(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnTouchEvent((OnTouchEvent)msg);
+ _proxyListener.onOnTouchEvent(msg);
onRPCNotificationReceived(msg);
}
}
@@ -3221,21 +3388,37 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_mainUIHandler.post(new Runnable() {
@Override
public void run() {
- _proxyListener.onOnWayPointChange((OnWayPointChange)msg);
+ _proxyListener.onOnWayPointChange(msg);
+ onRPCNotificationReceived(msg);
+ }
+ });
+ } else {
+ _proxyListener.onOnWayPointChange(msg);
+ onRPCNotificationReceived(msg);
+ }
+ }
+ else if (functionName.equals(FunctionID.ON_INTERIOR_VEHICLE_DATA.toString())) {
+ final OnInteriorVehicleData msg = new OnInteriorVehicleData(hash);
+ if (_callbackToUIThread) {
+ // Run in UI thread
+ _mainUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ _proxyListener.onOnInteriorVehicleData(msg);
onRPCNotificationReceived(msg);
}
});
} else {
- _proxyListener.onOnWayPointChange((OnWayPointChange)msg);
+ _proxyListener.onOnInteriorVehicleData(msg);
onRPCNotificationReceived(msg);
}
}
else {
if (_sdlMsgVersion != null) {
- DebugTool.logInfo("Unrecognized notification Message: " + functionName.toString() +
+ DebugTool.logInfo("Unrecognized notification Message: " + functionName +
" connected to SDL using message version: " + _sdlMsgVersion.getMajorVersion() + "." + _sdlMsgVersion.getMinorVersion());
} else {
- DebugTool.logInfo("Unrecognized notification Message: " + functionName.toString());
+ DebugTool.logInfo("Unrecognized notification Message: " + functionName);
}
} // end-if
} // end-if notification
@@ -3246,8 +3429,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Takes an RPCRequest and sends it to SDL. Responses are captured through callback on IProxyListener.
*
- * @param request
- * @throws SdlException
+ * @param request is the RPCRequest being sent
+ * @throws SdlException if an unrecoverable error is encountered if an unrecoverable error is encountered
*/
public void sendRPCRequest(RPCRequest request) throws SdlException {
if (_proxyDisposed) {
@@ -3264,7 +3447,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
// Test if SdlConnection is null
synchronized(CONNECTION_REFERENCE_LOCK) {
- if (sdlSession == null || !sdlSession.getIsConnected()) {
+ if (!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);
}
@@ -3310,7 +3493,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
queueInternalMessage(message);
}
- private void startRPCProtocolSession(byte sessionID, String correlationID) {
+ private void startRPCProtocolSession() {
// Set Proxy Lifecyclek Available
if (_advancedLifecycleManagementEnabled) {
@@ -3327,7 +3510,6 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_hmiDisplayLanguageDesired,
_appType,
_appID,
- _autoActivateIdDesired,
REGISTER_APP_INTERFACE_CORRELATION_ID);
} catch (Exception e) {
@@ -3416,15 +3598,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
try {
StreamRPCPacketizer rpcPacketizer = new StreamRPCPacketizer((SdlProxyBase<IProxyListenerBase>) this, sdlSession, is, request, sType, rpcSessionID, wiproVersion, lSize, sdlSession);
rpcPacketizer.start();
- RPCStreamController streamController = new RPCStreamController(rpcPacketizer, request.getCorrelationID());
- return streamController;
+ return new RPCStreamController(rpcPacketizer, request.getCorrelationID());
} catch (Exception e) {
Log.e("SyncConnection", "Unable to start streaming:" + e.toString());
return null;
}
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "UnusedReturnValue"})
private RPCStreamController startRPCStream(InputStream is, PutFile request, SessionType sType, byte rpcSessionID, byte wiproVersion)
{
if (sdlSession == null) return null;
@@ -3438,8 +3619,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
try {
StreamRPCPacketizer rpcPacketizer = new StreamRPCPacketizer((SdlProxyBase<IProxyListenerBase>) this, sdlSession, is, request, sType, rpcSessionID, wiproVersion, lSize, sdlSession);
rpcPacketizer.start();
- RPCStreamController streamController = new RPCStreamController(rpcPacketizer, request.getCorrelationID());
- return streamController;
+ return new RPCStreamController(rpcPacketizer, request.getCorrelationID());
} catch (Exception e) {
Log.e("SyncConnection", "Unable to start streaming:" + e.toString());
return null;
@@ -3454,10 +3634,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private RPCStreamController startPutFileStream(InputStream is, PutFile msg) {
if (sdlSession == null) return null;
if (is == null) return null;
- startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
- return null;
+ return startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
}
+ @SuppressWarnings("UnusedReturnValue")
public boolean startRPCStream(InputStream is, RPCRequest msg) {
if (sdlSession == null) return false;
sdlSession.startRPCStream(is, msg, SessionType.RPC, sdlSession.getSessionId(), _wiproVersion);
@@ -3475,38 +3655,68 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
private class CallableMethod implements Callable<Void> {
- private long waitTime;
- public CallableMethod(int timeInMillis){
+ private final long waitTime;
+
+ public CallableMethod(int timeInMillis){
this.waitTime=timeInMillis;
- }
- @Override
- public Void call() {
- try {
- Thread.sleep(waitTime);
- } catch (InterruptedException e) {
- e.printStackTrace();
}
- return null;
- }
+ @Override
+ public Void call() {
+ try {
+ Thread.sleep(waitTime);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
}
+
public FutureTask<Void> createFutureTask(CallableMethod callMethod){
return new FutureTask<Void>(callMethod);
}
+
public ScheduledExecutorService createScheduler(){
return Executors.newSingleThreadScheduledExecutor();
- }
+ }
+
+ @SuppressWarnings("unused")
+ public void startService(SessionType serviceType, boolean isEncrypted){
+ sdlSession.startService(serviceType, sdlSession.getSessionId(), isEncrypted);
+ }
+
+ @SuppressWarnings("unused")
+ public void endService(SessionType serviceType){
+ sdlSession.endService(serviceType, sdlSession.getSessionId());
+ }
+
+
/**
+ * @deprecated
*Opens the video service (serviceType 11) and subsequently streams raw H264 video from an InputStream provided by the app
*@return true if service is opened successfully and stream is started, return false otherwise
+ * @see #startRemoteDisplayStream(Context, Class, VideoStreamingParameters, boolean) startRemoteDisplayStream
+ * @see #startVideoStream(boolean, VideoStreamingParameters) startVideoStream
+ * @see #createOpenGLInputSurface(int, int, int, int, int, boolean) createOpenGLInputSurface
*/
+ @SuppressWarnings("unused")
+ @Deprecated
public boolean startH264(InputStream is, boolean isEncrypted) {
if (sdlSession == null) return false;
navServiceStartResponseReceived = false;
navServiceStartResponse = false;
+ navServiceStartRejectedParams = null;
+
+ // When startH264() API is used, we will not send video format / width / height information
+ // with StartService. (Reasons: InputStream does not provide timestamp information so RTP
+ // cannot be used. startH264() does not provide with/height information.)
+ VideoStreamingParameters emptyParam = new VideoStreamingParameters();
+ emptyParam.setResolution(null);
+ emptyParam.setFormat(null);
+ sdlSession.setDesiredVideoParams(emptyParam);
sdlSession.startService(SessionType.NAV, sdlSession.getSessionId(), isEncrypted);
@@ -3514,10 +3724,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
+ //noinspection StatementWithEmptyBody
while (!navServiceStartResponseReceived && !fTask.isDone());
scheduler.shutdown();
- scheduler = null;
- fTask = null;
if (navServiceStartResponse) {
try {
@@ -3532,25 +3741,40 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
/**
+ * @deprecated
*Opens the video service (serviceType 11) and subsequently provides an OutputStream to the app to use for a raw H264 video stream
- *@return OutputStream if service is opened successfully and stream is started, return null otherwise
+ *@return OutputStream if service is opened successfully and stream is started, return null otherwise
+ * @see #startRemoteDisplayStream(Context, Class, VideoStreamingParameters, boolean) startRemoteDisplayStream
+ * @see #startVideoStream(boolean, VideoStreamingParameters) startVideoStream
+ * @see #createOpenGLInputSurface(int, int, int, int, int, boolean) createOpenGLInputSurface
*/
+ @SuppressWarnings("unused")
+ @Deprecated
public OutputStream startH264(boolean isEncrypted) {
if (sdlSession == null) return null;
navServiceStartResponseReceived = false;
navServiceStartResponse = false;
+ navServiceStartRejectedParams = null;
+
+ // When startH264() API is used, we will not send video format / width / height information
+ // with StartService. (Reasons: OutputStream does not provide timestamp information so RTP
+ // cannot be used. startH264() does not provide with/height information.)
+ VideoStreamingParameters emptyParam = new VideoStreamingParameters();
+ emptyParam.setResolution(null);
+ emptyParam.setFormat(null);
+ sdlSession.setDesiredVideoParams(emptyParam);
+
sdlSession.startService(SessionType.NAV, sdlSession.getSessionId(), isEncrypted);
FutureTask<Void> fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME));
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
+ //noinspection StatementWithEmptyBody
while (!navServiceStartResponseReceived && !fTask.isDone());
scheduler.shutdown();
- scheduler = null;
- fTask = null;
if (navServiceStartResponse) {
try {
@@ -3567,66 +3791,49 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*Closes the opened video service (serviceType 11)
*@return true if the video service is closed successfully, return false otherwise
*/
+ @SuppressWarnings("unused")
+ @Deprecated
public boolean endH264() {
- if (sdlSession == null) return false;
-
- navServiceEndResponseReceived = false;
- navServiceEndResponse = false;
- sdlSession.stopVideoStream();
-
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME));
- ScheduledExecutorService scheduler = createScheduler();
- scheduler.execute(fTask);
-
- while (!navServiceEndResponseReceived && !fTask.isDone());
- scheduler.shutdown();
- scheduler = null;
- fTask = null;
-
- if (navServiceEndResponse) {
- return true;
- } else {
- return false;
- }
+ return endVideoStream();
}
/**
*Pauses the stream for the opened audio service (serviceType 10)
*@return true if the audio service stream is paused successfully, return false otherwise
*/
- public boolean pausePCM()
- {
- if (sdlSession == null) return false;
- return sdlSession.pauseAudioStream();
+ @SuppressWarnings("unused")
+ @Deprecated
+ public boolean pausePCM() {
+ return pauseAudioStream();
}
/**
*Pauses the stream for the opened video service (serviceType 11)
*@return true if the video service stream is paused successfully, return false otherwise
*/
- public boolean pauseH264()
- {
- if (sdlSession == null) return false;
- return sdlSession.pauseVideoStream();
+ @SuppressWarnings("unused")
+ @Deprecated
+ public boolean pauseH264() {
+ return pauseVideoStream();
}
/**
*Resumes the stream for the opened audio service (serviceType 10)
*@return true if the audio service stream is resumed successfully, return false otherwise
*/
- public boolean resumePCM()
- {
- if (sdlSession == null) return false;
- return sdlSession.resumeAudioStream();
+ @SuppressWarnings("unused")
+ @Deprecated
+ public boolean resumePCM() {
+ return resumeAudioStream();
}
/**
*Resumes the stream for the opened video service (serviceType 11)
*@return true if the video service is resumed successfully, return false otherwise
*/
- public boolean resumeH264()
- {
- if (sdlSession == null) return false;
- return sdlSession.resumeVideoStream();
+ @SuppressWarnings("unused")
+ @Deprecated
+ public boolean resumeH264() {
+ return resumeVideoStream();
}
@@ -3634,6 +3841,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*Opens the audio service (serviceType 10) and subsequently streams raw PCM audio from an InputStream provided by the app
*@return true if service is opened successfully and stream is started, return false otherwise
*/
+ @SuppressWarnings("unused")
+ @Deprecated
public boolean startPCM(InputStream is, boolean isEncrypted) {
if (sdlSession == null) return false;
@@ -3645,10 +3854,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
+ //noinspection StatementWithEmptyBody
while (!pcmServiceStartResponseReceived && !fTask.isDone());
scheduler.shutdown();
- scheduler = null;
- fTask = null;
if (pcmServiceStartResponse) {
try {
@@ -3666,6 +3874,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*Opens the audio service (serviceType 10) and subsequently provides an OutputStream to the app
*@return OutputStream if service is opened successfully and stream is started, return null otherwise
*/
+ @SuppressWarnings("unused")
+ @Deprecated
public OutputStream startPCM(boolean isEncrypted) {
if (sdlSession == null) return null;
@@ -3677,10 +3887,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
+ //noinspection StatementWithEmptyBody
while (!pcmServiceStartResponseReceived && !fTask.isDone());
scheduler.shutdown();
- scheduler = null;
- fTask = null;
if (pcmServiceStartResponse) {
try {
@@ -3689,6 +3898,19 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
return null;
}
} else {
+ if (pcmServiceStartRejectedParams != null) {
+ StringBuilder builder = new StringBuilder();
+ for (String paramName : pcmServiceStartRejectedParams) {
+ if (builder.length() > 0) {
+ builder.append(", ");
+ }
+ builder.append(paramName);
+ }
+ DebugTool.logWarning("StartService for nav failed. Rejected params: " + builder.toString());
+
+ } else {
+ DebugTool.logWarning("StartService for nav failed (rejected params not supplied)");
+ }
return null;
}
}
@@ -3697,31 +3919,86 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*Closes the opened audio service (serviceType 10)
*@return true if the audio service is closed successfully, return false otherwise
*/
+ @SuppressWarnings("unused")
+ @Deprecated
public boolean endPCM() {
- if (sdlSession == null) return false;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return false;
-
- pcmServiceEndResponseReceived = false;
- pcmServiceEndResponse = false;
- sdlSession.stopAudioStream();
-
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME));
- ScheduledExecutorService scheduler = createScheduler();
- scheduler.execute(fTask);
+ return endAudioStream();
+ }
+
+ /**
+ * Opens a video service (service type 11) and subsequently provides an IVideoStreamListener
+ * to the app to send video data. The supplied VideoStreamingParameters will be set as desired paramaters
+ * that will be used to negotiate
+ *
+ * @param isEncrypted Specify true if packets on this service have to be encrypted
+ * @param parameters Video streaming parameters including: codec which will be used for streaming (currently, only
+ * VideoStreamingCodec.H264 is accepted), height and width of the video in pixels.
+ *
+ * @return IVideoStreamListener interface if service is opened successfully and streaming is
+ * started, null otherwise
+ */
+ @SuppressWarnings("unused")
+ public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) {
+ if (sdlSession == null) {
+ DebugTool.logWarning("SdlSession is not created yet.");
+ return null;
+ }
+ if (sdlSession.getSdlConnection() == null) {
+ DebugTool.logWarning("SdlConnection is not available.");
+ return null;
+ }
- while (!pcmServiceEndResponseReceived && !fTask.isDone());
- scheduler.shutdown();
- scheduler = null;
- fTask = null;
+ sdlSession.setDesiredVideoParams(parameters);
+
+ VideoStreamingParameters acceptedParams = tryStartVideoStream(isEncrypted, parameters);
+ if (acceptedParams != null) {
+ return sdlSession.startVideoStream();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *Closes the opened video service (serviceType 11)
+ *@return true if the video service is closed successfully, return false otherwise
+ */
+ @SuppressWarnings("unused")
+ public boolean endVideoStream() {
+ if (sdlSession == null){ return false; }
+
+ navServiceEndResponseReceived = false;
+ navServiceEndResponse = false;
+ sdlSession.stopVideoStream();
+
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME));
+ ScheduledExecutorService scheduler = createScheduler();
+ scheduler.execute(fTask);
+
+ //noinspection StatementWithEmptyBody
+ while (!navServiceEndResponseReceived && !fTask.isDone());
+ scheduler.shutdown();
+
+ return navServiceEndResponse;
+ }
+
+ /**
+ *Pauses the stream for the opened video service (serviceType 11)
+ *@return true if the video service stream is paused successfully, return false otherwise
+ */
+ @SuppressWarnings("unused")
+ public boolean pauseVideoStream() {
+ return sdlSession != null && sdlSession.pauseVideoStream();
+ }
+
+ /**
+ *Resumes the stream for the opened video service (serviceType 11)
+ *@return true if the video service is resumed successfully, return false otherwise
+ */
+ @SuppressWarnings("unused")
+ public boolean resumeVideoStream() {
+ return sdlSession != null && sdlSession.resumeVideoStream();
+ }
- if (pcmServiceEndResponse) {
- return true;
- } else {
- return false;
- }
- }
-
/**
* Opens the video service (serviceType 11) and creates a Surface (used for streaming video) with input parameters provided by the app
* @param frameRate - specified rate of frames to utilize for creation of Surface
@@ -3731,38 +4008,170 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @param bitrate - specified bitrate to utilize for creation of Surface
*@return Surface if service is opened successfully and stream is started, return null otherwise
*/
- public Surface createOpenGLInputSurface(int frameRate, int iFrameInterval, int width,
- int height, int bitrate, boolean isEncrypted) {
+ @SuppressWarnings("unused")
+ public Surface createOpenGLInputSurface(int frameRate, int iFrameInterval, int width,
+ int height, int bitrate, boolean isEncrypted) {
- if (sdlSession == null) return null;
- SdlConnection sdlConn = sdlSession.getSdlConnection();
- if (sdlConn == null) return null;
-
- navServiceStartResponseReceived = false;
- navServiceStartResponse = false;
- sdlSession.startService(SessionType.NAV, sdlSession.getSessionId(), isEncrypted);
-
- FutureTask<Void> fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME));
- ScheduledExecutorService scheduler = createScheduler();
- scheduler.execute(fTask);
-
- while (!navServiceStartResponseReceived && !fTask.isDone());
- scheduler.shutdown();
- scheduler = null;
- fTask = null;
-
- if (navServiceStartResponse) {
+ if (sdlSession == null || sdlSession.getSdlConnection() == null){
+ return null;
+ }
+
+ VideoStreamingParameters desired = new VideoStreamingParameters();
+ desired.setFrameRate(frameRate);
+ desired.setInterval(iFrameInterval);
+ ImageResolution resolution = new ImageResolution();
+ resolution.setResolutionWidth(width);
+ resolution.setResolutionHeight(height);
+ desired.setResolution(resolution);
+ desired.setBitrate(bitrate);
+
+ VideoStreamingParameters acceptedParams = tryStartVideoStream(isEncrypted, desired);
+ if (acceptedParams != null) {
return sdlSession.createOpenGLInputSurface(frameRate, iFrameInterval, width,
- height, bitrate, SessionType.NAV, sdlSession.getSessionId());
+ height, bitrate, SessionType.NAV, sdlSession.getSessionId());
} else {
return null;
}
}
-
+
+ /**
+ * Starts streaming a remote display to the module if there is a connected session. This method of streaming requires the device to be on API level 19 or higher
+ * @param context a context that can be used to create the remote display
+ * @param remoteDisplay class object of the remote display. This class will be used to create an instance of the remote display and will be projected to the module
+ * @param parameters streaming parameters to be used when streaming. If null is sent in, the default/optimized options will be used.
+ * If you are unsure about what parameters to be used it is best to just send null and let the system determine what
+ * works best for the currently connected module.
+ *
+ * @param encrypted a flag of if the stream should be encrypted. Only set if you have a supplied encryption library that the module can understand.
+ */
+ @TargetApi(19)
+ public void startRemoteDisplayStream(Context context, final Class<? extends SdlRemoteDisplay> remoteDisplay, final VideoStreamingParameters parameters, final boolean encrypted){
+ if(getWiProVersion() >= 5 && !_systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)){
+ Log.e(TAG, "Video streaming not supported on this module");
+ return;
+ }
+ //Create streaming manager
+ if(manager == null){
+ manager = new VideoStreamingManager(context,this._internalInterface);
+ }
+
+ if(parameters == null){
+ if(getWiProVersion() >= 5) {
+ _systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING, new OnSystemCapabilityListener() {
+ @Override
+ public void onCapabilityRetrieved(Object capability) {
+ VideoStreamingParameters params = new VideoStreamingParameters();
+ params.update((VideoStreamingCapability)capability); //Streaming parameters are ready time to stream
+ sdlSession.setDesiredVideoParams(params);
+ manager.startVideoStreaming(remoteDisplay, params, encrypted);
+ }
+
+ @Override
+ public void onError(String info) {
+ Log.e(TAG, "Error retrieving video streaming capability: " + info);
+
+ }
+ });
+ }else{
+ //We just use default video streaming params
+ VideoStreamingParameters params = new VideoStreamingParameters();
+ DisplayCapabilities dispCap = (DisplayCapabilities)_systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY);
+ if(dispCap !=null){
+ params.setResolution(dispCap.getScreenParams().getImageResolution());
+ }
+ sdlSession.setDesiredVideoParams(params);
+ manager.startVideoStreaming(remoteDisplay,params, encrypted);
+ }
+ }else{
+ sdlSession.setDesiredVideoParams(parameters);
+ manager.startVideoStreaming(remoteDisplay,parameters, encrypted);
+ }
+ }
+
+ /**
+ * Stops the remote display stream if one has been started
+ */
+ public void stopRemoteDisplayStream(){
+ if(manager!=null){
+ manager.dispose();
+ }
+ manager = null;
+ }
+
+ /**
+ * Try to open a video service by using the video streaming parameters supplied.
+ *
+ * Only information from codecs, width and height are used during video format negotiation.
+ *
+ * @param isEncrypted Specify true if packets on this service have to be encrypted
+ * @param parameters VideoStreamingParameters that are desired. Does not guarantee this is what will be accepted.
+ *
+ * @return If the service is opened successfully, an instance of VideoStreamingParams is
+ * returned which contains accepted video format. If the service is opened with legacy
+ * mode (i.e. without any negotiation) then an instance of VideoStreamingParams is
+ * returned. If the service was not opened then null is returned.
+ */
+ @SuppressWarnings("unused")
+ private VideoStreamingParameters tryStartVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) {
+ if (sdlSession == null) {
+ DebugTool.logWarning("SdlSession is not created yet.");
+ return null;
+ }
+ if(getWiProVersion() >= 5 && !_systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)){
+ DebugTool.logWarning("Module doesn't support video streaming.");
+ return null;
+ }
+ if (parameters == null) {
+ DebugTool.logWarning("Video parameters were not supplied.");
+ return null;
+ }
+
+ sdlSession.setDesiredVideoParams(parameters);
+
+ navServiceStartResponseReceived = false;
+ navServiceStartResponse = false;
+ navServiceStartRejectedParams = null;
+
+ sdlSession.startService(SessionType.NAV, sdlSession.getSessionId(), isEncrypted);
+
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME));
+ ScheduledExecutorService scheduler = createScheduler();
+ scheduler.execute(fTask);
+
+ //noinspection StatementWithEmptyBody
+ while (!navServiceStartResponseReceived && !fTask.isDone());
+ scheduler.shutdown();
+
+ if (navServiceStartResponse) {
+ if(getWiProVersion() < 5){ //Versions 1-4 do not support streaming parameter negotiations
+ sdlSession.setAcceptedVideoParams(parameters);
+ }
+ return sdlSession.getAcceptedVideoParams();
+ }
+
+ if (navServiceStartRejectedParams != null) {
+ StringBuilder builder = new StringBuilder();
+ for (String paramName : navServiceStartRejectedParams) {
+ if (builder.length() > 0) {
+ builder.append(", ");
+ }
+ builder.append(paramName);
+ }
+
+ DebugTool.logWarning("StartService for nav failed. Rejected params: " + builder.toString());
+
+ } else {
+ DebugTool.logWarning("StartService for nav failed (rejected params not supplied)");
+ }
+
+ return null;
+ }
+
/**
*Starts the MediaCodec encoder utilized in conjunction with the Surface returned via the createOpenGLInputSurface method
*/
- public void startEncoder () {
+ @SuppressWarnings("unused")
+ public void startEncoder () {
if (sdlSession == null) return;
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return;
@@ -3773,7 +4182,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
*Releases the MediaCodec encoder utilized in conjunction with the Surface returned via the createOpenGLInputSurface method
*/
- public void releaseEncoder() {
+ @SuppressWarnings("unused")
+ public void releaseEncoder() {
if (sdlSession == null) return;
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return;
@@ -3784,22 +4194,134 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
*Releases the MediaCodec encoder utilized in conjunction with the Surface returned via the createOpenGLInputSurface method
*/
- public void drainEncoder(boolean endOfStream) {
+ @SuppressWarnings("unused")
+ public void drainEncoder(boolean endOfStream) {
if (sdlSession == null) return;
SdlConnection sdlConn = sdlSession.getSdlConnection();
if (sdlConn == null) return;
sdlSession.drainEncoder(endOfStream);
}
-
+
+ /**
+ * Opens a audio service (service type 10) and subsequently provides an IAudioStreamListener
+ * to the app to send audio data.
+ *
+ * Currently information passed by "params" are ignored, since Audio Streaming feature lacks
+ * capability negotiation mechanism. App should configure audio stream data to align with
+ * head unit's capability by checking (upcoming) pcmCapabilities. The default format is in
+ * 16kHz and 16 bits.
+ *
+ * @param isEncrypted Specify true if packets on this service have to be encrypted
+ * @param codec Audio codec which will be used for streaming. Currently, only
+ * AudioStreamingCodec.LPCM is accepted.
+ * @param params (Reserved for future use) Additional configuration information for each
+ * codec. If "codec" is AudioStreamingCodec.LPCM, "params" must be an
+ * instance of LPCMParams class.
+ *
+ * @return IAudioStreamListener interface if service is opened successfully and streaming is
+ * started, null otherwise
+ */
+ @SuppressWarnings("unused")
+ public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec,
+ AudioStreamingParams params) {
+ if (sdlSession == null) {
+ DebugTool.logWarning("SdlSession is not created yet.");
+ return null;
+ }
+ if (sdlSession.getSdlConnection() == null) {
+ DebugTool.logWarning("SdlConnection is not available.");
+ return null;
+ }
+ if (codec != AudioStreamingCodec.LPCM) {
+ DebugTool.logWarning("Audio codec " + codec + " is not supported.");
+ return null;
+ }
+
+ pcmServiceStartResponseReceived = false;
+ pcmServiceStartResponse = false;
+ sdlSession.startService(SessionType.PCM, sdlSession.getSessionId(), isEncrypted);
+
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME));
+ ScheduledExecutorService scheduler = createScheduler();
+ scheduler.execute(fTask);
+
+ //noinspection StatementWithEmptyBody
+ while (!pcmServiceStartResponseReceived && !fTask.isDone());
+ scheduler.shutdown();
+
+ if (pcmServiceStartResponse) {
+ DebugTool.logInfo("StartService for audio succeeded");
+ return sdlSession.startAudioStream();
+ } else {
+ if (pcmServiceStartRejectedParams != null) {
+ StringBuilder builder = new StringBuilder();
+ for (String paramName : pcmServiceStartRejectedParams) {
+ if (builder.length() > 0) {
+ builder.append(", ");
+ }
+ builder.append(paramName);
+ }
+ DebugTool.logWarning("StartService for audio failed. Rejected params: " + builder.toString());
+ } else {
+ DebugTool.logWarning("StartService for audio failed (rejected params not supplied)");
+ }
+ return null;
+ }
+ }
+
+ /**
+ *Closes the opened audio service (serviceType 10)
+ *@return true if the audio service is closed successfully, return false otherwise
+ */
+ @SuppressWarnings("unused")
+ public boolean endAudioStream() {
+ if (sdlSession == null) return false;
+ SdlConnection sdlConn = sdlSession.getSdlConnection();
+ if (sdlConn == null) return false;
+
+ pcmServiceEndResponseReceived = false;
+ pcmServiceEndResponse = false;
+ sdlSession.stopAudioStream();
+
+ FutureTask<Void> fTask = createFutureTask(new CallableMethod(RESPONSE_WAIT_TIME));
+ ScheduledExecutorService scheduler = createScheduler();
+ scheduler.execute(fTask);
+
+ //noinspection StatementWithEmptyBody
+ while (!pcmServiceEndResponseReceived && !fTask.isDone());
+ scheduler.shutdown();
+
+ return pcmServiceEndResponse;
+ }
+
+ /**
+ *Pauses the stream for the opened audio service (serviceType 10)
+ *@return true if the audio service stream is paused successfully, return false otherwise
+ */
+ @SuppressWarnings("unused")
+ public boolean pauseAudioStream() {
+ return sdlSession != null && sdlSession.pauseAudioStream();
+ }
+
+ /**
+ *Resumes the stream for the opened audio service (serviceType 10)
+ *@return true if the audio service stream is resumed successfully, return false otherwise
+ */
+ @SuppressWarnings("unused")
+ public boolean resumeAudioStream() {
+ return sdlSession != null && sdlSession.resumeAudioStream();
+ }
+
private void NavServiceStarted() {
navServiceStartResponseReceived = true;
navServiceStartResponse = true;
}
- private void NavServiceStartedNACK() {
+ private void NavServiceStartedNACK(List<String> rejectedParams) {
navServiceStartResponseReceived = true;
navServiceStartResponse = false;
+ navServiceStartRejectedParams = rejectedParams;
}
private void AudioServiceStarted() {
@@ -3811,9 +4333,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
rpcProtectedResponseReceived = true;
rpcProtectedStartResponse = true;
}
- private void AudioServiceStartedNACK() {
+ private void AudioServiceStartedNACK(List<String> rejectedParams) {
pcmServiceStartResponseReceived = true;
pcmServiceStartResponse = false;
+ pcmServiceStartRejectedParams = rejectedParams;
}
private void NavServiceEnded() {
@@ -3841,6 +4364,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_appService = mService;
}
+ @SuppressWarnings("unused")
public boolean startProtectedRPCService() {
rpcProtectedResponseReceived = false;
rpcProtectedStartResponse = false;
@@ -3850,18 +4374,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
ScheduledExecutorService scheduler = createScheduler();
scheduler.execute(fTask);
+ //noinspection StatementWithEmptyBody
while (!rpcProtectedResponseReceived && !fTask.isDone());
scheduler.shutdown();
- scheduler = null;
- fTask = null;
- if (rpcProtectedStartResponse) {
- return true;
- } else {
- return false;
- }
- }
-
+ return rpcProtectedStartResponse;
+ }
+
+ @SuppressWarnings("unused")
public void getLockScreenIcon(final OnLockScreenIconDownloadedListener l){
if(lockScreenIconRequest == null){
l.onLockScreenIconDownloadError(new SdlException("This version of SDL core may not support lock screen icons.",
@@ -3882,7 +4402,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
}
- /******************** Public Helper Methods *************************/
+ /* ******************* Public Helper Methods *************************/
/*Begin V1 Enhanced helper*/
@@ -3897,11 +4417,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("SameParameterValue")
public void addCommand(Integer commandID,
- String menuText, Integer parentID, Integer position,
- Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
+ 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,
@@ -3920,11 +4441,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- String menuText, Integer position,
- Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
+ String menuText, Integer position,
+ Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
throws SdlException {
addCommand(commandID, menuText, null, position, vrCommands, IconValue, IconType, correlationID);
@@ -3939,11 +4461,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- String menuText, Integer position, String IconValue, ImageType IconType,
- Integer correlationID)
+ String menuText, Integer position, String IconValue, ImageType IconType,
+ Integer correlationID)
throws SdlException {
addCommand(commandID, menuText, null, position, null, IconValue, IconType, correlationID);
@@ -3957,10 +4480,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- String menuText, String IconValue, ImageType IconType, Integer correlationID)
+ String menuText, String IconValue, ImageType IconType, Integer correlationID)
throws SdlException {
addCommand(commandID, menuText, null, null, null, IconValue, IconType, correlationID);
@@ -3975,10 +4499,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- String menuText, Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
+ String menuText, Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
throws SdlException {
addCommand(commandID, menuText, null, null, vrCommands, IconValue, IconType, correlationID);
@@ -3992,10 +4517,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
+ Vector<String> vrCommands, String IconValue, ImageType IconType, Integer correlationID)
throws SdlException {
addCommand(commandID, null, null, null, vrCommands, IconValue, IconType, correlationID);
@@ -4012,11 +4538,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("SameParameterValue")
public void addCommand(Integer commandID,
- String menuText, Integer parentID, Integer position,
- Vector<String> vrCommands, Integer correlationID)
+ String menuText, Integer parentID, Integer position,
+ Vector<String> vrCommands, Integer correlationID)
throws SdlException {
AddCommand msg = RPCRequestFactory.buildAddCommand(commandID, menuText, parentID, position,
@@ -4033,11 +4560,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- String menuText, Integer position,
- Vector<String> vrCommands, Integer correlationID)
+ String menuText, Integer position,
+ Vector<String> vrCommands, Integer correlationID)
throws SdlException {
addCommand(commandID, menuText, null, position, vrCommands, correlationID);
@@ -4050,11 +4578,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- String menuText, Integer position,
- Integer correlationID)
+ String menuText, Integer position,
+ Integer correlationID)
throws SdlException {
addCommand(commandID, menuText, null, position, null, correlationID);
@@ -4066,14 +4595,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- String menuText, Integer correlationID)
+ String menuText, Integer correlationID)
throws SdlException {
- Vector<String> vrCommands = null;
-
- addCommand(commandID, menuText, null, null, vrCommands, correlationID);
+ addCommand(commandID, menuText, null, null, (Vector<String>)null, correlationID);
}
/**
@@ -4083,10 +4611,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- String menuText, Vector<String> vrCommands, Integer correlationID)
+ String menuText, Vector<String> vrCommands, Integer correlationID)
throws SdlException {
addCommand(commandID, menuText, null, null, vrCommands, correlationID);
@@ -4098,10 +4627,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*@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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addCommand(Integer commandID,
- Vector<String> vrCommands, Integer correlationID)
+ Vector<String> vrCommands, Integer correlationID)
throws SdlException {
addCommand(commandID, null, null, null, vrCommands, correlationID);
@@ -4115,10 +4645,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("SameParameterValue")
public void addSubMenu(Integer menuID, String menuName,
- Integer position, Integer correlationID)
+ Integer position, Integer correlationID)
throws SdlException {
AddSubMenu msg = RPCRequestFactory.buildAddSubMenu(menuID, menuName,
@@ -4133,10 +4664,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void addSubMenu(Integer menuID, String menuName,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
addSubMenu(menuID, menuName, null, correlationID);
}
@@ -4153,11 +4685,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("SameParameterValue")
public void alert(String ttsText, String alertText1,
- String alertText2, String alertText3, Boolean playTone, Integer duration, Vector<SoftButton> softButtons,
- Integer correlationID) throws SdlException {
+ 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);
@@ -4175,7 +4708,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
public void alert(Vector<TTSChunk> ttsChunks,
String alertText1, String alertText2, String alertText3, Boolean playTone,
@@ -4193,10 +4726,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void alert(String ttsText, Boolean playTone, Vector<SoftButton> softButtons,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
alert(ttsText, null, null, null, playTone, null, softButtons, correlationID);
}
@@ -4208,10 +4742,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void alert(Vector<TTSChunk> chunks, Boolean playTone, Vector<SoftButton> softButtons,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
alert(chunks, null, null, null, playTone, null, softButtons, correlationID);
}
@@ -4226,10 +4761,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void alert(String alertText1, String alertText2, String alertText3,
- Boolean playTone, Integer duration, Vector<SoftButton> softButtons, Integer correlationID)
+ Boolean playTone, Integer duration, Vector<SoftButton> softButtons, Integer correlationID)
throws SdlException {
alert((Vector<TTSChunk>)null, alertText1, alertText2, alertText3, playTone, duration, softButtons, correlationID);
@@ -4246,11 +4782,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("SameParameterValue")
public void alert(String ttsText, String alertText1,
- String alertText2, Boolean playTone, Integer duration,
- Integer correlationID) throws SdlException {
+ String alertText2, Boolean playTone, Integer duration,
+ Integer correlationID) throws SdlException {
Alert msg = RPCRequestFactory.buildAlert(ttsText, alertText1, alertText2,
playTone, duration, correlationID);
@@ -4267,7 +4804,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
public void alert(Vector<TTSChunk> ttsChunks,
String alertText1, String alertText2, Boolean playTone,
@@ -4285,10 +4822,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void alert(String ttsText, Boolean playTone,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
alert(ttsText, null, null, playTone, null, correlationID);
}
@@ -4299,10 +4837,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void alert(Vector<TTSChunk> chunks, Boolean playTone,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
alert(chunks, null, null, playTone, null, correlationID);
}
@@ -4315,10 +4854,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void alert(String alertText1, String alertText2,
- Boolean playTone, Integer duration, Integer correlationID)
+ Boolean playTone, Integer duration, Integer correlationID)
throws SdlException {
alert((Vector<TTSChunk>)null, alertText1, alertText2, playTone, duration, correlationID);
@@ -4327,11 +4867,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Sends a CreateInteractionChoiceSet RPCRequest to SDL. Responses are captured through callback on IProxyListener.
*
- * @param choiceSet
- * @param interactionChoiceSetID
- * @param correlationID
- * @throws SdlException
+ * @param choiceSet to be sent to the module
+ * @param interactionChoiceSetID to be used in reference to the supplied choiceSet
+ * @param correlationID to be set to the RPCRequest
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void createInteractionChoiceSet(
Vector<Choice> choiceSet, Integer interactionChoiceSetID,
Integer correlationID) throws SdlException {
@@ -4347,10 +4888,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param commandID -ID of the command(s) to delete.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void deleteCommand(Integer commandID,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
DeleteCommand msg = RPCRequestFactory.buildDeleteCommand(commandID, correlationID);
@@ -4362,8 +4904,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param interactionChoiceSetID -ID of the interaction choice set to delete.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void deleteInteractionChoiceSet(
Integer interactionChoiceSetID, Integer correlationID)
throws SdlException {
@@ -4379,10 +4922,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param menuID -The menuID of the submenu to delete.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void deleteSubMenu(Integer menuID,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
DeleteSubMenu msg = RPCRequestFactory.buildDeleteSubMenu(menuID, correlationID);
@@ -4401,11 +4945,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void performInteraction(String initPrompt,
- String displayText, Integer interactionChoiceSetID, Vector<VrHelpItem> vrHelp,
- Integer correlationID) throws SdlException {
+ String displayText, Integer interactionChoiceSetID, Vector<VrHelpItem> vrHelp,
+ Integer correlationID) throws SdlException {
PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
displayText, interactionChoiceSetID, vrHelp, correlationID);
@@ -4425,13 +4970,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void performInteraction(String initPrompt,
- String displayText, Integer interactionChoiceSetID,
- String helpPrompt, String timeoutPrompt,
- InteractionMode interactionMode, Integer timeout, Vector<VrHelpItem> vrHelp,
- Integer correlationID) throws SdlException {
+ 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,
@@ -4453,13 +4999,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
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 {
+ 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,
@@ -4481,8 +5028,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void performInteraction(
Vector<TTSChunk> initChunks, String displayText,
Vector<Integer> interactionChoiceSetIDList,
@@ -4507,11 +5055,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void performInteraction(String initPrompt,
- String displayText, Integer interactionChoiceSetID,
- Integer correlationID) throws SdlException {
+ String displayText, Integer interactionChoiceSetID,
+ Integer correlationID) throws SdlException {
PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
displayText, interactionChoiceSetID, correlationID);
@@ -4530,13 +5079,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void performInteraction(String initPrompt,
- String displayText, Integer interactionChoiceSetID,
- String helpPrompt, String timeoutPrompt,
- InteractionMode interactionMode, Integer timeout,
- Integer correlationID) throws SdlException {
+ String displayText, Integer interactionChoiceSetID,
+ String helpPrompt, String timeoutPrompt,
+ InteractionMode interactionMode, Integer timeout,
+ Integer correlationID) throws SdlException {
PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(
initPrompt, displayText, interactionChoiceSetID,
@@ -4557,13 +5107,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void performInteraction(String initPrompt,
- String displayText, Vector<Integer> interactionChoiceSetIDList,
- String helpPrompt, String timeoutPrompt,
- InteractionMode interactionMode, Integer timeout,
- Integer correlationID) throws SdlException {
+ String displayText, Vector<Integer> interactionChoiceSetIDList,
+ String helpPrompt, String timeoutPrompt,
+ InteractionMode interactionMode, Integer timeout,
+ Integer correlationID) throws SdlException {
PerformInteraction msg = RPCRequestFactory.buildPerformInteraction(initPrompt,
displayText, interactionChoiceSetIDList,
@@ -4584,8 +5135,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void performInteraction(
Vector<TTSChunk> initChunks, String displayText,
Vector<Integer> interactionChoiceSetIDList,
@@ -4607,7 +5159,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
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)
+ String appID, Integer correlationID)
throws SdlException {
String carrierName = null;
if(telephonyManager != null){
@@ -4639,13 +5191,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* 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
+ * @param helpPrompt that will be used for the VR screen
+ * @param timeoutPrompt string to be displayed after timeout
+ * @param vrHelpTitle string that may be displayed on VR prompt dialog
+ * @param vrHelp a list of VR synonyms that may be displayed to user
+ * @param correlationID to be attached to the request
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void setGlobalProperties(
String helpPrompt, String timeoutPrompt, String vrHelpTitle, Vector<VrHelpItem> vrHelp, Integer correlationID)
throws SdlException {
@@ -4659,13 +5212,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* 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
+ * @param helpChunks tts chunks that should be used when prompting the user
+ * @param timeoutChunks tts chunks that will be used when a timeout occurs
+ * @param vrHelpTitle string that may be displayed on VR prompt dialog
+ * @param vrHelp a list of VR synonyms that may be displayed to user
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void setGlobalProperties(
Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks, String vrHelpTitle, Vector<VrHelpItem> vrHelp,
Integer correlationID) throws SdlException {
@@ -4680,12 +5234,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param helpPrompt
- * @param timeoutPrompt
- * @param correlationID
- * @throws SdlException
+ *
+ * @param helpPrompt that will be used for the VR screen
+ * @param timeoutPrompt string to be displayed after timeout
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void setGlobalProperties(
String helpPrompt, String timeoutPrompt, Integer correlationID)
throws SdlException {
@@ -4698,12 +5253,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Sends a SetGlobalProperties RPCRequest to SDL. Responses are captured through callback on IProxyListener.
- *
- * @param helpChunks
- * @param timeoutChunks
- * @param correlationID
- * @throws SdlException
+ *
+ * @param helpChunks tts chunks that should be used when prompting the user
+ * @param timeoutChunks tts chunks that will be used when a timeout occurs
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void setGlobalProperties(
Vector<TTSChunk> helpChunks, Vector<TTSChunk> timeoutChunks,
Integer correlationID) throws SdlException {
@@ -4714,8 +5270,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
sendRPCRequest(req);
}
+ @SuppressWarnings("unused")
public void resetGlobalProperties(Vector<GlobalProperty> properties,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
ResetGlobalProperties req = new ResetGlobalProperties();
@@ -4729,16 +5286,17 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* 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
+ * @param hours integer for hours
+ * @param minutes integer for minutes
+ * @param seconds integer for seconds
+ * @param updateMode mode in which the media clock timer should be updated
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void setMediaClockTimer(Integer hours,
- Integer minutes, Integer seconds, UpdateMode updateMode,
- Integer correlationID) throws SdlException {
+ Integer minutes, Integer seconds, UpdateMode updateMode,
+ Integer correlationID) throws SdlException {
SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(hours,
minutes, seconds, updateMode, correlationID);
@@ -4749,10 +5307,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Pauses the media clock. Responses are captured through callback on IProxyListener.
*
- * @param correlationID
- * @throws SdlException
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void pauseMediaClockTimer(Integer correlationID)
+ @SuppressWarnings("unused")
+ public void pauseMediaClockTimer(Integer correlationID)
throws SdlException {
SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
@@ -4764,10 +5323,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Resumes the media clock. Responses are captured through callback on IProxyListener.
*
- * @param correlationID
- * @throws SdlException
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void resumeMediaClockTimer(Integer correlationID)
+ @SuppressWarnings("unused")
+ public void resumeMediaClockTimer(Integer correlationID)
throws SdlException {
SetMediaClockTimer msg = RPCRequestFactory.buildSetMediaClockTimer(0,
@@ -4779,10 +5339,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Clears the media clock. Responses are captured through callback on IProxyListener.
*
- * @param correlationID
- * @throws SdlException
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void clearMediaClockTimer(Integer correlationID)
+ @SuppressWarnings("unused")
+ public void clearMediaClockTimer(Integer correlationID)
throws SdlException {
Show msg = RPCRequestFactory.buildShow(null, null, null, " ", null, null, correlationID);
@@ -4794,24 +5355,25 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* 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
+ * @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 text is placed in the status bar area (Only valid for NAVIGATION apps)
+ * @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 ID to be attached to the RPCRequest that correlates the RPCResponse -A unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("SameParameterValue")
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)
+ 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,
@@ -4833,11 +5395,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void show(String mainText1, String mainText2, String mainText3, String mainText4,
- Image graphic, Vector<SoftButton> softButtons, Vector <String> customPresets,
- TextAlignment alignment, Integer correlationID)
+ 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);
@@ -4847,18 +5410,19 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* 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
+ * @param mainText1 text displayed in a single or upper display line.
+ * @param mainText2 text displayed on the second display line.
+ * @param statusBar text is placed in the status bar area (Only valid for NAVIGATION apps)
+ * @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 unique ID that correlates each RPCRequest and RPCResponse.
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("SameParameterValue")
public void show(String mainText1, String mainText2,
- String statusBar, String mediaClock, String mediaTrack,
- TextAlignment alignment, Integer correlationID)
+ String statusBar, String mediaClock, String mediaTrack,
+ TextAlignment alignment, Integer correlationID)
throws SdlException {
Show msg = RPCRequestFactory.buildShow(mainText1, mainText2,
@@ -4875,10 +5439,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void show(String mainText1, String mainText2,
- TextAlignment alignment, Integer correlationID)
+ TextAlignment alignment, Integer correlationID)
throws SdlException {
show(mainText1, mainText2, null, null, null, alignment, correlationID);
@@ -4889,9 +5454,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void speak(String ttsText, Integer correlationID)
+ @SuppressWarnings("unused")
+ public void speak(String ttsText, Integer correlationID)
throws SdlException {
Speak msg = RPCRequestFactory.buildSpeak(TTSChunkFactory.createSimpleTTSChunks(ttsText),
@@ -4905,10 +5471,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param ttsChunks -Text/phonemes to speak in the form of ttsChunks.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void speak(Vector<TTSChunk> ttsChunks,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
Speak msg = RPCRequestFactory.buildSpeak(ttsChunks, correlationID);
@@ -4920,10 +5487,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param buttonName -Name of the button to subscribe.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void subscribeButton(ButtonName buttonName,
- Integer correlationID) throws SdlException {
+ Integer correlationID) throws SdlException {
SubscribeButton msg = RPCRequestFactory.buildSubscribeButton(buttonName,
correlationID);
@@ -4954,10 +5522,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param buttonName -Name of the button to unsubscribe.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void unsubscribeButton(ButtonName buttonName,
- Integer correlationID) throws SdlException {
+ @SuppressWarnings("unused")
+ public void unsubscribeButton(ButtonName buttonName,
+ Integer correlationID) throws SdlException {
UnsubscribeButton msg = RPCRequestFactory.buildUnsubscribeButton(
buttonName, correlationID);
@@ -4973,10 +5542,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
*/
+ @SuppressWarnings("unused")
public Choice createChoiceSetChoice(Integer choiceID, String choiceMenuName,
- Vector<String> choiceVrCommands) {
+ Vector<String> choiceVrCommands) {
Choice returnChoice = new Choice();
returnChoice.setChoiceID(choiceID);
@@ -4998,11 +5567,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void performaudiopassthru(String initialPrompt, String audioPassThruDisplayText1, String audioPassThruDisplayText2,
- SamplingRate samplingRate, Integer maxDuration, BitsPerSample bitsPerSample,
- AudioType audioType, Boolean muteAudio, Integer correlationID) throws SdlException {
+ 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);
@@ -5012,10 +5582,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Ends audio pass thru session. Responses are captured through callback on IProxyListener.
*
- * @param correlationID
- * @throws SdlException
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void endaudiopassthru(Integer correlationID) throws SdlException
+ @SuppressWarnings("unused")
+ public void endaudiopassthru(Integer correlationID) throws SdlException
{
EndAudioPassThru msg = RPCRequestFactory.BuildEndAudioPassThru(correlationID);
sendRPCRequest(msg);
@@ -5040,10 +5611,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void subscribevehicledata(boolean gps, boolean speed, boolean rpm, boolean fuelLevel, boolean fuelLevel_State,
- boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure,
+ boolean instantFuelConsumption, boolean externalTemperature, boolean prndl, boolean tirePressure,
boolean odometer, boolean beltStatus, boolean bodyInformation, boolean deviceStatus,
boolean driverBraking, Integer correlationID) throws SdlException
{
@@ -5072,13 +5644,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
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
+ 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);
@@ -5106,12 +5679,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
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
+ 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,
@@ -5128,8 +5702,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void scrollablemessage(String scrollableMessageBody, Integer timeout, Vector<SoftButton> softButtons, Integer correlationID) throws SdlException
{
ScrollableMessage msg = RPCRequestFactory.BuildScrollableMessage(scrollableMessageBody, timeout, softButtons, correlationID);
@@ -5147,8 +5722,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
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);
@@ -5158,11 +5734,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
/**
* Responses are captured through callback on IProxyListener.
*
- * @param language
- * @param hmiDisplayLanguage
- * @param correlationID
- * @throws SdlException
+ * @param language requested SDL voice engine (VR+TTS) language registration
+ * @param hmiDisplayLanguage request display language registration.
+ * @param correlationID ID to be attached to the RPCRequest that correlates the RPCResponse
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void changeregistration(Language language, Language hmiDisplayLanguage, Integer correlationID) throws SdlException
{
ChangeRegistration msg = RPCRequestFactory.BuildChangeRegistration(language, hmiDisplayLanguage, correlationID);
@@ -5178,13 +5755,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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)}
+ * @throws SdlException if an unrecoverable error is encountered
+ * @see #putFileStream(InputStream, String, Long, Long)
*/
+ @SuppressWarnings("unused")
@Deprecated
public void putFileStream(InputStream is, String sdlFileName, Integer iOffset, Integer iLength) throws SdlException
{
- PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
+ @SuppressWarnings("deprecation") PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
startRPCStream(is, msg);
}
@@ -5198,8 +5776,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* 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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void putFileStream(InputStream inputStream, String fileName, Long offset, Long length) throws SdlException {
PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length);
startRPCStream(inputStream, msg);
@@ -5215,13 +5794,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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)}
+ * @throws SdlException if an unrecoverable error is encountered
+ * @see #putFileStream(String, Long, Long)
*/
+ @SuppressWarnings("unused")
@Deprecated
public OutputStream putFileStream(String sdlFileName, Integer iOffset, Integer iLength) throws SdlException
{
- PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
+ @SuppressWarnings("deprecation") PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength);
return startRPCStream(msg);
}
@@ -5234,8 +5814,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* 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
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public OutputStream putFileStream(String fileName, Long offset, Long length) throws SdlException {
PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length);
return startRPCStream(msg);
@@ -5253,13 +5834,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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)}
+ * @throws SdlException if an unrecoverable error is encountered
+ * @see #putFileStream(InputStream, String, Long, Long, FileType, Boolean, Boolean, OnPutFileUpdateListener)
*/
+ @SuppressWarnings("unused")
@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);
+ @SuppressWarnings("deprecation") PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile);
startRPCStream(is, msg);
}
@@ -5279,8 +5861,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* sessions / ignition cycles.
* @param isSystemFile Indicates if the file is meant to be passed through
* core to elsewhere in the system.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void putFileStream(InputStream inputStream, String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, OnPutFileUpdateListener cb) throws SdlException {
PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length);
msg.setOnPutFileUpdateListener(cb);
@@ -5299,13 +5882,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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)}
+ * @throws SdlException if an unrecoverable error is encountered
+ * @see #putFileStream(String, Long, Long, FileType, Boolean, Boolean, OnPutFileUpdateListener)
*/
+ @SuppressWarnings("unused")
@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);
+ @SuppressWarnings("deprecation") PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile);
return startRPCStream(msg);
}
@@ -5324,8 +5908,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* sessions / ignition cycles.
* @param isSystemFile Indicates if the file is meant to be passed through
* core to elsewhere in the system.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public OutputStream putFileStream(String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, OnPutFileUpdateListener cb) throws SdlException {
PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length);
msg.setOnPutFileUpdateListener(cb);
@@ -5343,15 +5928,16 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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.
+ * @param iCorrelationID - 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)}
+ * @throws SdlException if an unrecoverable error is encountered
+ * @see #putFileStream(String, String, Long, FileType, Boolean, Boolean, Boolean, Integer, OnPutFileUpdateListener)
*/
+ @SuppressWarnings("unused")
@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);
+ @SuppressWarnings("deprecation") PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, 0, fileType, bPersistentFile, bSystemFile, iCorrelationID);
return startPutFileStream(sPath, msg);
}
@@ -5375,8 +5961,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @return RPCStreamController If the putFileStream was not started
* successfully null is returned, otherwise a valid object reference is
* returned .
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public RPCStreamController putFileStream(String path, String fileName, Long offset, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Boolean isPayloadProtected, Integer correlationId, OnPutFileUpdateListener cb ) throws SdlException {
PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, 0L, fileType, isPersistentFile, isSystemFile, isPayloadProtected, correlationId);
msg.setOnPutFileUpdateListener(cb);
@@ -5394,15 +5981,16 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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.
+ * @param iCorrelationID - 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)}
+ * @throws SdlException if an unrecoverable error is encountered
+ * @see #putFileStream(InputStream, String, Long, Long, FileType, Boolean, Boolean, Boolean, Integer)
*/
+ @SuppressWarnings("unused")
@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);
+ @SuppressWarnings("deprecation") PutFile msg = RPCRequestFactory.buildPutFile(sdlFileName, iOffset, iLength, fileType, bPersistentFile, bSystemFile, iCorrelationID);
return startPutFileStream(is, msg);
}
@@ -5424,8 +6012,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* core to elsewhere in the system.
* @param correlationId A unique id that correlates each RPCRequest and
* RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public RPCStreamController putFileStream(InputStream inputStream, String fileName, Long offset, Long length, FileType fileType, Boolean isPersistentFile, Boolean isSystemFile, Boolean isPayloadProtected, Integer correlationId) throws SdlException {
PutFile msg = RPCRequestFactory.buildPutFile(fileName, offset, length, fileType, isPersistentFile, isSystemFile, isPayloadProtected, correlationId);
return startPutFileStream(inputStream, msg);
@@ -5436,6 +6025,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* Used to end an existing putFileStream that was previously initiated with any putFileStream method.
*
*/
+ @SuppressWarnings("unused")
public void endPutFileStream()
{
endRPCStream();
@@ -5449,11 +6039,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* @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 fileData byte array of data of the file that is to be sent
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void putfile(String sdlFileName, FileType fileType, Boolean persistentFile, byte[] fileData, Integer correlationID) throws SdlException
+ @SuppressWarnings("unused")
+ 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);
@@ -5465,9 +6056,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param sdlFileName -File reference name.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void deletefile(String sdlFileName, Integer correlationID) throws SdlException
+ @SuppressWarnings("unused")
+ public void deletefile(String sdlFileName, Integer correlationID) throws SdlException
{
DeleteFile msg = RPCRequestFactory.buildDeleteFile(sdlFileName, correlationID);
sendRPCRequest(msg);
@@ -5478,8 +6070,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
* Responses are captured through callback on IProxyListener.
*
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void listfiles(Integer correlationID) throws SdlException
{
ListFiles msg = RPCRequestFactory.buildListFiles(correlationID);
@@ -5492,9 +6085,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param sdlFileName -File reference name.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
- public void setappicon(String sdlFileName, Integer correlationID) throws SdlException
+ @SuppressWarnings("unused")
+ public void setappicon(String sdlFileName, Integer correlationID) throws SdlException
{
SetAppIcon msg = RPCRequestFactory.buildSetAppIcon(sdlFileName, correlationID);
sendRPCRequest(msg);
@@ -5506,15 +6100,37 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @param displayLayout -Predefined or dynamically created screen layout.
* @param correlationID -A unique ID that correlates each RPCRequest and RPCResponse.
- * @throws SdlException
+ * @throws SdlException if an unrecoverable error is encountered
*/
+ @SuppressWarnings("unused")
public void setdisplaylayout(String displayLayout, Integer correlationID) throws SdlException
{
SetDisplayLayout msg = RPCRequestFactory.BuildSetDisplayLayout(displayLayout, correlationID);
sendRPCRequest(msg);
}
-
- /******************** END Public Helper Methods *************************/
+
+ @SuppressWarnings("unused")
+ public boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType) {
+ return _systemCapabilityManager != null && _systemCapabilityManager.isCapabilitySupported(systemCapabilityType);
+ }
+
+ @SuppressWarnings("unused")
+ public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener){
+ if(_systemCapabilityManager != null){
+ _systemCapabilityManager.getCapability(systemCapabilityType, scListener);
+ }
+ }
+
+ @SuppressWarnings("unused")
+ public Object getCapability(SystemCapabilityType systemCapabilityType){
+ if(_systemCapabilityManager != null ){
+ return _systemCapabilityManager.getCapability(systemCapabilityType);
+ }else{
+ return null;
+ }
+ }
+
+ /* ******************* END Public Helper Methods *************************/
/**
* Gets type of transport currently used by this SdlProxy.
@@ -5523,6 +6139,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
*
* @see TransportType
*/
+ @SuppressWarnings("unused")
public TransportType getCurrentTransportType() throws IllegalStateException {
if (sdlSession == null) {
throw new IllegalStateException("Incorrect state of SdlProxyBase: Calling for getCurrentTransportType() while connection is not initialized");
@@ -5542,50 +6159,74 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
}
- public boolean isServiceTypeProtected(SessionType sType)
- {
- if (sdlSession == null)
- return false;
-
- return sdlSession.isServiceProtected(sType);
+ @SuppressWarnings("unused")
+ public boolean isServiceTypeProtected(SessionType sType) {
+ return sdlSession != null && sdlSession.isServiceProtected(sType);
+
}
-
+
+
+ public void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener){
+ if(serviceType != null && sdlSession != null && sdlServiceListener != null){
+ sdlSession.addServiceListener(serviceType, sdlServiceListener);
+ }
+ }
+
+ public void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener){
+ if(serviceType != null && sdlSession != null && sdlServiceListener != null){
+ sdlSession.removeServiceListener(serviceType, sdlServiceListener);
+ }
+ }
+
+ @SuppressWarnings("unused")
+ public VideoStreamingParameters getAcceptedVideoParams(){
+ return sdlSession.getAcceptedVideoParams();
+ }
+
public IProxyListenerBase getProxyListener()
{
return _proxyListener;
}
+ @SuppressWarnings("unused")
public String getAppName()
{
return _applicationName;
}
+ @SuppressWarnings("unused")
public String getNgnAppName()
{
return _ngnMediaScreenAppName;
}
+ @SuppressWarnings("unused")
public String getAppID()
{
return _appID;
}
+ @SuppressWarnings("unused")
public DeviceInfo getDeviceInfo()
{
return deviceInfo;
}
+ @SuppressWarnings("unused")
public long getInstanceDT()
{
return instanceDateTime;
}
+ @SuppressWarnings("unused")
public void setConnectionDetails(String sDetails)
{
sConnectionDetails = sDetails;
}
+ @SuppressWarnings("unused")
public String getConnectionDetails()
{
return sConnectionDetails;
}
//for testing only
+ @SuppressWarnings("unused")
public void setPoliciesURL(String sText)
{
sPoliciesURL = sText;
@@ -5595,5 +6236,208 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
{
return sPoliciesURL;
}
-
+
+
+
+ /**
+ * VideoStreamingManager houses all the elements needed to create a scoped, streaming manager for video projection. It is only a private, instance
+ * dependant class at the moment until it can become public. Once the class is public and API defined, it will be moved into the SdlSession class
+ */
+ @TargetApi(19)
+ private class VideoStreamingManager implements ISdlServiceListener{
+ Context context;
+ ISdl internalInterface;
+ volatile VirtualDisplayEncoder encoder;
+ private Class<? extends SdlRemoteDisplay> remoteDisplayClass = null;
+ SdlRemoteDisplay remoteDisplay;
+ IVideoStreamListener streamListener;
+ float[] touchScalar = {1.0f,1.0f}; //x, y
+ private HapticInterfaceManager hapticManager;
+
+ public VideoStreamingManager(Context context,ISdl iSdl){
+ this.context = context;
+ this.internalInterface = iSdl;
+ encoder = new VirtualDisplayEncoder();
+ internalInterface.addServiceListener(SessionType.NAV,this);
+ //Take care of the touch events
+ internalInterface.addOnRPCNotificationListener(FunctionID.ON_TOUCH_EVENT, new OnRPCNotificationListener() {
+ @Override
+ public void onNotified(RPCNotification notification) {
+ if(notification !=null && remoteDisplay != null){
+ MotionEvent event = convertTouchEvent((OnTouchEvent)notification);
+ if(event!=null){
+ remoteDisplay.handleMotionEvent(event);
+ }
+ }
+ }
+ });
+ }
+
+ public void startVideoStreaming(Class<? extends SdlRemoteDisplay> remoteDisplayClass, VideoStreamingParameters parameters, boolean encrypted){
+ streamListener = startVideoStream(encrypted,parameters);
+ if(streamListener == null){
+ Log.e(TAG, "Error starting video service");
+ return;
+ }
+ VideoStreamingCapability capability = (VideoStreamingCapability)_systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING);
+ if(capability != null && capability.getIsHapticSpatialDataSupported()){
+ hapticManager = new HapticInterfaceManager(internalInterface);
+ }
+ this.remoteDisplayClass = remoteDisplayClass;
+ try {
+ encoder.init(context,streamListener,parameters);
+ //We are all set so we can start streaming at at this point
+ encoder.start();
+ //Encoder should be up and running
+ createRemoteDisplay(encoder.getVirtualDisplay());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Log.d(TAG, parameters.toString());
+ }
+
+ public void stopStreaming(){
+ if(remoteDisplay!=null){
+ remoteDisplay.stop();
+ }
+ if(encoder!=null){
+ encoder.shutDown();
+ }
+ }
+
+ public void dispose(){
+ stopStreaming();
+ internalInterface.removeServiceListener(SessionType.NAV,this);
+ }
+
+ private void createRemoteDisplay(final Display disp){
+ try{
+ if (disp == null){
+ return;
+ }
+
+ // Dismiss the current presentation if the display has changed.
+ if (remoteDisplay != null && remoteDisplay.getDisplay() != disp) {
+ remoteDisplay.dismissPresentation();
+ }
+
+ FutureTask<Boolean> fTask = new FutureTask<Boolean>( new SdlRemoteDisplay.Creator(context, disp, remoteDisplay, remoteDisplayClass, new SdlRemoteDisplay.Callback(){
+ @Override
+ public void onCreated(final SdlRemoteDisplay remoteDisplay) {
+ //Remote display has been created.
+ //Now is a good time to do parsing for spatial data
+ VideoStreamingManager.this.remoteDisplay = remoteDisplay;
+ if(hapticManager != null) {
+ remoteDisplay.getMainView().post(new Runnable() {
+ @Override
+ public void run() {
+ hapticManager.refreshHapticData(remoteDisplay.getMainView());
+ }
+ });
+ }
+ //Get touch scalars
+ ImageResolution resolution = null;
+ if(getWiProVersion()>=5){ //At this point we should already have the capability
+ VideoStreamingCapability capability = (VideoStreamingCapability)_systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING);
+ resolution = capability.getPreferredResolution();
+ }else {
+ DisplayCapabilities dispCap = (DisplayCapabilities) _systemCapabilityManager.getCapability(SystemCapabilityType.DISPLAY);
+ if (dispCap != null) {
+ resolution = (dispCap.getScreenParams().getImageResolution());
+ }
+ }
+ if(resolution != null){
+ DisplayMetrics displayMetrics = new DisplayMetrics();
+ disp.getMetrics(displayMetrics);
+ touchScalar[0] = ((float)displayMetrics.widthPixels) / resolution.getResolutionWidth();
+ touchScalar[1] = ((float)displayMetrics.heightPixels) / resolution.getResolutionHeight();
+ }
+
+ }
+
+ @Override
+ public void onInvalidated(final SdlRemoteDisplay remoteDisplay) {
+ //Our view has been invalidated
+ //A good time to refresh spatial data
+ if(hapticManager != null) {
+ remoteDisplay.getMainView().post(new Runnable() {
+ @Override
+ public void run() {
+ hapticManager.refreshHapticData(remoteDisplay.getMainView());
+ }
+ });
+ }
+ }
+ } ));
+ Thread showPresentation = new Thread(fTask);
+
+ showPresentation.start();
+ } catch (Exception ex) {
+ Log.e(TAG, "Unable to create Virtual Display.");
+ }
+ }
+
+ @Override
+ public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) {
+
+
+ }
+
+ @Override
+ public void onServiceEnded(SdlSession session, SessionType type) {
+ if(SessionType.NAV.equals(type)){
+ dispose();
+ }
+
+ }
+
+ @Override
+ public void onServiceError(SdlSession session, SessionType type, String reason) {
+
+ }
+
+ private MotionEvent convertTouchEvent(OnTouchEvent touchEvent){
+ List<TouchEvent> eventList = touchEvent.getEvent();
+ if (eventList == null || eventList.size() == 0) return null;
+
+ TouchType touchType = touchEvent.getType();
+ if (touchType == null){ return null;}
+
+ float x;
+ float y;
+
+ TouchEvent event = eventList.get(eventList.size() - 1);
+ List<TouchCoord> coordList = event.getTouchCoordinates();
+ if (coordList == null || coordList.size() == 0){ return null;}
+
+ TouchCoord coord = coordList.get(coordList.size() - 1);
+ if (coord == null){ return null;}
+
+ x = (coord.getX() * touchScalar[0]);
+ y = (coord.getY() * touchScalar[1]);
+
+ if (x == 0 && y == 0){ return null;}
+
+ int eventAction = MotionEvent.ACTION_DOWN;
+ long downTime = 0;
+
+ if (touchType == TouchType.BEGIN) {
+ downTime = SystemClock.uptimeMillis();
+ eventAction = MotionEvent.ACTION_DOWN;
+ }
+
+ long eventTime = SystemClock.uptimeMillis();
+ if (downTime == 0){ downTime = eventTime - 100;}
+
+ if (touchType == TouchType.MOVE) {
+ eventAction = MotionEvent.ACTION_MOVE;
+ }
+
+ if (touchType == TouchType.END) {
+ eventAction = MotionEvent.ACTION_UP;
+ }
+
+ return MotionEvent.obtain(downTime, eventTime, eventAction, x, y, 0);
+ }
+ }
} // end-class
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
new file mode 100644
index 000000000..b5dac4768
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java
@@ -0,0 +1,167 @@
+package com.smartdevicelink.proxy;
+
+import com.smartdevicelink.exception.SdlException;
+import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.interfaces.OnSystemCapabilityListener;
+import com.smartdevicelink.proxy.rpc.GetSystemCapability;
+import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse;
+import com.smartdevicelink.proxy.rpc.HMICapabilities;
+import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
+import com.smartdevicelink.proxy.rpc.enums.Result;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
+import com.smartdevicelink.util.CorrelationIdGenerator;
+
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class SystemCapabilityManager {
+ HashMap<SystemCapabilityType, Object> cachedSystemCapabilities = new HashMap<>();
+ ISdl callback;
+
+ public SystemCapabilityManager(ISdl callback){
+ this.callback = callback;
+ }
+
+ public void parseRAIResponse(RegisterAppInterfaceResponse response){
+ if(response!=null && response.getSuccess()) {
+ cachedSystemCapabilities.put(SystemCapabilityType.HMI, response.getHmiCapabilities());
+ cachedSystemCapabilities.put(SystemCapabilityType.DISPLAY, response.getDisplayCapabilities());
+ cachedSystemCapabilities.put(SystemCapabilityType.AUDIO_PASSTHROUGH, response.getAudioPassThruCapabilities());
+ cachedSystemCapabilities.put(SystemCapabilityType.BUTTON, response.getButtonCapabilities());
+ cachedSystemCapabilities.put(SystemCapabilityType.HMI_ZONE, response.getHmiZoneCapabilities());
+ cachedSystemCapabilities.put(SystemCapabilityType.PRESET_BANK, response.getPresetBankCapabilities());
+ cachedSystemCapabilities.put(SystemCapabilityType.SOFTBUTTON, response.getSoftButtonCapabilities());
+ cachedSystemCapabilities.put(SystemCapabilityType.SPEECH, response.getSpeechCapabilities());
+ cachedSystemCapabilities.put(SystemCapabilityType.VOICE_RECOGNITION, response.getVrCapabilities());
+ }
+ }
+
+ /**
+ * Sets a capability in the cached map. This should only be done when an RPC is received and contains updates to the capability
+ * that is being cached in the SystemCapabilityManager.
+ * @param systemCapabilityType
+ * @param capability
+ */
+ public void setCapability(SystemCapabilityType systemCapabilityType, Object capability){
+ cachedSystemCapabilities.put(systemCapabilityType,capability);
+ }
+
+ /**
+ * Ability to see if the connected module supports the given capability. Useful to check before
+ * attempting to query for capabilities that require asynchronous calls to initialize.
+ * @param type the SystemCapabilityType that is to be checked
+ * @return if that capability is supported with the current, connected module
+ */
+ public boolean isCapabilitySupported(SystemCapabilityType type){
+ if(cachedSystemCapabilities.containsKey(type)){
+ return true;
+ }else if(cachedSystemCapabilities.containsKey(SystemCapabilityType.HMI)){
+ HMICapabilities hmiCapabilities = ((HMICapabilities)cachedSystemCapabilities.get(SystemCapabilityType.HMI));
+ switch (type) {
+ case NAVIGATION:
+ return hmiCapabilities.isNavigationAvailable();
+ case PHONE_CALL:
+ return hmiCapabilities.isPhoneCallAvailable();
+ case VIDEO_STREAMING:
+ return hmiCapabilities.isVideoStreamingAvailable();
+ case REMOTE_CONTROL:
+ return hmiCapabilities.isRemoteControlAvailable();
+ default:
+ return false;
+ }
+ }else{
+ return false;
+ }
+ }
+ /**
+ * @param systemCapabilityType Type of capability desired
+ * @param scListener callback to execute upon retrieving capability
+ */
+ public void getCapability(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener){
+ Object capability = cachedSystemCapabilities.get(systemCapabilityType);
+ if(capability != null){
+ scListener.onCapabilityRetrieved(capability);
+ }else if(scListener == null){
+ return;
+ }
+
+ retrieveCapability(systemCapabilityType, scListener);
+ }
+
+ /**
+ * @param systemCapabilityType Type of capability desired
+ * @return Desired capability if it is cached in the manager, otherwise returns a null object
+ * and works in the background to retrieve the capability for the next call
+ */
+ public Object getCapability(final SystemCapabilityType systemCapabilityType){
+ Object capability = cachedSystemCapabilities.get(systemCapabilityType);
+ if(capability != null){
+ return capability;
+ }
+
+ retrieveCapability(systemCapabilityType, null);
+ return null;
+ }
+
+ /**
+ * @param systemCapabilityType Type of capability desired
+ * passes GetSystemCapabilityType request to `callback` to be sent by proxy
+ */
+ private void retrieveCapability(final SystemCapabilityType systemCapabilityType, final OnSystemCapabilityListener scListener){
+ final GetSystemCapability request = new GetSystemCapability();
+ request.setSystemCapabilityType(systemCapabilityType);
+ request.setOnRPCResponseListener(new OnRPCResponseListener() {
+ @Override
+ public void onResponse(int correlationId, RPCResponse response) {
+ if(response.getSuccess()){
+ Object retrievedCapability = ((GetSystemCapabilityResponse) response).getSystemCapability().getCapabilityForType(systemCapabilityType);
+ cachedSystemCapabilities.put(systemCapabilityType, retrievedCapability);
+ if(scListener!=null){scListener.onCapabilityRetrieved(retrievedCapability); }
+ }else{
+ if(scListener!=null){scListener.onError(response.getInfo());}
+ }
+ }
+
+ @Override
+ public void onError(int correlationId, Result resultCode, String info) {
+ if(scListener!=null){scListener.onError(info);}
+ }
+ });
+ request.setCorrelationID(CorrelationIdGenerator.generateId());
+
+ if(callback!=null){
+ callback.sendRPCRequest(request);
+ }
+ }
+
+ /**
+ * Converts a capability object into a list.
+ * @param object the capability that needs to be converted
+ * @param classType The class type of that should be contained in the list
+ * @return a List of capabilities if object is instance of List, otherwise it will return null.
+ */
+ @SuppressWarnings({"unchecked"})
+ public static <T> List<T> convertToList(Object object, Class<T> classType){
+ if(classType!=null && object!=null && object instanceof List ){
+ List list = (List)object;
+ if(!list.isEmpty()){
+ if(classType.isInstance(list.get(0))){
+ return (List<T>)object;
+ }else{
+ //The list is not of the correct list type
+ return null;
+ }
+ }else {
+ //We return a new list of type T instead of null because while we don't know if
+ //the original list was of type T we want to ensure that we don't throw a cast class exception
+ //but still
+ return new ArrayList<T>();
+ }
+ }else{
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IAudioStreamListener.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IAudioStreamListener.java
new file mode 100644
index 000000000..8d21b7615
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IAudioStreamListener.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.proxy.interfaces;
+
+import java.nio.ByteBuffer;
+
+/**
+ * A listener that receives audio streaming data from app.
+ */
+public interface IAudioStreamListener {
+ /**
+ * Sends a chunk of audio data to SDL Core.
+ * <p>
+ * Note: this method must not be called after SdlProxyBase.endAudioStream() is called.
+ *
+ * @param data Byte array containing audio data
+ * @param offset Starting offset in 'data'
+ * @param length Length of the data
+ * @param presentationTimeUs (Reserved for future use) Presentation timestamp (PTS) of the
+ * last audio sample data included in this chunk, in microseconds.
+ * It must be greater than the previous timestamp.
+ * Specify -1 if unknown.
+ * @throws ArrayIndexOutOfBoundsException When offset does not satisfy
+ * {@code 0 <= offset && offset <= data.length}
+ * or length does not satisfy
+ * {@code 0 < length && offset + length <= data.length}
+ */
+ void sendAudio(byte[] data, int offset, int length, long presentationTimeUs)
+ throws ArrayIndexOutOfBoundsException;
+
+ /**
+ * Sends a chunk of audio data to SDL Core.
+ * <p>
+ * Note: this method must not be called after SdlProxyBase.endAudioStream() is called.
+ *
+ * @param data Data chunk to send. Its position will be updated upon return.
+ * @param presentationTimeUs (Reserved for future use) Presentation timestamp (PTS) of the
+ * last audio sample data included in this chunk, in microseconds.
+ * It must be greater than the previous timestamp.
+ * Specify -1 if unknown.
+ */
+ void sendAudio(ByteBuffer data, long presentationTimeUs);
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
index 8b437e05e..618819f20 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IProxyListenerBase.java
@@ -6,6 +6,7 @@ import com.smartdevicelink.proxy.rpc.AddCommandResponse;
import com.smartdevicelink.proxy.rpc.AddSubMenuResponse;
import com.smartdevicelink.proxy.rpc.AlertManeuverResponse;
import com.smartdevicelink.proxy.rpc.AlertResponse;
+import com.smartdevicelink.proxy.rpc.ButtonPressResponse;
import com.smartdevicelink.proxy.rpc.ChangeRegistrationResponse;
import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSetResponse;
import com.smartdevicelink.proxy.rpc.DeleteCommandResponse;
@@ -17,6 +18,8 @@ import com.smartdevicelink.proxy.rpc.DialNumberResponse;
import com.smartdevicelink.proxy.rpc.EndAudioPassThruResponse;
import com.smartdevicelink.proxy.rpc.GenericResponse;
import com.smartdevicelink.proxy.rpc.GetDTCsResponse;
+import com.smartdevicelink.proxy.rpc.GetInteriorVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.GetSystemCapabilityResponse;
import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse;
import com.smartdevicelink.proxy.rpc.GetWayPointsResponse;
import com.smartdevicelink.proxy.rpc.ListFilesResponse;
@@ -27,13 +30,14 @@ import com.smartdevicelink.proxy.rpc.OnCommand;
import com.smartdevicelink.proxy.rpc.OnDriverDistraction;
import com.smartdevicelink.proxy.rpc.OnHMIStatus;
import com.smartdevicelink.proxy.rpc.OnHashChange;
+import com.smartdevicelink.proxy.rpc.OnInteriorVehicleData;
import com.smartdevicelink.proxy.rpc.OnKeyboardInput;
import com.smartdevicelink.proxy.rpc.OnLanguageChange;
import com.smartdevicelink.proxy.rpc.OnLockScreenStatus;
import com.smartdevicelink.proxy.rpc.OnPermissionsChange;
+import com.smartdevicelink.proxy.rpc.OnStreamRPC;
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.OnWayPointChange;
@@ -43,10 +47,12 @@ 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.SendHapticDataResponse;
import com.smartdevicelink.proxy.rpc.SendLocationResponse;
import com.smartdevicelink.proxy.rpc.SetAppIconResponse;
import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse;
+import com.smartdevicelink.proxy.rpc.SetInteriorVehicleDataResponse;
import com.smartdevicelink.proxy.rpc.SetMediaClockTimerResponse;
import com.smartdevicelink.proxy.rpc.ShowConstantTbtResponse;
import com.smartdevicelink.proxy.rpc.ShowResponse;
@@ -335,4 +341,16 @@ public interface IProxyListenerBase {
public void onUnsubscribeWayPointsResponse(UnsubscribeWayPointsResponse response);
public void onOnWayPointChange(OnWayPointChange notification);
+
+ public void onGetSystemCapabilityResponse(GetSystemCapabilityResponse response);
+
+ public void onGetInteriorVehicleDataResponse(GetInteriorVehicleDataResponse response);
+
+ public void onButtonPressResponse(ButtonPressResponse response);
+
+ public void onSetInteriorVehicleDataResponse(SetInteriorVehicleDataResponse response);
+
+ public void onOnInteriorVehicleData(OnInteriorVehicleData notification);
+
+ public void onSendHapticDataResponse(SendHapticDataResponse response);
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java
new file mode 100644
index 000000000..9177a146b
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java
@@ -0,0 +1,116 @@
+package com.smartdevicelink.proxy.interfaces;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
+import com.smartdevicelink.streaming.video.VideoStreamingParameters;
+
+/*
+ * Copyright (c) 2017 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+@SuppressWarnings("unused")
+public interface ISdl {
+
+ /**
+ * Starts the connection with the module
+ */
+ void start();
+
+ /**
+ * Ends connection with the module
+ */
+ void stop();
+
+ /**
+ * Method to check if the session is connected
+ * @return if there is a connected session
+ */
+ boolean isConnected();
+
+ /**
+ * Add a service listener for a specific service type
+ * @param serviceType service type that the listener will be attached to
+ * @param sdlServiceListener listener for events that happen to the service
+ */
+ void addServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener);
+
+ /**
+ * Remote a service listener for a specific service type
+ * @param serviceType service type that the listener was attached to
+ * @param sdlServiceListener service listener that was previously added for the service type
+ */
+ void removeServiceListener(SessionType serviceType, ISdlServiceListener sdlServiceListener);
+
+ /**
+ * Starts the video streaming service
+ * @param parameters desired video streaming params for this sevice to be started with
+ * @param encrypted flag to start this service with encryption or not
+ */
+ void startVideoService(VideoStreamingParameters parameters, boolean encrypted);
+
+ /**
+ * Stops the video service if open
+ */
+ void stopVideoService();
+
+ /**
+ * Starts the Audio streaming service
+ * @param encrypted flag to start this service with encryption or not
+ */
+ void startAudioService(boolean encrypted);
+
+ /**
+ * Stops the audio service if open
+ */
+ void stopAudioService();
+
+ /**
+ * Pass an RPC message through the proxy to be sent to the connected module
+ * @param message RPCRequest that should be sent to the module
+ */
+ void sendRPCRequest(RPCRequest message);
+
+ /**
+ * Add an OnRPCNotificationListener for specified notification
+ * @param notificationId FunctionID of the notification that is to be listened for
+ * @param listener listener that should be added for the notification ID
+ */
+ void addOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener);
+
+ /**
+ * Removes an OnRPCNotificationListener for specified notification
+ * @param notificationId FunctionID of the notification that was to be listened for
+ * @param listener listener that was previously added for the notification ID
+ */
+ boolean removeOnRPCNotificationListener(FunctionID notificationId, OnRPCNotificationListener listener);
+
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdlServiceListener.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdlServiceListener.java
new file mode 100644
index 000000000..db5179a73
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/ISdlServiceListener.java
@@ -0,0 +1,11 @@
+package com.smartdevicelink.proxy.interfaces;
+
+
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.protocol.enums.SessionType;
+
+public interface ISdlServiceListener {
+ public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted);
+ public void onServiceEnded(SdlSession session, SessionType type);
+ public void onServiceError(SdlSession session, SessionType type, String reason);
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IVideoStreamListener.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IVideoStreamListener.java
new file mode 100644
index 000000000..f645b0d55
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/IVideoStreamListener.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.proxy.interfaces;
+
+import java.nio.ByteBuffer;
+
+/**
+ * A listener that receives video streaming data from app.
+ */
+public interface IVideoStreamListener {
+
+ /**
+ * Sends a chunk of data which represents a frame to SDL Core.
+ * <p>
+ * The format of the chunk should align with MediaCodec's "Compressed Buffer" format, i.e. it
+ * should contain a single video frame, and it should start and end on frame boundaries.
+ * Please refer to https://developer.android.com/reference/android/media/MediaCodec.html
+ * Also, for H.264 codec case the stream must be in byte-stream format (also known as Annex-B
+ * format). This isn't explained in the document above, but MediaCodec does output in this
+ * format.
+ * <p>
+ * In short, you can just provide MediaCodec's data outputs to this method without tweaking
+ * any data.
+ * <p>
+ * Note: this method must not be called after SdlProxyBase.endVideoStream() is called.
+ *
+ * @param data Byte array containing a video frame
+ * @param offset Starting offset in 'data'
+ * @param length Length of the data
+ * @param presentationTimeUs Presentation timestamp (PTS) of this frame, in microseconds.
+ * It must be greater than the previous timestamp.
+ * Specify -1 if unknown.
+ * @throws ArrayIndexOutOfBoundsException When offset does not satisfy
+ * {@code 0 <= offset && offset <= data.length}
+ * or length does not satisfy
+ * {@code 0 < length && offset + length <= data.length}
+ */
+ void sendFrame(byte[] data, int offset, int length, long presentationTimeUs)
+ throws ArrayIndexOutOfBoundsException;
+
+ /**
+ * Sends chunks of data which represent a frame to SDL Core.
+ * <p>
+ * The format of the chunk should align with MediaCodec's "Compressed Buffer" format, i.e. it
+ * should contain a single video frame, and it should start and end on frame boundaries.
+ * Please refer to https://developer.android.com/reference/android/media/MediaCodec.html
+ * Also, for H.264 codec case the stream must be in byte-stream format (also known as Annex-B
+ * format). This isn't explained in the document above, but MediaCodec does output in this
+ * format.
+ * <p>
+ * In short, you can just provide MediaCodec's data outputs to this method without tweaking
+ * any data.
+ * <p>
+ * Note: this method must not be called after SdlProxyBase.endVideoStream() is called.
+ *
+ * @param data Data chunk to send. Its position will be updated upon return.
+ * @param presentationTimeUs Presentation timestamp (PTS) of this frame, in microseconds.
+ * It must be greater than the previous timestamp.
+ * Specify -1 if unknown.
+ */
+ void sendFrame(ByteBuffer data, long presentationTimeUs);
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/OnSystemCapabilityListener.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/OnSystemCapabilityListener.java
new file mode 100644
index 000000000..d6fb11b4d
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/interfaces/OnSystemCapabilityListener.java
@@ -0,0 +1,6 @@
+package com.smartdevicelink.proxy.interfaces;
+
+public interface OnSystemCapabilityListener {
+ void onCapabilityRetrieved(Object capability);
+ void onError(String info);
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java
index 57b58ea5b..c8936edb8 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddCommand.java
@@ -1,11 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-import java.util.List;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.util.DebugTool;
+
+import java.util.Hashtable;
+import java.util.List;
/**
*
@@ -119,7 +118,7 @@ public class AddCommand extends RPCRequest {
* @return Integer -an integer representation a Unique Command ID
*/
public Integer getCmdID() {
- return (Integer) parameters.get(KEY_CMD_ID);
+ return getInteger(KEY_CMD_ID);
}
/**
* <p>Sets an Unique Command ID that identifies the command. Is returned in an
@@ -133,11 +132,7 @@ public class AddCommand extends RPCRequest {
* <b>Notes:</b> Min Value: 0; Max Value: 2000000000</p>
*/
public void setCmdID(Integer cmdID) {
- if (cmdID != null) {
- parameters.put(KEY_CMD_ID, cmdID);
- } else {
- parameters.remove(KEY_CMD_ID);
- }
+ setParameters(KEY_CMD_ID, cmdID);
}
/**
* <p>
@@ -150,18 +145,7 @@ public class AddCommand extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public MenuParams getMenuParams() {
- Object obj = parameters.get(KEY_MENU_PARAMS);
- if (obj instanceof MenuParams) {
- return (MenuParams) obj;
- }
- else if (obj instanceof Hashtable) {
- try {
- return new MenuParams((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MENU_PARAMS, e);
- }
- }
- return null;
+ return (MenuParams) getObject(MenuParams.class, KEY_MENU_PARAMS);
}
/**
* <p>
@@ -175,11 +159,7 @@ public class AddCommand extends RPCRequest {
* a menuParams object
*/
public void setMenuParams(MenuParams menuParams) {
- if (menuParams != null) {
- parameters.put(KEY_MENU_PARAMS, menuParams);
- } else {
- parameters.remove(KEY_MENU_PARAMS);
- }
+ setParameters(KEY_MENU_PARAMS, menuParams);
}
/**
* <p>
@@ -190,16 +170,7 @@ public class AddCommand extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<String> getVrCommands() {
- 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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_VR_COMMANDS);
}
/**
* <p>
@@ -219,11 +190,7 @@ public class AddCommand extends RPCRequest {
* not zero-length, not whitespace only) element</p>
*/
public void setVrCommands( List<String> vrCommands ) {
- if (vrCommands != null) {
- parameters.put(KEY_VR_COMMANDS, vrCommands );
- } else {
- parameters.remove(KEY_VR_COMMANDS);
- }
+ setParameters(KEY_VR_COMMANDS, vrCommands);
}
/**
@@ -234,17 +201,7 @@ public class AddCommand extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public Image getCmdIcon() {
- Object obj = parameters.get(KEY_CMD_ICON);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CMD_ICON, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_CMD_ICON);
}
/**
@@ -259,10 +216,6 @@ public class AddCommand extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setCmdIcon(Image cmdIcon) {
- if (cmdIcon != null) {
- parameters.put(KEY_CMD_ICON, cmdIcon);
- } else {
- parameters.remove(KEY_CMD_ICON);
- }
+ setParameters(KEY_CMD_ICON, cmdIcon);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
index 2edc70c50..8c55bbd9a 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AddSubMenu.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* <p>Add a SubMenu to the Command Menu</p>
*
@@ -90,7 +90,7 @@ public class AddSubMenu extends RPCRequest {
* menu
*/
public Integer getMenuID() {
- return (Integer) parameters.get( KEY_MENU_ID );
+ return getInteger( KEY_MENU_ID );
}
/**
* <p>Sets a Menu ID that identifies a sub menu.</p><p> This value is used in
@@ -104,11 +104,7 @@ public class AddSubMenu extends RPCRequest {
* <p><b>Notes:</b> Min Value: 0; Max Value: 2000000000</p>
*/
public void setMenuID( Integer menuID ) {
- if (menuID != null) {
- parameters.put(KEY_MENU_ID, menuID );
- } else {
- parameters.remove(KEY_MENU_ID);
- }
+ setParameters(KEY_MENU_ID, menuID);
}
/**
* <p>Returns an <i>Integer</i> object representing the position of menu</p>
@@ -117,7 +113,7 @@ public class AddSubMenu extends RPCRequest {
* @return Integer -the value representing the relative position of menus
*/
public Integer getPosition() {
- return (Integer) parameters.get( KEY_POSITION );
+ return getInteger( KEY_POSITION );
}
/**
* Sets a position of menu
@@ -140,11 +136,7 @@ public class AddSubMenu extends RPCRequest {
* </ul>
*/
public void setPosition( Integer position ) {
- if (position != null) {
- parameters.put(KEY_POSITION, position );
- } else {
- parameters.remove(KEY_POSITION);
- }
+ setParameters(KEY_POSITION, position);
}
/**
* Returns String which is displayed representing this submenu item
@@ -152,7 +144,7 @@ public class AddSubMenu extends RPCRequest {
* @return String -a Submenu item's name
*/
public String getMenuName() {
- return (String) parameters.get( KEY_MENU_NAME );
+ return getString( KEY_MENU_NAME );
}
/**
* Sets a menuName which is displayed representing this submenu item
@@ -161,10 +153,6 @@ public class AddSubMenu extends RPCRequest {
* String which will be displayed representing this submenu item
*/
public void setMenuName( String menuName ) {
- if (menuName != null) {
- parameters.put(KEY_MENU_NAME, menuName );
- } else {
- parameters.remove(KEY_MENU_NAME);
- }
+ setParameters(KEY_MENU_NAME, menuName);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java
index b80a9c2c4..1c6fb52bb 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AirbagStatus.java
@@ -4,6 +4,10 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
+
+import static com.smartdevicelink.proxy.constants.Names.driverCurtainAirbagDeployed;
+import static com.smartdevicelink.proxy.constants.Names.driverSideAirbagDeployed;
+
/**
* <p>The status of the air bags.</p>
*
@@ -104,131 +108,51 @@ public class AirbagStatus extends RPCStruct {
}
public void setDriverAirbagDeployed(VehicleDataEventStatus driverAirbagDeployed) {
- if (driverAirbagDeployed != null) {
- store.put(KEY_DRIVER_AIRBAG_DEPLOYED, driverAirbagDeployed);
- } else {
- store.remove(KEY_DRIVER_AIRBAG_DEPLOYED);
- }
+ setValue(KEY_DRIVER_AIRBAG_DEPLOYED, driverAirbagDeployed);
}
public VehicleDataEventStatus getDriverAirbagDeployed() {
- Object obj = store.get(KEY_DRIVER_AIRBAG_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_AIRBAG_DEPLOYED);
}
public void setDriverSideAirbagDeployed(VehicleDataEventStatus driverSideAirbagDeployed) {
- if (driverSideAirbagDeployed != null) {
- store.put(KEY_DRIVER_SIDE_AIRBAG_DEPLOYED, driverSideAirbagDeployed);
- } else {
- store.remove(KEY_DRIVER_SIDE_AIRBAG_DEPLOYED);
- }
+ setValue(KEY_DRIVER_SIDE_AIRBAG_DEPLOYED, driverSideAirbagDeployed);
}
public VehicleDataEventStatus getDriverSideAirbagDeployed() {
- Object obj = store.get(KEY_DRIVER_SIDE_AIRBAG_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_SIDE_AIRBAG_DEPLOYED);
}
public void setDriverCurtainAirbagDeployed(VehicleDataEventStatus driverCurtainAirbagDeployed) {
- if (driverCurtainAirbagDeployed != null) {
- store.put(KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED, driverCurtainAirbagDeployed);
- } else {
- store.remove(KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED);
- }
+ setValue(KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED, driverCurtainAirbagDeployed);
}
public VehicleDataEventStatus getDriverCurtainAirbagDeployed() {
- Object obj = store.get(KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED);
}
public void setPassengerAirbagDeployed(VehicleDataEventStatus passengerAirbagDeployed) {
- if (passengerAirbagDeployed != null) {
- store.put(KEY_PASSENGER_AIRBAG_DEPLOYED, passengerAirbagDeployed);
- } else {
- store.remove(KEY_PASSENGER_AIRBAG_DEPLOYED);
- }
+ setValue(KEY_PASSENGER_AIRBAG_DEPLOYED, passengerAirbagDeployed);
}
public VehicleDataEventStatus getPassengerAirbagDeployed() {
- Object obj = store.get(KEY_PASSENGER_AIRBAG_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_AIRBAG_DEPLOYED);
}
public void setPassengerCurtainAirbagDeployed(VehicleDataEventStatus passengerCurtainAirbagDeployed) {
- if (passengerCurtainAirbagDeployed != null) {
- store.put(KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED, passengerCurtainAirbagDeployed);
- } else {
- store.remove(KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED);
- }
+ setValue(KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED, passengerCurtainAirbagDeployed);
}
public VehicleDataEventStatus getPassengerCurtainAirbagDeployed() {
- Object obj = store.get(KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_CURTAIN_AIRBAG_DEPLOYED);
}
public void setDriverKneeAirbagDeployed(VehicleDataEventStatus driverKneeAirbagDeployed) {
- if (driverKneeAirbagDeployed != null) {
- store.put(KEY_DRIVER_KNEE_AIRBAG_DEPLOYED, driverKneeAirbagDeployed);
- } else {
- store.remove(KEY_DRIVER_KNEE_AIRBAG_DEPLOYED);
- }
+ setValue(KEY_DRIVER_KNEE_AIRBAG_DEPLOYED, driverKneeAirbagDeployed);
}
public VehicleDataEventStatus getDriverKneeAirbagDeployed() {
- Object obj = store.get(KEY_DRIVER_KNEE_AIRBAG_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_KNEE_AIRBAG_DEPLOYED);
}
public void setPassengerSideAirbagDeployed(VehicleDataEventStatus passengerSideAirbagDeployed) {
- if (passengerSideAirbagDeployed != null) {
- store.put(KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED, passengerSideAirbagDeployed);
- } else {
- store.remove(KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED);
- }
+ setValue(KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED, passengerSideAirbagDeployed);
}
public VehicleDataEventStatus getPassengerSideAirbagDeployed() {
- Object obj = store.get(KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_SIDE_AIRBAG_DEPLOYED);
}
public void setPassengerKneeAirbagDeployed(VehicleDataEventStatus passengerKneeAirbagDeployed) {
- if (passengerKneeAirbagDeployed != null) {
- store.put(KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED, passengerKneeAirbagDeployed);
- } else {
- store.remove(KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED);
- }
+ setValue(KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED, passengerKneeAirbagDeployed);
}
public VehicleDataEventStatus getPassengerKneeAirbagDeployed() {
- Object obj = store.get(KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_KNEE_AIRBAG_DEPLOYED);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java
index 811d65a42..d0c4e0400 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Alert.java
@@ -1,12 +1,11 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* Provides information to the user using either TTS, the Display or both and
* can include a system-generated alert tone
@@ -149,7 +148,7 @@ public class Alert extends RPCRequest {
* in the first field during the Alert
*/
public String getAlertText1() {
- return (String) parameters.get(KEY_ALERT_TEXT_1);
+ return getString(KEY_ALERT_TEXT_1);
}
/**
* Sets the String to be displayed in the first field of the display during
@@ -167,11 +166,7 @@ public class Alert extends RPCRequest {
* </ul>
*/
public void setAlertText1(String alertText1) {
- if (alertText1 != null) {
- parameters.put(KEY_ALERT_TEXT_1, alertText1);
- } else {
- parameters.remove(KEY_ALERT_TEXT_1);
- }
+ setParameters(KEY_ALERT_TEXT_1, alertText1);
}
/**
* Gets the text which is displayed in the second field of the display
@@ -181,7 +176,7 @@ public class Alert extends RPCRequest {
* in the second field during the Alert
*/
public String getAlertText2() {
- return (String) parameters.get(KEY_ALERT_TEXT_2);
+ return getString(KEY_ALERT_TEXT_2);
}
/**
* Sets the String to be displayed in the second field of the display during
@@ -200,11 +195,7 @@ public class Alert extends RPCRequest {
* </ul>
*/
public void setAlertText2(String alertText2) {
- if (alertText2 != null) {
- parameters.put(KEY_ALERT_TEXT_2, alertText2);
- } else {
- parameters.remove(KEY_ALERT_TEXT_2);
- }
+ setParameters(KEY_ALERT_TEXT_2, alertText2);
}
/**
@@ -217,7 +208,7 @@ public class Alert extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public String getAlertText3() {
- return (String) parameters.get(KEY_ALERT_TEXT_3);
+ return getString(KEY_ALERT_TEXT_3);
}
/**
@@ -239,11 +230,7 @@ public class Alert extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setAlertText3(String alertText3) {
- if (alertText3 != null) {
- parameters.put(KEY_ALERT_TEXT_3, alertText3);
- } else {
- parameters.remove(KEY_ALERT_TEXT_3);
- }
+ setParameters(KEY_ALERT_TEXT_3, alertText3);
}
/**
* Gets TTSChunk[], the Array of type TTSChunk which, taken together,
@@ -254,22 +241,7 @@ public class Alert extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getTtsChunks() {
- if (parameters.get(KEY_TTS_CHUNKS) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_TTS_CHUNKS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TTSChunk) {
- return (List<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;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_TTS_CHUNKS);
}
/**
* Sets array of type TTSChunk which, taken together, specify what is to be
@@ -280,11 +252,7 @@ public class Alert extends RPCRequest {
* <p> <b>Notes: </b>Array must have a least one element</p>
*/
public void setTtsChunks(List<TTSChunk> ttsChunks) {
- if (ttsChunks != null) {
- parameters.put(KEY_TTS_CHUNKS, ttsChunks);
- } else {
- parameters.remove(KEY_TTS_CHUNKS);
- }
+ setParameters(KEY_TTS_CHUNKS, ttsChunks);
}
/**
* Gets the duration of the displayed portion of the alert, in milliseconds
@@ -293,7 +261,7 @@ public class Alert extends RPCRequest {
* displayed portion of the alert, in milliseconds
*/
public Integer getDuration() {
- return (Integer) parameters.get(KEY_DURATION);
+ return getInteger(KEY_DURATION);
}
/**
* <p>Sets the duration of the displayed portion of the alert, in milliseconds.
@@ -313,11 +281,7 @@ public class Alert extends RPCRequest {
* </ul>
*/
public void setDuration(Integer duration) {
- if (duration != null) {
- parameters.put(KEY_DURATION, duration);
- } else {
- parameters.remove(KEY_DURATION);
- }
+ setParameters(KEY_DURATION, duration);
}
/**
* Gets a Boolean value representing the alert tone
@@ -326,7 +290,7 @@ public class Alert extends RPCRequest {
* TTS (if any) is spoken
*/
public Boolean getPlayTone() {
- return (Boolean) parameters.get(KEY_PLAY_TONE);
+ return getBoolean(KEY_PLAY_TONE);
}
/**
* Sets whether the alert tone should be played before the TTS (if any) is
@@ -339,11 +303,7 @@ public class Alert extends RPCRequest {
* <p> <b>Notes: </b>If omitted, default is true</p>
*/
public void setPlayTone(Boolean playTone) {
- if (playTone != null) {
- parameters.put(KEY_PLAY_TONE, playTone);
- } else {
- parameters.remove(KEY_PLAY_TONE);
- }
+ setParameters(KEY_PLAY_TONE, playTone);
}
/**
@@ -355,22 +315,7 @@ public class Alert extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<SoftButton> getSoftButtons() {
- if (parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTONS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof SoftButton) {
- return (List<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;
- }
- }
- }
- return null;
+ return (List<SoftButton>) getObject(SoftButton.class, KEY_SOFT_BUTTONS);
}
/**
@@ -390,24 +335,12 @@ public class Alert extends RPCRequest {
*/
public void setSoftButtons(List<SoftButton> softButtons) {
- if (softButtons != null) {
- parameters.put(KEY_SOFT_BUTTONS, softButtons);
- } else {
- parameters.remove(KEY_SOFT_BUTTONS);
- }
+ setParameters(KEY_SOFT_BUTTONS, softButtons);
}
public Boolean getProgressIndicator() {
- final Object obj = parameters.get(KEY_PROGRESS_INDICATOR);
- if (obj instanceof Boolean) {
- return (Boolean) obj;
- }
- return null;
+ return getBoolean(KEY_PROGRESS_INDICATOR);
}
public void setProgressIndicator(Boolean progressIndicator) {
- if (progressIndicator != null) {
- parameters.put(KEY_PROGRESS_INDICATOR, progressIndicator);
- } else {
- parameters.remove(KEY_PROGRESS_INDICATOR);
- }
- }
+ setParameters(KEY_PROGRESS_INDICATOR, progressIndicator);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java
index fba595150..4fd218fa8 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertManeuver.java
@@ -1,12 +1,11 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* <p>This will bring up an alert with information related to the next navigation maneuver including potential voice
* navigation instructions. Shown information will be taken from the ShowConstantTBT function
@@ -51,23 +50,7 @@ public class AlertManeuver extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public List<SoftButton> getSoftButtons(){
- if(parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>){
- List<?> list = (List<?>) parameters.get(KEY_SOFT_BUTTONS);
- if(list != null && list.size() > 0){
- Object obj = list.get(0);
- if(obj instanceof SoftButton){
- return (List<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;
- }
- }
- }
- return null;
+ return (List<SoftButton>) getObject(SoftButton.class, KEY_SOFT_BUTTONS);
}
/**
@@ -86,12 +69,7 @@ public class AlertManeuver extends RPCRequest{
*/
public void setSoftButtons(List<SoftButton> softButtons){
- if(softButtons != null){
- parameters.put(KEY_SOFT_BUTTONS, softButtons);
- }
- else{
- parameters.remove(KEY_SOFT_BUTTONS);
- }
+ setParameters(KEY_SOFT_BUTTONS, softButtons);
}
/**
@@ -101,23 +79,7 @@ public class AlertManeuver extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getTtsChunks(){
- if(parameters.get(KEY_TTS_CHUNKS) instanceof List<?>){
- List<?> list = (List<?>) parameters.get(KEY_TTS_CHUNKS);
- if(list != null && list.size() > 0){
- Object obj = list.get(0);
- if(obj instanceof TTSChunk){
- return (List<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;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_TTS_CHUNKS);
}
/**
@@ -128,12 +90,7 @@ public class AlertManeuver extends RPCRequest{
* <b>Notes: </b></p>Array must have a least one element
*/
public void setTtsChunks(List<TTSChunk> ttsChunks){
- if(ttsChunks != null){
- parameters.put(KEY_TTS_CHUNKS, ttsChunks);
- }
- else{
- parameters.remove(KEY_TTS_CHUNKS);
- }
+ setParameters(KEY_TTS_CHUNKS, ttsChunks);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java
index cea706d4e..0ecf2579a 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AlertResponse.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
+import java.util.Hashtable;
+
/**
* Alert Response is sent, when Alert has been called
*
@@ -32,13 +32,9 @@ public class AlertResponse extends RPCResponse {
super(hash);
}
public Integer getTryAgainTime() {
- return (Integer) parameters.get(KEY_TRY_AGAIN_TIME);
+ return getInteger(KEY_TRY_AGAIN_TIME);
}
public void setTryAgainTime(Integer tryAgainTime) {
- if (tryAgainTime != null) {
- parameters.put(KEY_TRY_AGAIN_TIME, tryAgainTime);
- } else {
- parameters.remove(KEY_TRY_AGAIN_TIME);
- }
+ setParameters(KEY_TRY_AGAIN_TIME, tryAgainTime);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java
index 48cfd129b..61de1d1f5 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/AudioPassThruCapabilities.java
@@ -1,11 +1,14 @@
package com.smartdevicelink.proxy.rpc;
-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.proxy.rpc.enums.VehicleDataEventStatus;
+
+import java.util.Hashtable;
+
+import static com.smartdevicelink.proxy.rpc.AirbagStatus.KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED;
/**
*<p> Describes different audio type configurations for PerformAudioPassThru, e.g. {8kHz,8-bit,PCM}
@@ -68,11 +71,7 @@ public class AudioPassThruCapabilities extends RPCStruct {
* @param samplingRate the sampling rate for AudioPassThru
*/
public void setSamplingRate(SamplingRate samplingRate) {
- if (samplingRate != null) {
- store.put(KEY_SAMPLING_RATE, samplingRate);
- } else {
- store.remove(KEY_SAMPLING_RATE);
- }
+ setValue(KEY_SAMPLING_RATE, samplingRate);
}
/**
@@ -80,13 +79,7 @@ public class AudioPassThruCapabilities extends RPCStruct {
* @return the sampling rate for AudioPassThru
*/
public SamplingRate getSamplingRate() {
- Object obj = store.get(KEY_SAMPLING_RATE);
- if (obj instanceof SamplingRate) {
- return (SamplingRate) obj;
- } else if (obj instanceof String) {
- return SamplingRate.valueForString((String) obj);
- }
- return null;
+ return (SamplingRate) getObject(SamplingRate.class, KEY_SAMPLING_RATE);
}
/**
@@ -94,11 +87,7 @@ public class AudioPassThruCapabilities extends RPCStruct {
* @param bitsPerSample the sample depth in bit for AudioPassThru
*/
public void setBitsPerSample(BitsPerSample bitsPerSample) {
- if (bitsPerSample != null) {
- store.put(KEY_BITS_PER_SAMPLE, bitsPerSample);
- } else {
- store.remove(KEY_BITS_PER_SAMPLE);
- }
+ setValue(KEY_BITS_PER_SAMPLE, bitsPerSample);
}
/**
@@ -106,13 +95,7 @@ public class AudioPassThruCapabilities extends RPCStruct {
* @return the sample depth in bit for AudioPassThru
*/
public BitsPerSample getBitsPerSample() {
- Object obj = store.get(KEY_BITS_PER_SAMPLE);
- if (obj instanceof BitsPerSample) {
- return (BitsPerSample) obj;
- } else if (obj instanceof String) {
- return BitsPerSample.valueForString((String) obj);
- }
- return null;
+ return (BitsPerSample) getObject(BitsPerSample.class, KEY_BITS_PER_SAMPLE);
}
/**
@@ -120,11 +103,7 @@ public class AudioPassThruCapabilities extends RPCStruct {
* @param audioType the audiotype for AudioPassThru
*/
public void setAudioType(AudioType audioType) {
- if (audioType != null) {
- store.put(KEY_AUDIO_TYPE, audioType);
- } else {
- store.remove(KEY_AUDIO_TYPE);
- }
+ setValue(KEY_AUDIO_TYPE, audioType);
}
/**
@@ -132,12 +111,6 @@ public class AudioPassThruCapabilities extends RPCStruct {
* @return the audiotype for AudioPassThru
*/
public AudioType getAudioType() {
- Object obj = store.get(KEY_AUDIO_TYPE);
- if (obj instanceof AudioType) {
- return (AudioType) obj;
- } else if (obj instanceof String) {
- return AudioType.valueForString((String) obj);
- }
- return null;
+ return (AudioType) getObject(AudioType.class, KEY_AUDIO_TYPE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java
index 71db21640..598cf3adf 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BeltStatus.java
@@ -4,7 +4,11 @@ import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
-/** The status of the seat belts.
+
+import static com.smartdevicelink.proxy.rpc.AirbagStatus.KEY_DRIVER_AIRBAG_DEPLOYED;
+import static com.smartdevicelink.proxy.rpc.AirbagStatus.KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED;
+
+/** The status of the seat belts.
*
* <p><b>Parameter List</b></p>
*
@@ -143,243 +147,93 @@ public class BeltStatus extends RPCStruct {
}
public void setDriverBeltDeployed(VehicleDataEventStatus driverBeltDeployed) {
- if (driverBeltDeployed != null) {
- store.put(KEY_DRIVER_BELT_DEPLOYED, driverBeltDeployed);
- } else {
- store.remove(KEY_DRIVER_BELT_DEPLOYED);
- }
+ setValue(KEY_DRIVER_BELT_DEPLOYED, driverBeltDeployed);
}
public VehicleDataEventStatus getDriverBeltDeployed() {
- Object obj = store.get(KEY_DRIVER_BELT_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_BELT_DEPLOYED);
}
public void setPassengerBeltDeployed(VehicleDataEventStatus passengerBeltDeployed) {
- if (passengerBeltDeployed != null) {
- store.put(KEY_PASSENGER_BELT_DEPLOYED, passengerBeltDeployed);
- } else {
- store.remove(KEY_PASSENGER_BELT_DEPLOYED);
- }
+ setValue(KEY_PASSENGER_BELT_DEPLOYED, passengerBeltDeployed);
}
public VehicleDataEventStatus getPassengerBeltDeployed() {
- Object obj = store.get(KEY_PASSENGER_BELT_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_BELT_DEPLOYED);
}
public void setPassengerBuckleBelted(VehicleDataEventStatus passengerBuckleBelted) {
- if (passengerBuckleBelted != null) {
- store.put(KEY_PASSENGER_BUCKLE_BELTED, passengerBuckleBelted);
- } else {
- store.remove(KEY_PASSENGER_BUCKLE_BELTED);
- }
+ setValue(KEY_PASSENGER_BUCKLE_BELTED, passengerBuckleBelted);
}
public VehicleDataEventStatus getPassengerBuckleBelted() {
- Object obj = store.get(KEY_PASSENGER_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_BUCKLE_BELTED);
}
public void setDriverBuckleBelted(VehicleDataEventStatus driverBuckleBelted) {
- if (driverBuckleBelted != null) {
- store.put(KEY_DRIVER_BUCKLE_BELTED, driverBuckleBelted);
- } else {
- store.remove(KEY_DRIVER_BUCKLE_BELTED);
- }
+ setValue(KEY_DRIVER_BUCKLE_BELTED, driverBuckleBelted);
}
public VehicleDataEventStatus getDriverBuckleBelted() {
- Object obj = store.get(KEY_DRIVER_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_BUCKLE_BELTED);
}
public void setLeftRow2BuckleBelted(VehicleDataEventStatus leftRow2BuckleBelted) {
- if (leftRow2BuckleBelted != null) {
- store.put(KEY_LEFT_ROW_2_BUCKLE_BELTED, leftRow2BuckleBelted);
- } else {
- store.remove(KEY_LEFT_ROW_2_BUCKLE_BELTED);
- }
+ setValue(KEY_LEFT_ROW_2_BUCKLE_BELTED, leftRow2BuckleBelted);
}
public VehicleDataEventStatus getLeftRow2BuckleBelted() {
- Object obj = store.get(KEY_LEFT_ROW_2_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_LEFT_ROW_2_BUCKLE_BELTED);
}
public void setPassengerChildDetected(VehicleDataEventStatus passengerChildDetected) {
- if (passengerChildDetected != null) {
- store.put(KEY_PASSENGER_CHILD_DETECTED, passengerChildDetected);
- } else {
- store.remove(KEY_PASSENGER_CHILD_DETECTED);
- }
+ setValue(KEY_PASSENGER_CHILD_DETECTED, passengerChildDetected);
}
public VehicleDataEventStatus getPassengerChildDetected() {
- Object obj = store.get(KEY_PASSENGER_CHILD_DETECTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_PASSENGER_CHILD_DETECTED);
}
public void setRightRow2BuckleBelted(VehicleDataEventStatus rightRow2BuckleBelted) {
- if (rightRow2BuckleBelted != null) {
- store.put(KEY_RIGHT_ROW_2_BUCKLE_BELTED, rightRow2BuckleBelted);
- } else {
- store.remove(KEY_RIGHT_ROW_2_BUCKLE_BELTED);
- }
+ setValue(KEY_RIGHT_ROW_2_BUCKLE_BELTED, rightRow2BuckleBelted);
}
public VehicleDataEventStatus getRightRow2BuckleBelted() {
- Object obj = store.get(KEY_RIGHT_ROW_2_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_RIGHT_ROW_2_BUCKLE_BELTED);
}
public void setMiddleRow2BuckleBelted(VehicleDataEventStatus middleRow2BuckleBelted) {
- if (middleRow2BuckleBelted != null) {
- store.put(KEY_MIDDLE_ROW_2_BUCKLE_BELTED, middleRow2BuckleBelted);
- } else {
- store.remove(KEY_MIDDLE_ROW_2_BUCKLE_BELTED);
- }
+ setValue(KEY_MIDDLE_ROW_2_BUCKLE_BELTED, middleRow2BuckleBelted);
}
public VehicleDataEventStatus getMiddleRow2BuckleBelted() {
- Object obj = store.get(KEY_MIDDLE_ROW_2_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MIDDLE_ROW_2_BUCKLE_BELTED);
}
public void setMiddleRow3BuckleBelted(VehicleDataEventStatus middleRow3BuckleBelted) {
- if (middleRow3BuckleBelted != null) {
- store.put(KEY_MIDDLE_ROW_3_BUCKLE_BELTED, middleRow3BuckleBelted);
- } else {
- store.remove(KEY_MIDDLE_ROW_3_BUCKLE_BELTED);
- }
+ setValue(KEY_MIDDLE_ROW_3_BUCKLE_BELTED, middleRow3BuckleBelted);
}
public VehicleDataEventStatus getMiddleRow3BuckleBelted() {
- Object obj = store.get(KEY_MIDDLE_ROW_3_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MIDDLE_ROW_3_BUCKLE_BELTED);
}
public void setLeftRow3BuckleBelted(VehicleDataEventStatus leftRow3BuckleBelted) {
- if (leftRow3BuckleBelted != null) {
- store.put(KEY_LEFT_ROW_3_BUCKLE_BELTED, leftRow3BuckleBelted);
- } else {
- store.remove(KEY_LEFT_ROW_3_BUCKLE_BELTED);
- }
+ setValue(KEY_LEFT_ROW_3_BUCKLE_BELTED, leftRow3BuckleBelted);
}
public VehicleDataEventStatus getLeftRow3BuckleBelted() {
- Object obj = store.get(KEY_LEFT_ROW_3_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_LEFT_ROW_3_BUCKLE_BELTED);
}
public void setRightRow3BuckleBelted(VehicleDataEventStatus rightRow3BuckleBelted) {
- if (rightRow3BuckleBelted != null) {
- store.put(KEY_RIGHT_ROW_3_BUCKLE_BELTED, rightRow3BuckleBelted);
- } else {
- store.remove(KEY_RIGHT_ROW_3_BUCKLE_BELTED);
- }
+ setValue(KEY_RIGHT_ROW_3_BUCKLE_BELTED, rightRow3BuckleBelted);
}
public VehicleDataEventStatus getRightRow3BuckleBelted() {
- Object obj = store.get(KEY_RIGHT_ROW_3_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_RIGHT_ROW_3_BUCKLE_BELTED);
}
public void setLeftRearInflatableBelted(VehicleDataEventStatus rearInflatableBelted) {
- if (rearInflatableBelted != null) {
- store.put(KEY_REAR_INFLATABLE_BELTED, rearInflatableBelted);
- } else {
- store.remove(KEY_REAR_INFLATABLE_BELTED);
- }
+ setValue(KEY_REAR_INFLATABLE_BELTED, rearInflatableBelted);
}
public VehicleDataEventStatus getLeftRearInflatableBelted() {
- Object obj = store.get(KEY_REAR_INFLATABLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_REAR_INFLATABLE_BELTED);
}
public void setRightRearInflatableBelted(VehicleDataEventStatus rightRearInflatableBelted) {
- if (rightRearInflatableBelted != null) {
- store.put(KEY_RIGHT_REAR_INFLATABLE_BELTED, rightRearInflatableBelted);
- } else {
- store.remove(KEY_RIGHT_REAR_INFLATABLE_BELTED);
- }
+ setValue(KEY_RIGHT_REAR_INFLATABLE_BELTED, rightRearInflatableBelted);
}
public VehicleDataEventStatus getRightRearInflatableBelted() {
- Object obj = store.get(KEY_RIGHT_REAR_INFLATABLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_RIGHT_REAR_INFLATABLE_BELTED);
}
public void setMiddleRow1BeltDeployed(VehicleDataEventStatus middleRow1BeltDeployed) {
- if (middleRow1BeltDeployed != null) {
- store.put(KEY_MIDDLE_ROW_1_BELT_DEPLOYED, middleRow1BeltDeployed);
- } else {
- store.remove(KEY_MIDDLE_ROW_1_BELT_DEPLOYED);
- }
+ setValue(KEY_MIDDLE_ROW_1_BELT_DEPLOYED, middleRow1BeltDeployed);
}
public VehicleDataEventStatus getMiddleRow1BeltDeployed() {
- Object obj = store.get(KEY_MIDDLE_ROW_1_BELT_DEPLOYED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MIDDLE_ROW_1_BELT_DEPLOYED);
}
public void setMiddleRow1BuckleBelted(VehicleDataEventStatus middleRow1BuckleBelted) {
- if (middleRow1BuckleBelted != null) {
- store.put(KEY_MIDDLE_ROW_1_BUCKLE_BELTED, middleRow1BuckleBelted);
- } else {
- store.remove(KEY_MIDDLE_ROW_1_BUCKLE_BELTED);
- }
+ setValue(KEY_MIDDLE_ROW_1_BUCKLE_BELTED, middleRow1BuckleBelted);
}
public VehicleDataEventStatus getMiddleRow1BuckleBelted() {
- Object obj = store.get(KEY_MIDDLE_ROW_1_BUCKLE_BELTED);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MIDDLE_ROW_1_BUCKLE_BELTED);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java
index 038b1970e..4f851c383 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/BodyInformation.java
@@ -1,11 +1,15 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.IgnitionStableStatus;
import com.smartdevicelink.proxy.rpc.enums.IgnitionStatus;
-/** The body information including power modes.
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
+
+import java.util.Hashtable;
+
+import static com.smartdevicelink.proxy.rpc.AirbagStatus.KEY_DRIVER_CURTAIN_AIRBAG_DEPLOYED;
+
+/** The body information including power modes.
*
* <p><b>Note:</b> The structure defines the information about the park brake and ignition.</p>
*
@@ -105,91 +109,51 @@ public class BodyInformation extends RPCStruct {
}
public void setParkBrakeActive(Boolean parkBrakeActive) {
- if (parkBrakeActive != null) {
- store.put(KEY_PARK_BRAKE_ACTIVE, parkBrakeActive);
- } else {
- store.remove(KEY_PARK_BRAKE_ACTIVE);
- }
+ setValue(KEY_PARK_BRAKE_ACTIVE, parkBrakeActive);
}
public Boolean getParkBrakeActive() {
- return (Boolean) store.get(KEY_PARK_BRAKE_ACTIVE);
+ return getBoolean(KEY_PARK_BRAKE_ACTIVE);
}
public void setIgnitionStableStatus(IgnitionStableStatus ignitionStableStatus) {
- if (ignitionStableStatus != null) {
- store.put(KEY_IGNITION_STABLE_STATUS, ignitionStableStatus);
- } else {
- store.remove(KEY_IGNITION_STABLE_STATUS);
- }
+ setValue(KEY_IGNITION_STABLE_STATUS, ignitionStableStatus);
}
public IgnitionStableStatus getIgnitionStableStatus() {
- Object obj = store.get(KEY_IGNITION_STABLE_STATUS);
- if (obj instanceof IgnitionStableStatus) {
- return (IgnitionStableStatus) obj;
- } else if (obj instanceof String) {
- return IgnitionStableStatus.valueForString((String) obj);
- }
- return null;
+ return (IgnitionStableStatus) getObject(IgnitionStableStatus.class, KEY_IGNITION_STABLE_STATUS);
}
public void setIgnitionStatus(IgnitionStatus ignitionStatus) {
- if (ignitionStatus != null) {
- store.put(KEY_IGNITION_STATUS, ignitionStatus);
- } else {
- store.remove(KEY_IGNITION_STATUS);
- }
+ setValue(KEY_IGNITION_STATUS, ignitionStatus);
}
public IgnitionStatus getIgnitionStatus() {
- Object obj = store.get(KEY_IGNITION_STATUS);
- if (obj instanceof IgnitionStatus) {
- return (IgnitionStatus) obj;
- } else if (obj instanceof String) {
- return IgnitionStatus.valueForString((String) obj);
- }
- return null;
+ return (IgnitionStatus) getObject(IgnitionStatus.class, KEY_IGNITION_STATUS);
}
public void setDriverDoorAjar(Boolean driverDoorAjar) {
- if (driverDoorAjar != null) {
- store.put(KEY_DRIVER_DOOR_AJAR, driverDoorAjar);
- } else {
- store.remove(KEY_DRIVER_DOOR_AJAR);
- }
+ setValue(KEY_DRIVER_DOOR_AJAR, driverDoorAjar);
}
public Boolean getDriverDoorAjar() {
- return (Boolean) store.get(KEY_DRIVER_DOOR_AJAR);
+ return getBoolean(KEY_DRIVER_DOOR_AJAR);
}
public void setPassengerDoorAjar(Boolean passengerDoorAjar) {
- if (passengerDoorAjar != null) {
- store.put(KEY_PASSENGER_DOOR_AJAR, passengerDoorAjar);
- } else {
- store.remove(KEY_PASSENGER_DOOR_AJAR);
- }
+ setValue(KEY_PASSENGER_DOOR_AJAR, passengerDoorAjar);
}
public Boolean getPassengerDoorAjar() {
- return (Boolean) store.get(KEY_PASSENGER_DOOR_AJAR);
+ return getBoolean(KEY_PASSENGER_DOOR_AJAR);
}
public void setRearLeftDoorAjar(Boolean rearLeftDoorAjar) {
- if (rearLeftDoorAjar != null) {
- store.put(KEY_REAR_LEFT_DOOR_AJAR, rearLeftDoorAjar);
- } else {
- store.remove(KEY_REAR_LEFT_DOOR_AJAR);
- }
+ setValue(KEY_REAR_LEFT_DOOR_AJAR, rearLeftDoorAjar);
}
public Boolean getRearLeftDoorAjar() {
- return (Boolean) store.get(KEY_REAR_LEFT_DOOR_AJAR);
+ return getBoolean(KEY_REAR_LEFT_DOOR_AJAR);
}
public void setRearRightDoorAjar(Boolean rearRightDoorAjar) {
- if (rearRightDoorAjar != null) {
- store.put(KEY_REAR_RIGHT_DOOR_AJAR, rearRightDoorAjar);
- } else {
- store.remove(KEY_REAR_RIGHT_DOOR_AJAR);
- }
+ setValue(KEY_REAR_RIGHT_DOOR_AJAR, rearRightDoorAjar);
}
public Boolean getRearRightDoorAjar() {
- return (Boolean) store.get(KEY_REAR_RIGHT_DOOR_AJAR);
+ return getBoolean(KEY_REAR_RIGHT_DOOR_AJAR);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java
index 9b15c5be9..5c0ebd779 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonCapabilities.java
@@ -80,77 +80,55 @@ public class ButtonCapabilities extends RPCStruct {
* @return ButtonName the name of the Button
*/
public ButtonName getName() {
- Object obj = store.get(KEY_NAME);
- if (obj instanceof ButtonName) {
- return (ButtonName) obj;
- } else if (obj instanceof String) {
- return ButtonName.valueForString((String) obj);
- }
- return null;
+ return (ButtonName) getObject(ButtonName.class, KEY_NAME);
}
/**
* Set the name of theSDL HMI button.
* @param name the name of button
*/
public void setName( ButtonName name ) {
- if (name != null) {
- store.put(KEY_NAME, name );
- } else {
- store.remove(KEY_NAME);
- }
+ setValue(KEY_NAME, name);
}
/**
* Whether the button supports a SHORT press. See <i>{@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonPressMode}</i> for more information.
* @return True if support otherwise False.
*/
public Boolean getShortPressAvailable() {
- return (Boolean) store.get( KEY_SHORT_PRESS_AVAILABLE );
+ return getBoolean( KEY_SHORT_PRESS_AVAILABLE );
}
/**
* Set the button supports a SHORT press. See <i>{@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonPressMode}</i> for more information.
* @param shortPressAvailable True if support otherwise False.
*/
public void setShortPressAvailable( Boolean shortPressAvailable ) {
- if (shortPressAvailable != null) {
- store.put(KEY_SHORT_PRESS_AVAILABLE, shortPressAvailable );
- } else {
- store.remove(KEY_SHORT_PRESS_AVAILABLE);
- }
+ setValue(KEY_SHORT_PRESS_AVAILABLE, shortPressAvailable);
}
/**
* Whether the button supports a LONG press. See <i>{@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonPressMode}</i> for more information.
* @return True if support otherwise False.
*/
public Boolean getLongPressAvailable() {
- return (Boolean) store.get( KEY_LONG_PRESS_AVAILABLE );
+ return getBoolean( KEY_LONG_PRESS_AVAILABLE );
}
/**
* Set the button supports a LONG press. See <i>{@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonPressMode}</i> for more information.
* @param longPressAvailable True if support otherwise False.
*/
public void setLongPressAvailable( Boolean longPressAvailable ) {
- if (longPressAvailable != null) {
- store.put(KEY_LONG_PRESS_AVAILABLE, longPressAvailable );
- } else {
- store.remove(KEY_LONG_PRESS_AVAILABLE);
- }
+ setValue(KEY_LONG_PRESS_AVAILABLE, longPressAvailable);
}
/**
* Whether the button supports "button down" and "button up". When the button is depressed, the <i>{@linkplain OnButtonEvent}</i> notification will be invoked with a value of BUTTONDOWN.
* @return True if support otherwise False.
*/
public Boolean getUpDownAvailable() {
- return (Boolean) store.get( KEY_UP_DOWN_AVAILABLE );
+ return getBoolean( KEY_UP_DOWN_AVAILABLE );
}
/**
* Set the button supports "button down" and "button up". When the button is depressed, the <i>{@linkplain OnButtonEvent}</i> notification will be invoked with a value of BUTTONDOWN.
* @param upDownAvailable True if support otherwise False.
*/
public void setUpDownAvailable( Boolean upDownAvailable ) {
- if (upDownAvailable != null) {
- store.put(KEY_UP_DOWN_AVAILABLE, upDownAvailable );
- } else {
- store.remove(KEY_UP_DOWN_AVAILABLE);
- }
+ setValue(KEY_UP_DOWN_AVAILABLE, upDownAvailable);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPress.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPress.java
new file mode 100644
index 000000000..d0162e7ac
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPress.java
@@ -0,0 +1,94 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.enums.ButtonName;
+import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode;
+import com.smartdevicelink.proxy.rpc.enums.ModuleType;
+import java.util.Hashtable;
+
+/**
+ * This function allows a remote control type mobile application
+ * simulate a hardware button press event.
+ */
+public class ButtonPress extends RPCRequest {
+ public static final String KEY_MODULE_TYPE = "moduleType";
+ public static final String KEY_BUTTON_NAME = "buttonName";
+ public static final String KEY_BUTTON_PRESS_MODE = "buttonPressMode";
+
+ /**
+ * Constructs a new ButtonPress object
+ */
+ public ButtonPress() {
+ super(FunctionID.BUTTON_PRESS.toString());
+ }
+
+ /**
+ * <p>Constructs a new ButtonPress object indicated by the
+ * Hashtable parameter</p>
+ *
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public ButtonPress(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Gets the ModuleType
+ *
+ * @return ModuleType - The module where the button should be pressed
+ */
+ public ModuleType getModuleType() {
+ return (ModuleType) getObject(ModuleType.class, KEY_MODULE_TYPE);
+ }
+
+ /**
+ * Sets a ModuleType
+ *
+ * @param moduleType
+ * Represents module where the button should be pressed
+ */
+ public void setModuleType(ModuleType moduleType) {
+ setParameters(KEY_MODULE_TYPE, moduleType);
+ }
+
+ /**
+ * Gets the ButtonName
+ *
+ * @return ButtonName - The name of supported RC climate or radio button
+ */
+ public ButtonName getButtonName() {
+ return (ButtonName) getObject(ButtonName.class, KEY_BUTTON_NAME);
+ }
+
+ /**
+ * Sets a ButtonName
+ *
+ * @param buttonName
+ * Represents name of supported RC climate or radio button
+ */
+ public void setButtonName(ButtonName buttonName) {
+ setParameters(KEY_BUTTON_NAME, buttonName);
+ }
+
+ /**
+ * Gets the ButtonPressMode
+ *
+ * @return ButtonPressMode - Indicates whether this is a LONG or SHORT button press event.
+ */
+ public ButtonPressMode getButtonPressMode() {
+ return (ButtonPressMode) getObject(ButtonPressMode.class, KEY_BUTTON_PRESS_MODE);
+ }
+
+ /**
+ * Sets a ButtonPressMode
+ *
+ * @param buttonPressMode
+ * Indicates whether this is a LONG or SHORT button press event.
+ */
+ public void setButtonPressMode(ButtonPressMode buttonPressMode) {
+ setParameters(KEY_BUTTON_PRESS_MODE, buttonPressMode);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPressResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPressResponse.java
new file mode 100644
index 000000000..94ccd61a6
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ButtonPressResponse.java
@@ -0,0 +1,28 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCResponse;
+
+import java.util.Hashtable;
+
+public class ButtonPressResponse extends RPCResponse {
+
+ /**
+ * Constructs a new ButtonPressResponse object
+ */
+ public ButtonPressResponse() {
+ super(FunctionID.BUTTON_PRESS.toString());
+ }
+
+ /**
+ * <p>Constructs a new ButtonPressResponse object indicated by the
+ * Hashtable parameter</p>
+ *
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public ButtonPressResponse(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java
index 2b4c69f42..c481e36c6 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ChangeRegistration.java
@@ -1,13 +1,12 @@
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.Language;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* If the app recognizes during the app registration that the SDL HMI language
* (voice/TTS and/or display) does not match the app language, the app will be
@@ -132,11 +131,7 @@ public class ChangeRegistration extends RPCRequest {
* a language value
*/
public void setLanguage(Language language) {
- if (language != null) {
- parameters.put(KEY_LANGUAGE, language);
- } else {
- parameters.remove(KEY_LANGUAGE);
- }
+ setParameters(KEY_LANGUAGE, language);
}
/**
@@ -145,13 +140,7 @@ public class ChangeRegistration extends RPCRequest {
* @return Language -a Language value
*/
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;
+ return (Language) getObject(Language.class, KEY_LANGUAGE);
}
/**
@@ -161,11 +150,7 @@ public class ChangeRegistration extends RPCRequest {
* a Language value
*/
public void setHmiDisplayLanguage(Language hmiDisplayLanguage) {
- if (hmiDisplayLanguage != null) {
- parameters.put(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage);
- } else {
- parameters.remove(KEY_HMI_DISPLAY_LANGUAGE);
- }
+ setParameters(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage);
}
/**
@@ -174,13 +159,7 @@ public class ChangeRegistration extends RPCRequest {
* @return Language -a Language value
*/
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;
+ return (Language) getObject(Language.class, KEY_HMI_DISPLAY_LANGUAGE);
}
/**
@@ -189,12 +168,7 @@ public class ChangeRegistration extends RPCRequest {
* @param appName App name to set
*/
public void setAppName(String appName){
- if(appName != null){
- parameters.put(KEY_APP_NAME, appName);
- }
- else{
- parameters.remove(KEY_APP_NAME);
- }
+ setParameters(KEY_APP_NAME, appName);
}
/**
@@ -203,7 +177,7 @@ public class ChangeRegistration extends RPCRequest {
* @return The app name
*/
public String getAppName(){
- return (String) parameters.get(KEY_APP_NAME);
+ return getString(KEY_APP_NAME);
}
/**
@@ -212,12 +186,7 @@ public class ChangeRegistration extends RPCRequest {
* @param ngnAppName The NGN app name
*/
public void setNgnMediaScreenAppName(String ngnAppName){
- if(ngnAppName != null){
- parameters.put(KEY_NGN_MEDIA_SCREEN_NAME, ngnAppName);
- }
- else{
- parameters.remove(KEY_NGN_MEDIA_SCREEN_NAME);
- }
+ setParameters(KEY_NGN_MEDIA_SCREEN_NAME, ngnAppName);
}
/**
@@ -226,7 +195,7 @@ public class ChangeRegistration extends RPCRequest {
* @return The NGN app name
*/
public String getNgnMediaScreenAppName(){
- return (String) parameters.get(KEY_NGN_MEDIA_SCREEN_NAME);
+ return getString(KEY_NGN_MEDIA_SCREEN_NAME);
}
/**
@@ -235,12 +204,7 @@ public class ChangeRegistration extends RPCRequest {
* @param ttsName The TTS name to set
*/
public void setTtsName(List<TTSChunk> ttsName){
- if(ttsName != null){
- parameters.put(KEY_TTS_NAME, ttsName);
- }
- else{
- parameters.remove(KEY_TTS_NAME);
- }
+ setParameters(KEY_TTS_NAME, ttsName);
}
/**
@@ -250,22 +214,7 @@ public class ChangeRegistration extends RPCRequest {
*/
@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;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_TTS_NAME);
}
/**
@@ -278,16 +227,7 @@ 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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_VR_SYNONYMS);
}
/**
@@ -308,10 +248,6 @@ public class ChangeRegistration extends RPCRequest {
* </ul>
*/
public void setVrSynonyms(List<String> vrSynonyms) {
- if (vrSynonyms != null) {
- parameters.put(KEY_VR_SYNONYMS, vrSynonyms);
- } else {
- parameters.remove(KEY_VR_SYNONYMS);
- }
+ setParameters(KEY_VR_SYNONYMS, vrSynonyms);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java
index 2bc59736e..886a88d23 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Choice.java
@@ -1,11 +1,10 @@
package com.smartdevicelink.proxy.rpc;
+import com.smartdevicelink.proxy.RPCStruct;
+
import java.util.Hashtable;
import java.util.List;
-import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.util.DebugTool;
-
/**
* A choice is an option which a user can select either via the menu or via voice recognition (VR) during an application initiated interaction.
* For example, the application may request for the user`s choice among several suggested ones: Yes, No, Skip.
@@ -79,18 +78,14 @@ public class Choice extends RPCStruct {
* @return choiceID Min: 0; Max: 65535
*/
public Integer getChoiceID() {
- return (Integer) store.get(KEY_CHOICE_ID);
+ return getInteger(KEY_CHOICE_ID);
}
/**
* Set the application-scoped identifier that uniquely identifies this choice.
* @param choiceID Min: 0 Max: 65535
*/
public void setChoiceID(Integer choiceID) {
- if (choiceID != null) {
- store.put(KEY_CHOICE_ID, choiceID);
- } else {
- store.remove(KEY_CHOICE_ID);
- }
+ setValue(KEY_CHOICE_ID, choiceID);
}
/**
* Text which appears in menu, representing this choice.
@@ -99,7 +94,7 @@ public class Choice extends RPCStruct {
* @return menuName the menu name
*/
public String getMenuName() {
- return (String) store.get(KEY_MENU_NAME);
+ return getString(KEY_MENU_NAME);
}
/**
* Text which appears in menu, representing this choice.
@@ -108,11 +103,7 @@ public class Choice extends RPCStruct {
* @param menuName the menu name
*/
public void setMenuName(String menuName) {
- if (menuName != null) {
- store.put(KEY_MENU_NAME, menuName);
- } else {
- store.remove(KEY_MENU_NAME);
- }
+ setValue(KEY_MENU_NAME, menuName);
}
/**
* Get an array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element
@@ -121,16 +112,7 @@ public class Choice extends RPCStruct {
*/
@SuppressWarnings("unchecked")
public List<String> getVrCommands() {
- 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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_VR_COMMANDS);
}
/**
* Set an array of strings to be used as VR synonyms for this choice. If this array is provided, it must have at least one non-empty element
@@ -138,22 +120,14 @@ public class Choice extends RPCStruct {
* @since SmartDeviceLink 2.0
*/
public void setVrCommands(List<String> vrCommands) {
- if (vrCommands != null) {
- store.put(KEY_VR_COMMANDS, vrCommands);
- } else {
- store.remove(KEY_VR_COMMANDS);
- }
+ setValue(KEY_VR_COMMANDS, vrCommands);
}
/**
* Set the image
* @param image the image of the choice
*/
public void setImage(Image image) {
- if (image != null) {
- store.put(KEY_IMAGE, image);
- } else {
- store.remove(KEY_IMAGE);
- }
+ setValue(KEY_IMAGE, image);
}
/**
* Get the image
@@ -161,65 +135,31 @@ public class Choice extends RPCStruct {
*/
@SuppressWarnings("unchecked")
public Image getImage() {
- Object obj = store.get(KEY_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_IMAGE);
}
public String getSecondaryText() {
- return (String) store.get(KEY_SECONDARY_TEXT);
+ return getString(KEY_SECONDARY_TEXT);
}
public void setSecondaryText(String secondaryText) {
- if (secondaryText != null) {
- store.put(KEY_SECONDARY_TEXT, secondaryText);
- }
- else {
- store.remove(KEY_SECONDARY_TEXT);
- }
+ setValue(KEY_SECONDARY_TEXT, secondaryText);
}
public String getTertiaryText() {
- return (String) store.get(KEY_TERTIARY_TEXT);
+ return getString(KEY_TERTIARY_TEXT);
}
public void setTertiaryText(String tertiaryText) {
- if (tertiaryText != null) {
- store.put(KEY_TERTIARY_TEXT, tertiaryText);
- }
- else {
- store.remove(KEY_TERTIARY_TEXT);
- }
+ setValue(KEY_TERTIARY_TEXT, tertiaryText);
}
public void setSecondaryImage(Image image) {
- if (image != null) {
- store.put(KEY_SECONDARY_IMAGE, image);
- } else {
- store.remove(KEY_SECONDARY_IMAGE);
- }
+ setValue(KEY_SECONDARY_IMAGE, image);
}
@SuppressWarnings("unchecked")
public Image getSecondaryImage() {
- Object obj = store.get(KEY_SECONDARY_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SECONDARY_IMAGE, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_SECONDARY_IMAGE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlCapabilities.java
new file mode 100644
index 000000000..ac9c3fc1c
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlCapabilities.java
@@ -0,0 +1,280 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.DefrostZone;
+import com.smartdevicelink.proxy.rpc.enums.VentilationMode;
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Contains information about a climate control module's capabilities.
+ */
+
+public class ClimateControlCapabilities extends RPCStruct{
+ public static final String KEY_MODULE_NAME= "moduleName";
+ public static final String KEY_FAN_SPEED_AVAILABLE= "fanSpeedAvailable";
+ public static final String KEY_DESIRED_TEMPERATURE_AVAILABLE= "desiredTemperatureAvailable";
+ public static final String KEY_AC_ENABLE_AVAILABLE= "acEnableAvailable";
+ public static final String KEY_AC_MAX_ENABLE_AVAILABLE= "acMaxEnableAvailable";
+ public static final String KEY_CIRCULATE_AIR_ENABLE_AVAILABLE= "circulateAirEnableAvailable";
+ public static final String KEY_AUTO_MODE_ENABLE_AVAILABLE= "autoModeEnableAvailable";
+ public static final String KEY_DUAL_MODE_ENABLE_AVAILABLE= "dualModeEnableAvailable";
+ public static final String KEY_DEFROST_ZONE_AVAILABLE= "defrostZoneAvailable";
+ public static final String KEY_DEFROST_ZONE= "defrostZone";
+ public static final String KEY_VENTILATION_MODE_AVAILABLE= "ventilationModeAvailable";
+ public static final String KEY_VENTILATION_MODE= "ventilationMode";
+
+ public ClimateControlCapabilities() {
+ }
+
+ public ClimateControlCapabilities(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the moduleName portion of the ClimateControlCapabilities class
+ *
+ * @param moduleName
+ * The short friendly name of the climate control module.
+ * It should not be used to identify a module by mobile application.
+ */
+ public void setModuleName(String moduleName) {
+ setValue(KEY_MODULE_NAME, moduleName);
+ }
+
+ /**
+ * Gets the moduleName portion of the ClimateControlCapabilities class
+ *
+ * @return String - Short friendly name of the climate control module.
+ */
+ public String getModuleName() {
+ return getString(KEY_MODULE_NAME);
+ }
+
+ /**
+ * Sets the fanSpeedAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param fanSpeedAvailable
+ * Availability of the control of fan speed.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setFanSpeedAvailable(Boolean fanSpeedAvailable) {
+ setValue(KEY_FAN_SPEED_AVAILABLE, fanSpeedAvailable);
+ }
+
+ /**
+ * Gets the fanSpeedAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of fan speed.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getFanSpeedAvailable() {
+ return getBoolean(KEY_FAN_SPEED_AVAILABLE);
+ }
+
+ /**
+ * Sets the desiredTemperatureAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param desiredTemperatureAvailable
+ * Availability of the control of desired temperature.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setDesiredTemperatureAvailable(Boolean desiredTemperatureAvailable) {
+ setValue(KEY_DESIRED_TEMPERATURE_AVAILABLE, desiredTemperatureAvailable);
+ }
+
+ /**
+ * Gets the desiredTemperatureAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of desired temperature.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getDesiredTemperatureAvailable() {
+ return getBoolean(KEY_DESIRED_TEMPERATURE_AVAILABLE);
+ }
+
+ /**
+ * Sets the acEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param acEnableAvailable
+ * Availability of the control of turn on/off AC.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setAcEnableAvailable(Boolean acEnableAvailable) {
+ setValue(KEY_AC_ENABLE_AVAILABLE, acEnableAvailable);
+ }
+
+ /**
+ * Gets the acEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of turn on/off AC.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getAcEnableAvailable() {
+ return getBoolean(KEY_AC_ENABLE_AVAILABLE);
+ }
+
+ /**
+ * Sets the acMaxEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param acMaxEnableAvailable
+ * Availability of the control of enable/disable air conditioning is ON on the maximum level.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setAcMaxEnableAvailable(Boolean acMaxEnableAvailable) {
+ setValue(KEY_AC_MAX_ENABLE_AVAILABLE, acMaxEnableAvailable);
+ }
+
+ /**
+ * Gets the acMaxEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of enable/disable air conditioning is ON on the maximum level.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getAcMaxEnableAvailable() {
+ return getBoolean(KEY_AC_MAX_ENABLE_AVAILABLE);
+ }
+
+ /**
+ * Sets the circulateAirEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param circulateAirEnableAvailable
+ * Availability of the control of enable/disable circulate Air mode.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setCirculateAirEnableAvailable(Boolean circulateAirEnableAvailable) {
+ setValue(KEY_CIRCULATE_AIR_ENABLE_AVAILABLE, circulateAirEnableAvailable);
+ }
+
+ /**
+ * Gets the circulateAirEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of enable/disable circulate Air mode.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getCirculateAirEnableAvailable() {
+ return getBoolean(KEY_CIRCULATE_AIR_ENABLE_AVAILABLE);
+ }
+
+ /**
+ * Sets the autoModeEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param autoModeEnableAvailable
+ * Availability of the control of enable/disable auto mode.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setAutoModeEnableAvailable(Boolean autoModeEnableAvailable) {
+ setValue(KEY_AUTO_MODE_ENABLE_AVAILABLE, autoModeEnableAvailable);
+ }
+
+ /**
+ * Gets the autoModeEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of enable/disable auto mode.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getAutoModeEnableAvailable() {
+ return getBoolean(KEY_AUTO_MODE_ENABLE_AVAILABLE);
+ }
+
+ /**
+ * Sets the dualModeEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param dualModeEnableAvailable
+ * Availability of the control of enable/disable dual mode.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setDualModeEnableAvailable(Boolean dualModeEnableAvailable) {
+ setValue(KEY_DUAL_MODE_ENABLE_AVAILABLE, dualModeEnableAvailable);
+ }
+
+ /**
+ * Gets the dualModeEnableAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of enable/disable dual mode.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getDualModeEnableAvailable() {
+ return getBoolean(KEY_DUAL_MODE_ENABLE_AVAILABLE);
+ }
+
+ /**
+ * Sets the defrostZoneAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param defrostZoneAvailable
+ * Availability of the control of defrost zones.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setDefrostZoneAvailable(Boolean defrostZoneAvailable) {
+ setValue(KEY_DEFROST_ZONE_AVAILABLE, defrostZoneAvailable);
+ }
+
+ /**
+ * Gets the defrostZoneAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of defrost zones.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getDefrostZoneAvailable() {
+ return getBoolean(KEY_DEFROST_ZONE_AVAILABLE);
+ }
+
+ /**
+ * Gets the List<DefrostZone> portion of the ClimateControlCapabilities class
+ *
+ * @return List<DefrostZone> - A set of all defrost zones that are controllable.
+ */
+ public List<DefrostZone> getDefrostZone() {
+ return (List<DefrostZone>) getObject(DefrostZone.class, KEY_DEFROST_ZONE);
+ }
+
+ /**
+ * Sets the defrostZone portion of the ClimateControlCapabilities class
+ *
+ * @param defrostZone
+ * A set of all defrost zones that are controllable.
+ */
+ public void setDefrostZone(List<DefrostZone> defrostZone) {
+ setValue(KEY_DEFROST_ZONE, defrostZone);
+ }
+
+ /**
+ * Sets the ventilationModeAvailable portion of the ClimateControlCapabilities class
+ *
+ * @param ventilationModeAvailable
+ * Availability of the control of air ventilation mode.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setVentilationModeAvailable(Boolean ventilationModeAvailable) {
+ setValue(KEY_VENTILATION_MODE_AVAILABLE, ventilationModeAvailable);
+ }
+
+ /**
+ * Gets the ventilationModeAvailable portion of the ClimateControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of air ventilation mode.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getVentilationModeAvailable() {
+ return getBoolean(KEY_VENTILATION_MODE_AVAILABLE);
+ }
+
+ /**
+ * Gets the List<VentilationMode> portion of the ClimateControlCapabilities class
+ *
+ * @return List<VentilationMode> - A set of all ventilation modes that are controllable.
+ */
+ public List<VentilationMode> getVentilationMode() {
+ return (List<VentilationMode>) getObject(VentilationMode.class, KEY_VENTILATION_MODE);
+ }
+
+ /**
+ * Sets the ventilationMode portion of the ClimateControlCapabilities class
+ *
+ * @param ventilationMode
+ * A set of all ventilation modes that are controllable.
+ */
+ public void setVentilationMode(List<VentilationMode> ventilationMode) {
+ setValue(KEY_VENTILATION_MODE, ventilationMode);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlData.java
new file mode 100644
index 000000000..0da8060f3
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClimateControlData.java
@@ -0,0 +1,106 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.DefrostZone;
+import com.smartdevicelink.proxy.rpc.enums.VentilationMode;
+import java.util.Hashtable;
+
+public class ClimateControlData extends RPCStruct{
+ public static final String KEY_FAN_SPEED= "fanSpeed";
+ public static final String KEY_CURRENT_TEMPERATURE= "currentTemperature";
+ public static final String KEY_DESIRED_TEMPERATURE= "desiredTemperature";
+ public static final String KEY_AC_ENABLE= "acEnable";
+ public static final String KEY_CIRCULATE_AIR_ENABLE= "circulateAirEnable";
+ public static final String KEY_AUTO_MODE_ENABLE= "autoModeEnable";
+ public static final String KEY_DEFROST_ZONE= "defrostZone";
+ public static final String KEY_DUAL_MODE_ENABLE= "dualModeEnable";
+ public static final String KEY_AC_MAX_ENABLE= "acMaxEnable";
+ public static final String KEY_VENTILATION_MODE= "ventilationMode";
+
+ public ClimateControlData() {
+ }
+
+ public ClimateControlData(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ public void setFanSpeed(Integer fanSpeed) {
+ setValue(KEY_FAN_SPEED, fanSpeed);
+ }
+
+ public Integer getFanSpeed() {
+ return getInteger(KEY_FAN_SPEED);
+ }
+
+ public void setCurrentTemperature(Temperature currentTemperature) {
+ setValue(KEY_CURRENT_TEMPERATURE, currentTemperature);
+ }
+
+ public Temperature getCurrentTemperature() {
+ return (Temperature) getObject(Temperature.class, KEY_CURRENT_TEMPERATURE);
+ }
+
+ public void setDesiredTemperature(Temperature desiredTemperature) {
+ setValue(KEY_DESIRED_TEMPERATURE, desiredTemperature);
+ }
+
+ public Temperature getDesiredTemperature() {
+ return (Temperature) getObject(Temperature.class, KEY_DESIRED_TEMPERATURE);
+ }
+
+ public void setAcEnable(Boolean acEnable) {
+ setValue(KEY_AC_ENABLE, acEnable);
+ }
+
+ public Boolean getAcEnable() {
+ return getBoolean(KEY_AC_ENABLE);
+ }
+
+ public void setCirculateAirEnable(Boolean circulateAirEnable) {
+ setValue(KEY_CIRCULATE_AIR_ENABLE, circulateAirEnable);
+ }
+
+ public Boolean getCirculateAirEnable() {
+ return getBoolean(KEY_CIRCULATE_AIR_ENABLE);
+ }
+
+ public void setAutoModeEnable(Boolean autoModeEnable) {
+ setValue(KEY_AUTO_MODE_ENABLE, autoModeEnable);
+ }
+
+ public Boolean getAutoModeEnable() {
+ return getBoolean(KEY_AUTO_MODE_ENABLE);
+ }
+
+ public void setDefrostZone(DefrostZone defrostZone) {
+ setValue(KEY_DEFROST_ZONE, defrostZone);
+ }
+
+ public DefrostZone getDefrostZone() {
+ return (DefrostZone) getObject(DefrostZone.class, KEY_DEFROST_ZONE);
+ }
+
+ public void setDualModeEnable(Boolean dualModeEnable) {
+ setValue(KEY_DUAL_MODE_ENABLE, dualModeEnable);
+ }
+
+ public Boolean getDualModeEnable() {
+ return getBoolean(KEY_DUAL_MODE_ENABLE);
+ }
+
+ public void setAcMaxEnable(Boolean acMaxEnable) {
+ setValue(KEY_AC_MAX_ENABLE, acMaxEnable);
+ }
+
+ public Boolean getAcMaxEnable() {
+ return getBoolean(KEY_AC_MAX_ENABLE);
+ }
+
+ public void setVentilationMode(VentilationMode ventilationMode) {
+ setValue(KEY_VENTILATION_MODE, ventilationMode);
+ }
+
+ public VentilationMode getVentilationMode() {
+ return (VentilationMode) getObject(VentilationMode.class, KEY_VENTILATION_MODE);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java
index 17e16af65..c58f70b50 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ClusterModeStatus.java
@@ -6,6 +6,9 @@ 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 static android.provider.Contacts.SettingsColumns.KEY;
+
/** <p>The status modes of the instrument panel cluster.</p>
*
*
@@ -69,61 +72,27 @@ public class ClusterModeStatus extends RPCStruct {
}
public void setPowerModeActive(Boolean powerModeActive) {
- if (powerModeActive != null) {
- store.put(KEY_POWER_MODE_ACTIVE, powerModeActive);
- } else {
- store.remove(KEY_POWER_MODE_ACTIVE);
- }
+ setValue(KEY_POWER_MODE_ACTIVE, powerModeActive);
}
public Boolean getPowerModeActive() {
- return (Boolean) store.get(KEY_POWER_MODE_ACTIVE);
+ return getBoolean(KEY_POWER_MODE_ACTIVE);
}
public void setPowerModeQualificationStatus(PowerModeQualificationStatus powerModeQualificationStatus) {
- if (powerModeQualificationStatus != null) {
- store.put(KEY_POWER_MODE_QUALIFICATION_STATUS, powerModeQualificationStatus);
- } else {
- store.remove(KEY_POWER_MODE_QUALIFICATION_STATUS);
- }
+ setValue(KEY_POWER_MODE_QUALIFICATION_STATUS, powerModeQualificationStatus);
}
public PowerModeQualificationStatus getPowerModeQualificationStatus() {
- Object obj = store.get(KEY_POWER_MODE_QUALIFICATION_STATUS);
- if (obj instanceof PowerModeQualificationStatus) {
- return (PowerModeQualificationStatus) obj;
- } else if (obj instanceof String) {
- return PowerModeQualificationStatus.valueForString((String) obj);
- }
- return null;
+ return (PowerModeQualificationStatus) getObject(PowerModeQualificationStatus.class, KEY_POWER_MODE_QUALIFICATION_STATUS);
}
public void setCarModeStatus(CarModeStatus carModeStatus) {
- if (carModeStatus != null) {
- store.put(KEY_CAR_MODE_STATUS, carModeStatus);
- } else {
- store.remove(KEY_CAR_MODE_STATUS);
- }
+ setValue(KEY_CAR_MODE_STATUS, carModeStatus);
}
public CarModeStatus getCarModeStatus() {
- Object obj = store.get(KEY_CAR_MODE_STATUS);
- if (obj instanceof CarModeStatus) {
- return (CarModeStatus) obj;
- } else if (obj instanceof String) {
- return CarModeStatus.valueForString((String) obj);
- }
- return null;
+ return (CarModeStatus) getObject(CarModeStatus.class, KEY_CAR_MODE_STATUS);
}
public void setPowerModeStatus(PowerModeStatus powerModeStatus) {
- if (powerModeStatus != null) {
- store.put(KEY_POWER_MODE_STATUS, powerModeStatus);
- } else {
- store.remove(KEY_POWER_MODE_STATUS);
- }
+ setValue(KEY_POWER_MODE_STATUS, powerModeStatus);
}
public PowerModeStatus getPowerModeStatus() {
- Object obj = store.get(KEY_POWER_MODE_STATUS);
- if (obj instanceof PowerModeStatus) {
- return (PowerModeStatus) obj;
- } else if (obj instanceof String) {
- return PowerModeStatus.valueForString((String) obj);
- }
- return null;
+ return (PowerModeStatus) getObject(PowerModeStatus.class, KEY_POWER_MODE_STATUS);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java
index 7e899168c..433f9540b 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Coordinate.java
@@ -17,28 +17,20 @@ public class Coordinate extends RPCStruct{
}
public Float getLatitudeDegrees() {
- Object value = store.get(KEY_LATITUDE_DEGREES);
+ Object value = getValue(KEY_LATITUDE_DEGREES);
return SdlDataTypeConverter.objectToFloat(value);
}
public void setLatitudeDegrees(Float latitudeDegrees) {
- if (latitudeDegrees != null) {
- store.put(KEY_LATITUDE_DEGREES, latitudeDegrees);
- } else {
- store.remove(KEY_LATITUDE_DEGREES);
- }
+ setValue(KEY_LATITUDE_DEGREES, latitudeDegrees);
}
public Float getLongitudeDegrees() {
- Object value = store.get(KEY_LONGITUDE_DEGREES);
+ Object value = getValue(KEY_LONGITUDE_DEGREES);
return SdlDataTypeConverter.objectToFloat(value);
}
public void setLongitudeDegrees(Float longitudeDegrees) {
- if (longitudeDegrees != null) {
- store.put(KEY_LONGITUDE_DEGREES, longitudeDegrees);
- } else {
- store.remove(KEY_LONGITUDE_DEGREES);
- }
+ setValue(KEY_LONGITUDE_DEGREES, longitudeDegrees);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java
index 97793558f..dc813d048 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/CreateInteractionChoiceSet.java
@@ -1,12 +1,11 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* Creates a Choice Set which can be used in subsequent <i>
* {@linkplain PerformInteraction}</i> Operations.
@@ -100,7 +99,7 @@ public class CreateInteractionChoiceSet extends RPCRequest {
* @return Integer -an Integer representing the Choice Set ID
*/
public Integer getInteractionChoiceSetID() {
- return (Integer) parameters.get( KEY_INTERACTION_CHOICE_SET_ID );
+ return getInteger( KEY_INTERACTION_CHOICE_SET_ID );
}
/**
* Sets a unique ID that identifies the Choice Set
@@ -111,11 +110,7 @@ public class CreateInteractionChoiceSet extends RPCRequest {
* <b>Notes: </b>Min Value: 0; Max Value: 2000000000
*/
public void setInteractionChoiceSetID( Integer interactionChoiceSetID ) {
- if (interactionChoiceSetID != null) {
- parameters.put(KEY_INTERACTION_CHOICE_SET_ID, interactionChoiceSetID );
- } else {
- parameters.remove(KEY_INTERACTION_CHOICE_SET_ID);
- }
+ setParameters(KEY_INTERACTION_CHOICE_SET_ID, interactionChoiceSetID);
}
/**
* Gets Choice Set Array of one or more elements
@@ -125,22 +120,7 @@ public class CreateInteractionChoiceSet extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<Choice> getChoiceSet() {
- 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;
- }
- }
- }
- return null;
+ return (List<Choice>) getObject(Choice.class, KEY_CHOICE_SET);
}
/**
* Sets a Choice Set that is an Array of one or more elements
@@ -152,10 +132,6 @@ public class CreateInteractionChoiceSet extends RPCRequest {
* <b>Notes: </b>Min Value: 1; Max Value: 100
*/
public void setChoiceSet( List<Choice> choiceSet ) {
- if (choiceSet != null) {
- parameters.put(KEY_CHOICE_SET, choiceSet );
- } else {
- parameters.remove(KEY_CHOICE_SET);
- }
+ setParameters(KEY_CHOICE_SET, choiceSet);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java
index 84afe2a70..cd9d24c78 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DIDResult.java
@@ -59,39 +59,21 @@ public class DIDResult extends RPCStruct {
super(hash);
}
public void setResultCode(VehicleDataResultCode resultCode) {
- if (resultCode != null) {
- store.put(KEY_RESULT_CODE, resultCode);
- } else {
- store.remove(KEY_RESULT_CODE);
- }
+ setValue(KEY_RESULT_CODE, resultCode);
}
public VehicleDataResultCode getResultCode() {
- Object obj = store.get(KEY_RESULT_CODE);
- if (obj instanceof VehicleDataResultCode) {
- return (VehicleDataResultCode) obj;
- } else if (obj instanceof String) {
- return VehicleDataResultCode.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataResultCode) getObject(VehicleDataResultCode.class, KEY_RESULT_CODE);
}
public void setDidLocation(Integer didLocation) {
- if (didLocation != null) {
- store.put(KEY_DID_LOCATION, didLocation);
- } else {
- store.remove(KEY_DID_LOCATION);
- }
+ setValue(KEY_DID_LOCATION, didLocation);
}
public Integer getDidLocation() {
- return (Integer) store.get(KEY_DID_LOCATION);
+ return getInteger(KEY_DID_LOCATION);
}
public void setData(String data) {
- if (data != null) {
- store.put(KEY_DATA, data);
- } else {
- store.remove(KEY_DATA);
- }
+ setValue(KEY_DATA, data);
}
public String getData() {
- return (String) store.get(KEY_DATA);
+ return getString(KEY_DATA);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java
index e8ff471d8..57595672e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DTC.java
@@ -1,9 +1,9 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+
/**
* String containing hexadecimal identifier as well as other common names.
* <p><b>Parameter List</b></p>
@@ -48,11 +48,7 @@ public class DTC extends RPCStruct {
* @param identifier
*/
public void setIdentifier(String identifier) {
- if (identifier != null) {
- store.put(KEY_IDENTIFIER, identifier);
- } else {
- store.remove(KEY_IDENTIFIER);
- }
+ setValue(KEY_IDENTIFIER, identifier);
}
/**
@@ -60,7 +56,7 @@ public class DTC extends RPCStruct {
* @return identifier
*/
public String getIdentifier() {
- return (String) store.get(KEY_IDENTIFIER);
+ return getString(KEY_IDENTIFIER);
}
/**
@@ -68,11 +64,7 @@ public class DTC extends RPCStruct {
* @param statusByte Hexadecimal byte string
*/
public void setStatusByte(String statusByte) {
- if (statusByte != null) {
- store.put(KEY_STATUS_BYTE, statusByte);
- } else {
- store.remove(KEY_STATUS_BYTE);
- }
+ setValue(KEY_STATUS_BYTE, statusByte);
}
/**
@@ -80,6 +72,6 @@ public class DTC extends RPCStruct {
* @return Hexadecimal byte string
*/
public String getStatusByte() {
- return (String) store.get(KEY_STATUS_BYTE);
+ return getString(KEY_STATUS_BYTE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java
index aeb302ffb..1c3af0e88 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DateTime.java
@@ -30,7 +30,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getMilliSecond() {
- return (Integer) store.get(KEY_MILLISECOND);
+ return getInteger(KEY_MILLISECOND);
}
/**
@@ -41,11 +41,7 @@ public class DateTime extends RPCStruct{
*
*/
public void setMilliSecond(Integer milliSecond) {
- if (milliSecond != null) {
- store.put(KEY_MILLISECOND, milliSecond);
- } else {
- store.remove(KEY_MILLISECOND);
- }
+ setValue(KEY_MILLISECOND, milliSecond);
}
@@ -56,7 +52,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getSecond() {
- return (Integer) store.get(KEY_SECOND);
+ return getInteger(KEY_SECOND);
}
/**
@@ -67,11 +63,7 @@ public class DateTime extends RPCStruct{
*
*/
public void setSecond(Integer second) {
- if (second != null) {
- store.put(KEY_SECOND, second);
- } else {
- store.remove(KEY_SECOND);
- }
+ setValue(KEY_SECOND, second);
}
@@ -82,7 +74,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getMinute() {
- return (Integer) store.get(KEY_MINUTE);
+ return getInteger(KEY_MINUTE);
}
/**
@@ -93,11 +85,7 @@ public class DateTime extends RPCStruct{
*
*/
public void setMinute(Integer minute) {
- if (minute != null) {
- store.put(KEY_MINUTE, minute);
- } else {
- store.remove(KEY_MINUTE);
- }
+ setValue(KEY_MINUTE, minute);
}
/**
@@ -107,7 +95,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getHour() {
- return (Integer) store.get(KEY_HOUR);
+ return getInteger(KEY_HOUR);
}
/**
@@ -118,11 +106,7 @@ public class DateTime extends RPCStruct{
*
*/
public void setHour(Integer hour) {
- if (hour != null) {
- store.put(KEY_HOUR, hour);
- } else {
- store.remove(KEY_HOUR);
- }
+ setValue(KEY_HOUR, hour);
}
/**
@@ -132,7 +116,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getDay() {
- return (Integer) store.get(KEY_DAY);
+ return getInteger(KEY_DAY);
}
/**
@@ -143,11 +127,7 @@ public class DateTime extends RPCStruct{
*
*/
public void setDay(Integer day) {
- if (day != null) {
- store.put(KEY_DAY, day);
- } else {
- store.remove(KEY_DAY);
- }
+ setValue(KEY_DAY, day);
}
/**
@@ -157,7 +137,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getMonth() {
- return (Integer) store.get(KEY_MONTH);
+ return getInteger(KEY_MONTH);
}
/**
@@ -168,11 +148,7 @@ public class DateTime extends RPCStruct{
*
*/
public void setMonth(Integer month) {
- if (month != null) {
- store.put(KEY_MONTH, month);
- } else {
- store.remove(KEY_MONTH);
- }
+ setValue(KEY_MONTH, month);
}
/**
@@ -182,7 +158,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getYear() {
- return (Integer) store.get(KEY_YEAR);
+ return getInteger(KEY_YEAR);
}
/**
@@ -193,11 +169,7 @@ public class DateTime extends RPCStruct{
*
*/
public void setYear(Integer year) {
- if (year != null) {
- store.put(KEY_YEAR, year);
- } else {
- store.remove(KEY_YEAR);
- }
+ setValue(KEY_YEAR, year);
}
/**
@@ -207,7 +179,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getTzHour() {
- return (Integer) store.get(KEY_TZ_HOUR);
+ return getInteger(KEY_TZ_HOUR);
}
/**
@@ -218,11 +190,7 @@ public class DateTime extends RPCStruct{
*
*/
public void setTzHour(Integer tzHour) {
- if (tzHour != null) {
- store.put(KEY_TZ_HOUR, tzHour);
- } else {
- store.remove(KEY_TZ_HOUR);
- }
+ setValue(KEY_TZ_HOUR, tzHour);
}
/**
@@ -232,7 +200,7 @@ public class DateTime extends RPCStruct{
*
*/
public Integer getTzMinute() {
- return (Integer) store.get(KEY_TZ_MINUTE);
+ return getInteger(KEY_TZ_MINUTE);
}
/**
@@ -242,10 +210,6 @@ public class DateTime extends RPCStruct{
* The time zone offset in Minutes with regard to UTC associated with this DateTime class
*/
public void setTzMinute(Integer tzMinute) {
- if (tzMinute != null) {
- store.put(KEY_TZ_MINUTE, tzMinute);
- } else {
- store.remove(KEY_TZ_MINUTE);
- }
+ setValue(KEY_TZ_MINUTE, tzMinute);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java
index 635f85814..5c5820fbd 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteCommand.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* Removes a command from the Command Menu.
*
@@ -80,7 +80,7 @@ public class DeleteCommand extends RPCRequest {
* the Command to be deleted from Command Menu
*/
public Integer getCmdID() {
- return (Integer) parameters.get( KEY_CMD_ID );
+ return getInteger( KEY_CMD_ID );
}
/**
* Sets the Command ID that identifies the Command to be deleted from Command Menu
@@ -91,10 +91,6 @@ public class DeleteCommand extends RPCRequest {
* <p><b>Notes: </b>Min Value: 0; Max Value: 2000000000</p>
*/
public void setCmdID( Integer cmdID ) {
- if (cmdID != null) {
- parameters.put(KEY_CMD_ID, cmdID );
- } else {
- parameters.remove(KEY_CMD_ID);
- }
+ setParameters(KEY_CMD_ID, cmdID);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java
index 4d35c6fd3..7be0e7859 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFile.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* Used to delete a file resident on the SDL module in the app's local cache.
* Not supported on first generation SDL vehicles
@@ -71,11 +71,7 @@ public class DeleteFile extends RPCRequest {
* a String value representing a file reference name
*/
public void setSdlFileName(String sdlFileName) {
- if (sdlFileName != null) {
- parameters.put(KEY_SDL_FILE_NAME, sdlFileName);
- } else {
- parameters.remove(KEY_SDL_FILE_NAME);
- }
+ setParameters(KEY_SDL_FILE_NAME, sdlFileName);
}
/**
@@ -84,6 +80,6 @@ public class DeleteFile extends RPCRequest {
* @return String -a String value representing a file reference name
*/
public String getSdlFileName() {
- return (String) parameters.get(KEY_SDL_FILE_NAME);
+ return getString(KEY_SDL_FILE_NAME);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java
index 9916b95dc..499b5e518 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteFileResponse.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
+import java.util.Hashtable;
+
/**
* Delete File Response is sent, when DeleteFile has been called
*
@@ -23,13 +23,9 @@ public class DeleteFileResponse extends RPCResponse {
super(hash);
}
public void setSpaceAvailable(Integer spaceAvailable) {
- if (spaceAvailable != null) {
- parameters.put(KEY_SPACE_AVAILABLE, spaceAvailable);
- } else {
- parameters.remove(KEY_SPACE_AVAILABLE);
- }
+ setParameters(KEY_SPACE_AVAILABLE, spaceAvailable);
}
public Integer getSpaceAvailable() {
- return (Integer) parameters.get(KEY_SPACE_AVAILABLE);
+ return getInteger(KEY_SPACE_AVAILABLE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java
index 87f8cdbc3..41e884bce 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteInteractionChoiceSet.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* Deletes an existing Choice Set identified by the parameter
* interactionChoiceSetID. If the specified interactionChoiceSetID is currently
@@ -83,7 +83,7 @@ public class DeleteInteractionChoiceSet extends RPCRequest {
* @return Integer -an Integer value representing the unique Choice Set ID
*/
public Integer getInteractionChoiceSetID() {
- return (Integer) parameters.get( KEY_INTERACTION_CHOICE_SET_ID );
+ return getInteger( KEY_INTERACTION_CHOICE_SET_ID );
}
/**
* Sets a unique ID that identifies the Choice Set
@@ -91,10 +91,6 @@ public class DeleteInteractionChoiceSet extends RPCRequest {
* <p><b>Notes: </b>Min Value: 0; Max Value: 2000000000 </p>
*/
public void setInteractionChoiceSetID( Integer interactionChoiceSetID ) {
- if (interactionChoiceSetID != null) {
- parameters.put(KEY_INTERACTION_CHOICE_SET_ID, interactionChoiceSetID );
- } else {
- parameters.remove(KEY_INTERACTION_CHOICE_SET_ID);
- }
+ setParameters(KEY_INTERACTION_CHOICE_SET_ID, interactionChoiceSetID);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java
index aac605f51..db3524aa1 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeleteSubMenu.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* Deletes a submenu from the Command Menu.
*
@@ -72,7 +72,7 @@ public class DeleteSubMenu extends RPCRequest {
* @return Integer -an Integer value representing menuID that identifies the SubMenu to be delete
*/
public Integer getMenuID() {
- return (Integer) parameters.get( KEY_MENU_ID );
+ return getInteger( KEY_MENU_ID );
}
/**
* Sets the MenuID that identifies the SubMenu to be delete
@@ -81,10 +81,6 @@ public class DeleteSubMenu extends RPCRequest {
* <p><b>Notes: </b>Min Value: 0; Max Value: 2000000000</p>
*/
public void setMenuID( Integer menuID ) {
- if (menuID != null) {
- parameters.put(KEY_MENU_ID, menuID );
- } else {
- parameters.remove(KEY_MENU_ID);
- }
+ setParameters(KEY_MENU_ID, menuID);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java
index b7d8ea5cf..485d859b7 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceInfo.java
@@ -95,76 +95,51 @@ public class DeviceInfo extends RPCStruct{
}
public void setHardware(String hardware) {
- if (hardware != null) {
- store.put(KEY_HARDWARE, hardware);
- } else {
- store.remove(KEY_HARDWARE);
- }
+ setValue(KEY_HARDWARE, hardware);
}
public String getHardware() {
- return (String) store.get(KEY_HARDWARE);
+ return getString(KEY_HARDWARE);
}
public void setFirmwareRev(String firmwareRev) {
- if (firmwareRev != null) {
- store.put(KEY_FIRMWARE_REV, firmwareRev);
- } else {
- store.remove(KEY_FIRMWARE_REV);
- }
+ setValue(KEY_FIRMWARE_REV, firmwareRev);
}
public String getFirmwareRev() {
- return (String) store.get(KEY_FIRMWARE_REV);
+ return getString(KEY_FIRMWARE_REV);
}
public void setOs(String os) {
- if (os != null) {
- store.put(KEY_OS, os);
- } else {
- store.remove(KEY_OS);
- }
+ setValue(KEY_OS, os);
}
public String getOs() {
- return (String) store.get(KEY_OS);
+ return getString(KEY_OS);
}
public void setOsVersion(String osVersion) {
- if (osVersion != null) {
- store.put(KEY_OS_VERSION, osVersion);
- } else {
- store.remove(KEY_OS_VERSION);
- }
+ setValue(KEY_OS_VERSION, osVersion);
}
public String getOsVersion() {
- return (String) store.get(KEY_OS_VERSION);
+ return getString(KEY_OS_VERSION);
}
public void setCarrier(String carrier) {
- if (carrier != null) {
- store.put(KEY_CARRIER, carrier);
- } else {
- store.remove(KEY_CARRIER);
- }
+ setValue(KEY_CARRIER, carrier);
}
public String getCarrier() {
- return (String) store.get(KEY_CARRIER);
+ return getString(KEY_CARRIER);
}
public Integer getMaxNumberRFCOMMPorts() {
- return (Integer) store.get( KEY_MAX_NUMBER_RFCOMM_PORTS );
+ return getInteger( KEY_MAX_NUMBER_RFCOMM_PORTS );
}
public void setMaxNumberRFCOMMPorts( Integer maxNumberRFCOMMPorts ) {
- if (maxNumberRFCOMMPorts != null) {
- store.put(KEY_MAX_NUMBER_RFCOMM_PORTS, maxNumberRFCOMMPorts );
- }
- else {
- store.remove(KEY_MAX_NUMBER_RFCOMM_PORTS);
- }
+ setValue(KEY_MAX_NUMBER_RFCOMM_PORTS, maxNumberRFCOMMPorts);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java
index 51d5304b4..d90c4631f 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DeviceStatus.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.DeviceLevelStatus;
import com.smartdevicelink.proxy.rpc.enums.PrimaryAudioSource;
+import java.util.Hashtable;
+
/**
* Describes the status related to a connected mobile device or SDL and if or how it is represented in the vehicle.
* <p><b>Parameter List</b></p>
@@ -132,11 +132,7 @@ public class DeviceStatus extends RPCStruct {
* @param voiceRecOn
*/
public void setVoiceRecOn(Boolean voiceRecOn) {
- if (voiceRecOn != null) {
- store.put(KEY_VOICE_REC_ON, voiceRecOn);
- } else {
- store.remove(KEY_VOICE_REC_ON);
- }
+ setValue(KEY_VOICE_REC_ON, voiceRecOn);
}
/**
@@ -144,7 +140,7 @@ public class DeviceStatus extends RPCStruct {
* @return whether the voice recognition is on
*/
public Boolean getVoiceRecOn() {
- return (Boolean) store.get(KEY_VOICE_REC_ON);
+ return getBoolean(KEY_VOICE_REC_ON);
}
/**
@@ -152,11 +148,7 @@ public class DeviceStatus extends RPCStruct {
* @param btIconOn the bluetooth connection established
*/
public void setBtIconOn(Boolean btIconOn) {
- if (btIconOn != null) {
- store.put(KEY_BT_ICON_ON, btIconOn);
- } else {
- store.remove(KEY_BT_ICON_ON);
- }
+ setValue(KEY_BT_ICON_ON, btIconOn);
}
/**
@@ -164,7 +156,7 @@ public class DeviceStatus extends RPCStruct {
* @return the bluetooth connection established
*/
public Boolean getBtIconOn() {
- return (Boolean) store.get(KEY_BT_ICON_ON);
+ return getBoolean(KEY_BT_ICON_ON);
}
/**
@@ -172,11 +164,7 @@ public class DeviceStatus extends RPCStruct {
* @param callActive a call is being active
*/
public void setCallActive(Boolean callActive) {
- if (callActive != null) {
- store.put(KEY_CALL_ACTIVE, callActive);
- } else {
- store.remove(KEY_CALL_ACTIVE);
- }
+ setValue(KEY_CALL_ACTIVE, callActive);
}
/**
@@ -184,7 +172,7 @@ public class DeviceStatus extends RPCStruct {
* @return a call is being active
*/
public Boolean getCallActive() {
- return (Boolean) store.get(KEY_CALL_ACTIVE);
+ return getBoolean(KEY_CALL_ACTIVE);
}
/**
@@ -192,11 +180,7 @@ public class DeviceStatus extends RPCStruct {
* @param phoneRoaming the phone is in roaming mode
*/
public void setPhoneRoaming(Boolean phoneRoaming) {
- if (phoneRoaming != null) {
- store.put(KEY_PHONE_ROAMING, phoneRoaming);
- } else {
- store.remove(KEY_PHONE_ROAMING);
- }
+ setValue(KEY_PHONE_ROAMING, phoneRoaming);
}
/**
@@ -204,14 +188,10 @@ public class DeviceStatus extends RPCStruct {
* @return the phone is in roaming mode
*/
public Boolean getPhoneRoaming() {
- return (Boolean) store.get(KEY_PHONE_ROAMING);
+ return getBoolean(KEY_PHONE_ROAMING);
}
public void setTextMsgAvailable(Boolean textMsgAvailable) {
- if (textMsgAvailable != null) {
- store.put(KEY_TEXT_MSG_AVAILABLE, textMsgAvailable);
- } else {
- store.remove(KEY_TEXT_MSG_AVAILABLE);
- }
+ setValue(KEY_TEXT_MSG_AVAILABLE, textMsgAvailable);
}
/**
@@ -219,7 +199,7 @@ public class DeviceStatus extends RPCStruct {
* @return a textmessage is available
*/
public Boolean getTextMsgAvailable() {
- return (Boolean) store.get(KEY_TEXT_MSG_AVAILABLE);
+ return getBoolean(KEY_TEXT_MSG_AVAILABLE);
}
/**
@@ -227,11 +207,7 @@ public class DeviceStatus extends RPCStruct {
* @param battLevelStatus battery level status
*/
public void setBattLevelStatus(DeviceLevelStatus battLevelStatus) {
- if (battLevelStatus != null) {
- store.put(KEY_BATT_LEVEL_STATUS, battLevelStatus);
- } else {
- store.remove(KEY_BATT_LEVEL_STATUS);
- }
+ setValue(KEY_BATT_LEVEL_STATUS, battLevelStatus);
}
/**
@@ -239,13 +215,7 @@ public class DeviceStatus extends RPCStruct {
* @return battery level status
*/
public DeviceLevelStatus getBattLevelStatus() {
- Object obj = store.get(KEY_BATT_LEVEL_STATUS);
- if (obj instanceof DeviceLevelStatus) {
- return (DeviceLevelStatus) obj;
- } else if (obj instanceof String) {
- return DeviceLevelStatus.valueForString((String) obj);
- }
- return null;
+ return (DeviceLevelStatus) getObject(DeviceLevelStatus.class, KEY_BATT_LEVEL_STATUS);
}
/**
@@ -253,11 +223,7 @@ public class DeviceStatus extends RPCStruct {
* @param stereoAudioOutputMuted the status of the stereo audio output channel
*/
public void setStereoAudioOutputMuted(Boolean stereoAudioOutputMuted) {
- if (stereoAudioOutputMuted != null) {
- store.put(KEY_STEREO_AUDIO_OUTPUT_MUTED, stereoAudioOutputMuted);
- } else {
- store.remove(KEY_STEREO_AUDIO_OUTPUT_MUTED);
- }
+ setValue(KEY_STEREO_AUDIO_OUTPUT_MUTED, stereoAudioOutputMuted);
}
/**
@@ -265,7 +231,7 @@ public class DeviceStatus extends RPCStruct {
* @return the status of the stereo audio output channel
*/
public Boolean getStereoAudioOutputMuted() {
- return (Boolean) store.get(KEY_STEREO_AUDIO_OUTPUT_MUTED);
+ return getBoolean(KEY_STEREO_AUDIO_OUTPUT_MUTED);
}
/**
@@ -273,11 +239,7 @@ public class DeviceStatus extends RPCStruct {
* @param monoAudioOutputMuted the status of the mono audio output channel
*/
public void setMonoAudioOutputMuted(Boolean monoAudioOutputMuted) {
- if (monoAudioOutputMuted != null) {
- store.put(KEY_MONO_AUDIO_OUTPUT_MUTED, monoAudioOutputMuted);
- } else {
- store.remove(KEY_MONO_AUDIO_OUTPUT_MUTED);
- }
+ setValue(KEY_MONO_AUDIO_OUTPUT_MUTED, monoAudioOutputMuted);
}
/**
@@ -285,7 +247,7 @@ public class DeviceStatus extends RPCStruct {
* @return the status of the mono audio output channel
*/
public Boolean getMonoAudioOutputMuted() {
- return (Boolean) store.get(KEY_MONO_AUDIO_OUTPUT_MUTED);
+ return getBoolean(KEY_MONO_AUDIO_OUTPUT_MUTED);
}
/**
@@ -293,11 +255,7 @@ public class DeviceStatus extends RPCStruct {
* @param signalLevelStatus signal level status
*/
public void setSignalLevelStatus(DeviceLevelStatus signalLevelStatus) {
- if (signalLevelStatus != null) {
- store.put(KEY_SIGNAL_LEVEL_STATUS, signalLevelStatus);
- } else {
- store.remove(KEY_SIGNAL_LEVEL_STATUS);
- }
+ setValue(KEY_SIGNAL_LEVEL_STATUS, signalLevelStatus);
}
/**
@@ -305,13 +263,7 @@ public class DeviceStatus extends RPCStruct {
* @return signal level status
*/
public DeviceLevelStatus getSignalLevelStatus() {
- Object obj = store.get(KEY_SIGNAL_LEVEL_STATUS);
- if (obj instanceof DeviceLevelStatus) {
- return (DeviceLevelStatus) obj;
- } else if (obj instanceof String) {
- return DeviceLevelStatus.valueForString((String) obj);
- }
- return null;
+ return (DeviceLevelStatus) getObject(DeviceLevelStatus.class, KEY_SIGNAL_LEVEL_STATUS);
}
/**
@@ -319,11 +271,7 @@ public class DeviceStatus extends RPCStruct {
* @param primaryAudioSource the current primary audio source of SDL (if selected).
*/
public void setPrimaryAudioSource(PrimaryAudioSource primaryAudioSource) {
- if (primaryAudioSource != null) {
- store.put(KEY_PRIMARY_AUDIO_SOURCE, primaryAudioSource);
- } else {
- store.remove(KEY_PRIMARY_AUDIO_SOURCE);
- }
+ setValue(KEY_PRIMARY_AUDIO_SOURCE, primaryAudioSource);
}
/**
@@ -331,22 +279,12 @@ public class DeviceStatus extends RPCStruct {
* @return the current primary audio source of SDL (if selected).
*/
public PrimaryAudioSource getPrimaryAudioSource() {
- Object obj = store.get(KEY_PRIMARY_AUDIO_SOURCE);
- if (obj instanceof PrimaryAudioSource) {
- return (PrimaryAudioSource) obj;
- } else if (obj instanceof String) {
- return PrimaryAudioSource.valueForString((String) obj);
- }
- return null;
+ return (PrimaryAudioSource) getObject(PrimaryAudioSource.class, KEY_PRIMARY_AUDIO_SOURCE);
}
public void setECallEventActive(Boolean eCallEventActive) {
- if (eCallEventActive != null) {
- store.put(KEY_E_CALL_EVENT_ACTIVE, eCallEventActive);
- } else {
- store.remove(KEY_E_CALL_EVENT_ACTIVE);
- }
+ setValue(KEY_E_CALL_EVENT_ACTIVE, eCallEventActive);
}
public Boolean getECallEventActive() {
- return (Boolean) store.get(KEY_E_CALL_EVENT_ACTIVE);
+ return getBoolean(KEY_E_CALL_EVENT_ACTIVE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java
index 0a0d8f997..f83c07735 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessage.java
@@ -1,10 +1,11 @@
package com.smartdevicelink.proxy.rpc;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+
import java.util.Hashtable;
import java.util.List;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.RPCRequest;
/** Non periodic vehicle diagnostic request.
*
* <p><b>Parameter List</b></p>
@@ -81,11 +82,7 @@ public class DiagnosticMessage extends RPCRequest {
public void setTargetID(Integer targetID) {
- if (targetID != null) {
- parameters.put(KEY_TARGET_ID, targetID);
- } else {
- parameters.remove(KEY_TARGET_ID);
- }
+ setParameters(KEY_TARGET_ID, targetID);
}
/**
* <p>
@@ -96,39 +93,22 @@ public class DiagnosticMessage extends RPCRequest {
*/
public Integer getTargetID() {
- return (Integer) parameters.get(KEY_TARGET_ID);
+ return getInteger(KEY_TARGET_ID);
}
public void setMessageLength(Integer messageLength) {
- if (messageLength != null) {
- parameters.put(KEY_MESSAGE_LENGTH, messageLength);
- } else {
- parameters.remove(KEY_MESSAGE_LENGTH);
- }
+ setParameters(KEY_MESSAGE_LENGTH, messageLength);
}
public Integer getMessageLength() {
- return (Integer) parameters.get(KEY_MESSAGE_LENGTH);
+ return getInteger(KEY_MESSAGE_LENGTH);
}
@SuppressWarnings("unchecked")
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;
- }
- }
- }
- return null;
+ return (List<Integer>) getObject(Integer.class, KEY_MESSAGE_DATA);
}
public void setMessageData(List<Integer> messageData) {
- if (messageData != null) {
- parameters.put(KEY_MESSAGE_DATA, messageData);
- } else {
- parameters.remove(KEY_MESSAGE_DATA);
- }
+ setParameters(KEY_MESSAGE_DATA, messageData);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
index 8cb0bc8d4..c478496f7 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DiagnosticMessageResponse.java
@@ -1,10 +1,11 @@
package com.smartdevicelink.proxy.rpc;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCResponse;
+
import java.util.Hashtable;
import java.util.List;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.RPCResponse;
/**
* Diagnostic Message Response is sent, when DiagnosticMessage has been called.
*
@@ -24,23 +25,10 @@ public class DiagnosticMessageResponse extends RPCResponse {
}
@SuppressWarnings("unchecked")
public List<Integer> getMessageDataResult() {
- 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;
- }
- }
- }
- return null;
+ return (List<Integer>) getObject(Integer.class, KEY_MESSAGE_DATA_RESULT);
}
public void setMessageDataResult(List<Integer> messageDataResult) {
- if (messageDataResult != null) {
- parameters.put(KEY_MESSAGE_DATA_RESULT, messageDataResult);
- } else {
- parameters.remove(KEY_MESSAGE_DATA_RESULT);
- }
+ setParameters(KEY_MESSAGE_DATA_RESULT, messageDataResult);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java
index 4651e1f20..4afc68a0c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DialNumber.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* Dials a phone number and switches to phone application.
*
@@ -34,10 +34,8 @@ public class DialNumber extends RPCRequest {
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);
}
+ setParameters(KEY_NUMBER, number);
}
/**
@@ -46,6 +44,6 @@ public class DialNumber extends RPCRequest {
* @return String - a String value representing a number to dial
*/
public String getNumber() {
- return (String) parameters.get(KEY_NUMBER);
+ return getString(KEY_NUMBER);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
index f0739e371..69928a128 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/DisplayCapabilities.java
@@ -1,13 +1,14 @@
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.proxy.rpc.enums.VehicleDataResultCode;
import com.smartdevicelink.util.DebugTool;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
/**
* Contains information about the display for the SDL system to which the application is currently connected.
* <p><b> Parameter List</b></p>
@@ -78,24 +79,14 @@ public class DisplayCapabilities extends RPCStruct {
* @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;
+ return (DisplayType) getObject(DisplayType.class, KEY_DISPLAY_TYPE);
}
/**
* 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);
- }
+ setValue(KEY_DISPLAY_TYPE, displayType);
}
/**
*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.
@@ -104,22 +95,7 @@ public class DisplayCapabilities extends RPCStruct {
*/
@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;
+ return (List<TextField>) getObject(TextField.class, KEY_TEXT_FIELDS);
}
/**
* 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.
@@ -127,57 +103,26 @@ public class DisplayCapabilities extends RPCStruct {
* @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);
- }
+ setValue(KEY_TEXT_FIELDS, textFields);
}
@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;
+ return (List<ImageField>) getObject(ImageField.class, KEY_IMAGE_FIELDS);
}
public void setImageFields( List<ImageField> imageFields ) {
- if (imageFields != null) {
- store.put(KEY_IMAGE_FIELDS, imageFields );
- }
- else
- {
- store.remove(KEY_IMAGE_FIELDS);
- }
+ setValue(KEY_IMAGE_FIELDS, imageFields);
}
public Integer getNumCustomPresetsAvailable() {
- return (Integer) store.get(KEY_NUM_CUSTOM_PRESETS_AVAILABLE);
+ return getInteger(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);
- }
+ setValue(KEY_NUM_CUSTOM_PRESETS_AVAILABLE, numCustomPresetsAvailable);
}
/**
@@ -186,37 +131,14 @@ public class DisplayCapabilities extends RPCStruct {
*/
@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 = MediaClockFormat.valueForString(strFormat);
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<MediaClockFormat>) getObject(MediaClockFormat.class, KEY_MEDIA_CLOCK_FORMATS);
}
/**
* 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);
- }
+ setValue(KEY_MEDIA_CLOCK_FORMATS, mediaClockFormats);
}
/**
@@ -225,11 +147,7 @@ public class DisplayCapabilities extends RPCStruct {
* @since SmartDeviceLink 2.0
*/
public void setGraphicSupported(Boolean graphicSupported) {
- if (graphicSupported != null) {
- store.put(KEY_GRAPHIC_SUPPORTED, graphicSupported);
- } else {
- store.remove(KEY_GRAPHIC_SUPPORTED);
- }
+ setValue(KEY_GRAPHIC_SUPPORTED, graphicSupported);
}
/**
@@ -238,53 +156,24 @@ public class DisplayCapabilities extends RPCStruct {
* @since SmartDeviceLink 2.0
*/
public Boolean getGraphicSupported() {
- return (Boolean) store.get(KEY_GRAPHIC_SUPPORTED);
+ return getBoolean(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;
+ return (List<String>) getObject(String.class, KEY_TEMPLATES_AVAILABLE);
}
public void setTemplatesAvailable(List<String> templatesAvailable) {
- if (templatesAvailable != null) {
- store.put(KEY_TEMPLATES_AVAILABLE, templatesAvailable);
- }
- else
- {
- store.remove(KEY_TEMPLATES_AVAILABLE);
- }
+ setValue(KEY_TEMPLATES_AVAILABLE, templatesAvailable);
}
public void setScreenParams(ScreenParams screenParams) {
- if (screenParams != null) {
- store.put(KEY_SCREEN_PARAMS, screenParams);
- } else {
- store.remove(KEY_SCREEN_PARAMS);
- }
+ setValue(KEY_SCREEN_PARAMS, screenParams);
}
@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) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SCREEN_PARAMS, e);
- }
- }
- return null;
+ return (ScreenParams) getObject(ScreenParams.class, KEY_SCREEN_PARAMS);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java
index 88eb89e03..da6c37d9a 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ECallInfo.java
@@ -1,10 +1,12 @@
package com.smartdevicelink.proxy.rpc;
-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.proxy.rpc.enums.VehicleDataResultCode;
+
+import java.util.Hashtable;
+
/** Emergency Call notification and confirmation data.
*
* <p><b>Parameter List</b></p>
@@ -67,51 +69,21 @@ public class ECallInfo extends RPCStruct {
}
public void setECallNotificationStatus(VehicleDataNotificationStatus eCallNotificationStatus) {
- if (eCallNotificationStatus != null) {
- store.put(KEY_E_CALL_NOTIFICATION_STATUS, eCallNotificationStatus);
- } else {
- store.remove(KEY_E_CALL_NOTIFICATION_STATUS);
- }
+ setValue(KEY_E_CALL_NOTIFICATION_STATUS, eCallNotificationStatus);
}
public VehicleDataNotificationStatus getECallNotificationStatus() {
- Object obj = store.get(KEY_E_CALL_NOTIFICATION_STATUS);
- if (obj instanceof VehicleDataNotificationStatus) {
- return (VehicleDataNotificationStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataNotificationStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataNotificationStatus) getObject(VehicleDataNotificationStatus.class, KEY_E_CALL_NOTIFICATION_STATUS);
}
public void setAuxECallNotificationStatus(VehicleDataNotificationStatus auxECallNotificationStatus) {
- if (auxECallNotificationStatus != null) {
- store.put(KEY_AUX_E_CALL_NOTIFICATION_STATUS, auxECallNotificationStatus);
- } else {
- store.remove(KEY_AUX_E_CALL_NOTIFICATION_STATUS);
- }
+ setValue(KEY_AUX_E_CALL_NOTIFICATION_STATUS, auxECallNotificationStatus);
}
public VehicleDataNotificationStatus getAuxECallNotificationStatus() {
- Object obj = store.get(KEY_AUX_E_CALL_NOTIFICATION_STATUS);
- if (obj instanceof VehicleDataNotificationStatus) {
- return (VehicleDataNotificationStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataNotificationStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataNotificationStatus) getObject(VehicleDataNotificationStatus.class, KEY_AUX_E_CALL_NOTIFICATION_STATUS);
}
public void setECallConfirmationStatus(ECallConfirmationStatus eCallConfirmationStatus) {
- if (eCallConfirmationStatus != null) {
- store.put(KEY_E_CALL_CONFIRMATION_STATUS, eCallConfirmationStatus);
- } else {
- store.remove(KEY_E_CALL_CONFIRMATION_STATUS);
- }
+ setValue(KEY_E_CALL_CONFIRMATION_STATUS, eCallConfirmationStatus);
}
public ECallConfirmationStatus getECallConfirmationStatus() {
- Object obj = store.get(KEY_E_CALL_CONFIRMATION_STATUS);
- if (obj instanceof ECallConfirmationStatus) {
- return (ECallConfirmationStatus) obj;
- } else if (obj instanceof String) {
- return ECallConfirmationStatus.valueForString((String) obj);
- }
- return null;
+ return (ECallConfirmationStatus) getObject(ECallConfirmationStatus.class, KEY_E_CALL_CONFIRMATION_STATUS);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java
index 5e1f2ede1..19b8f69bb 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/EmergencyEvent.java
@@ -6,6 +6,11 @@ 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 static android.provider.Contacts.SettingsColumns.KEY;
+import static com.smartdevicelink.proxy.constants.Names.multipleEvents;
+import static com.smartdevicelink.proxy.rpc.TireStatus.KEY_INNER_RIGHT_REAR;
+
/** Information related to an emergency event (and if it occurred).
*
* <p><b>Parameter List</b></p>
@@ -88,77 +93,33 @@ public class EmergencyEvent extends RPCStruct {
}
public void setEmergencyEventType(EmergencyEventType emergencyEventType) {
- if (emergencyEventType != null) {
- store.put(KEY_EMERGENCY_EVENT_TYPE, emergencyEventType);
- } else {
- store.remove(KEY_EMERGENCY_EVENT_TYPE);
- }
+ setValue(KEY_EMERGENCY_EVENT_TYPE, emergencyEventType);
}
public EmergencyEventType getEmergencyEventType() {
- Object obj = store.get(KEY_EMERGENCY_EVENT_TYPE);
- if (obj instanceof EmergencyEventType) {
- return (EmergencyEventType) obj;
- } else if (obj instanceof String) {
- return EmergencyEventType.valueForString((String) obj);
- }
- return null;
+ return (EmergencyEventType) getObject(EmergencyEventType.class, KEY_EMERGENCY_EVENT_TYPE);
}
public void setFuelCutoffStatus(FuelCutoffStatus fuelCutoffStatus) {
- if (fuelCutoffStatus != null) {
- store.put(KEY_FUEL_CUTOFF_STATUS, fuelCutoffStatus);
- } else {
- store.remove(KEY_FUEL_CUTOFF_STATUS);
- }
+ setValue(KEY_FUEL_CUTOFF_STATUS, fuelCutoffStatus);
}
public FuelCutoffStatus getFuelCutoffStatus() {
- Object obj = store.get(KEY_FUEL_CUTOFF_STATUS);
- if (obj instanceof FuelCutoffStatus) {
- return (FuelCutoffStatus) obj;
- } else if (obj instanceof String) {
- return FuelCutoffStatus.valueForString((String) obj);
- }
- return null;
+ return (FuelCutoffStatus) getObject(FuelCutoffStatus.class, KEY_FUEL_CUTOFF_STATUS);
}
public void setRolloverEvent(VehicleDataEventStatus rolloverEvent) {
- if (rolloverEvent != null) {
- store.put(KEY_ROLLOVER_EVENT, rolloverEvent);
- } else {
- store.remove(KEY_ROLLOVER_EVENT);
- }
+ setValue(KEY_ROLLOVER_EVENT, rolloverEvent);
}
public VehicleDataEventStatus getRolloverEvent() {
- Object obj = store.get(KEY_ROLLOVER_EVENT);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_ROLLOVER_EVENT);
}
public void setMaximumChangeVelocity(Integer maximumChangeVelocity) {
- if (maximumChangeVelocity != null) {
- store.put(KEY_MAXIMUM_CHANGE_VELOCITY, maximumChangeVelocity);
- } else {
- store.remove(KEY_MAXIMUM_CHANGE_VELOCITY);
- }
+ setValue(KEY_MAXIMUM_CHANGE_VELOCITY, maximumChangeVelocity);
}
public Integer getMaximumChangeVelocity() {
- return (Integer) store.get(KEY_MAXIMUM_CHANGE_VELOCITY);
+ return getInteger(KEY_MAXIMUM_CHANGE_VELOCITY);
}
public void setMultipleEvents(VehicleDataEventStatus multipleEvents) {
- if (multipleEvents != null) {
- store.put(KEY_MULTIPLE_EVENTS, multipleEvents);
- } else {
- store.remove(KEY_MULTIPLE_EVENTS);
- }
+ setValue(KEY_MULTIPLE_EVENTS, multipleEvents);
}
public VehicleDataEventStatus getMultipleEvents() {
- Object obj = store.get(KEY_MULTIPLE_EVENTS);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_MULTIPLE_EVENTS);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java
index d76b11355..fec91005b 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GPSData.java
@@ -1,11 +1,12 @@
package com.smartdevicelink.proxy.rpc;
-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.SdlDataTypeConverter;
+
+import java.util.Hashtable;
+
/**
* Describes the GPS data. Not all data will be available on all carlines.
* <p><b>Parameter List</b></p>
@@ -180,11 +181,7 @@ public class GPSData extends RPCStruct {
* @param longitudeDegrees
*/
public void setLongitudeDegrees(Double longitudeDegrees) {
- if (longitudeDegrees != null) {
- store.put(KEY_LONGITUDE_DEGREES, longitudeDegrees);
- } else {
- store.remove(KEY_LONGITUDE_DEGREES);
- }
+ setValue(KEY_LONGITUDE_DEGREES, longitudeDegrees);
}
/**
@@ -192,7 +189,7 @@ public class GPSData extends RPCStruct {
* @return longitude degrees
*/
public Double getLongitudeDegrees() {
- Object object = store.get(KEY_LONGITUDE_DEGREES);
+ Object object = getValue(KEY_LONGITUDE_DEGREES);
return SdlDataTypeConverter.objectToDouble(object);
}
@@ -201,11 +198,7 @@ public class GPSData extends RPCStruct {
* @param latitudeDegrees latitude degrees
*/
public void setLatitudeDegrees(Double latitudeDegrees) {
- if (latitudeDegrees != null) {
- store.put(KEY_LATITUDE_DEGREES, latitudeDegrees);
- } else {
- store.remove(KEY_LATITUDE_DEGREES);
- }
+ setValue(KEY_LATITUDE_DEGREES, latitudeDegrees);
}
/**
@@ -213,7 +206,7 @@ public class GPSData extends RPCStruct {
* @return latitude degrees
*/
public Double getLatitudeDegrees() {
- Object object = store.get(KEY_LATITUDE_DEGREES);
+ Object object = getValue(KEY_LATITUDE_DEGREES);
return SdlDataTypeConverter.objectToDouble(object);
}
@@ -222,11 +215,7 @@ public class GPSData extends RPCStruct {
* @param utcYear utc year
*/
public void setUtcYear(Integer utcYear) {
- if (utcYear != null) {
- store.put(KEY_UTC_YEAR, utcYear);
- } else {
- store.remove(KEY_UTC_YEAR);
- }
+ setValue(KEY_UTC_YEAR, utcYear);
}
/**
@@ -234,7 +223,7 @@ public class GPSData extends RPCStruct {
* @return utc year
*/
public Integer getUtcYear() {
- return (Integer) store.get(KEY_UTC_YEAR);
+ return getInteger(KEY_UTC_YEAR);
}
/**
@@ -242,11 +231,7 @@ public class GPSData extends RPCStruct {
* @param utcMonth utc month
*/
public void setUtcMonth(Integer utcMonth) {
- if (utcMonth != null) {
- store.put(KEY_UTC_MONTH, utcMonth);
- } else {
- store.remove(KEY_UTC_MONTH);
- }
+ setValue(KEY_UTC_MONTH, utcMonth);
}
/**
@@ -254,7 +239,7 @@ public class GPSData extends RPCStruct {
* @return utc month
*/
public Integer getUtcMonth() {
- return (Integer) store.get(KEY_UTC_MONTH);
+ return getInteger(KEY_UTC_MONTH);
}
/**
@@ -262,11 +247,7 @@ public class GPSData extends RPCStruct {
* @param utcDay utc day
*/
public void setUtcDay(Integer utcDay) {
- if (utcDay != null) {
- store.put(KEY_UTC_DAY, utcDay);
- } else {
- store.remove(KEY_UTC_DAY);
- }
+ setValue(KEY_UTC_DAY, utcDay);
}
/**
@@ -274,7 +255,7 @@ public class GPSData extends RPCStruct {
* @return utc day
*/
public Integer getUtcDay() {
- return (Integer) store.get(KEY_UTC_DAY);
+ return getInteger(KEY_UTC_DAY);
}
/**
@@ -282,11 +263,7 @@ public class GPSData extends RPCStruct {
* @param utcHours utc hours
*/
public void setUtcHours(Integer utcHours) {
- if (utcHours != null) {
- store.put(KEY_UTC_HOURS, utcHours);
- } else {
- store.remove(KEY_UTC_HOURS);
- }
+ setValue(KEY_UTC_HOURS, utcHours);
}
/**
@@ -294,7 +271,7 @@ public class GPSData extends RPCStruct {
* @return utc hours
*/
public Integer getUtcHours() {
- return (Integer) store.get(KEY_UTC_HOURS);
+ return getInteger(KEY_UTC_HOURS);
}
/**
@@ -302,11 +279,7 @@ public class GPSData extends RPCStruct {
* @param utcMinutes utc minutes
*/
public void setUtcMinutes(Integer utcMinutes) {
- if (utcMinutes != null) {
- store.put(KEY_UTC_MINUTES, utcMinutes);
- } else {
- store.remove(KEY_UTC_MINUTES);
- }
+ setValue(KEY_UTC_MINUTES, utcMinutes);
}
/**
@@ -314,7 +287,7 @@ public class GPSData extends RPCStruct {
* @return utc minutes
*/
public Integer getUtcMinutes() {
- return (Integer) store.get(KEY_UTC_MINUTES);
+ return getInteger(KEY_UTC_MINUTES);
}
/**
@@ -322,11 +295,7 @@ public class GPSData extends RPCStruct {
* @param utcSeconds utc seconds
*/
public void setUtcSeconds(Integer utcSeconds) {
- if (utcSeconds != null) {
- store.put(KEY_UTC_SECONDS, utcSeconds);
- } else {
- store.remove(KEY_UTC_SECONDS);
- }
+ setValue(KEY_UTC_SECONDS, utcSeconds);
}
/**
@@ -334,23 +303,13 @@ public class GPSData extends RPCStruct {
* @return utc seconds
*/
public Integer getUtcSeconds() {
- return (Integer) store.get(KEY_UTC_SECONDS);
+ return getInteger(KEY_UTC_SECONDS);
}
public void setCompassDirection(CompassDirection compassDirection) {
- if (compassDirection != null) {
- store.put(KEY_COMPASS_DIRECTION, compassDirection);
- } else {
- store.remove(KEY_COMPASS_DIRECTION);
- }
+ setValue(KEY_COMPASS_DIRECTION, compassDirection);
}
public CompassDirection getCompassDirection() {
- Object obj = store.get(KEY_COMPASS_DIRECTION);
- if (obj instanceof CompassDirection) {
- return (CompassDirection) obj;
- } else if (obj instanceof String) {
- return CompassDirection.valueForString((String) obj);
- }
- return null;
+ return (CompassDirection) getObject(CompassDirection.class, KEY_COMPASS_DIRECTION);
}
/**
@@ -358,18 +317,14 @@ public class GPSData extends RPCStruct {
* @param pdop the positional dilution of precision
*/
public void setPdop(Double pdop) {
- if (pdop != null) {
- store.put(KEY_PDOP, pdop);
- } else {
- store.remove(KEY_PDOP);
- }
+ setValue(KEY_PDOP, pdop);
}
/**
* get the positional dilution of precision
*/
public Double getPdop() {
- Object object = store.get(KEY_PDOP);
+ Object object = getValue(KEY_PDOP);
return SdlDataTypeConverter.objectToDouble(object);
}
@@ -378,11 +333,7 @@ public class GPSData extends RPCStruct {
* @param hdop the horizontal dilution of precision
*/
public void setHdop(Double hdop) {
- if (hdop != null) {
- store.put(KEY_HDOP, hdop);
- } else {
- store.remove(KEY_HDOP);
- }
+ setValue(KEY_HDOP, hdop);
}
/**
@@ -390,7 +341,7 @@ public class GPSData extends RPCStruct {
* @return the horizontal dilution of precision
*/
public Double getHdop() {
- Object object = store.get(KEY_HDOP);
+ Object object = getValue(KEY_HDOP);
return SdlDataTypeConverter.objectToDouble(object);
}
@@ -399,11 +350,7 @@ public class GPSData extends RPCStruct {
* @param vdop the vertical dilution of precision
*/
public void setVdop(Double vdop) {
- if (vdop != null) {
- store.put(KEY_VDOP, vdop);
- } else {
- store.remove(KEY_VDOP);
- }
+ setValue(KEY_VDOP, vdop);
}
/**
@@ -411,7 +358,7 @@ public class GPSData extends RPCStruct {
* @return the vertical dilution of precision
*/
public Double getVdop() {
- Object object = store.get(KEY_VDOP);
+ Object object = getValue(KEY_VDOP);
return SdlDataTypeConverter.objectToDouble(object);
}
@@ -420,11 +367,7 @@ public class GPSData extends RPCStruct {
* @param actual True, if coordinates are based on satellites.False, if based on dead reckoning
*/
public void setActual(Boolean actual) {
- if (actual != null) {
- store.put(KEY_ACTUAL, actual);
- } else {
- store.remove(KEY_ACTUAL);
- }
+ setValue(KEY_ACTUAL, actual);
}
/**
@@ -432,7 +375,7 @@ public class GPSData extends RPCStruct {
* @return True, if coordinates are based on satellites.False, if based on dead reckoning
*/
public Boolean getActual() {
- return (Boolean) store.get(KEY_ACTUAL);
+ return getBoolean(KEY_ACTUAL);
}
/**
@@ -440,11 +383,7 @@ public class GPSData extends RPCStruct {
* @param satellites the number of satellites in view
*/
public void setSatellites(Integer satellites) {
- if (satellites != null) {
- store.put(KEY_SATELLITES, satellites);
- } else {
- store.remove(KEY_SATELLITES);
- }
+ setValue(KEY_SATELLITES, satellites);
}
/**
@@ -452,23 +391,13 @@ public class GPSData extends RPCStruct {
* @return the number of satellites in view
*/
public Integer getSatellites() {
- return (Integer) store.get(KEY_SATELLITES);
+ return getInteger(KEY_SATELLITES);
}
public void setDimension(Dimension dimension) {
- if (dimension != null) {
- store.put(KEY_DIMENSION, dimension);
- } else {
- store.remove(KEY_DIMENSION);
- }
+ setValue(KEY_DIMENSION, dimension);
}
public Dimension getDimension() {
- Object obj = store.get(KEY_DIMENSION);
- if (obj instanceof Dimension) {
- return (Dimension) obj;
- } else if (obj instanceof String) {
- return Dimension.valueForString((String) obj);
- }
- return null;
+ return (Dimension) getObject(Dimension.class, KEY_DIMENSION);
}
/**
@@ -476,11 +405,7 @@ public class GPSData extends RPCStruct {
* @param altitude altitude in meters
*/
public void setAltitude(Double altitude) {
- if (altitude != null) {
- store.put(KEY_ALTITUDE, altitude);
- } else {
- store.remove(KEY_ALTITUDE);
- }
+ setValue(KEY_ALTITUDE, altitude);
}
/**
@@ -488,7 +413,7 @@ public class GPSData extends RPCStruct {
* @return altitude in meters
*/
public Double getAltitude() {
- Object object = store.get(KEY_ALTITUDE);
+ Object object = getValue(KEY_ALTITUDE);
return SdlDataTypeConverter.objectToDouble(object);
}
@@ -497,18 +422,14 @@ public class GPSData extends RPCStruct {
* @param heading the heading.
*/
public void setHeading(Double heading) {
- if (heading != null) {
- store.put(KEY_HEADING, heading);
- } else {
- store.remove(KEY_HEADING);
- }
+ setValue(KEY_HEADING, heading);
}
/**
* get the heading
*/
public Double getHeading() {
- Object object = store.get(KEY_HEADING);
+ Object object = getValue(KEY_HEADING);
return SdlDataTypeConverter.objectToDouble(object);
}
@@ -517,11 +438,7 @@ public class GPSData extends RPCStruct {
* @param speed the speed
*/
public void setSpeed(Double speed) {
- if (speed != null) {
- store.put(KEY_SPEED, speed);
- } else {
- store.remove(KEY_SPEED);
- }
+ setValue(KEY_SPEED, speed);
}
/**
@@ -529,7 +446,7 @@ public class GPSData extends RPCStruct {
* @return the speed in KPH
*/
public Double getSpeed() {
- Object object = store.get(KEY_SPEED);
+ Object object = getValue(KEY_SPEED);
return SdlDataTypeConverter.objectToDouble(object);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java
index fa3ba1c01..83243823e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCs.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* This RPC allows to request diagnostic module trouble codes from a certain
* vehicle module.
@@ -86,11 +86,7 @@ public class GetDTCs extends RPCRequest {
* <b>Notes:</p> </b>Minvalue:0; Maxvalue:65535
*/
public void setEcuName(Integer ecuName) {
- if (ecuName != null) {
- parameters.put(KEY_ECU_NAME, ecuName);
- } else {
- parameters.remove(KEY_ECU_NAME);
- }
+ setParameters(KEY_ECU_NAME, ecuName);
}
/**
@@ -100,16 +96,12 @@ public class GetDTCs extends RPCRequest {
* receive the DTC form
*/
public Integer getEcuName() {
- return (Integer) parameters.get(KEY_ECU_NAME);
+ return getInteger(KEY_ECU_NAME);
}
public void setDtcMask(Integer dtcMask) {
- if (dtcMask != null) {
- parameters.put(KEY_DTC_MASK, dtcMask);
- } else {
- parameters.remove(KEY_DTC_MASK);
- }
+ setParameters(KEY_DTC_MASK, dtcMask);
}
public Integer getDtcMask() {
- return (Integer) parameters.get(KEY_DTC_MASK);
+ return getInteger(KEY_DTC_MASK);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java
index b3c49b251..02d130db8 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetDTCsResponse.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-import java.util.List;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* Get DTCs Response is sent, when GetDTCs has been called
*
@@ -26,37 +26,18 @@ public class GetDTCsResponse extends RPCResponse{
@SuppressWarnings("unchecked")
public List<String> getDtc(){
- if(parameters.get(KEY_DTC) instanceof List<?>){
- List<?> list = (List<?>) parameters.get(KEY_DTC);
- if(list != null && list.size() > 0){
- Object obj = list.get(0);
- if(obj instanceof String){
- return (List<String>) list;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_DTC);
}
public void setDtc(List<String> dtc){
- if(dtc != null){
- parameters.put(KEY_DTC, dtc);
- }
- else{
- parameters.remove(KEY_DTC);
- }
+ setParameters(KEY_DTC, dtc);
}
public Integer getEcuHeader(){
- return (Integer) parameters.get(KEY_ECU_HEADER);
+ return getInteger(KEY_ECU_HEADER);
}
public void setEcuHeader(Integer ecuHeader){
- if(ecuHeader != null){
- parameters.put(KEY_ECU_HEADER, ecuHeader);
- }
- else{
- parameters.remove(KEY_ECU_HEADER);
- }
+ setParameters(KEY_ECU_HEADER, ecuHeader);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleData.java
new file mode 100644
index 000000000..53108b4fb
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleData.java
@@ -0,0 +1,79 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.enums.ModuleType;
+import java.util.Hashtable;
+
+/**
+ * Read the current status value of specified remote control module (type). In addition,
+ * When subscribe=true, subscribes for specific remote control module data items;
+ * When subscribe=false, un-subscribes for specific remote control module data items.
+ * Once subscribed, the application will be notified by the onInteriorVehicleData notification
+ * whenever new data is available for the module.
+ */
+public class GetInteriorVehicleData extends RPCRequest {
+ public static final String KEY_MODULE_TYPE = "moduleType";
+ public static final String KEY_SUBSCRIBE = "subscribe";
+
+ /**
+ * Constructs a new GetInteriorVehicleData object
+ */
+ public GetInteriorVehicleData() {
+ super(FunctionID.GET_INTERIOR_VEHICLE_DATA.toString());
+ }
+
+ /**
+ * <p>Constructs a new GetInteriorVehicleData object indicated by the
+ * Hashtable parameter</p>
+ *
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public GetInteriorVehicleData(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Gets the ModuleType
+ *
+ * @return ModuleType - The type of a RC module to retrieve module data from the vehicle.
+ * In the future, this should be the Identification of a module.
+ */
+ public ModuleType getModuleType() {
+ return (ModuleType) getObject(ModuleType.class, KEY_MODULE_TYPE);
+ }
+
+ /**
+ * Sets a ModuleType
+ *
+ * @param moduleType
+ * The type of a RC module to retrieve module data from the vehicle.
+ * In the future, this should be the Identification of a module.
+ */
+ public void setModuleType(ModuleType moduleType) {
+ setParameters(KEY_MODULE_TYPE, moduleType);
+ }
+
+ /**
+ * Sets subscribe parameter
+ *
+ * @param subscribe
+ * If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduelType.
+ * If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduelType.
+ */
+ public void setSubscribe(Boolean subscribe) {
+ setParameters(KEY_SUBSCRIBE, subscribe);
+ }
+
+ /**
+ * Gets subscribe parameter
+ *
+ * @return Boolean - If subscribe is true, the head unit will register onInteriorVehicleData notifications for the requested moduelType.
+ * If subscribe is false, the head unit will unregister onInteriorVehicleData notifications for the requested moduelType.
+ */
+ public Boolean getSubscribe() {
+ return getBoolean(KEY_SUBSCRIBE);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java
new file mode 100644
index 000000000..0e74001f6
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetInteriorVehicleDataResponse.java
@@ -0,0 +1,70 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCResponse;
+import java.util.Hashtable;
+
+public class GetInteriorVehicleDataResponse extends RPCResponse {
+ public static final String KEY_MODULE_DATA = "moduleData";
+ public static final String KEY_IS_SUBSCRIBED = "isSubscribed";
+
+ /**
+ * Constructs a new GetInteriorVehicleDataResponse object
+ */
+ public GetInteriorVehicleDataResponse() {
+ super(FunctionID.GET_INTERIOR_VEHICLE_DATA.toString());
+ }
+
+ /**
+ * <p>Constructs a new GetInteriorVehicleDataResponse object indicated by the
+ * Hashtable parameter</p>
+ *
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public GetInteriorVehicleDataResponse(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Gets the moduleData
+ *
+ * @return ModuleData
+ */
+ public ModuleData getModuleData() {
+ return (ModuleData) getObject(ModuleData.class, KEY_MODULE_DATA);
+ }
+
+ /**
+ * Sets the moduleData
+ *
+ * @param moduleData
+ */
+ public void setModuleData(ModuleData moduleData) {
+ setParameters(KEY_MODULE_DATA, moduleData);
+ }
+
+ /**
+ * Sets isSubscribed parameter
+ *
+ * @param isSubscribed
+ * It is a conditional-mandatory parameter: must be returned in case "subscribe" parameter was present in the related request.
+ * If "true" - the "moduleType" from request is successfully subscribed and the head unit will send onInteriorVehicleData notifications for the moduleType.
+ * If "false" - the "moduleType" from request is either unsubscribed or failed to subscribe.
+ * */
+ public void setIsSubscribed(Boolean isSubscribed) {
+ setParameters(KEY_IS_SUBSCRIBED, isSubscribed);
+ }
+
+ /**
+ * Gets isSubscribed parameter
+ *
+ * @return Boolean - It is a conditional-mandatory parameter: must be returned in case "subscribe" parameter was present in the related request.
+ * If "true" - the "moduleType" from request is successfully subscribed and the head unit will send onInteriorVehicleData notifications for the moduleType.
+ * If "false" - the "moduleType" from request is either unsubscribed or failed to subscribe.
+ * */
+ public Boolean getIsSubscribed() {
+ return getBoolean(KEY_IS_SUBSCRIBED);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapability.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapability.java
new file mode 100644
index 000000000..190403096
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapability.java
@@ -0,0 +1,48 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+
+import java.util.Hashtable;
+
+/**
+ * Used to request the corresponding capability object for a given capability.
+ */
+
+public class GetSystemCapability extends RPCRequest {
+ public static final String KEY_SYSTEM_CAPABILITY_TYPE = "systemCapabilityType";
+
+ /**
+ * Constructs a new GetSystemCapability object
+ */
+ public GetSystemCapability(){
+ super(FunctionID.GET_SYSTEM_CAPABILITY.toString());
+ }
+
+ /**
+ * <p>Constructs a new GetSystemCapability object indicated by the Hashtable parameter</p>
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public GetSystemCapability(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Used to get the SystemCapabilityType being requested
+ * @return the SystemCapabilityType being requested
+ */
+ public SystemCapabilityType getSystemCapabilityType(){
+ return (SystemCapabilityType) getObject(SystemCapabilityType.class, KEY_SYSTEM_CAPABILITY_TYPE);
+ }
+
+ /**
+ * Used to set the SystemCapabilityType being requested
+ * @param value SystemCapabilityType being requested
+ */
+ public void setSystemCapabilityType(SystemCapabilityType value){
+ setParameters(KEY_SYSTEM_CAPABILITY_TYPE, value);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java
new file mode 100644
index 000000000..bccce6331
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetSystemCapabilityResponse.java
@@ -0,0 +1,48 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCResponse;
+
+import java.util.Hashtable;
+
+/**
+ * GetSystemCapabilityResponse is sent, when GetSystemCapability has been called
+ */
+
+public class GetSystemCapabilityResponse extends RPCResponse {
+ public static final String KEY_SYSTEM_CAPABILITY = "systemCapability";
+
+ /**
+ * Constructs a new GetSystemCapability object
+ */
+ public GetSystemCapabilityResponse(){
+ super(FunctionID.GET_SYSTEM_CAPABILITY.toString());
+ }
+
+ /**
+ * <p>Constructs a new GetSystemCapability object indicated by the Hashtable parameter</p>
+ *
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public GetSystemCapabilityResponse(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Get the SystemCapability object returned after a GetSystemCapability call
+ * @return SystemCapability object
+ */
+ public SystemCapability getSystemCapability(){
+ return (SystemCapability) getObject(SystemCapability.class, KEY_SYSTEM_CAPABILITY);
+ }
+
+ /**
+ * Set a SystemCapability object in the response
+ * @param value SystemCapability object
+ */
+ public void setSystemCapability(SystemCapability value){
+ setParameters(KEY_SYSTEM_CAPABILITY, value);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java
index 0c15c02c9..e29f01be0 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleData.java
@@ -4,6 +4,15 @@ import java.util.Hashtable;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+
+import static android.provider.Contacts.SettingsColumns.KEY;
+import static com.smartdevicelink.proxy.constants.Names.choiceSet;
+import static com.smartdevicelink.proxy.constants.Names.externalTemperature;
+import static com.smartdevicelink.proxy.constants.Names.instantFuelConsumption;
+import static com.smartdevicelink.proxy.constants.Names.prndl;
+import static com.smartdevicelink.proxy.constants.Names.vin;
+import static com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSet.KEY_CHOICE_SET;
+
/**
* Non periodic vehicle data read request.
*
@@ -195,7 +204,7 @@ import com.smartdevicelink.proxy.RPCRequest;
* <p> USER_DISALLOWED</p>
*
* @see SubscribeVehicleData
- * @see UnSubscribeVehicleData
+ * @see UnsubscribeVehicleData
* @since SmartDeviceLink 2.0
*
*
@@ -247,44 +256,28 @@ public class GetVehicleData extends RPCRequest {
super(hash);
}
public void setGps(Boolean gps) {
- if (gps != null) {
- parameters.put(KEY_GPS, gps);
- } else {
- parameters.remove(KEY_GPS);
- }
+ setParameters(KEY_GPS, gps);
}
public Boolean getGps() {
- return (Boolean) parameters.get(KEY_GPS);
+ return getBoolean(KEY_GPS);
}
public void setSpeed(Boolean speed) {
- if (speed != null) {
- parameters.put(KEY_SPEED, speed);
- } else {
- parameters.remove(KEY_SPEED);
- }
+ setParameters(KEY_SPEED, speed);
}
public Boolean getSpeed() {
- return (Boolean) parameters.get(KEY_SPEED);
+ return getBoolean(KEY_SPEED);
}
public void setRpm(Boolean rpm) {
- if (rpm != null) {
- parameters.put(KEY_RPM, rpm);
- } else {
- parameters.remove(KEY_RPM);
- }
+ setParameters(KEY_RPM, rpm);
}
public Boolean getRpm() {
- return (Boolean) parameters.get(KEY_RPM);
+ return getBoolean(KEY_RPM);
}
public void setFuelLevel(Boolean fuelLevel) {
- if (fuelLevel != null) {
- parameters.put(KEY_FUEL_LEVEL, fuelLevel);
- } else {
- parameters.remove(KEY_FUEL_LEVEL);
- }
+ setParameters(KEY_FUEL_LEVEL, fuelLevel);
}
public Boolean getFuelLevel() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL);
+ return getBoolean(KEY_FUEL_LEVEL);
}
@Deprecated
public void setFuelLevel_State(Boolean fuelLevel_State) {
@@ -295,218 +288,134 @@ public class GetVehicleData extends RPCRequest {
return getFuelLevelState();
}
public void setFuelLevelState(Boolean fuelLevelState) {
- if (fuelLevelState != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevelState);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState);
}
public Boolean getFuelLevelState() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL_STATE);
+ return getBoolean(KEY_FUEL_LEVEL_STATE);
}
public void setInstantFuelConsumption(Boolean instantFuelConsumption) {
- if (instantFuelConsumption != null) {
- parameters.put(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
- } else {
- parameters.remove(KEY_INSTANT_FUEL_CONSUMPTION);
- }
+ setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
}
public Boolean getInstantFuelConsumption() {
- return (Boolean) parameters.get(KEY_INSTANT_FUEL_CONSUMPTION);
+ return getBoolean(KEY_INSTANT_FUEL_CONSUMPTION);
}
public void setExternalTemperature(Boolean externalTemperature) {
- if (externalTemperature != null) {
- parameters.put(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
- } else {
- parameters.remove(KEY_EXTERNAL_TEMPERATURE);
- }
+ setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
}
public Boolean getExternalTemperature() {
- return (Boolean) parameters.get(KEY_EXTERNAL_TEMPERATURE);
+ return getBoolean(KEY_EXTERNAL_TEMPERATURE);
}
public void setVin(Boolean vin) {
- if (vin != null) {
- parameters.put(KEY_VIN, vin);
- } else {
- parameters.remove(KEY_VIN);
- }
+ setParameters(KEY_VIN, vin);
}
public Boolean getVin() {
- return (Boolean) parameters.get(KEY_VIN);
+ return getBoolean(KEY_VIN);
}
public void setPrndl(Boolean prndl) {
- if (prndl != null) {
- parameters.put(KEY_PRNDL, prndl);
- } else {
- parameters.remove(KEY_PRNDL);
- }
+ setParameters(KEY_PRNDL, prndl);
}
public Boolean getPrndl() {
- return (Boolean) parameters.get(KEY_PRNDL);
+ return getBoolean(KEY_PRNDL);
}
public void setTirePressure(Boolean tirePressure) {
- if (tirePressure != null) {
- parameters.put(KEY_TIRE_PRESSURE, tirePressure);
- } else {
- parameters.remove(KEY_TIRE_PRESSURE);
- }
+ setParameters(KEY_TIRE_PRESSURE, tirePressure);
}
public Boolean getTirePressure() {
- return (Boolean) parameters.get(KEY_TIRE_PRESSURE);
+ return getBoolean(KEY_TIRE_PRESSURE);
}
public void setOdometer(Boolean odometer) {
- if (odometer != null) {
- parameters.put(KEY_ODOMETER, odometer);
- } else {
- parameters.remove(KEY_ODOMETER);
- }
+ setParameters(KEY_ODOMETER, odometer);
}
public Boolean getOdometer() {
- return (Boolean) parameters.get(KEY_ODOMETER);
+ return getBoolean(KEY_ODOMETER);
}
public void setBeltStatus(Boolean beltStatus) {
- if (beltStatus != null) {
- parameters.put(KEY_BELT_STATUS, beltStatus);
- } else {
- parameters.remove(KEY_BELT_STATUS);
- }
+ setParameters(KEY_BELT_STATUS, beltStatus);
}
public Boolean getBeltStatus() {
- return (Boolean) parameters.get(KEY_BELT_STATUS);
+ return getBoolean(KEY_BELT_STATUS);
}
public void setBodyInformation(Boolean bodyInformation) {
- if (bodyInformation != null) {
- parameters.put(KEY_BODY_INFORMATION, bodyInformation);
- } else {
- parameters.remove(KEY_BODY_INFORMATION);
- }
+ setParameters(KEY_BODY_INFORMATION, bodyInformation);
}
public Boolean getBodyInformation() {
- return (Boolean) parameters.get(KEY_BODY_INFORMATION);
+ return getBoolean(KEY_BODY_INFORMATION);
}
public void setDeviceStatus(Boolean deviceStatus) {
- if (deviceStatus != null) {
- parameters.put(KEY_DEVICE_STATUS, deviceStatus);
- } else {
- parameters.remove(KEY_DEVICE_STATUS);
- }
+ setParameters(KEY_DEVICE_STATUS, deviceStatus);
}
public Boolean getDeviceStatus() {
- return (Boolean) parameters.get(KEY_DEVICE_STATUS);
+ return getBoolean(KEY_DEVICE_STATUS);
}
public void setDriverBraking(Boolean driverBraking) {
- if (driverBraking != null) {
- parameters.put(KEY_DRIVER_BRAKING, driverBraking);
- } else {
- parameters.remove(KEY_DRIVER_BRAKING);
- }
+ setParameters(KEY_DRIVER_BRAKING, driverBraking);
}
public Boolean getDriverBraking() {
- return (Boolean) parameters.get(KEY_DRIVER_BRAKING);
+ return getBoolean(KEY_DRIVER_BRAKING);
}
public void setWiperStatus(Boolean wiperStatus) {
- if (wiperStatus != null) {
- parameters.put(KEY_WIPER_STATUS, wiperStatus);
- } else {
- parameters.remove(KEY_WIPER_STATUS);
- }
+ setParameters(KEY_WIPER_STATUS, wiperStatus);
}
public Boolean getWiperStatus() {
- return (Boolean) parameters.get(KEY_WIPER_STATUS);
+ return getBoolean(KEY_WIPER_STATUS);
}
public void setHeadLampStatus(Boolean headLampStatus) {
- if (headLampStatus != null) {
- parameters.put(KEY_HEAD_LAMP_STATUS, headLampStatus);
- } else {
- parameters.remove(KEY_HEAD_LAMP_STATUS);
- }
+ setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus);
}
public Boolean getHeadLampStatus() {
- return (Boolean) parameters.get(KEY_HEAD_LAMP_STATUS);
+ return getBoolean(KEY_HEAD_LAMP_STATUS);
}
public void setEngineTorque(Boolean engineTorque) {
- if (engineTorque != null) {
- parameters.put(KEY_ENGINE_TORQUE, engineTorque);
- } else {
- parameters.remove(KEY_ENGINE_TORQUE);
- }
+ setParameters(KEY_ENGINE_TORQUE, engineTorque);
}
public Boolean getEngineTorque() {
- return (Boolean) parameters.get(KEY_ENGINE_TORQUE);
+ return getBoolean(KEY_ENGINE_TORQUE);
}
public void setAccPedalPosition(Boolean accPedalPosition) {
- if (accPedalPosition != null) {
- parameters.put(KEY_ACC_PEDAL_POSITION, accPedalPosition);
- } else {
- parameters.remove(KEY_ACC_PEDAL_POSITION);
- }
+ setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition);
}
public Boolean getAccPedalPosition() {
- return (Boolean) parameters.get(KEY_ACC_PEDAL_POSITION);
+ return getBoolean(KEY_ACC_PEDAL_POSITION);
}
public void setSteeringWheelAngle(Boolean steeringWheelAngle) {
- if (steeringWheelAngle != null) {
- parameters.put(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
- } else {
- parameters.remove(KEY_STEERING_WHEEL_ANGLE);
- }
+ setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
}
public Boolean getSteeringWheelAngle() {
- return (Boolean) parameters.get(KEY_STEERING_WHEEL_ANGLE);
+ return getBoolean(KEY_STEERING_WHEEL_ANGLE);
}
public void setECallInfo(Boolean eCallInfo) {
- if (eCallInfo != null) {
- parameters.put(KEY_E_CALL_INFO, eCallInfo);
- } else {
- parameters.remove(KEY_E_CALL_INFO);
- }
+ setParameters(KEY_E_CALL_INFO, eCallInfo);
}
public Boolean getECallInfo() {
- return (Boolean) parameters.get(KEY_E_CALL_INFO);
+ return getBoolean(KEY_E_CALL_INFO);
}
public void setAirbagStatus(Boolean airbagStatus) {
- if (airbagStatus != null) {
- parameters.put(KEY_AIRBAG_STATUS, airbagStatus);
- } else {
- parameters.remove(KEY_AIRBAG_STATUS);
- }
+ setParameters(KEY_AIRBAG_STATUS, airbagStatus);
}
public Boolean getAirbagStatus() {
- return (Boolean) parameters.get(KEY_AIRBAG_STATUS);
+ return getBoolean(KEY_AIRBAG_STATUS);
}
public void setEmergencyEvent(Boolean emergencyEvent) {
- if (emergencyEvent != null) {
- parameters.put(KEY_EMERGENCY_EVENT, emergencyEvent);
- } else {
- parameters.remove(KEY_EMERGENCY_EVENT);
- }
+ setParameters(KEY_EMERGENCY_EVENT, emergencyEvent);
}
public Boolean getEmergencyEvent() {
- return (Boolean) parameters.get(KEY_EMERGENCY_EVENT);
+ return getBoolean(KEY_EMERGENCY_EVENT);
}
public void setClusterModeStatus(Boolean clusterModeStatus) {
- if (clusterModeStatus != null) {
- parameters.put(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
- } else {
- parameters.remove(KEY_CLUSTER_MODE_STATUS);
- }
+ setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
}
public Boolean getClusterModeStatus() {
- return (Boolean) parameters.get(KEY_CLUSTER_MODE_STATUS);
+ return getBoolean(KEY_CLUSTER_MODE_STATUS);
}
public void setMyKey(Boolean myKey) {
- if (myKey != null) {
- parameters.put(KEY_MY_KEY, myKey);
- } else {
- parameters.remove(KEY_MY_KEY);
- }
+ setParameters(KEY_MY_KEY, myKey);
}
public Boolean getMyKey() {
- return (Boolean) parameters.get(KEY_MY_KEY);
+ return getBoolean(KEY_MY_KEY);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java
index 51eb7a4b7..39e33993b 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetVehicleDataResponse.java
@@ -1,17 +1,16 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
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.DebugTool;
import com.smartdevicelink.util.SdlDataTypeConverter;
+import java.util.Hashtable;
+
/**
* Get Vehicle Data Response is sent, when GetVehicleData has been called.
*
@@ -55,58 +54,30 @@ public class GetVehicleDataResponse extends RPCResponse {
super(hash);
}
public void setGps(GPSData gps) {
- if (gps != null) {
- parameters.put(KEY_GPS, gps);
- } else {
- parameters.remove(KEY_GPS);
- }
+ setParameters(KEY_GPS, gps);
}
@SuppressWarnings("unchecked")
public GPSData getGps() {
- Object obj = parameters.get(KEY_GPS);
- if (obj instanceof GPSData) {
- return (GPSData) obj;
- } else if (obj instanceof Hashtable) {
- GPSData theCode = null;
- try {
- theCode = new GPSData((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
- }
- return theCode;
- }
- return null;
+ return (GPSData) getObject(GPSData.class, KEY_GPS);
}
public void setSpeed(Double speed) {
- if (speed != null) {
- parameters.put(KEY_SPEED, speed);
- } else {
- parameters.remove(KEY_SPEED);
- }
+ setParameters(KEY_SPEED, speed);
}
public Double getSpeed() {
- Object object = parameters.get(KEY_SPEED);
+ Object object = getParameters(KEY_SPEED);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setRpm(Integer rpm) {
- if (rpm != null) {
- parameters.put(KEY_RPM, rpm);
- } else {
- parameters.remove(KEY_RPM);
- }
+ setParameters(KEY_RPM, rpm);
}
public Integer getRpm() {
- return (Integer) parameters.get(KEY_RPM);
+ return getInteger(KEY_RPM);
}
public void setFuelLevel(Double fuelLevel) {
- if (fuelLevel != null) {
- parameters.put(KEY_FUEL_LEVEL, fuelLevel);
- } else {
- parameters.remove(KEY_FUEL_LEVEL);
- }
+ setParameters(KEY_FUEL_LEVEL, fuelLevel);
}
public Double getFuelLevel() {
- Object object = parameters.get(KEY_FUEL_LEVEL);
+ Object object = getParameters(KEY_FUEL_LEVEL);
return SdlDataTypeConverter.objectToDouble(object);
}
@Deprecated
@@ -118,364 +89,150 @@ public class GetVehicleDataResponse extends RPCResponse {
return getFuelLevelState();
}
public void setFuelLevelState(ComponentVolumeStatus fuelLevelState) {
- if (fuelLevelState != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevelState);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState);
}
public ComponentVolumeStatus getFuelLevelState() {
- 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) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
- }
- return theCode;
- }
- return null;
+ return (ComponentVolumeStatus) getObject(ComponentVolumeStatus.class, KEY_FUEL_LEVEL_STATE);
}
public void setInstantFuelConsumption(Double instantFuelConsumption) {
- if (instantFuelConsumption != null) {
- parameters.put(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
- } else {
- parameters.remove(KEY_INSTANT_FUEL_CONSUMPTION);
- }
+ setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
}
public Double getInstantFuelConsumption() {
- Object object = parameters.get(KEY_INSTANT_FUEL_CONSUMPTION);
+ Object object = getParameters(KEY_INSTANT_FUEL_CONSUMPTION);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setExternalTemperature(Double externalTemperature) {
- if (externalTemperature != null) {
- parameters.put(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
- } else {
- parameters.remove(KEY_EXTERNAL_TEMPERATURE);
- }
+ setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
}
public Double getExternalTemperature() {
- Object object = parameters.get(KEY_EXTERNAL_TEMPERATURE);
+ Object object = getParameters(KEY_EXTERNAL_TEMPERATURE);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setVin(String vin) {
- if (vin != null) {
- parameters.put(KEY_VIN, vin);
- } else {
- parameters.remove(KEY_VIN);
- }
+ setParameters(KEY_VIN, vin);
}
public String getVin() {
- return (String) parameters.get(KEY_VIN);
+ return getString(KEY_VIN);
}
public void setPrndl(PRNDL prndl) {
- if (prndl != null) {
- parameters.put(KEY_PRNDL, prndl);
- } else {
- parameters.remove(KEY_PRNDL);
- }
+ setParameters(KEY_PRNDL, prndl);
}
public PRNDL getPrndl() {
- Object obj = parameters.get(KEY_PRNDL);
- if (obj instanceof PRNDL) {
- return (PRNDL) obj;
- } else if (obj instanceof String) {
- return PRNDL.valueForString((String) obj);
- }
- return null;
+ return (PRNDL) getObject(PRNDL.class, KEY_PRNDL);
}
public void setTirePressure(TireStatus tirePressure) {
- if (tirePressure != null) {
- parameters.put(KEY_TIRE_PRESSURE, tirePressure);
- } else {
- parameters.remove(KEY_TIRE_PRESSURE);
- }
+ setParameters(KEY_TIRE_PRESSURE, tirePressure);
}
@SuppressWarnings("unchecked")
public TireStatus getTirePressure() {
- Object obj = parameters.get(KEY_TIRE_PRESSURE);
- if (obj instanceof TireStatus) {
- return (TireStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new TireStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
- }
- }
- return null;
+ return (TireStatus) getObject(TireStatus.class, KEY_TIRE_PRESSURE);
}
public void setOdometer(Integer odometer) {
- if (odometer != null) {
- parameters.put(KEY_ODOMETER, odometer);
- } else {
- parameters.remove(KEY_ODOMETER);
- }
+ setParameters(KEY_ODOMETER, odometer);
}
public Integer getOdometer() {
- return (Integer) parameters.get(KEY_ODOMETER);
+ return getInteger(KEY_ODOMETER);
}
public void setBeltStatus(BeltStatus beltStatus) {
- if (beltStatus != null) {
- parameters.put(KEY_BELT_STATUS, beltStatus);
- } else {
- parameters.remove(KEY_BELT_STATUS);
- }
+ setParameters(KEY_BELT_STATUS, beltStatus);
}
@SuppressWarnings("unchecked")
public BeltStatus getBeltStatus() {
- Object obj = parameters.get(KEY_BELT_STATUS);
- if (obj instanceof BeltStatus) {
- return (BeltStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new BeltStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
- }
- }
- return null;
+ return (BeltStatus) getObject(BeltStatus.class, KEY_BELT_STATUS);
}
public void setBodyInformation(BodyInformation bodyInformation) {
- if (bodyInformation != null) {
- parameters.put(KEY_BODY_INFORMATION, bodyInformation);
- } else {
- parameters.remove(KEY_BODY_INFORMATION);
- }
+ setParameters(KEY_BODY_INFORMATION, bodyInformation);
}
@SuppressWarnings("unchecked")
public BodyInformation getBodyInformation() {
- Object obj = parameters.get(KEY_BODY_INFORMATION);
- if (obj instanceof BodyInformation) {
- return (BodyInformation) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new BodyInformation((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
- }
- }
- return null;
+ return (BodyInformation) getObject(BodyInformation.class, KEY_BODY_INFORMATION);
}
public void setDeviceStatus(DeviceStatus deviceStatus) {
- if (deviceStatus != null) {
- parameters.put(KEY_DEVICE_STATUS, deviceStatus);
- } else {
- parameters.remove(KEY_DEVICE_STATUS);
- }
+ setParameters(KEY_DEVICE_STATUS, deviceStatus);
}
@SuppressWarnings("unchecked")
public DeviceStatus getDeviceStatus() {
- Object obj = parameters.get(KEY_DEVICE_STATUS);
- if (obj instanceof DeviceStatus) {
- return (DeviceStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new DeviceStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
- }
- }
- return null;
+ return (DeviceStatus) getObject(DeviceStatus.class, KEY_DEVICE_STATUS);
}
public void setDriverBraking(VehicleDataEventStatus driverBraking) {
- if (driverBraking != null) {
- parameters.put(KEY_DRIVER_BRAKING, driverBraking);
- } else {
- parameters.remove(KEY_DRIVER_BRAKING);
- }
+ setParameters(KEY_DRIVER_BRAKING, driverBraking);
}
public VehicleDataEventStatus getDriverBraking() {
- Object obj = parameters.get(KEY_DRIVER_BRAKING);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_BRAKING);
}
public void setWiperStatus(WiperStatus wiperStatus) {
- if (wiperStatus != null) {
- parameters.put(KEY_WIPER_STATUS, wiperStatus);
- } else {
- parameters.remove(KEY_WIPER_STATUS);
- }
+ setParameters(KEY_WIPER_STATUS, wiperStatus);
}
public WiperStatus getWiperStatus() {
- Object obj = parameters.get(KEY_WIPER_STATUS);
- if (obj instanceof WiperStatus) {
- return (WiperStatus) obj;
- } else if (obj instanceof String) {
- return WiperStatus.valueForString((String) obj);
- }
- return null;
+ return (WiperStatus) getObject(WiperStatus.class, KEY_WIPER_STATUS);
}
public void setHeadLampStatus(HeadLampStatus headLampStatus) {
- if (headLampStatus != null) {
- parameters.put(KEY_HEAD_LAMP_STATUS, headLampStatus);
- } else {
- parameters.remove(KEY_HEAD_LAMP_STATUS);
- }
+ setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus);
}
@SuppressWarnings("unchecked")
public HeadLampStatus getHeadLampStatus() {
- Object obj = parameters.get(KEY_HEAD_LAMP_STATUS);
- if (obj instanceof HeadLampStatus) {
- return (HeadLampStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new HeadLampStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
- }
- }
- return null;
+ return (HeadLampStatus) getObject(HeadLampStatus.class, KEY_HEAD_LAMP_STATUS);
}
public void setEngineTorque(Double engineTorque) {
- if (engineTorque != null) {
- parameters.put(KEY_ENGINE_TORQUE, engineTorque);
- } else {
- parameters.remove(KEY_ENGINE_TORQUE);
- }
+ setParameters(KEY_ENGINE_TORQUE, engineTorque);
}
public Double getEngineTorque() {
- Object object = parameters.get(KEY_ENGINE_TORQUE);
+ Object object = getParameters(KEY_ENGINE_TORQUE);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setAccPedalPosition(Double accPedalPosition) {
- if (accPedalPosition != null) {
- parameters.put(KEY_ACC_PEDAL_POSITION, accPedalPosition);
- } else {
- parameters.remove(KEY_ACC_PEDAL_POSITION);
- }
+ setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition);
}
public Double getAccPedalPosition() {
- Object object = parameters.get(KEY_ACC_PEDAL_POSITION);
+ Object object = getParameters(KEY_ACC_PEDAL_POSITION);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setSteeringWheelAngle(Double steeringWheelAngle) {
- if (steeringWheelAngle != null) {
- parameters.put(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
- } else {
- parameters.remove(KEY_STEERING_WHEEL_ANGLE);
- }
+ setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
}
public Double getSteeringWheelAngle() {
- Object object = parameters.get(KEY_STEERING_WHEEL_ANGLE);
+ Object object = getParameters(KEY_STEERING_WHEEL_ANGLE);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setECallInfo(ECallInfo eCallInfo) {
- if (eCallInfo != null) {
- parameters.put(KEY_E_CALL_INFO, eCallInfo);
- } else {
- parameters.remove(KEY_E_CALL_INFO);
- }
+ setParameters(KEY_E_CALL_INFO, eCallInfo);
}
@SuppressWarnings("unchecked")
public ECallInfo getECallInfo() {
- Object obj = parameters.get(KEY_E_CALL_INFO);
- if (obj instanceof ECallInfo) {
- return (ECallInfo) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new ECallInfo((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
- }
- }
- return null;
+ return (ECallInfo) getObject(ECallInfo.class, KEY_E_CALL_INFO);
}
public void setAirbagStatus(AirbagStatus airbagStatus) {
- if (airbagStatus != null) {
- parameters.put(KEY_AIRBAG_STATUS, airbagStatus);
- } else {
- parameters.remove(KEY_AIRBAG_STATUS);
- }
+ setParameters(KEY_AIRBAG_STATUS, airbagStatus);
}
@SuppressWarnings("unchecked")
public AirbagStatus getAirbagStatus() {
- Object obj = parameters.get(KEY_AIRBAG_STATUS);
- if (obj instanceof AirbagStatus) {
- return (AirbagStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new AirbagStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
- }
- }
- return null;
+ return (AirbagStatus) getObject(AirbagStatus.class, KEY_AIRBAG_STATUS);
}
public void setEmergencyEvent(EmergencyEvent emergencyEvent) {
- if (emergencyEvent != null) {
- parameters.put(KEY_EMERGENCY_EVENT, emergencyEvent);
- } else {
- parameters.remove(KEY_EMERGENCY_EVENT);
- }
+ setParameters(KEY_EMERGENCY_EVENT, emergencyEvent);
}
@SuppressWarnings("unchecked")
public EmergencyEvent getEmergencyEvent() {
- Object obj = parameters.get(KEY_EMERGENCY_EVENT);
- if (obj instanceof EmergencyEvent) {
- return (EmergencyEvent) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new EmergencyEvent((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
- }
- }
- return null;
+ return (EmergencyEvent) getObject(EmergencyEvent.class, KEY_EMERGENCY_EVENT);
}
public void setClusterModeStatus(ClusterModeStatus clusterModeStatus) {
- if (clusterModeStatus != null) {
- parameters.put(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
- } else {
- parameters.remove(KEY_CLUSTER_MODE_STATUS);
- }
+ setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
}
@SuppressWarnings("unchecked")
public ClusterModeStatus getClusterModeStatus() {
- Object obj = parameters.get(KEY_CLUSTER_MODE_STATUS);
- if (obj instanceof ClusterModeStatus) {
- return (ClusterModeStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new ClusterModeStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
- }
- }
- return null;
+ return (ClusterModeStatus) getObject(ClusterModeStatus.class, KEY_CLUSTER_MODE_STATUS);
}
public void setMyKey(MyKey myKey) {
- if (myKey != null) {
- parameters.put(KEY_MY_KEY, myKey);
- } else {
- parameters.remove(KEY_MY_KEY);
- }
+ setParameters(KEY_MY_KEY, myKey);
}
@SuppressWarnings("unchecked")
public MyKey getMyKey() {
- Object obj = parameters.get(KEY_MY_KEY);
- if (obj instanceof MyKey) {
- return (MyKey) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new MyKey((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
- }
- }
- return null;
+ return (MyKey) getObject(MyKey.class, KEY_MY_KEY);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java
index f9832da0e..443e66b3d 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPoints.java
@@ -18,20 +18,10 @@ public class GetWayPoints extends RPCRequest {
}
public WayPointType getWayPointType() {
- Object obj = parameters.get(KEY_WAY_POINT_TYPE);
- if (obj instanceof WayPointType) {
- return (WayPointType) obj;
- } else if (obj instanceof String) {
- return WayPointType.valueForString((String) obj);
- }
- return null;
+ return (WayPointType) getObject(WayPointType.class, KEY_WAY_POINT_TYPE);
}
public void setWayPointType(WayPointType wayPointType) {
- if (wayPointType != null) {
- parameters.put(KEY_WAY_POINT_TYPE, wayPointType);
- } else {
- parameters.remove(KEY_WAY_POINT_TYPE);
- }
+ setParameters(KEY_WAY_POINT_TYPE, wayPointType);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java
index 24048c826..13eb85642 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/GetWayPointsResponse.java
@@ -3,7 +3,6 @@ package com.smartdevicelink.proxy.rpc;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
-import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@@ -18,29 +17,10 @@ public class GetWayPointsResponse extends RPCResponse {
}
public void setWayPoints(List<LocationDetails> wayPoints) {
- if (wayPoints != null) {
- parameters.put(KEY_WAY_POINTS, wayPoints);
- } else {
- parameters.remove(KEY_WAY_POINTS);
- }
+ setParameters(KEY_WAY_POINTS, wayPoints);
}
@SuppressWarnings("unchecked")
public List<LocationDetails> getWayPoints() {
- if (parameters.get(KEY_WAY_POINTS) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_WAY_POINTS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof LocationDetails) {
- return (List<LocationDetails>) list;
- } else if (obj instanceof Hashtable) {
- List<LocationDetails> newList = new ArrayList<LocationDetails>();
- for (Object hashObj : list) {
- newList.add(new LocationDetails((Hashtable<String, Object>)hashObj));
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<LocationDetails>) getObject(LocationDetails.class, KEY_WAY_POINTS);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java
index efc94f57c..8f4cdfe66 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMICapabilities.java
@@ -1,21 +1,23 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+
public class HMICapabilities extends RPCStruct{
public static final String KEY_NAVIGATION = "navigation";
public static final String KEY_PHONE_CALL = "phoneCall";
-
- public HMICapabilities() { }
+ public static final String KEY_VIDEO_STREAMING = "videoStreaming";
+ public static final String KEY_REMOTE_CONTROL = "remoteControl";
+
+ public HMICapabilities() { }
public HMICapabilities(Hashtable<String, Object> hash) {
super(hash);
}
public boolean isNavigationAvailable(){
- Object available = store.get(KEY_NAVIGATION);
+ Object available = getValue(KEY_NAVIGATION);
if(available == null){
return false;
}
@@ -23,15 +25,11 @@ public class HMICapabilities extends RPCStruct{
}
public void setNavigationAvilable(Boolean available){
- if (available) {
- store.put(KEY_NAVIGATION, available);
- } else {
- store.remove(KEY_NAVIGATION);
- }
+ setValue(KEY_NAVIGATION, available);
}
public boolean isPhoneCallAvailable(){
- Object available = store.get(KEY_PHONE_CALL);
+ Object available = getValue(KEY_PHONE_CALL);
if(available == null){
return false;
}
@@ -39,11 +37,32 @@ public class HMICapabilities extends RPCStruct{
}
public void setPhoneCallAvilable(Boolean available){
- if (available) {
- store.put(KEY_PHONE_CALL, available);
- } else {
- store.remove(KEY_PHONE_CALL);
- }
+ setValue(KEY_PHONE_CALL, available);
}
+ public boolean isVideoStreamingAvailable(){
+ Object available = getValue(KEY_VIDEO_STREAMING);
+ if(available == null){
+ return false;
+ }
+ return (Boolean)available;
+ }
+
+ public void setVideoStreamingAvailable(Boolean available){
+ setValue(KEY_VIDEO_STREAMING, available);
+ }
+
+ public boolean isRemoteControlAvailable(){
+ Object available = getValue(KEY_REMOTE_CONTROL);
+ if(available == null){
+ return false;
+ }
+ return (Boolean)available;
+ }
+
+ public void setRemoteControlAvailable(Boolean available){
+ setValue(KEY_REMOTE_CONTROL, available);
+ }
+
+
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java
index d8223279a..bf2184d0c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HMIPermissions.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.ArrayList;
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.HMILevel;
+
import java.util.Hashtable;
import java.util.List;
-import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.proxy.rpc.enums.HMILevel;
/**
* Defining sets of HMI levels, which are permitted or prohibited for a given RPC.
* <p><b>Parameter List</b></p>
@@ -63,26 +63,7 @@ public class HMIPermissions extends RPCStruct {
*/
@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 = HMILevel.valueForString(strFormat);
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<HMILevel>) getObject(HMILevel.class, KEY_ALLOWED);
}
/**
@@ -90,11 +71,7 @@ public class HMIPermissions extends RPCStruct {
* @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);
- }
+ setValue(KEY_ALLOWED, allowed);
}
/**
@@ -103,26 +80,7 @@ public class HMIPermissions extends RPCStruct {
*/
@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;
+ return (List<HMILevel>) getObject(HMILevel.class, KEY_USER_DISALLOWED);
}
/**
@@ -130,10 +88,6 @@ public class HMIPermissions extends RPCStruct {
* @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);
- }
+ setValue(KEY_USER_DISALLOWED, userDisallowed);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java
new file mode 100644
index 000000000..64a9f8354
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HapticRect.java
@@ -0,0 +1,82 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
+
+/*
+ * Copyright (c) 2017 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Defines a haptic rectangle that contains a reference ID and the spatial data of a rectangle UI component.
+ * @since SmartDeviceLink 4.5.0
+ *
+ */
+
+public class HapticRect extends RPCStruct {
+ public static final String KEY_ID = "id";
+ public static final String KEY_RECT = "rect";
+
+ public HapticRect() {}
+
+ public HapticRect(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Set a user control spatial identifier that references the supplied spatial data
+ */
+ public void setId(Integer id) {
+ setValue(KEY_ID, id);
+ }
+
+ /**
+ * @return a user control spatial identifier that references the supplied spatial data
+ */
+ public Integer getId() {
+ return getInteger(KEY_ID);
+ }
+
+ /**
+ * Set the position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs.
+ */
+ public void setRect(Rectangle rect) {
+ setValue(KEY_RECT, rect);
+ }
+
+ /**
+ * @return the position of the haptic rectangle to be highlighted. The center of this rectangle will be "touched" when a press occurs.
+ */
+ public Rectangle getRect() {
+ return (Rectangle) getObject(Rectangle.class, KEY_RECT);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java
index 46a982fe2..935b8357e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/HeadLampStatus.java
@@ -55,39 +55,21 @@ public class HeadLampStatus extends RPCStruct {
super(hash);
}
public void setAmbientLightStatus(AmbientLightStatus ambientLightSensorStatus) {
- if (ambientLightSensorStatus != null) {
- store.put(KEY_AMBIENT_LIGHT_SENSOR_STATUS, ambientLightSensorStatus);
- } else {
- store.remove(KEY_AMBIENT_LIGHT_SENSOR_STATUS);
- }
+ setValue(KEY_AMBIENT_LIGHT_SENSOR_STATUS, ambientLightSensorStatus);
}
public AmbientLightStatus getAmbientLightStatus() {
- Object obj = store.get(KEY_AMBIENT_LIGHT_SENSOR_STATUS);
- if (obj instanceof AmbientLightStatus) {
- return (AmbientLightStatus) obj;
- } else if (obj instanceof String) {
- return AmbientLightStatus.valueForString((String) obj);
- }
- return null;
+ return (AmbientLightStatus) getObject(AmbientLightStatus.class, KEY_AMBIENT_LIGHT_SENSOR_STATUS);
}
public void setHighBeamsOn(Boolean highBeamsOn) {
- if (highBeamsOn != null) {
- store.put(KEY_HIGH_BEAMS_ON, highBeamsOn);
- } else {
- store.remove(KEY_HIGH_BEAMS_ON);
- }
+ setValue(KEY_HIGH_BEAMS_ON, highBeamsOn);
}
public Boolean getHighBeamsOn() {
- return (Boolean) store.get(KEY_HIGH_BEAMS_ON);
+ return getBoolean(KEY_HIGH_BEAMS_ON);
}
public void setLowBeamsOn(Boolean lowBeamsOn) {
- if (lowBeamsOn != null) {
- store.put(KEY_LOW_BEAMS_ON, lowBeamsOn);
- } else {
- store.remove(KEY_LOW_BEAMS_ON);
- }
+ setValue(KEY_LOW_BEAMS_ON, lowBeamsOn);
}
public Boolean getLowBeamsOn() {
- return (Boolean) store.get(KEY_LOW_BEAMS_ON);
+ return getBoolean(KEY_LOW_BEAMS_ON);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java
index 2be4f1a17..2ae607100 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Headers.java
@@ -1,8 +1,8 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
/**
*
* @since SmartDeviceLink 3.0
@@ -37,123 +37,83 @@ public class Headers extends RPCStruct {
}
public void setContentType(String contenttype) {
- if (contenttype != null) {
- store.put(KEY_CONTENT_TYPE, contenttype);
- } else {
- store.remove(KEY_CONTENT_TYPE);
- }
+ setValue(KEY_CONTENT_TYPE, contenttype);
}
public String getContentType() {
- return (String) store.get(KEY_CONTENT_TYPE);
+ return getString(KEY_CONTENT_TYPE);
}
public void setConnectTimeout(Integer connectiontimeout) {
- if (connectiontimeout != null) {
- store.put(KEY_CONNECT_TIMEOUT, connectiontimeout);
- } else {
- store.remove(KEY_CONNECT_TIMEOUT);
- }
+ setValue(KEY_CONNECT_TIMEOUT, connectiontimeout);
}
public Integer getConnectTimeout() {
- return (Integer) store.get(KEY_CONNECT_TIMEOUT);
+ return getInteger(KEY_CONNECT_TIMEOUT);
}
public void setDoOutput(Boolean dooutput) {
- if (dooutput != null) {
- store.put(KEY_DO_OUTPUT, dooutput);
- } else {
- store.remove(KEY_DO_OUTPUT);
- }
+ setValue(KEY_DO_OUTPUT, dooutput);
}
public Boolean getDoOutput() {
- return (Boolean) store.get(KEY_DO_OUTPUT);
+ return getBoolean(KEY_DO_OUTPUT);
}
- public void setDoInput(Boolean dooutput) {
- if (dooutput != null) {
- store.put(KEY_DO_INPUT, dooutput);
- } else {
- store.remove(KEY_DO_INPUT);
- }
+ public void setDoInput(Boolean doinput) {
+ setValue(KEY_DO_INPUT, doinput);
}
public Boolean getDoInput() {
- return (Boolean) store.get(KEY_DO_INPUT);
+ return getBoolean(KEY_DO_INPUT);
}
public void setUseCaches(Boolean usescaches) {
- if (usescaches != null) {
- store.put(KEY_USE_CACHES, usescaches);
- } else {
- store.remove(KEY_USE_CACHES);
- }
+ setValue(KEY_USE_CACHES, usescaches);
}
public Boolean getUseCaches() {
- return (Boolean) store.get(KEY_USE_CACHES);
+ return getBoolean(KEY_USE_CACHES);
}
public void setRequestMethod(String requestmethod) {
- if (requestmethod != null) {
- store.put(KEY_REQUEST_METHOD, requestmethod);
- } else {
- store.remove(KEY_REQUEST_METHOD);
- }
+ setValue(KEY_REQUEST_METHOD, requestmethod);
}
public String getRequestMethod() {
- return (String) store.get(KEY_REQUEST_METHOD);
+ return getString(KEY_REQUEST_METHOD);
}
public void setReadTimeout(Integer readtimeout) {
- if (readtimeout != null) {
- store.put(KEY_READ_TIMEOUT, readtimeout);
- } else {
- store.remove(KEY_READ_TIMEOUT);
- }
+ setValue(KEY_READ_TIMEOUT, readtimeout);
}
public Integer getReadTimeout() {
- return (Integer) store.get(KEY_READ_TIMEOUT);
+ return getInteger(KEY_READ_TIMEOUT);
}
public void setInstanceFollowRedirects(Boolean instancefollowredirects) {
- if (instancefollowredirects != null) {
- store.put(KEY_INSTANCE_FOLLOW_REDIRECTS, instancefollowredirects);
- } else {
- store.remove(KEY_INSTANCE_FOLLOW_REDIRECTS);
- }
+ setValue(KEY_INSTANCE_FOLLOW_REDIRECTS, instancefollowredirects);
}
public Boolean getInstanceFollowRedirects() {
- return (Boolean) store.get(KEY_INSTANCE_FOLLOW_REDIRECTS);
+ return getBoolean(KEY_INSTANCE_FOLLOW_REDIRECTS);
}
public void setCharset(String charset) {
- if (charset != null) {
- store.put(KEY_CHARSET, charset);
- } else {
- store.remove(KEY_CHARSET);
- }
+ setValue(KEY_CHARSET, charset);
}
public String getCharset() {
- return (String) store.get(KEY_CHARSET);
+ return getString(KEY_CHARSET);
}
public void setContentLength(Integer contentlength) {
- if (contentlength != null) {
- store.put(KEY_CONTENT_LENGTH, contentlength);
- } else {
- store.remove(KEY_CONTENT_LENGTH);
- }
+ setValue(KEY_CONTENT_LENGTH, contentlength);
}
public Integer getContentLength() {
- return (Integer) store.get(KEY_CONTENT_LENGTH);
+ return getInteger(KEY_CONTENT_LENGTH);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Image.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Image.java
index 76ad2d224..8182fc43c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Image.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Image.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.ImageType;
+import java.util.Hashtable;
+
/**
*Specifies, which image shall be used, e.g. in Alerts or on Softbuttons provided the display supports it.
*<p><b>Parameter List</b></p>
@@ -57,11 +57,7 @@ public class Image extends RPCStruct {
* @param value either the static hex icon value or the binary image file name identifier (sent by PutFile)
*/
public void setValue(String value) {
- if (value != null) {
- store.put(KEY_VALUE, value);
- } else {
- store.remove(KEY_VALUE);
- }
+ setValue(KEY_VALUE, value);
}
/**
@@ -69,7 +65,7 @@ public class Image extends RPCStruct {
* @return either the static hex icon value or the binary image file name identifier (sent by PutFile)
*/
public String getValue() {
- return (String) store.get(KEY_VALUE);
+ return getString(KEY_VALUE);
}
/**
@@ -77,11 +73,7 @@ public class Image extends RPCStruct {
* @param imageType whether it is a static or dynamic image
*/
public void setImageType(ImageType imageType) {
- if (imageType != null) {
- store.put(KEY_IMAGE_TYPE, imageType);
- } else {
- store.remove(KEY_IMAGE_TYPE);
- }
+ setValue(KEY_IMAGE_TYPE, imageType);
}
/**
@@ -89,12 +81,6 @@ public class Image extends RPCStruct {
* @return the image type
*/
public ImageType getImageType() {
- Object obj = store.get(KEY_IMAGE_TYPE);
- if (obj instanceof ImageType) {
- return (ImageType) obj;
- } else if (obj instanceof String) {
- return ImageType.valueForString((String) obj);
- }
- return null;
+ return (ImageType) getObject(ImageType.class, KEY_IMAGE_TYPE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java
index 9e38dc264..1d3b32967 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageField.java
@@ -1,13 +1,17 @@
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.AmbientLightStatus;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.ImageFieldName;
import com.smartdevicelink.util.DebugTool;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import static com.smartdevicelink.proxy.rpc.HeadLampStatus.KEY_AMBIENT_LIGHT_SENSOR_STATUS;
+
/** <p>The name that identifies the field.For example AppIcon,SoftButton, LocationImage, etc.</p>
*
* <p><b>Parameter List</b></p>
@@ -68,73 +72,23 @@ public class ImageField extends RPCStruct {
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;
+ return (ImageFieldName) getObject(ImageFieldName.class, KEY_NAME);
}
public void setName( ImageFieldName name ) {
- if (name != null) {
- store.put(KEY_NAME, name );
- }
- else {
- store.remove(KEY_NAME);
- }
+ setValue(KEY_NAME, 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 = FileType.valueForString(strFormat);
- if (theCode != null) {
- newList.add(theCode);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<FileType>) getObject(FileType.class, KEY_IMAGE_TYPE_SUPPORTED);
}
public void setImageTypeSupported( List<FileType> imageTypeSupported ) {
- if (imageTypeSupported != null) {
- store.put(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported );
- }
- else {
- store.remove(KEY_IMAGE_TYPE_SUPPORTED);
- }
+ setValue(KEY_IMAGE_TYPE_SUPPORTED, imageTypeSupported);
}
@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) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE_RESOLUTION, e);
- }
- }
- return null;
+ return (ImageResolution) getObject(ImageResolution.class, KEY_IMAGE_RESOLUTION);
}
public void setImageResolution( ImageResolution imageResolution ) {
- if (imageResolution != null) {
- store.put(KEY_IMAGE_RESOLUTION, imageResolution );
- }
- else {
- store.remove(KEY_IMAGE_RESOLUTION);
- }
+ setValue(KEY_IMAGE_RESOLUTION, imageResolution);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java
index 682092082..5858a45d0 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ImageResolution.java
@@ -62,26 +62,24 @@ public class ImageResolution extends RPCStruct {
}
public void setResolutionWidth(Integer resolutionWidth) {
- if (resolutionWidth != null) {
- store.put(KEY_RESOLUTION_WIDTH, resolutionWidth);
- } else {
- store.remove(KEY_RESOLUTION_WIDTH);
- }
+ setValue(KEY_RESOLUTION_WIDTH, resolutionWidth);
}
public Integer getResolutionWidth() {
- return (Integer) store.get(KEY_RESOLUTION_WIDTH);
+ return getInteger(KEY_RESOLUTION_WIDTH);
}
public void setResolutionHeight(Integer resolutionHeight) {
- if (resolutionHeight != null) {
- store.put(KEY_RESOLUTION_HEIGHT, resolutionHeight);
- } else {
- store.remove(KEY_RESOLUTION_HEIGHT);
- }
+ setValue(KEY_RESOLUTION_HEIGHT, resolutionHeight);
}
public Integer getResolutionHeight() {
- return (Integer) store.get(KEY_RESOLUTION_HEIGHT);
+ return getInteger(KEY_RESOLUTION_HEIGHT);
+ }
+
+ @Override
+ public String toString() {
+ return "width=" + String.valueOf(getResolutionWidth()) +
+ ", height=" + String.valueOf(getResolutionHeight());
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java
index fb35dcf24..6f651b832 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/KeyboardProperties.java
@@ -1,12 +1,17 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-import java.util.List;
-
import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus;
import com.smartdevicelink.proxy.rpc.enums.KeyboardLayout;
import com.smartdevicelink.proxy.rpc.enums.KeypressMode;
import com.smartdevicelink.proxy.rpc.enums.Language;
+
+import java.util.Hashtable;
+import java.util.List;
+
+import static android.provider.Contacts.SettingsColumns.KEY;
+import static com.smartdevicelink.proxy.rpc.HeadLampStatus.KEY_AMBIENT_LIGHT_SENSOR_STATUS;
+
/** This mode causes the interaction to immediately display a keyboard entry through the HMI.
*
* <p><b>Parameter List</b></p>
@@ -78,106 +83,62 @@ public class KeyboardProperties extends RPCStruct {
private static final KeypressMode KEYPRESS_MODE_DEFAULT = KeypressMode.RESEND_CURRENT_ENTRY;
public KeyboardProperties() {
- store.put(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
+ setValue(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
}
public KeyboardProperties(Hashtable<String, Object> hash) {
super(hash);
if (!store.containsKey(KEY_KEYPRESS_MODE)) {
- store.put(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
+ setValue(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
}
}
public Language getLanguage() {
- Object obj = store.get(KEY_LANGUAGE);
- if (obj instanceof Language) {
- return (Language) obj;
- } else if (obj instanceof String) {
- return Language.valueForString((String) obj);
- }
- return null;
+ return (Language) getObject(Language.class, KEY_LANGUAGE);
}
public void setLanguage(Language language) {
- if (language != null) {
- store.put(KEY_LANGUAGE, language);
- } else {
- store.remove(KEY_LANGUAGE);
- }
+ setValue(KEY_LANGUAGE, language);
}
public KeyboardLayout getKeyboardLayout() {
- Object obj = store.get(KEY_KEYBOARD_LAYOUT);
- if (obj instanceof KeyboardLayout) {
- return (KeyboardLayout) obj;
- } else if (obj instanceof String) {
- return KeyboardLayout.valueForString((String) obj);
- }
- return null;
+ return (KeyboardLayout) getObject(KeyboardLayout.class, KEY_KEYBOARD_LAYOUT);
}
public void setKeyboardLayout(KeyboardLayout keyboardLayout) {
- if (keyboardLayout != null) {
- store.put(KEY_KEYBOARD_LAYOUT, keyboardLayout);
- } else {
- store.remove(KEY_KEYBOARD_LAYOUT);
- }
+ setValue(KEY_KEYBOARD_LAYOUT, keyboardLayout);
}
public KeypressMode getKeypressMode() {
- Object obj = store.get(KEY_KEYPRESS_MODE);
- if (obj instanceof KeypressMode) {
- return (KeypressMode) obj;
- } else if (obj instanceof String) {
- return KeypressMode.valueForString((String) obj);
+ KeypressMode kp = (KeypressMode) getObject(KeypressMode.class, KEY_KEYPRESS_MODE);
+ if(kp == null){
+ kp = KEYPRESS_MODE_DEFAULT;
}
- return KEYPRESS_MODE_DEFAULT;
+ return kp;
}
public void setKeypressMode(KeypressMode keypressMode) {
if (keypressMode != null) {
- store.put(KEY_KEYPRESS_MODE, keypressMode);
+ setValue(KEY_KEYPRESS_MODE, keypressMode);
} else {
- store.put(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
+ setValue(KEY_KEYPRESS_MODE, KEYPRESS_MODE_DEFAULT);
}
}
@SuppressWarnings("unchecked")
public List<String> getLimitedCharacterList() {
- final Object listObj = store.get(KEY_LIMITED_CHARACTER_LIST);
- 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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_LIMITED_CHARACTER_LIST);
}
public void setLimitedCharacterList(List<String> limitedCharacterList) {
- if (limitedCharacterList != null) {
- store.put(KEY_LIMITED_CHARACTER_LIST, limitedCharacterList);
- } else {
- store.remove(KEY_LIMITED_CHARACTER_LIST);
- }
+ setValue(KEY_LIMITED_CHARACTER_LIST, limitedCharacterList);
}
public String getAutoCompleteText() {
- final Object obj = store.get(KEY_AUTO_COMPLETE_TEXT);
- if (obj instanceof String) {
- return (String) obj;
- }
- return null;
+ return (String) getObject(String.class, KEY_AUTO_COMPLETE_TEXT);
}
public void setAutoCompleteText(String autoCompleteText) {
- if (autoCompleteText != null) {
- store.put(KEY_AUTO_COMPLETE_TEXT, autoCompleteText);
- } else {
- store.remove(KEY_AUTO_COMPLETE_TEXT);
- }
+ setValue(KEY_AUTO_COMPLETE_TEXT, autoCompleteText);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java
index 2c7a62e3e..f1f77a7df 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ListFilesResponse.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-import java.util.List;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* List Files Response is sent, when ListFiles has been called
*
@@ -25,33 +25,16 @@ public class ListFilesResponse extends RPCResponse {
super(hash);
}
public void setFilenames(List<String> filenames) {
- if (filenames != null) {
- parameters.put(KEY_FILENAMES, filenames);
- } else {
- parameters.remove(KEY_FILENAMES);
- }
+ setParameters(KEY_FILENAMES, 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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_FILENAMES);
}
public void setSpaceAvailable(Integer spaceAvailable) {
- if (spaceAvailable != null) {
- parameters.put(KEY_SPACE_AVAILABLE, spaceAvailable);
- } else {
- parameters.remove(KEY_SPACE_AVAILABLE);
- }
+ setParameters(KEY_SPACE_AVAILABLE, spaceAvailable);
}
public Integer getSpaceAvailable() {
- return (Integer) parameters.get(KEY_SPACE_AVAILABLE);
+ return getInteger(KEY_SPACE_AVAILABLE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java
index 50dcaf49b..51d150a2b 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/LocationDetails.java
@@ -1,7 +1,6 @@
package com.smartdevicelink.proxy.rpc;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.util.DebugTool;
import java.util.Hashtable;
import java.util.List;
@@ -24,127 +23,59 @@ public class LocationDetails extends RPCStruct{
@SuppressWarnings("unchecked")
public Coordinate getCoordinate() {
- Object obj = store.get(KEY_COORDINATE);
- if (obj instanceof Coordinate) {
- return (Coordinate) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Coordinate((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_COORDINATE, e);
- }
- }
- return null;
+ return (Coordinate) getObject(Coordinate.class, KEY_COORDINATE);
}
public void setCoordinate(Coordinate coordinate) {
- if (coordinate != null) {
- store.put(KEY_COORDINATE, coordinate);
- } else {
- store.remove(KEY_COORDINATE);
- }
+ setValue(KEY_COORDINATE, coordinate);
}
public String getLocationName() {
- return (String) store.get(KEY_LOCATION_NAME);
+ return getString(KEY_LOCATION_NAME);
}
public void setLocationName(String locationName) {
- if (locationName != null) {
- store.put(KEY_LOCATION_NAME, locationName);
- } else {
- store.remove(KEY_LOCATION_NAME);
- }
+ setValue(KEY_LOCATION_NAME, locationName);
}
@SuppressWarnings("unchecked")
public List<String> getAddressLines() {
- final Object listObj = store.get(KEY_ADDRESS_LINES);
- if (listObj instanceof List<?>) {
- List<?> list = (List<?>) listObj;
- if (list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof String) {
- return (List<String>) list;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_ADDRESS_LINES);
}
public void setAddressLines(List<String> addressLines) {
- if (addressLines != null) {
- store.put(KEY_ADDRESS_LINES, addressLines);
- } else {
- store.remove(KEY_ADDRESS_LINES);
- }
+ setValue(KEY_ADDRESS_LINES, addressLines);
}
public String getLocationDescription() {
- return (String) store.get(KEY_LOCATION_DESCRIPTION);
+ return getString(KEY_LOCATION_DESCRIPTION);
}
public void setLocationDescription(String locationDescription) {
- if (locationDescription != null) {
- store.put(KEY_LOCATION_DESCRIPTION, locationDescription);
- } else {
- store.remove(KEY_LOCATION_DESCRIPTION);
- }
+ setValue(KEY_LOCATION_DESCRIPTION, locationDescription);
}
public String getPhoneNumber() {
- return (String) store.get(KEY_PHONE_NUMBER);
+ return getString(KEY_PHONE_NUMBER);
}
public void setPhoneNumber(String phoneNumber) {
- if (phoneNumber != null) {
- store.put(KEY_PHONE_NUMBER, phoneNumber);
- } else {
- store.remove(KEY_PHONE_NUMBER);
- }
+ setValue(KEY_PHONE_NUMBER, phoneNumber);
}
@SuppressWarnings("unchecked")
public Image getLocationImage() {
- Object obj = store.get(KEY_LOCATION_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LOCATION_IMAGE, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_LOCATION_IMAGE);
}
public void setLocationImage(Image locationImage) {
- if (locationImage != null) {
- store.put(KEY_LOCATION_IMAGE, locationImage);
- } else {
- store.remove(KEY_LOCATION_IMAGE);
- }
+ setValue(KEY_LOCATION_IMAGE, locationImage);
}
@SuppressWarnings("unchecked")
public OasisAddress getSearchAddress() {
- Object obj = store.get(KEY_SEARCH_ADDRESS);
- if (obj instanceof OasisAddress) {
- return (OasisAddress) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new OasisAddress((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SEARCH_ADDRESS, e);
- }
- }
- return null;
+ return (OasisAddress) getObject(OasisAddress.class, KEY_SEARCH_ADDRESS);
}
public void setSearchAddress(OasisAddress searchAddress) {
- if (searchAddress != null) {
- store.put(KEY_SEARCH_ADDRESS, searchAddress);
- } else {
- store.remove(KEY_SEARCH_ADDRESS);
- }
+ setValue(KEY_SEARCH_ADDRESS, searchAddress);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java
index a9f22238a..e096cb7df 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MenuParams.java
@@ -1,8 +1,8 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
/**
* Used when adding a sub menu to an application menu or existing sub menu.
* <p><b> Parameter List</b></p>
@@ -76,7 +76,7 @@ public class MenuParams extends RPCStruct {
* @return parentID Min: 0 Max: 2000000000
*/
public Integer getParentID() {
- return (Integer) store.get( KEY_PARENT_ID );
+ return getInteger( KEY_PARENT_ID );
}
/**
* Set the unique ID of an existing submenu to which a command will be added.
@@ -84,11 +84,7 @@ public class MenuParams extends RPCStruct {
* @param parentID Min: 0; Max: 2000000000
*/
public void setParentID( Integer parentID ) {
- if (parentID != null) {
- store.put(KEY_PARENT_ID, parentID );
- } else {
- store.remove(KEY_PARENT_ID);
- }
+ setValue(KEY_PARENT_ID, parentID);
}
/**
* Get the position within the items of the parent Command Menu. 0 will insert at the front, 1 will insert after the first existing element, etc.
@@ -102,7 +98,7 @@ public class MenuParams extends RPCStruct {
* @return the position within the items of the parent Command Menu
*/
public Integer getPosition() {
- return (Integer) store.get( KEY_POSITION );
+ return getInteger( KEY_POSITION );
}
/**
* Set the position within the items of the parent Command Menu. 0 will insert at the front, 1 will insert after the first existing element, etc.
@@ -116,11 +112,7 @@ public class MenuParams extends RPCStruct {
* @param position Mix: 0 Max: 1000
*/
public void setPosition( Integer position ) {
- if (position != null) {
- store.put(KEY_POSITION, position );
- } else {
- store.remove(KEY_POSITION);
- }
+ setValue(KEY_POSITION, position);
}
/**
* Get the text which appears in menu, representing this command.
@@ -132,7 +124,7 @@ public class MenuParams extends RPCStruct {
*/
public String getMenuName() {
- return (String) store.get( KEY_MENU_NAME );
+ return getString( KEY_MENU_NAME );
}
/**
* Set text which appears in menu, representing this command.
@@ -144,10 +136,6 @@ public class MenuParams extends RPCStruct {
*/
public void setMenuName( String menuName ) {
- if (menuName != null) {
- store.put(KEY_MENU_NAME, menuName );
- } else {
- store.remove(KEY_MENU_NAME);
- }
+ setValue(KEY_MENU_NAME, menuName);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MetadataTags.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MetadataTags.java
new file mode 100644
index 000000000..dc5a9b5aa
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MetadataTags.java
@@ -0,0 +1,116 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.MetadataType;
+
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
+
+public class MetadataTags extends RPCStruct {
+
+ public static final String KEY_MAIN_FIELD_1_TYPE = "mainField1";
+ public static final String KEY_MAIN_FIELD_2_TYPE = "mainField2";
+ public static final String KEY_MAIN_FIELD_3_TYPE = "mainField3";
+ public static final String KEY_MAIN_FIELD_4_TYPE = "mainField4";
+
+ /**
+ * Constructs a newly allocated MetadataTags object
+ */
+ public MetadataTags(){}
+
+ /**
+ * Constructs a newly allocated MetadataTags object indicated by the Hashtable parameter
+ * @param hash The Hashtable to use
+ */
+ public MetadataTags(Hashtable<String, Object> hash){super(hash);}
+
+ /**
+ * Set the metadata types of data contained in the "mainField1" text field
+ */
+ public void setMainField1( List<MetadataType> metadataTypes ) {
+ setValue(KEY_MAIN_FIELD_1_TYPE, metadataTypes);
+ }
+
+ /**
+ * Set the metadata type of data contained in the "mainField1" text field
+ */
+ public void setMainField1(MetadataType metadataType) {
+ setValue(KEY_MAIN_FIELD_1_TYPE, Collections.singletonList(metadataType));
+ }
+
+ /**
+ * @return The type of data contained in the "mainField1" text field
+ */
+ @SuppressWarnings("unchecked")
+ public List<MetadataType> getMainField1() {
+ return (List<MetadataType>) getObject(MetadataType.class, KEY_MAIN_FIELD_1_TYPE);
+ }
+
+ /**
+ * Set the metadata types of data contained in the "mainField2" text field
+ */
+ public void setMainField2( List<MetadataType> metadataTypes ) {
+ setValue(KEY_MAIN_FIELD_2_TYPE, metadataTypes);
+ }
+
+ /**
+ * Set the metadata type of data contained in the "mainField2" text field
+ */
+ public void setMainField2(MetadataType metadataType) {
+ setValue(KEY_MAIN_FIELD_2_TYPE, Collections.singletonList(metadataType));
+ }
+
+ /**
+ * @return The type of data contained in the "mainField2" text field
+ */
+ @SuppressWarnings("unchecked")
+ public List<MetadataType> getMainField2() {
+ return (List<MetadataType>) getObject(MetadataType.class, KEY_MAIN_FIELD_2_TYPE);
+ }
+
+ /**
+ * Set the metadata types of data contained in the "mainField3" text field
+ */
+ public void setMainField3( List<MetadataType> metadataTypes ) {
+ setValue(KEY_MAIN_FIELD_3_TYPE, metadataTypes);
+ }
+
+ /**
+ * Set the metadata type of data contained in the "mainField3" text field
+ */
+ public void setMainField3(MetadataType metadataType) {
+ setValue(KEY_MAIN_FIELD_3_TYPE, Collections.singletonList(metadataType));
+ }
+
+ /**
+ * @return The type of data contained in the "mainField3" text field
+ */
+ @SuppressWarnings("unchecked")
+ public List<MetadataType> getMainField3() {
+ return (List<MetadataType>) getObject(MetadataType.class, KEY_MAIN_FIELD_3_TYPE);
+ }
+
+ /**
+ * Set the metadata types of data contained in the "mainField4" text field
+ */
+ public void setMainField4( List<MetadataType> metadataTypes ) {
+ setValue(KEY_MAIN_FIELD_4_TYPE, metadataTypes);
+ }
+
+ /**
+ * Set the metadata type of data contained in the "mainField4" text field
+ */
+ public void setMainField4(MetadataType metadataType) {
+ setValue(KEY_MAIN_FIELD_4_TYPE, Collections.singletonList(metadataType));
+ }
+
+ /**
+ * @return The type of data contained in the "mainField4" text field
+ */
+ @SuppressWarnings("unchecked")
+ public List<MetadataType> getMainField4() {
+ return (List<MetadataType>) getObject(MetadataType.class, KEY_MAIN_FIELD_4_TYPE);
+ }
+
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ModuleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ModuleData.java
new file mode 100644
index 000000000..e04ab1ad5
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ModuleData.java
@@ -0,0 +1,75 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.ModuleType;
+import java.util.Hashtable;
+
+public class ModuleData extends RPCStruct{
+ public static final String KEY_MODULE_TYPE= "moduleType";
+ public static final String KEY_RADIO_CONTROL_DATA = "radioControlData";
+ public static final String KEY_CLIMATE_CONTROL_DATA = "climateControlData";
+
+ public ModuleData() {
+ }
+
+ public ModuleData(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the moduleType portion of the ModuleData class
+ *
+ * @param moduleType
+ * The moduleType indicates which type of data should be changed and identifies which data object exists in this struct.
+ * For example, if the moduleType is CLIMATE then a "climateControlData" should exist
+ */
+ public void setModuleType(ModuleType moduleType) {
+ setValue(KEY_MODULE_TYPE, moduleType);
+ }
+
+ /**
+ * Gets the moduleType portion of the ModuleData class
+ *
+ * @return ModuleType - The moduleType indicates which type of data should be changed and identifies which data object exists in this struct.
+ * For example, if the moduleType is CLIMATE then a "climateControlData" should exist.
+ */
+ public ModuleType getModuleType() {
+ return (ModuleType) getObject(ModuleType.class, KEY_MODULE_TYPE);
+ }
+
+ /**
+ * Sets the radioControlData portion of the ModuleData class
+ *
+ * @param radioControlData
+ */
+ public void setRadioControlData(RadioControlData radioControlData) {
+ setValue(KEY_RADIO_CONTROL_DATA, radioControlData);
+ }
+
+ /**
+ * Gets the radioControlData portion of the ModuleData class
+ *
+ * @return RadioControlData
+ */
+ public RadioControlData getRadioControlData() {
+ return (RadioControlData) getObject(RadioControlData.class, KEY_RADIO_CONTROL_DATA);
+ }
+
+ /**
+ * Sets the climateControlData portion of the ModuleData class
+ *
+ * @param climateControlData
+ */
+ public void setClimateControlData(ClimateControlData climateControlData) {
+ setValue(KEY_CLIMATE_CONTROL_DATA, climateControlData);
+ }
+
+ /**
+ * Gets the climateControlData portion of the ModuleData class
+ *
+ * @return ClimateControlData
+ */
+ public ClimateControlData getClimateControlData() {
+ return (ClimateControlData) getObject(ClimateControlData.class, KEY_CLIMATE_CONTROL_DATA);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java
index 4936f9fec..f17a6b54c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/MyKey.java
@@ -48,19 +48,9 @@ public class MyKey extends RPCStruct {
}
public void setE911Override(VehicleDataStatus e911Override) {
- if (e911Override != null) {
- store.put(KEY_E_911_OVERRIDE, e911Override);
- } else {
- store.remove(KEY_E_911_OVERRIDE);
- }
+ setValue(KEY_E_911_OVERRIDE, e911Override);
}
public VehicleDataStatus getE911Override() {
- Object obj = store.get(KEY_E_911_OVERRIDE);
- if (obj instanceof VehicleDataStatus) {
- return (VehicleDataStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataStatus) getObject(VehicleDataStatus.class, KEY_E_911_OVERRIDE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/NavigationCapability.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/NavigationCapability.java
new file mode 100644
index 000000000..c3d0d59f8
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/NavigationCapability.java
@@ -0,0 +1,35 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
+
+/*
+ * Extended capabilities for an onboard navigation system
+ */
+public class NavigationCapability extends RPCStruct{
+ public static final String KEY_LOCATION_ENABLED = "sendLocationEnabled";
+ public static final String KEY_GETWAYPOINTS_ENABLED = "getWayPointsEnabled";
+
+ public NavigationCapability(){}
+
+ public NavigationCapability(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ public Boolean getSendLocationEnabled(){
+ return getBoolean(KEY_LOCATION_ENABLED);
+ }
+
+ public void setSendLocationEnabled(Boolean sendLocationEnabled){
+ setValue(KEY_LOCATION_ENABLED, sendLocationEnabled);
+ }
+
+ public Boolean getWayPointsEnabled(){
+ return getBoolean(KEY_GETWAYPOINTS_ENABLED);
+ }
+
+ public void setWayPointsEnabled(Boolean getWayPointsEnabled){
+ setValue(KEY_GETWAYPOINTS_ENABLED, getWayPointsEnabled);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java
index 131edaa9a..54b95e300 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OasisAddress.java
@@ -35,7 +35,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public String getCountryName() {
- return (String) store.get(KEY_COUNTRY_NAME);
+ return getString(KEY_COUNTRY_NAME);
}
/**
@@ -46,11 +46,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setCountryName(String countryName) {
- if (countryName != null) {
- store.put(KEY_COUNTRY_NAME, countryName);
- } else {
- store.remove(KEY_COUNTRY_NAME);
- }
+ setValue(KEY_COUNTRY_NAME, countryName);
}
/**
@@ -60,7 +56,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public String getCountryCode() {
- return (String) store.get(KEY_COUNTRY_CODE);
+ return getString(KEY_COUNTRY_CODE);
}
/**
@@ -71,11 +67,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setCountryCode(String countryCode) {
- if (countryCode != null) {
- store.put(KEY_COUNTRY_CODE, countryCode);
- } else {
- store.remove(KEY_COUNTRY_CODE);
- }
+ setValue(KEY_COUNTRY_CODE, countryCode);
}
/**
@@ -85,7 +77,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public String getPostalCode() {
- return (String) store.get(KEY_POSTAL_CODE);
+ return getString(KEY_POSTAL_CODE);
}
/**
@@ -96,11 +88,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setPostalCode(String postalCode) {
- if (postalCode != null) {
- store.put(KEY_POSTAL_CODE, postalCode);
- } else {
- store.remove(KEY_POSTAL_CODE);
- }
+ setValue(KEY_POSTAL_CODE, postalCode);
}
/**
@@ -110,7 +98,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public String getAdministrativeArea() {
- return (String) store.get(KEY_ADMINISTRATIVE_AREA);
+ return getString(KEY_ADMINISTRATIVE_AREA);
}
/**
@@ -121,11 +109,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setAdministrativeArea(String administrativeArea) {
- if (administrativeArea != null) {
- store.put(KEY_ADMINISTRATIVE_AREA, administrativeArea);
- } else {
- store.remove(KEY_ADMINISTRATIVE_AREA);
- }
+ setValue(KEY_ADMINISTRATIVE_AREA, administrativeArea);
}
/**
@@ -135,7 +119,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public String getSubAdministrativeArea() {
- return (String) store.get(KEY_SUB_ADMINISTRATIVE_AREA);
+ return getString(KEY_SUB_ADMINISTRATIVE_AREA);
}
/**
@@ -146,11 +130,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setSubAdministrativeArea(String subAdministrativeArea) {
- if (subAdministrativeArea != null) {
- store.put(KEY_SUB_ADMINISTRATIVE_AREA, subAdministrativeArea);
- } else {
- store.remove(KEY_SUB_ADMINISTRATIVE_AREA);
- }
+ setValue(KEY_SUB_ADMINISTRATIVE_AREA, subAdministrativeArea);
}
/**
@@ -160,7 +140,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public String getLocality() {
- return (String) store.get(KEY_LOCALITY);
+ return getString(KEY_LOCALITY);
}
/**
@@ -171,11 +151,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setLocality(String locality) {
- if (locality != null) {
- store.put(KEY_LOCALITY, locality);
- } else {
- store.remove(KEY_LOCALITY);
- }
+ setValue(KEY_LOCALITY, locality);
}
/**
@@ -185,7 +161,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public String getSubLocality() {
- return (String) store.get(KEY_SUB_LOCALITY);
+ return getString(KEY_SUB_LOCALITY);
}
/**
@@ -196,11 +172,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setSubLocality(String subLocality) {
- if (subLocality != null) {
- store.put(KEY_SUB_LOCALITY, subLocality);
- } else {
- store.remove(KEY_SUB_LOCALITY);
- }
+ setValue(KEY_SUB_LOCALITY, subLocality);
}
/**
@@ -210,7 +182,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public String getThoroughfare() {
- return (String) store.get(KEY_THOROUGH_FARE);
+ return getString(KEY_THOROUGH_FARE);
}
/**
@@ -221,11 +193,7 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setThoroughfare(String thoroughFare) {
- if (thoroughFare != null) {
- store.put(KEY_THOROUGH_FARE, thoroughFare);
- } else {
- store.remove(KEY_THOROUGH_FARE);
- }
+ setValue(KEY_THOROUGH_FARE, thoroughFare);
}
/**
@@ -234,7 +202,7 @@ public class OasisAddress extends RPCStruct{
* @return String - The Sub-Thoroughfare associated with the OasisAddress class.
*/
public String getSubThoroughfare() {
- return (String) store.get(KEY_SUB_THOROUGH_FARE);
+ return getString(KEY_SUB_THOROUGH_FARE);
}
/**
@@ -245,10 +213,6 @@ public class OasisAddress extends RPCStruct{
*
*/
public void setSubThoroughfare(String subThoroughfare) {
- if (subThoroughfare != null) {
- store.put(KEY_SUB_THOROUGH_FARE, subThoroughfare);
- } else {
- store.remove(KEY_SUB_THOROUGH_FARE);
- }
+ setValue(KEY_SUB_THOROUGH_FARE, subThoroughfare);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java
index af155226e..0e4a4f7c7 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnAppInterfaceUnregistered.java
@@ -1,11 +1,11 @@
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.AppInterfaceUnregisteredReason;
+import java.util.Hashtable;
+
/**
* <p>Notifies an application that its interface registration has been terminated. This means that all SDL resources
* associated with the application are discarded, including the Command Menu, Choice Sets, button subscriptions, etc.</p>
@@ -59,23 +59,13 @@ public class OnAppInterfaceUnregistered extends RPCNotification {
* @return {@linkplain AppInterfaceUnregisteredReason} the reason the application's interface registration was terminated
*/
public AppInterfaceUnregisteredReason getReason() {
- Object obj = parameters.get(KEY_REASON);
- if (obj instanceof AppInterfaceUnregisteredReason) {
- return (AppInterfaceUnregisteredReason) obj;
- } else if (obj instanceof String) {
- return AppInterfaceUnregisteredReason.valueForString((String) obj);
- }
- return null;
+ return (AppInterfaceUnregisteredReason) getObject(AppInterfaceUnregisteredReason.class, KEY_REASON);
}
/**
* <p>Set the reason application's interface was terminated</p>
* @param reason The reason application's interface registration was terminated
*/
public void setReason( AppInterfaceUnregisteredReason reason ) {
- if (reason != null) {
- parameters.put(KEY_REASON, reason );
- } else {
- parameters.remove(KEY_REASON);
- }
+ setParameters(KEY_REASON, reason);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java
index 7f9afb627..185493ec7 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonEvent.java
@@ -1,12 +1,12 @@
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.ButtonEventMode;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
+import java.util.Hashtable;
+
/**
* Notifies application that user has depressed or released a button to which
* the application has subscribed.Further information about button events
@@ -109,37 +109,21 @@ public class OnButtonEvent extends RPCNotification {
* @return ButtonName Name of the button
*/
public ButtonName getButtonName() {
- Object obj = parameters.get(KEY_BUTTON_NAME);
- if (obj instanceof ButtonName) {
- return (ButtonName) obj;
- } else if (obj instanceof String) {
- return ButtonName.valueForString((String) obj);
- }
- return null;
+ return (ButtonName) getObject(ButtonName.class, KEY_BUTTON_NAME);
}
/**
* <p>Set the button's name</p>
* @param buttonName name of the button
*/
public void setButtonName(ButtonName buttonName) {
- if (buttonName != null) {
- parameters.put(KEY_BUTTON_NAME, buttonName);
- } else {
- parameters.remove(KEY_BUTTON_NAME);
- }
+ setParameters(KEY_BUTTON_NAME, buttonName);
}
/**
* <p>Return <i>{@linkplain ButtonEventMode} indicates the button was depressed or released</i></p>
* @return ButtonEventMode the button depressed or released
*/
public ButtonEventMode getButtonEventMode() {
- Object obj = parameters.get(KEY_BUTTON_EVENT_MODE);
- if (obj instanceof ButtonEventMode) {
- return (ButtonEventMode) obj;
- } else if (obj instanceof String) {
- return ButtonEventMode.valueForString((String) obj);
- }
- return null;
+ return (ButtonEventMode) getObject(ButtonEventMode.class, KEY_BUTTON_EVENT_MODE);
}
/**
* <p> Set the event mode of the button,pressed or released</p>
@@ -147,20 +131,12 @@ public class OnButtonEvent extends RPCNotification {
* @see ButtonEventMode
*/
public void setButtonEventMode(ButtonEventMode buttonEventMode) {
- if (buttonEventMode != null) {
- parameters.put(KEY_BUTTON_EVENT_MODE, buttonEventMode);
- } else {
- parameters.remove(KEY_BUTTON_EVENT_MODE);
- }
+ setParameters(KEY_BUTTON_EVENT_MODE, buttonEventMode);
}
public void setCustomButtonID(Integer customButtonID) {
- if (customButtonID != null) {
- parameters.put(KEY_CUSTOM_BUTTON_ID, customButtonID);
- } else {
- parameters.remove(KEY_CUSTOM_BUTTON_ID);
- }
+ setParameters(KEY_CUSTOM_BUTTON_ID, customButtonID);
}
public Integer getCustomButtonID() {
- return (Integer) parameters.get(KEY_CUSTOM_BUTTON_ID);
+ return getInteger(KEY_CUSTOM_BUTTON_ID);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java
index c881cc297..48562ab2f 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnButtonPress.java
@@ -1,12 +1,12 @@
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.ButtonName;
import com.smartdevicelink.proxy.rpc.enums.ButtonPressMode;
+import java.util.Hashtable;
+
/**
* <p>
* Notifies application of button press events for buttons to which the
@@ -114,56 +114,32 @@ public class OnButtonPress extends RPCNotification {
* @return ButtonName Name of the button
*/
public ButtonName getButtonName() {
- Object obj = parameters.get(KEY_BUTTON_NAME);
- if (obj instanceof ButtonName) {
- return (ButtonName) obj;
- } else if (obj instanceof String) {
- return ButtonName.valueForString((String) obj);
- }
- return null;
+ return (ButtonName) getObject(ButtonName.class, KEY_BUTTON_NAME);
}
/**
* <p>Set the button's name</p>
* @param buttonName name of the button
*/
public void setButtonName( ButtonName buttonName ) {
- if (buttonName != null) {
- parameters.put(KEY_BUTTON_NAME, buttonName );
- } else {
- parameters.remove(KEY_BUTTON_NAME);
- }
+ setParameters(KEY_BUTTON_NAME, buttonName);
}
/**<p>Returns <i>{@linkplain ButtonPressMode}</i></p>
* @return ButtonPressMode whether this is a long or short button press event
*/
public ButtonPressMode getButtonPressMode() {
- Object obj = parameters.get(KEY_BUTTON_PRESS_MODE);
- if (obj instanceof ButtonPressMode) {
- return (ButtonPressMode) obj;
- } else if (obj instanceof String) {
- return ButtonPressMode.valueForString((String) obj);
- }
- return null;
+ return (ButtonPressMode) getObject(ButtonPressMode.class, KEY_BUTTON_PRESS_MODE);
}
/**
* <p>Set the button press mode of the event</p>
* @param buttonPressMode indicates whether this is a short or long press
*/
public void setButtonPressMode( ButtonPressMode buttonPressMode ) {
- if (buttonPressMode != null) {
- parameters.put(KEY_BUTTON_PRESS_MODE, buttonPressMode );
- } else {
- parameters.remove(KEY_BUTTON_PRESS_MODE);
- }
+ setParameters(KEY_BUTTON_PRESS_MODE, buttonPressMode);
}
public void setCustomButtonName(Integer customButtonID) {
- if (customButtonID != null) {
- parameters.put(KEY_CUSTOM_BUTTON_ID, customButtonID);
- } else {
- parameters.remove(KEY_CUSTOM_BUTTON_ID);
- }
+ setParameters(KEY_CUSTOM_BUTTON_ID, customButtonID);
}
public Integer getCustomButtonName() {
- return (Integer) parameters.get(KEY_CUSTOM_BUTTON_ID);
+ return getInteger(KEY_CUSTOM_BUTTON_ID);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java
index eae7e77f8..0ce4ef7b7 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnCommand.java
@@ -1,11 +1,11 @@
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.TriggerSource;
+import java.util.Hashtable;
+
/**
* This is called when a command was selected via VR after pressing the PTT button, or selected from the menu after
* pressing the MENU button. <p>
@@ -72,31 +72,21 @@ public class OnCommand extends RPCNotification {
* @return Integer an integer representation of this object
*/
public Integer getCmdID() {
- return (Integer) parameters.get( KEY_CMD_ID );
+ return getInteger( KEY_CMD_ID );
}
/**
* <p>Sets a Command ID</p>
* @param cmdID an integer object representing a Command ID
*/
public void setCmdID( Integer cmdID ) {
- if (cmdID != null) {
- parameters.put(KEY_CMD_ID, cmdID );
- } else {
- parameters.remove(KEY_CMD_ID);
- }
+ setParameters(KEY_CMD_ID, cmdID);
}
/**
* <p>Returns a <I>TriggerSource</I> object which will be shown in the HMI</p>
* @return TriggerSource a TriggerSource object
*/
public TriggerSource getTriggerSource() {
- Object obj = parameters.get(KEY_TRIGGER_SOURCE);
- if (obj instanceof TriggerSource) {
- return (TriggerSource) obj;
- } else if (obj instanceof String) {
- return TriggerSource.valueForString((String) obj);
- }
- return null;
+ return (TriggerSource) getObject(TriggerSource.class, KEY_TRIGGER_SOURCE);
}
/**
* <p>Sets TriggerSource</p>
@@ -104,10 +94,6 @@ public class OnCommand extends RPCNotification {
* @param triggerSource a TriggerSource object
*/
public void setTriggerSource( TriggerSource triggerSource ) {
- if (triggerSource != null) {
- parameters.put(KEY_TRIGGER_SOURCE, triggerSource );
- } else {
- parameters.remove(KEY_TRIGGER_SOURCE);
- }
+ setParameters(KEY_TRIGGER_SOURCE, triggerSource);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java
index 69280ad21..82517ca28 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnDriverDistraction.java
@@ -1,11 +1,11 @@
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 java.util.Hashtable;
+
/**
* <p>Notifies the application of the current driver distraction state (whether driver distraction rules are in effect, or
* not).</p>
@@ -58,23 +58,13 @@ public class OnDriverDistraction extends RPCNotification {
* @return {@linkplain DriverDistractionState} the Current driver distraction state.
*/
public DriverDistractionState getState() {
- Object obj = parameters.get(KEY_STATE);
- if (obj instanceof DriverDistractionState) {
- return (DriverDistractionState)obj;
- } else if(obj instanceof String) {
- return DriverDistractionState.valueForString((String) obj);
- }
- return null;
+ return (DriverDistractionState) getObject(DriverDistractionState.class, KEY_STATE);
}
/**
* <p>Called to set the driver distraction state(i.e. whether driver distraction rules are in effect, or not)</p>
* @param state the current driver distraction state
*/
public void setState( DriverDistractionState state ) {
- if (state != null) {
- parameters.put(KEY_STATE, state );
- } else {
- parameters.remove(KEY_STATE);
- }
+ setParameters(KEY_STATE, state);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java
index 31161f2f1..930e742f5 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHMIStatus.java
@@ -1,12 +1,13 @@
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.AudioStreamingState;
import com.smartdevicelink.proxy.rpc.enums.HMILevel;
import com.smartdevicelink.proxy.rpc.enums.SystemContext;
+
+import java.util.Hashtable;
+
/**
* <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
@@ -86,61 +87,35 @@ public class OnHMIStatus extends RPCNotification {
* @return {@linkplain HMILevel} the current HMI Level in effect for the application
*/
public HMILevel getHmiLevel() {
- Object obj = parameters.get(KEY_HMI_LEVEL);
- if (obj instanceof HMILevel) {
- return (HMILevel) obj;
- } else if (obj instanceof String) {
- return HMILevel.valueForString((String) obj);
- }
- return null;
+ return (HMILevel) getObject(HMILevel.class, KEY_HMI_LEVEL);
}
/**
* <p>Set the HMILevel of OnHMIStatus</p>
* @param hmiLevel the HMILevel to set
*/
public void setHmiLevel( HMILevel hmiLevel ) {
- if (hmiLevel != null) {
- parameters.put(KEY_HMI_LEVEL, hmiLevel );
- } else {
- parameters.remove(KEY_HMI_LEVEL);
- }
+ setParameters(KEY_HMI_LEVEL, hmiLevel);
}
/**
* <p>Get current state of audio streaming for the application</p>
* @return {@linkplain AudioStreamingState} Returns current state of audio streaming for the application
*/
public AudioStreamingState getAudioStreamingState() {
- Object obj = parameters.get(KEY_AUDIO_STREAMING_STATE);
- if (obj instanceof AudioStreamingState) {
- return (AudioStreamingState) obj;
- } else if (obj instanceof String) {
- return AudioStreamingState.valueForString((String) obj);
- }
- return null;
+ return (AudioStreamingState) getObject(AudioStreamingState.class, KEY_AUDIO_STREAMING_STATE);
}
/**
* <p>Set the audio streaming state</p>
* @param audioStreamingState the state of audio streaming of the application
*/
public void setAudioStreamingState( AudioStreamingState audioStreamingState ) {
- if (audioStreamingState != null) {
- parameters.put(KEY_AUDIO_STREAMING_STATE, audioStreamingState );
- } else {
- parameters.remove(KEY_AUDIO_STREAMING_STATE);
- }
+ setParameters(KEY_AUDIO_STREAMING_STATE, audioStreamingState);
}
/**
* <p>Get the System Context</p>
* @return {@linkplain SystemContext} whether a user-initiated interaction is in-progress (VRSESSION or MENU), or not (MAIN).
*/
public SystemContext getSystemContext() {
- Object obj = parameters.get(KEY_SYSTEM_CONTEXT);
- if (obj instanceof SystemContext) {
- return (SystemContext) obj;
- } else if (obj instanceof String) {
- return SystemContext.valueForString((String) obj);
- }
- return null;
+ return (SystemContext) getObject(SystemContext.class, KEY_SYSTEM_CONTEXT);
}
/**
* <p>Set the System Context of OnHMIStatus</p>
@@ -148,11 +123,7 @@ public class OnHMIStatus extends RPCNotification {
* (VRSESSION or MENU), or not (MAIN)
*/
public void setSystemContext( SystemContext systemContext ) {
- if (systemContext != null) {
- parameters.put(KEY_SYSTEM_CONTEXT, systemContext );
- } else {
- parameters.remove(KEY_SYSTEM_CONTEXT);
- }
+ setParameters(KEY_SYSTEM_CONTEXT, systemContext);
}
/**
* <p>Query whether it's the first run</p>
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java
index 776d69e4a..7ac4df083 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnHashChange.java
@@ -1,9 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
+
+import java.util.Hashtable;
+
/**
* Notification containing an updated hashID which can be used over connection cycles (i.e. loss of connection, ignition cycles, etc.).
* Sent after initial registration and subsequently after any change in the calculated hash of all persisted app data.
@@ -54,15 +55,11 @@ public class OnHashChange extends RPCNotification {
}
public String getHashID() {
- return (String) parameters.get(KEY_HASH_ID);
+ return getString(KEY_HASH_ID);
}
public void setHashID(String hashID) {
- if (hashID != null) {
- parameters.put(KEY_HASH_ID, hashID);
- } else {
- parameters.remove(KEY_HASH_ID);
- }
+ setParameters(KEY_HASH_ID, hashID);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnInteriorVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnInteriorVehicleData.java
new file mode 100644
index 000000000..61e9ee17a
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnInteriorVehicleData.java
@@ -0,0 +1,47 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCNotification;
+
+import java.util.Hashtable;
+
+public class OnInteriorVehicleData extends RPCNotification {
+ public static final String KEY_MODULE_DATA = "moduleData";
+
+ /**
+ * Constructs a new OnInteriorVehicleData object
+ */
+ public OnInteriorVehicleData() {
+ super(FunctionID.ON_INTERIOR_VEHICLE_DATA.toString());
+ }
+
+ /**
+ * <p>Constructs a new OnInteriorVehicleData object indicated by the
+ * Hashtable parameter</p>
+ *
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public OnInteriorVehicleData(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Gets the moduleData
+ *
+ * @return ModuleData
+ */
+ public ModuleData getModuleData() {
+ return (ModuleData) getObject(ModuleData.class, KEY_MODULE_DATA);
+ }
+
+ /**
+ * Sets the moduleData
+ *
+ * @param moduleData
+ */
+ public void setModuleData(ModuleData moduleData) {
+ setParameters(KEY_MODULE_DATA, moduleData);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java
index e71cda0a8..900091dc2 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnKeyboardInput.java
@@ -1,11 +1,11 @@
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 java.util.Hashtable;
+
/**
* On-screen keyboard event. Can be full string or individual keypresses depending on keyboard mode.
* <p></p>
@@ -65,32 +65,18 @@ public class OnKeyboardInput extends RPCNotification {
}
public KeyboardEvent getEvent() {
- Object obj = parameters.get(KEY_EVENT);
- if (obj instanceof KeyboardEvent) {
- return (KeyboardEvent) obj;
- } else if (obj instanceof String) {
- return KeyboardEvent.valueForString((String) obj);
- }
- return null;
+ return (KeyboardEvent) getObject(KeyboardEvent.class, KEY_EVENT);
}
public void setEvent(KeyboardEvent event) {
- if (event != null) {
- parameters.put(KEY_EVENT, event);
- } else {
- parameters.remove(KEY_EVENT);
- }
+ setParameters(KEY_EVENT, event);
}
public void setData(String data) {
- if (data != null) {
- parameters.put(KEY_DATA, data);
- } else {
- parameters.remove(KEY_DATA);
- }
+ setParameters(KEY_DATA, data);
}
public String getData() {
- Object obj = parameters.get(KEY_DATA);
+ Object obj = getParameters(KEY_DATA);
if (obj instanceof String) {
return (String) obj;
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java
index 4f39d55cb..1b514f1cd 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLanguageChange.java
@@ -1,11 +1,11 @@
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.Language;
+import java.util.Hashtable;
+
/**
* Provides information to what language the Sdl HMI language was changed
* <p>
@@ -77,47 +77,27 @@ public class OnLanguageChange extends RPCNotification {
* @param language language that current SDL voice engine(VR+TTS) use
*/
public void setLanguage(Language language) {
- if (language != null) {
- parameters.put(KEY_LANGUAGE, language);
- } else {
- parameters.remove(KEY_LANGUAGE);
- }
+ setParameters(KEY_LANGUAGE, language);
}
/**
* <p>Returns language that current SDL voice engine(VR+TTS) use</p>
* @return {@linkplain Language} language that current SDL voice engine(VR+TTS) use
*/
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;
+ return (Language) getObject(Language.class, KEY_LANGUAGE);
}
/**
* <p>Sets language that current display use</p>
* @param hmiDisplayLanguage language that current SDL voice engine(VR+TTS) use
*/
public void setHmiDisplayLanguage(Language hmiDisplayLanguage) {
- if (hmiDisplayLanguage != null) {
- parameters.put(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage);
- } else {
- parameters.remove(KEY_HMI_DISPLAY_LANGUAGE);
- }
+ setParameters(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage);
}
/**
* <p>Returns language that current display use</p>
* @return {@linkplain Language} language that current display use
*/
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;
+ return (Language) getObject(Language.class, KEY_HMI_DISPLAY_LANGUAGE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java
index 11f6469ef..21a5c3520 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnLockScreenStatus.java
@@ -4,7 +4,9 @@ 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;
+
+import static com.smartdevicelink.proxy.rpc.OnHMIStatus.KEY_HMI_LEVEL;
+
/**
* The lockscreen must perform the following:
* Limit all application control usability from the mobile device with a full-screen static image overlay or separate view.
@@ -27,16 +29,11 @@ public class OnLockScreenStatus extends RPCNotification {
*/
public Boolean getDriverDistractionStatus() {
- return (Boolean)parameters.get(KEY_DRIVER_DISTRACTION);
+ return getBoolean(KEY_DRIVER_DISTRACTION);
}
public void setDriverDistractionStatus(Boolean driverDistractionStatus) {
-
- if (driverDistractionStatus != null){
- parameters.put(KEY_DRIVER_DISTRACTION, driverDistractionStatus);
- } else {
- parameters.remove(KEY_DRIVER_DISTRACTION);
- }
+ setParameters(KEY_DRIVER_DISTRACTION, driverDistractionStatus);
}
/**
* <p>Get the {@linkplain LockScreenStatus} enumeration, indicating if the lockscreen should be required, optional or off </p>
@@ -44,15 +41,11 @@ public class OnLockScreenStatus extends RPCNotification {
*/
public LockScreenStatus getShowLockScreen() {
- return (LockScreenStatus)parameters.get(KEY_SHOW_LOCK_SCREEN);
+ return (LockScreenStatus) getParameters(KEY_SHOW_LOCK_SCREEN);
}
public void setShowLockScreen(LockScreenStatus showLockScreen) {
- if (showLockScreen != null) {
- parameters.put(KEY_SHOW_LOCK_SCREEN, showLockScreen );
- } else {
- parameters.remove(KEY_SHOW_LOCK_SCREEN);
- }
+ setParameters(KEY_SHOW_LOCK_SCREEN, showLockScreen);
}
/**
* <p>Get user selection status for the application (has the app been selected via hmi or voice command)</p>
@@ -60,15 +53,11 @@ public class OnLockScreenStatus extends RPCNotification {
*/
public Boolean getUserSelected() {
- return (Boolean)parameters.get(KEY_USER_SELECTED);
+ return getBoolean(KEY_USER_SELECTED);
}
public void setUserSelected(Boolean userSelected) {
- if (userSelected != null) {
- parameters.put(KEY_USER_SELECTED, userSelected );
- } else {
- parameters.remove(KEY_USER_SELECTED);
- }
+ setParameters(KEY_USER_SELECTED, userSelected);
}
/**
* <p>Get HMILevel in effect for the application</p>
@@ -76,14 +65,10 @@ public class OnLockScreenStatus extends RPCNotification {
*/
public HMILevel getHMILevel() {
- return (HMILevel)parameters.get(OnHMIStatus.KEY_HMI_LEVEL);
+ return (HMILevel) getParameters(KEY_HMI_LEVEL);
}
public void setHMILevel(HMILevel setHMILevel) {
- if (setHMILevel != null) {
- parameters.put(OnHMIStatus.KEY_HMI_LEVEL, setHMILevel );
- } else {
- parameters.remove(OnHMIStatus.KEY_HMI_LEVEL);
- }
+ setParameters(KEY_HMI_LEVEL, setHMILevel);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
index 4c88c9baa..a98d69fb5 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnPermissionsChange.java
@@ -1,12 +1,11 @@
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.RPCNotification;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* Provides update to app of which sets of functions are available
* <p>
@@ -69,30 +68,13 @@ public class OnPermissionsChange extends RPCNotification {
*/
@SuppressWarnings("unchecked")
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;
- }
- }
- return null;
+ return (List<PermissionItem>) getObject(PermissionItem.class, KEY_PERMISSION_ITEM);
}
/**
* <p>Sets PermissionItems describing change in permissions for a given set of RPCs</p>
* @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) {
- parameters.put(KEY_PERMISSION_ITEM, permissionItem);
- } else {
- parameters.remove(KEY_PERMISSION_ITEM);
- }
+ setParameters(KEY_PERMISSION_ITEM, permissionItem);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java
index a878ade77..5eec2db91 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSdlChoiceChosen.java
@@ -1,12 +1,12 @@
package com.smartdevicelink.proxy.rpc;
-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.TriggerSource;
+import java.util.Hashtable;
+import java.util.List;
+
public class OnSdlChoiceChosen extends RPCNotification {
public static final String KEY_SDL_CHOICE = "sdlChoice";
public static final String KEY_TRIGGER_SOURCE = "triggerSource";
@@ -144,29 +144,15 @@ public class OnSdlChoiceChosen extends RPCNotification {
super(hash);
}
public SdlChoice getSdlChoice() {
- return (SdlChoice) parameters.get(KEY_SDL_CHOICE);
+ return (SdlChoice) getParameters(KEY_SDL_CHOICE);
}
public void setSdlChoice(SdlChoice sdlChoice) {
- if (sdlChoice != null) {
- parameters.put(KEY_SDL_CHOICE, sdlChoice);
- } else {
- parameters.remove(KEY_SDL_CHOICE);
- }
+ setParameters(KEY_SDL_CHOICE, sdlChoice);
}
public TriggerSource getTriggerSource() {
- Object obj = parameters.get(KEY_TRIGGER_SOURCE);
- if (obj instanceof TriggerSource) {
- return (TriggerSource) obj;
- } else if (obj instanceof String) {
- return TriggerSource.valueForString((String) obj);
- }
- return null;
+ return (TriggerSource) getObject(TriggerSource.class, KEY_TRIGGER_SOURCE);
}
public void setTriggerSource( TriggerSource triggerSource ) {
- if (triggerSource != null) {
- parameters.put(KEY_TRIGGER_SOURCE, triggerSource );
- } else {
- parameters.remove(KEY_TRIGGER_SOURCE);
- }
+ setParameters(KEY_TRIGGER_SOURCE, triggerSource);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnStreamRPC.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnStreamRPC.java
index bb4bcc324..679596026 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnStreamRPC.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnStreamRPC.java
@@ -13,35 +13,23 @@ public class OnStreamRPC extends RPCNotification {
}
public void setFileName(String fileName) {
- if (fileName != null) {
- parameters.put(KEY_FILENAME, fileName);
- } else {
- parameters.remove(KEY_FILENAME);
- }
+ setParameters(KEY_FILENAME, fileName);
}
public String getFileName() {
- return (String) parameters.get(KEY_FILENAME);
+ return getString(KEY_FILENAME);
}
public void setBytesComplete(Long bytesComplete) {
- if (bytesComplete != null) {
- parameters.put(KEY_BYTESCOMPLETE, bytesComplete);
- } else {
- parameters.remove(KEY_BYTESCOMPLETE);
- }
+ setParameters(KEY_BYTESCOMPLETE, bytesComplete);
}
public Long getBytesComplete() {
- return (Long) parameters.get(KEY_BYTESCOMPLETE);
+ return getLong(KEY_BYTESCOMPLETE);
}
public void setFileSize(Long fileSize) {
- if (fileSize != null) {
- parameters.put(KEY_FILESIZE, fileSize);
- } else {
- parameters.remove(KEY_FILESIZE);
- }
+ setParameters(KEY_FILESIZE, fileSize);
}
public Long getFileSize() {
- return (Long) parameters.get(KEY_FILESIZE);
+ return getLong(KEY_FILESIZE);
}
} \ No newline at end of file
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java
index a034626a9..271f94f7f 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java
@@ -1,11 +1,5 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
import android.util.Log;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
@@ -14,6 +8,13 @@ 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 org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Hashtable;
+import java.util.List;
+
/**
* An asynchronous request from the system for specific data from the device or the cloud or response to a request from the device or cloud. Binary data can be included in hybrid part of message for some requests (such as Authentication request responses)
*
@@ -198,16 +199,7 @@ public class OnSystemRequest extends RPCNotification {
@SuppressWarnings("unchecked")
public List<String> getLegacyData() {
- 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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_DATA);
}
public String getBody(){
@@ -227,30 +219,19 @@ public class OnSystemRequest extends RPCNotification {
}
public RequestType getRequestType() {
- Object obj = parameters.get(KEY_REQUEST_TYPE);
- if (obj == null) return null;
- if (obj instanceof RequestType) {
- return (RequestType) obj;
- } else if (obj instanceof String) {
- return RequestType.valueForString((String) obj);
- }
- return null;
+ return (RequestType) getObject(RequestType.class, KEY_REQUEST_TYPE);
}
public void setRequestType(RequestType requestType) {
- if (requestType != null) {
- parameters.put(KEY_REQUEST_TYPE, requestType);
- } else {
- parameters.remove(KEY_REQUEST_TYPE);
- }
+ setParameters(KEY_REQUEST_TYPE, requestType);
}
public String getUrl() {
- Object o = parameters.get(KEY_URL);
+ Object o = getParameters(KEY_URL);
if (o == null)
{
//try again for gen 1.1
- o = parameters.get(KEY_URL_V1);
+ o = getParameters(KEY_URL_V1);
}
if (o == null)
return null;
@@ -262,30 +243,15 @@ public class OnSystemRequest extends RPCNotification {
}
public void setUrl(String url) {
- if (url != null) {
- parameters.put(KEY_URL, url);
- } else {
- parameters.remove(KEY_URL);
- }
+ setParameters(KEY_URL, url);
}
public FileType getFileType() {
- Object obj = parameters.get(KEY_FILE_TYPE);
- if (obj == null) return null;
- if (obj instanceof FileType) {
- return (FileType) obj;
- } else if (obj instanceof String) {
- return FileType.valueForString((String) obj);
- }
- return null;
+ return (FileType) getObject(FileType.class, KEY_FILE_TYPE);
}
public void setFileType(FileType fileType) {
- if (fileType != null) {
- parameters.put(KEY_FILE_TYPE, fileType);
- } else {
- parameters.remove(KEY_FILE_TYPE);
- }
+ setParameters(KEY_FILE_TYPE, fileType);
}
/**
@@ -301,7 +267,7 @@ public class OnSystemRequest extends RPCNotification {
}
public Long getOffset() {
- final Object o = parameters.get(KEY_OFFSET);
+ final Object o = getParameters(KEY_OFFSET);
if (o == null){
return null;
@@ -316,18 +282,14 @@ public class OnSystemRequest extends RPCNotification {
}
public void setOffset(Long offset) {
- if (offset != null) {
- parameters.put(KEY_OFFSET, offset);
- } else {
- parameters.remove(KEY_OFFSET);
- }
+ setParameters(KEY_OFFSET, offset);
}
public Integer getTimeout() {
- Object o = parameters.get(KEY_TIMEOUT);
+ Object o = getParameters(KEY_TIMEOUT);
if (o == null){
- o = parameters.get(KEY_TIMEOUT_V1);
+ o = getParameters(KEY_TIMEOUT_V1);
if (o == null) return null;
}
@@ -338,15 +300,11 @@ public class OnSystemRequest extends RPCNotification {
}
public void setTimeout(Integer timeout) {
- if (timeout != null) {
- parameters.put(KEY_TIMEOUT, timeout);
- } else {
- parameters.remove(KEY_TIMEOUT);
- }
+ setParameters(KEY_TIMEOUT, timeout);
}
public Long getLength() {
- final Object o = parameters.get(KEY_LENGTH);
+ final Object o = getParameters(KEY_LENGTH);
if (o == null){
return null;
}
@@ -372,10 +330,6 @@ public class OnSystemRequest extends RPCNotification {
}
public void setLength(Long length) {
- if (length != null) {
- parameters.put(KEY_LENGTH, length);
- } else {
- parameters.remove(KEY_LENGTH);
- }
+ setParameters(KEY_LENGTH, length);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java
index 26965c891..a8f05a291 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTBTClientState.java
@@ -1,11 +1,11 @@
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.TBTState;
+import java.util.Hashtable;
+
/**
* <p>Notifies the application of the current TBT client status on the module.</p>
*
@@ -58,23 +58,13 @@ public class OnTBTClientState extends RPCNotification {
* @return {@linkplain TBTState} the current state of TBT client
*/
public TBTState getState() {
- Object obj = parameters.get(KEY_STATE);
- if (obj instanceof TBTState) {
- return (TBTState)obj;
- } else if(obj instanceof String) {
- return TBTState.valueForString((String) obj);
- }
- return null;
+ return (TBTState) getObject(TBTState.class, KEY_STATE);
}
/**
* <p>Called to set the current state of TBT client</p>
* @param state current state of TBT client
*/
public void setState( TBTState state ) {
- if (state != null) {
- parameters.put(KEY_STATE, state );
- } else {
- parameters.remove(KEY_STATE);
- }
+ setParameters(KEY_STATE, state);
}
} // end-class
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java
index bfb31d789..36905aad6 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnTouchEvent.java
@@ -1,13 +1,12 @@
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.RPCNotification;
import com.smartdevicelink.proxy.rpc.enums.TouchType;
+import java.util.Hashtable;
+import java.util.List;
+
/**
*
* Notifies about touch events on the screen's prescribed area.
@@ -69,48 +68,19 @@ public class OnTouchEvent extends RPCNotification {
}
public void setType(TouchType type) {
- if (type != null) {
- parameters.put(KEY_TYPE, type);
- } else {
- parameters.remove(KEY_TYPE);
- }
+ setParameters(KEY_TYPE, type);
}
public TouchType getType() {
- Object obj = parameters.get(KEY_TYPE);
- if (obj instanceof TouchType) {
- return (TouchType) obj;
- } else if (obj instanceof String) {
- return TouchType.valueForString((String) obj);
- }
- return null;
+ return (TouchType) getObject(TouchType.class, KEY_TYPE);
}
public void setEvent(List<TouchEvent> event) {
- if (event != null) {
- parameters.put(KEY_EVENT, event);
- } else {
- parameters.remove(KEY_EVENT);
- }
+ setParameters(KEY_EVENT, event);
}
@SuppressWarnings("unchecked")
public List<TouchEvent> getEvent() {
- 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;
- }
- }
- }
- return null;
+ return (List<TouchEvent>) getObject(TouchEvent.class, KEY_EVENT);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java
index 1a6baefef..32dba7500 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnVehicleData.java
@@ -10,6 +10,9 @@ import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus;
import com.smartdevicelink.proxy.rpc.enums.WiperStatus;
import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.SdlDataTypeConverter;
+
+import static com.smartdevicelink.proxy.constants.Names.timeout;
+
/**
*Individual requested DID result and data.
*
@@ -277,58 +280,30 @@ public class OnVehicleData extends RPCNotification {
super(hash);
}
public void setGps(GPSData gps) {
- if (gps != null) {
- parameters.put(KEY_GPS, gps);
- } else {
- parameters.remove(KEY_GPS);
- }
+ setParameters(KEY_GPS, gps);
}
@SuppressWarnings("unchecked")
public GPSData getGps() {
- Object obj = parameters.get(KEY_GPS);
- if (obj instanceof GPSData) {
- return (GPSData) obj;
- } else if (obj instanceof Hashtable) {
- GPSData theCode = null;
- try {
- theCode = new GPSData((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
- }
- return theCode;
- }
- return null;
+ return (GPSData) getObject(GPSData.class, KEY_GPS);
}
public void setSpeed(Double speed) {
- if (speed != null) {
- parameters.put(KEY_SPEED, speed);
- } else {
- parameters.remove(KEY_SPEED);
- }
+ setParameters(KEY_SPEED, speed);
}
public Double getSpeed() {
- Object object = parameters.get(KEY_SPEED);
+ Object object = getParameters(KEY_SPEED);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setRpm(Integer rpm) {
- if (rpm != null) {
- parameters.put(KEY_RPM, rpm);
- } else {
- parameters.remove(KEY_RPM);
- }
+ setParameters(KEY_RPM, rpm);
}
public Integer getRpm() {
- return (Integer) parameters.get(KEY_RPM);
+ return getInteger(KEY_RPM);
}
public void setFuelLevel(Double fuelLevel) {
- if (fuelLevel != null) {
- parameters.put(KEY_FUEL_LEVEL, fuelLevel);
- } else {
- parameters.remove(KEY_FUEL_LEVEL);
- }
+ setParameters(KEY_FUEL_LEVEL, fuelLevel);
}
public Double getFuelLevel() {
- Object object = parameters.get(KEY_FUEL_LEVEL);
+ Object object = getParameters(KEY_FUEL_LEVEL);
return SdlDataTypeConverter.objectToDouble(object);
}
@Deprecated
@@ -340,358 +315,144 @@ public class OnVehicleData extends RPCNotification {
return getFuelLevelState();
}
public void setFuelLevelState(ComponentVolumeStatus fuelLevelState) {
- if (fuelLevelState != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevelState);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState);
}
public ComponentVolumeStatus getFuelLevelState() {
- 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) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL_STATE, e);
- }
- return theCode;
- }
- return null;
+ return (ComponentVolumeStatus) getObject(ComponentVolumeStatus.class, KEY_FUEL_LEVEL_STATE);
}
public void setInstantFuelConsumption(Double instantFuelConsumption) {
- if (instantFuelConsumption != null) {
- parameters.put(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
- } else {
- parameters.remove(KEY_INSTANT_FUEL_CONSUMPTION);
- }
+ setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
}
public Double getInstantFuelConsumption() {
- Object object = parameters.get(KEY_INSTANT_FUEL_CONSUMPTION);
+ Object object = getParameters(KEY_INSTANT_FUEL_CONSUMPTION);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setExternalTemperature(Double externalTemperature) {
- if (externalTemperature != null) {
- parameters.put(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
- } else {
- parameters.remove(KEY_EXTERNAL_TEMPERATURE);
- }
+ setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
}
public Double getExternalTemperature() {
- Object object = parameters.get(KEY_EXTERNAL_TEMPERATURE);
+ Object object = getParameters(KEY_EXTERNAL_TEMPERATURE);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setVin(String vin) {
- if (vin != null) {
- parameters.put(KEY_VIN, vin);
- } else {
- parameters.remove(KEY_VIN);
- }
+ setParameters(KEY_VIN, vin);
}
public String getVin() {
- return (String) parameters.get(KEY_VIN);
+ return getString(KEY_VIN);
}
public void setPrndl(PRNDL prndl) {
- if (prndl != null) {
- parameters.put(KEY_PRNDL, prndl);
- } else {
- parameters.remove(KEY_PRNDL);
- }
+ setParameters(KEY_PRNDL, prndl);
}
public PRNDL getPrndl() {
- Object obj = parameters.get(KEY_PRNDL);
- if (obj instanceof PRNDL) {
- return (PRNDL) obj;
- } else if (obj instanceof String) {
- return PRNDL.valueForString((String) obj);
- }
- return null;
+ return (PRNDL) getObject(PRNDL.class, KEY_PRNDL);
}
public void setTirePressure(TireStatus tirePressure) {
- if (tirePressure != null) {
- parameters.put(KEY_TIRE_PRESSURE, tirePressure);
- } else {
- parameters.remove(KEY_TIRE_PRESSURE);
- }
+ setParameters(KEY_TIRE_PRESSURE, tirePressure);
}
@SuppressWarnings("unchecked")
public TireStatus getTirePressure() {
- Object obj = parameters.get(KEY_TIRE_PRESSURE);
- if (obj instanceof TireStatus) {
- return (TireStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new TireStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
- }
- }
- return null;
+ return (TireStatus) getObject(TireStatus.class, KEY_TIRE_PRESSURE);
}
public void setOdometer(Integer odometer) {
- if (odometer != null) {
- parameters.put(KEY_ODOMETER, odometer);
- } else {
- parameters.remove(KEY_ODOMETER);
- }
+ setParameters(KEY_ODOMETER, odometer);
}
public Integer getOdometer() {
- return (Integer) parameters.get(KEY_ODOMETER);
+ return getInteger(KEY_ODOMETER);
}
public void setBeltStatus(BeltStatus beltStatus) {
- if (beltStatus != null) {
- parameters.put(KEY_BELT_STATUS, beltStatus);
- } else {
- parameters.remove(KEY_BELT_STATUS);
- }
+ setParameters(KEY_BELT_STATUS, beltStatus);
}
@SuppressWarnings("unchecked")
public BeltStatus getBeltStatus() {
- Object obj = parameters.get(KEY_BELT_STATUS);
- if (obj instanceof BeltStatus) {
- return (BeltStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new BeltStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
- }
- }
- return null;
+ return (BeltStatus) getObject(BeltStatus.class, KEY_BELT_STATUS);
}
public void setBodyInformation(BodyInformation bodyInformation) {
- if (bodyInformation != null) {
- parameters.put(KEY_BODY_INFORMATION, bodyInformation);
- } else {
- parameters.remove(KEY_BODY_INFORMATION);
- }
+ setParameters(KEY_BODY_INFORMATION, bodyInformation);
}
@SuppressWarnings("unchecked")
public BodyInformation getBodyInformation() {
- Object obj = parameters.get(KEY_BODY_INFORMATION);
- if (obj instanceof BodyInformation) {
- return (BodyInformation) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new BodyInformation((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
- }
- }
- return null;
+ return (BodyInformation) getObject(BodyInformation.class, KEY_BODY_INFORMATION);
}
public void setDeviceStatus(DeviceStatus deviceStatus) {
- if (deviceStatus != null) {
- parameters.put(KEY_DEVICE_STATUS, deviceStatus);
- } else {
- parameters.remove(KEY_DEVICE_STATUS);
- }
+ setParameters(KEY_DEVICE_STATUS, deviceStatus);
}
@SuppressWarnings("unchecked")
public DeviceStatus getDeviceStatus() {
- Object obj = parameters.get(KEY_DEVICE_STATUS);
- if (obj instanceof DeviceStatus) {
- return (DeviceStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new DeviceStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
- }
- }
- return null;
+ return (DeviceStatus) getObject(DeviceStatus.class, KEY_DEVICE_STATUS);
}
public void setDriverBraking(VehicleDataEventStatus driverBraking) {
- if (driverBraking != null) {
- parameters.put(KEY_DRIVER_BRAKING, driverBraking);
- } else {
- parameters.remove(KEY_DRIVER_BRAKING);
- }
+ setParameters(KEY_DRIVER_BRAKING, driverBraking);
}
public VehicleDataEventStatus getDriverBraking() {
- Object obj = parameters.get(KEY_DRIVER_BRAKING);
- if (obj instanceof VehicleDataEventStatus) {
- return (VehicleDataEventStatus) obj;
- } else if (obj instanceof String) {
- return VehicleDataEventStatus.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataEventStatus) getObject(VehicleDataEventStatus.class, KEY_DRIVER_BRAKING);
}
public void setWiperStatus(WiperStatus wiperStatus) {
- if (wiperStatus != null) {
- parameters.put(KEY_WIPER_STATUS, wiperStatus);
- } else {
- parameters.remove(KEY_WIPER_STATUS);
- }
+ setParameters(KEY_WIPER_STATUS, wiperStatus);
}
public WiperStatus getWiperStatus() {
- Object obj = parameters.get(KEY_WIPER_STATUS);
- if (obj instanceof WiperStatus) {
- return (WiperStatus) obj;
- } else if (obj instanceof String) {
- return WiperStatus.valueForString((String) obj);
- }
- return null;
+ return (WiperStatus) getObject(WiperStatus.class, KEY_WIPER_STATUS);
}
public void setHeadLampStatus(HeadLampStatus headLampStatus) {
- if (headLampStatus != null) {
- parameters.put(KEY_HEAD_LAMP_STATUS, headLampStatus);
- } else {
- parameters.remove(KEY_HEAD_LAMP_STATUS);
- }
+ setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus);
}
@SuppressWarnings("unchecked")
public HeadLampStatus getHeadLampStatus() {
- Object obj = parameters.get(KEY_HEAD_LAMP_STATUS);
- if (obj instanceof HeadLampStatus) {
- return (HeadLampStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new HeadLampStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
- }
- }
- return null;
+ return (HeadLampStatus) getObject(HeadLampStatus.class, KEY_HEAD_LAMP_STATUS);
}
public void setEngineTorque(Double engineTorque) {
- if (engineTorque != null) {
- parameters.put(KEY_ENGINE_TORQUE, engineTorque);
- } else {
- parameters.remove(KEY_ENGINE_TORQUE);
- }
+ setParameters(KEY_ENGINE_TORQUE, engineTorque);
}
public Double getEngineTorque() {
- Object object = parameters.get(KEY_ENGINE_TORQUE);
+ Object object = getParameters(KEY_ENGINE_TORQUE);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setAccPedalPosition(Double accPedalPosition) {
- if (accPedalPosition != null) {
- parameters.put(KEY_ACC_PEDAL_POSITION, accPedalPosition);
- } else {
- parameters.remove(KEY_ACC_PEDAL_POSITION);
- }
+ setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition);
}
public Double getAccPedalPosition() {
- Object object = parameters.get(KEY_ACC_PEDAL_POSITION);
+ Object object = getParameters(KEY_ACC_PEDAL_POSITION);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setSteeringWheelAngle(Double steeringWheelAngle) {
- if (steeringWheelAngle != null) {
- parameters.put(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
- } else {
- parameters.remove(KEY_STEERING_WHEEL_ANGLE);
- }
+ setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
}
public Double getSteeringWheelAngle() {
- Object object = parameters.get(KEY_STEERING_WHEEL_ANGLE);
+ Object object = getParameters(KEY_STEERING_WHEEL_ANGLE);
return SdlDataTypeConverter.objectToDouble(object);
}
public void setECallInfo(ECallInfo eCallInfo) {
- if (eCallInfo != null) {
- parameters.put(KEY_E_CALL_INFO, eCallInfo);
- } else {
- parameters.remove(KEY_E_CALL_INFO);
- }
+ setParameters(KEY_E_CALL_INFO, eCallInfo);
}
@SuppressWarnings("unchecked")
public ECallInfo getECallInfo() {
- Object obj = parameters.get(KEY_E_CALL_INFO);
- if (obj instanceof ECallInfo) {
- return (ECallInfo) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new ECallInfo((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
- }
- }
- return null;
+ return (ECallInfo) getObject(ECallInfo.class, KEY_E_CALL_INFO);
}
public void setAirbagStatus(AirbagStatus airbagStatus) {
- if (airbagStatus != null) {
- parameters.put(KEY_AIRBAG_STATUS, airbagStatus);
- } else {
- parameters.remove(KEY_AIRBAG_STATUS);
- }
+ setParameters(KEY_AIRBAG_STATUS, airbagStatus);
}
@SuppressWarnings("unchecked")
public AirbagStatus getAirbagStatus() {
- Object obj = parameters.get(KEY_AIRBAG_STATUS);
- if (obj instanceof AirbagStatus) {
- return (AirbagStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new AirbagStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
- }
- }
- return null;
+ return (AirbagStatus) getObject(AirbagStatus.class, KEY_AIRBAG_STATUS);
}
public void setEmergencyEvent(EmergencyEvent emergencyEvent) {
- if (emergencyEvent != null) {
- parameters.put(KEY_EMERGENCY_EVENT, emergencyEvent);
- } else {
- parameters.remove(KEY_EMERGENCY_EVENT);
- }
+ setParameters(KEY_EMERGENCY_EVENT, emergencyEvent);
}
@SuppressWarnings("unchecked")
public EmergencyEvent getEmergencyEvent() {
- Object obj = parameters.get(KEY_EMERGENCY_EVENT);
- if (obj instanceof EmergencyEvent) {
- return (EmergencyEvent) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new EmergencyEvent((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
- }
- }
- return null;
+ return (EmergencyEvent) getObject(EmergencyEvent.class, KEY_EMERGENCY_EVENT);
}
public void setClusterModeStatus(ClusterModeStatus clusterModeStatus) {
- if (clusterModeStatus != null) {
- parameters.put(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
- } else {
- parameters.remove(KEY_CLUSTER_MODE_STATUS);
- }
+ setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
}
@SuppressWarnings("unchecked")
public ClusterModeStatus getClusterModeStatus() {
- Object obj = parameters.get(KEY_CLUSTER_MODE_STATUS);
- if (obj instanceof ClusterModeStatus) {
- return (ClusterModeStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new ClusterModeStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
- }
- }
- return null;
+ return (ClusterModeStatus) getObject(ClusterModeStatus.class, KEY_CLUSTER_MODE_STATUS);
}
public void setMyKey(MyKey myKey) {
- if (myKey != null) {
- parameters.put(KEY_MY_KEY, myKey);
- } else {
- parameters.remove(KEY_MY_KEY);
- }
+ setParameters(KEY_MY_KEY, myKey);
}
@SuppressWarnings("unchecked")
public MyKey getMyKey() {
- Object obj = parameters.get(KEY_MY_KEY);
- if (obj instanceof MyKey) {
- return (MyKey) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new MyKey((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
- }
- }
- return null;
+ return (MyKey) getObject(MyKey.class, KEY_MY_KEY);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java
index 4e197b3eb..5f102dce0 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/OnWayPointChange.java
@@ -3,7 +3,6 @@ package com.smartdevicelink.proxy.rpc;
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCNotification;
-import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@@ -20,29 +19,10 @@ public class OnWayPointChange extends RPCNotification {
@SuppressWarnings("unchecked")
public List<LocationDetails> getWayPoints() {
- if (parameters.get(KEY_WAY_POINTS) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_WAY_POINTS);
- if (list != null && list.size()>0) {
- Object obj = list.get(0);
- if(obj instanceof LocationDetails){
- return (List<LocationDetails>) list;
- } else if(obj instanceof Hashtable) {
- List<LocationDetails> newList = new ArrayList<LocationDetails>();
- for (Object hash:list) {
- newList.add(new LocationDetails((Hashtable<String, Object>)hash));
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<LocationDetails>) getObject(LocationDetails.class, KEY_WAY_POINTS);
}
public void setWayPoints(List<LocationDetails> wayPoints) {
- if (wayPoints != null) {
- parameters.put(KEY_WAY_POINTS, wayPoints);
- } else {
- parameters.remove(KEY_WAY_POINTS);
- }
+ setParameters(KEY_WAY_POINTS, wayPoints);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java
index 996de27ac..244b73b89 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ParameterPermissions.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
+import com.smartdevicelink.proxy.RPCStruct;
+
import java.util.Hashtable;
import java.util.List;
-import com.smartdevicelink.proxy.RPCStruct;
-
/**
* Defining sets of parameters, which are permitted or prohibited for a given RPC.
* <p><b>Parameter List</b></p>
@@ -65,16 +65,7 @@ public class ParameterPermissions extends RPCStruct {
*/
@SuppressWarnings("unchecked")
public List<String> 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 String) {
- return (List<String>) list;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_ALLOWED);
}
/**
@@ -82,11 +73,7 @@ public class ParameterPermissions extends RPCStruct {
* @param allowed parameter that is permitted for this given RPC
*/
public void setAllowed(List<String> allowed) {
- if (allowed != null) {
- store.put(KEY_ALLOWED, allowed);
- } else {
- store.remove(KEY_ALLOWED);
- }
+ setValue(KEY_ALLOWED, allowed);
}
/**
@@ -95,16 +82,7 @@ public class ParameterPermissions extends RPCStruct {
*/
@SuppressWarnings("unchecked")
public List<String> 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 String) {
- return (List<String>) list;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_USER_DISALLOWED);
}
/**
@@ -112,10 +90,6 @@ public class ParameterPermissions extends RPCStruct {
* @param userDisallowed paramter that is prohibited for this given RPC
*/
public void setUserDisallowed(List<String> userDisallowed) {
- if (userDisallowed != null) {
- store.put(KEY_USER_DISALLOWED, userDisallowed);
- } else {
- store.remove(KEY_USER_DISALLOWED);
- }
+ setValue(KEY_USER_DISALLOWED, userDisallowed);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java
index 0e663f63d..5f2d27e1c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformAudioPassThru.java
@@ -1,15 +1,14 @@
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.AudioType;
import com.smartdevicelink.proxy.rpc.enums.BitsPerSample;
import com.smartdevicelink.proxy.rpc.enums.SamplingRate;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* This will open an audio pass thru session. By doing so the app can receive
* audio data through the vehicles microphone
@@ -141,11 +140,7 @@ public class PerformAudioPassThru extends RPCRequest {
* </ul>
*/
public void setInitialPrompt(List<TTSChunk> initialPrompt) {
- if (initialPrompt != null) {
- parameters.put(KEY_INITIAL_PROMPT, initialPrompt);
- } else {
- parameters.remove(KEY_INITIAL_PROMPT);
- }
+ setParameters(KEY_INITIAL_PROMPT, initialPrompt);
}
/**
@@ -158,22 +153,7 @@ public class PerformAudioPassThru extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getInitialPrompt() {
- 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;
- }
- }
- }
- return null;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_INITIAL_PROMPT);
}
/**
@@ -186,11 +166,7 @@ public class PerformAudioPassThru extends RPCRequest {
* <b>Notes: </b>Maxlength=500
*/
public void setAudioPassThruDisplayText1(String audioPassThruDisplayText1) {
- if (audioPassThruDisplayText1 != null) {
- parameters.put(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_1, audioPassThruDisplayText1);
- } else {
- parameters.remove(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_1);
- }
+ setParameters(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_1, audioPassThruDisplayText1);
}
/**
@@ -200,7 +176,7 @@ public class PerformAudioPassThru extends RPCRequest {
* displayed during audio capture
*/
public String getAudioPassThruDisplayText1() {
- return (String) parameters.get(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_1);
+ return getString(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_1);
}
/**
@@ -213,11 +189,7 @@ public class PerformAudioPassThru extends RPCRequest {
* <b>Notes: </b>Maxlength=500
*/
public void setAudioPassThruDisplayText2(String audioPassThruDisplayText2) {
- if (audioPassThruDisplayText2 != null) {
- parameters.put(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_2, audioPassThruDisplayText2);
- } else {
- parameters.remove(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_2);
- }
+ setParameters(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_2, audioPassThruDisplayText2);
}
/**
@@ -227,7 +199,7 @@ public class PerformAudioPassThru extends RPCRequest {
* displayed during audio capture
*/
public String getAudioPassThruDisplayText2() {
- return (String) parameters.get(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_2);
+ return getString(KEY_AUDIO_PASS_THRU_DISPLAY_TEXT_2);
}
/**
@@ -237,11 +209,7 @@ public class PerformAudioPassThru extends RPCRequest {
* a SamplingRate value representing a 8 or 16 or 22 or 24 khz
*/
public void setSamplingRate(SamplingRate samplingRate) {
- if (samplingRate != null) {
- parameters.put(KEY_SAMPLING_RATE, samplingRate);
- } else {
- parameters.remove(KEY_SAMPLING_RATE);
- }
+ setParameters(KEY_SAMPLING_RATE, samplingRate);
}
/**
@@ -250,13 +218,7 @@ public class PerformAudioPassThru extends RPCRequest {
* @return SamplingRate -a SamplingRate value
*/
public SamplingRate getSamplingRate() {
- Object obj = parameters.get(KEY_SAMPLING_RATE);
- if (obj instanceof SamplingRate) {
- return (SamplingRate) obj;
- } else if (obj instanceof String) {
- return SamplingRate.valueForString((String) obj);
- }
- return null;
+ return (SamplingRate) getObject(SamplingRate.class, KEY_SAMPLING_RATE);
}
/**
@@ -269,11 +231,7 @@ public class PerformAudioPassThru extends RPCRequest {
* <b>Notes: </b>Minvalue:1; Maxvalue:1000000
*/
public void setMaxDuration(Integer maxDuration) {
- if (maxDuration != null) {
- parameters.put(KEY_MAX_DURATION, maxDuration);
- } else {
- parameters.remove(KEY_MAX_DURATION);
- }
+ setParameters(KEY_MAX_DURATION, maxDuration);
}
/**
@@ -283,7 +241,7 @@ public class PerformAudioPassThru extends RPCRequest {
* recording in milliseconds
*/
public Integer getMaxDuration() {
- return (Integer) parameters.get(KEY_MAX_DURATION);
+ return getInteger(KEY_MAX_DURATION);
}
/**
@@ -293,11 +251,7 @@ public class PerformAudioPassThru extends RPCRequest {
* a BitsPerSample value representing 8 bit or 16 bit
*/
public void setBitsPerSample(BitsPerSample audioQuality) {
- if (audioQuality != null) {
- parameters.put(KEY_BITS_PER_SAMPLE, audioQuality);
- } else {
- parameters.remove(KEY_BITS_PER_SAMPLE);
- }
+ setParameters(KEY_BITS_PER_SAMPLE, audioQuality);
}
/**
@@ -306,13 +260,7 @@ public class PerformAudioPassThru extends RPCRequest {
* @return BitsPerSample -a BitsPerSample value
*/
public BitsPerSample getBitsPerSample() {
- Object obj = parameters.get(KEY_BITS_PER_SAMPLE);
- if (obj instanceof BitsPerSample) {
- return (BitsPerSample) obj;
- } else if (obj instanceof String) {
- return BitsPerSample.valueForString((String) obj);
- }
- return null;
+ return (BitsPerSample) getObject(BitsPerSample.class, KEY_BITS_PER_SAMPLE);
}
/**
@@ -322,11 +270,7 @@ public class PerformAudioPassThru extends RPCRequest {
* an audioType
*/
public void setAudioType(AudioType audioType) {
- if (audioType != null) {
- parameters.put(KEY_AUDIO_TYPE, audioType);
- } else {
- parameters.remove(KEY_AUDIO_TYPE);
- }
+ setParameters(KEY_AUDIO_TYPE, audioType);
}
/**
@@ -335,13 +279,7 @@ public class PerformAudioPassThru extends RPCRequest {
* @return AudioType -an AudioType
*/
public AudioType getAudioType() {
- Object obj = parameters.get(KEY_AUDIO_TYPE);
- if (obj instanceof AudioType) {
- return (AudioType) obj;
- } else if (obj instanceof String) {
- return AudioType.valueForString((String) obj);
- }
- return null;
+ return (AudioType) getObject(AudioType.class, KEY_AUDIO_TYPE);
}
/**
@@ -353,7 +291,7 @@ public class PerformAudioPassThru extends RPCRequest {
* should be muted during the APT session
*/
public Boolean getMuteAudio() {
- return (Boolean) parameters.get(KEY_MUTE_AUDIO);
+ return getBoolean(KEY_MUTE_AUDIO);
}
/**
@@ -368,10 +306,6 @@ public class PerformAudioPassThru extends RPCRequest {
* should be muted during the APT session
*/
public void setMuteAudio(Boolean muteAudio) {
- if (muteAudio != null) {
- parameters.put(KEY_MUTE_AUDIO, muteAudio);
- } else {
- parameters.remove(KEY_MUTE_AUDIO);
- }
+ setParameters(KEY_MUTE_AUDIO, muteAudio);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java
index 9ad8c1034..d8aeee70d 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteraction.java
@@ -1,13 +1,13 @@
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.InteractionMode;
import com.smartdevicelink.proxy.rpc.enums.LayoutMode;
+
+import java.util.Hashtable;
+import java.util.List;
+
/**
* Performs an application-initiated interaction in which the user can select a
* {@linkplain Choice} from among the specified Choice Sets. For instance, an
@@ -144,7 +144,7 @@ public class PerformInteraction extends RPCRequest {
* @return String -the text displayed when the interaction begins
*/
public String getInitialText() {
- return (String) parameters.get(KEY_INITIAL_TEXT);
+ return getString(KEY_INITIAL_TEXT);
}
/**
* Sets the Text that Displayed when the interaction begins. This text may
@@ -156,11 +156,7 @@ public class PerformInteraction extends RPCRequest {
* a String value that Displayed when the interaction begins
*/
public void setInitialText(String initialText) {
- if (initialText != null) {
- parameters.put(KEY_INITIAL_TEXT, initialText);
- } else {
- parameters.remove(KEY_INITIAL_TEXT);
- }
+ setParameters(KEY_INITIAL_TEXT, initialText);
}
/**
* Gets an An array of one or more TTSChunks that, taken together, specify
@@ -171,22 +167,7 @@ public class PerformInteraction extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getInitialPrompt() {
- 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;
- }
- }
- }
- return null;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_INITIAL_PROMPT);
}
/**
* Sets An array of one or more TTSChunks that, taken together, specify what
@@ -197,11 +178,7 @@ public class PerformInteraction extends RPCRequest {
* user at the start of an interaction
*/
public void setInitialPrompt(List<TTSChunk> initialPrompt) {
- if (initialPrompt != null) {
- parameters.put(KEY_INITIAL_PROMPT, initialPrompt);
- } else {
- parameters.remove(KEY_INITIAL_PROMPT);
- }
+ setParameters(KEY_INITIAL_PROMPT, initialPrompt);
}
/**
* Gets the Indicates mode that indicate how user selects interaction
@@ -212,13 +189,7 @@ public class PerformInteraction extends RPCRequest {
* (VR_ONLY, MANUAL_ONLY or BOTH)
*/
public InteractionMode getInteractionMode() {
- Object obj = parameters.get(KEY_INTERACTION_MODE);
- if (obj instanceof InteractionMode) {
- return (InteractionMode) obj;
- } else if (obj instanceof String) {
- return InteractionMode.valueForString((String) obj);
- }
- return null;
+ return (InteractionMode) getObject(InteractionMode.class, KEY_INTERACTION_MODE);
}
/**
* Sets the Indicates mode that indicate how user selects interaction
@@ -230,11 +201,7 @@ public class PerformInteraction extends RPCRequest {
* MANUAL_ONLY or BOTH)
*/
public void setInteractionMode(InteractionMode interactionMode) {
- if (interactionMode != null) {
- parameters.put(KEY_INTERACTION_MODE, interactionMode);
- } else {
- parameters.remove(KEY_INTERACTION_MODE);
- }
+ setParameters(KEY_INTERACTION_MODE, interactionMode);
}
/**
* Gets a List<Integer> value representing an Array of one or more Choice
@@ -246,16 +213,7 @@ public class PerformInteraction extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<Integer> getInteractionChoiceSetIDList() {
- 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;
- }
- }
- }
- return null;
+ return (List<Integer>) getObject(Integer.class, KEY_INTERACTION_CHOICE_SET_ID_LIST);
}
/**
* Sets a List<Integer> representing an Array of one or more Choice Set
@@ -269,11 +227,7 @@ public class PerformInteraction extends RPCRequest {
* <b>Notes: </b>Min Value: 0; Max Vlaue: 2000000000
*/
public void setInteractionChoiceSetIDList(List<Integer> interactionChoiceSetIDList) {
- if (interactionChoiceSetIDList != null) {
- parameters.put(KEY_INTERACTION_CHOICE_SET_ID_LIST, interactionChoiceSetIDList);
- } else {
- parameters.remove(KEY_INTERACTION_CHOICE_SET_ID_LIST);
- }
+ setParameters(KEY_INTERACTION_CHOICE_SET_ID_LIST, interactionChoiceSetIDList);
}
/**
* Gets a List<TTSChunk> which taken together, specify the help phrase to
@@ -285,22 +239,7 @@ public class PerformInteraction extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getHelpPrompt() {
- 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;
- }
- }
- }
- return null;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_HELP_PROMPT);
}
/**
* Sets An array of TTSChunks which, taken together, specify the help phrase
@@ -319,11 +258,7 @@ public class PerformInteraction extends RPCRequest {
* session
*/
public void setHelpPrompt(List<TTSChunk> helpPrompt) {
- if (helpPrompt != null) {
- parameters.put(KEY_HELP_PROMPT, helpPrompt);
- } else {
- parameters.remove(KEY_HELP_PROMPT);
- }
+ setParameters(KEY_HELP_PROMPT, helpPrompt);
}
/**
* Gets An array of TTSChunks which, taken together, specify the phrase to
@@ -334,22 +269,7 @@ public class PerformInteraction extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getTimeoutPrompt() {
- 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;
- }
- }
- }
- return null;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_TIMEOUT_PROMPT);
}
/**
* Sets An array of TTSChunks which, taken together, specify the phrase to
@@ -363,11 +283,7 @@ public class PerformInteraction extends RPCRequest {
* listen times out during the VR session
*/
public void setTimeoutPrompt(List<TTSChunk> timeoutPrompt) {
- if (timeoutPrompt != null) {
- parameters.put(KEY_TIMEOUT_PROMPT, timeoutPrompt);
- } else {
- parameters.remove(KEY_TIMEOUT_PROMPT);
- }
+ setParameters(KEY_TIMEOUT_PROMPT, timeoutPrompt);
}
/**
* Gets a Integer value representing the amount of time, in milliseconds,
@@ -378,7 +294,7 @@ public class PerformInteraction extends RPCRequest {
* Menu)
*/
public Integer getTimeout() {
- return (Integer) parameters.get(KEY_TIMEOUT);
+ return getInteger(KEY_TIMEOUT);
}
/**
* Sets the amount of time, in milliseconds, SDL will wait for the user to
@@ -397,11 +313,7 @@ public class PerformInteraction extends RPCRequest {
* <b>Notes: </b>Min Value: 5000; Max Value: 100000
*/
public void setTimeout(Integer timeout) {
- if (timeout != null) {
- parameters.put(KEY_TIMEOUT, timeout);
- } else {
- parameters.remove(KEY_TIMEOUT);
- }
+ setParameters(KEY_TIMEOUT, timeout);
}
/**
@@ -414,22 +326,7 @@ public class PerformInteraction extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<VrHelpItem> getVrHelp() {
- 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;
- }
- }
- }
- return null;
+ return (List<VrHelpItem>) getObject(VrHelpItem.class, KEY_VR_HELP);
}
/**
@@ -444,29 +341,14 @@ public class PerformInteraction extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setVrHelp(List<VrHelpItem> vrHelp) {
- if (vrHelp != null) {
- parameters.put(KEY_VR_HELP, vrHelp);
- } else {
- parameters.remove(KEY_VR_HELP);
- }
+ setParameters(KEY_VR_HELP, vrHelp);
}
public LayoutMode getInteractionLayout() {
- Object obj = parameters.get(KEY_INTERACTION_LAYOUT);
- if (obj instanceof LayoutMode) {
- return (LayoutMode) obj;
- } else if (obj instanceof String) {
- return LayoutMode.valueForString((String) obj);
- }
- return null;
+ return (LayoutMode) getObject(LayoutMode.class, KEY_INTERACTION_LAYOUT);
}
public void setInteractionLayout( LayoutMode interactionLayout ) {
- if (interactionLayout != null) {
- parameters.put(KEY_INTERACTION_LAYOUT, interactionLayout );
- }
- else {
- parameters.remove(KEY_INTERACTION_LAYOUT);
- }
+ setParameters(KEY_INTERACTION_LAYOUT, interactionLayout);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java
index c2b56dcd0..3e4b10b1c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PerformInteractionResponse.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
import com.smartdevicelink.proxy.rpc.enums.TriggerSource;
+import java.util.Hashtable;
+
/**
* PerformInteraction Response is sent, when PerformInteraction has been called
*
@@ -39,31 +39,21 @@ public class PerformInteractionResponse extends RPCResponse {
* @return choiceID Min: 0 Max: 65535
*/
public Integer getChoiceID() {
- return (Integer) parameters.get( KEY_CHOICE_ID );
+ return getInteger( KEY_CHOICE_ID );
}
/**
* Sets the application-scoped identifier that uniquely identifies this choice.
* @param choiceID Min: 0 Max: 65535
*/
public void setChoiceID( Integer choiceID ) {
- if (choiceID != null) {
- parameters.put(KEY_CHOICE_ID, choiceID );
- } else {
- parameters.remove(KEY_CHOICE_ID);
- }
+ setParameters(KEY_CHOICE_ID, choiceID);
}
/**
* <p>Returns a <I>TriggerSource</I> object which will be shown in the HMI</p>
* @return TriggerSource a TriggerSource object
*/
public TriggerSource getTriggerSource() {
- Object obj = parameters.get(KEY_TRIGGER_SOURCE);
- if (obj instanceof TriggerSource) {
- return (TriggerSource) obj;
- } else if (obj instanceof String) {
- return TriggerSource.valueForString((String) obj);
- }
- return null;
+ return (TriggerSource) getObject(TriggerSource.class, KEY_TRIGGER_SOURCE);
}
/**
* <p>Sets TriggerSource
@@ -71,21 +61,13 @@ public class PerformInteractionResponse extends RPCResponse {
* @param triggerSource a TriggerSource object
*/
public void setTriggerSource( TriggerSource triggerSource ) {
- if (triggerSource != null) {
- parameters.put(KEY_TRIGGER_SOURCE, triggerSource );
- } else {
- parameters.remove(KEY_TRIGGER_SOURCE);
- }
+ setParameters(KEY_TRIGGER_SOURCE, triggerSource);
}
public void setManualTextEntry(String manualTextEntry) {
- if (manualTextEntry != null) {
- parameters.put(KEY_MANUAL_TEXT_ENTRY, manualTextEntry);
- } else {
- parameters.remove(KEY_MANUAL_TEXT_ENTRY);
- }
+ setParameters(KEY_MANUAL_TEXT_ENTRY, manualTextEntry);
}
public String getManualTextEntry() {
- return (String) parameters.get(KEY_MANUAL_TEXT_ENTRY);
+ return getString(KEY_MANUAL_TEXT_ENTRY);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java
index 7776c12b7..59b6a347a 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PermissionItem.java
@@ -4,6 +4,7 @@ package com.smartdevicelink.proxy.rpc;
import java.util.Hashtable;
import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.HMILevel;
import com.smartdevicelink.util.DebugTool;
/**
* Change in permissions for a given set of RPCs
@@ -66,55 +67,23 @@ public class PermissionItem extends RPCStruct {
super(hash);
}
public String getRpcName() {
- return (String) store.get(KEY_RPC_NAME);
+ return getString(KEY_RPC_NAME);
}
public void setRpcName(String rpcName) {
- if (rpcName != null) {
- store.put(KEY_RPC_NAME, rpcName);
- } else {
- store.remove(KEY_RPC_NAME);
- }
+ setValue(KEY_RPC_NAME, rpcName);
}
@SuppressWarnings("unchecked")
public HMIPermissions getHMIPermissions() {
- Object obj = store.get(KEY_HMI_PERMISSIONS);
- if (obj instanceof HMIPermissions) {
- return (HMIPermissions) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new HMIPermissions((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HMI_PERMISSIONS, e);
- }
- }
- return null;
+ return (HMIPermissions) getObject(HMIPermissions.class, KEY_HMI_PERMISSIONS);
}
public void setHMIPermissions(HMIPermissions hmiPermissions) {
- if (hmiPermissions != null) {
- store.put(KEY_HMI_PERMISSIONS, hmiPermissions);
- } else {
- store.remove(KEY_HMI_PERMISSIONS);
- }
+ setValue(KEY_HMI_PERMISSIONS, hmiPermissions);
}
@SuppressWarnings("unchecked")
public ParameterPermissions getParameterPermissions() {
- Object obj = store.get(KEY_PARAMETER_PERMISSIONS);
- if (obj instanceof ParameterPermissions) {
- return (ParameterPermissions) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new ParameterPermissions((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PARAMETER_PERMISSIONS, e);
- }
- }
- return null;
+ return (ParameterPermissions) getObject(ParameterPermissions.class, KEY_PARAMETER_PERMISSIONS);
}
public void setParameterPermissions(ParameterPermissions parameterPermissions) {
- if (parameterPermissions != null) {
- store.put(KEY_PARAMETER_PERMISSIONS, parameterPermissions);
- } else {
- store.remove(KEY_PARAMETER_PERMISSIONS);
- }
+ setValue(KEY_PARAMETER_PERMISSIONS, parameterPermissions);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PhoneCapability.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PhoneCapability.java
new file mode 100644
index 000000000..c317e0eb9
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PhoneCapability.java
@@ -0,0 +1,27 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
+
+/**
+ * Extended capabilities of the module's phone feature
+ */
+
+public class PhoneCapability extends RPCStruct {
+ public static final String KEY_DIALNUMBER_ENABLED = "dialNumberEnabled";
+
+ public PhoneCapability(){}
+
+ public PhoneCapability(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ public Boolean getDialNumberEnabled(){
+ return getBoolean(KEY_DIALNUMBER_ENABLED);
+ }
+
+ public void setDialNumberEnabled(Boolean dialNumberEnabled){
+ setValue(KEY_DIALNUMBER_ENABLED, dialNumberEnabled);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java
index df28213c7..211586da9 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PresetBankCapabilities.java
@@ -1,9 +1,9 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+
/**
* Contains information about on-screen preset capabilities.
* <p><b>Parameter List</b></p>
@@ -45,11 +45,7 @@ public class PresetBankCapabilities extends RPCStruct {
* @param onScreenPresetsAvailable if Onscreen custom presets are available.
*/
public void setOnScreenPresetsAvailable(Boolean onScreenPresetsAvailable) {
- if (onScreenPresetsAvailable != null) {
- store.put(KEY_ON_SCREEN_PRESETS_AVAILABLE, onScreenPresetsAvailable);
- } else {
- store.remove(KEY_ON_SCREEN_PRESETS_AVAILABLE);
- }
+ setValue(KEY_ON_SCREEN_PRESETS_AVAILABLE, onScreenPresetsAvailable);
}
/**
@@ -57,6 +53,6 @@ public class PresetBankCapabilities extends RPCStruct {
* @return if Onscreen custom presets are available
*/
public Boolean onScreenPresetsAvailable() {
- return (Boolean) store.get(KEY_ON_SCREEN_PRESETS_AVAILABLE);
+ return getBoolean(KEY_ON_SCREEN_PRESETS_AVAILABLE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java
index 065ad14d5..a0be90fbd 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFile.java
@@ -1,13 +1,13 @@
package com.smartdevicelink.proxy.rpc;
-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.proxy.rpc.listeners.OnPutFileUpdateListener;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener;
+import java.util.Hashtable;
+
/**
* Used to push a binary data onto the SDL module from a mobile device, such as
* icons and album art.
@@ -143,14 +143,10 @@ public class PutFile extends RPCRequest {
* @param sdlFileName
* a String value representing a file reference name
* <p></p>
- * <b>Notes: </b>Maxlength=500
+ * <b>Notes: </b>Maxlength=500, however the max file name length may vary based on remote filesystem limitations
*/
public void setSdlFileName(String sdlFileName) {
- if (sdlFileName != null) {
- parameters.put(KEY_SDL_FILE_NAME, sdlFileName);
- } else {
- parameters.remove(KEY_SDL_FILE_NAME);
- }
+ setParameters(KEY_SDL_FILE_NAME, sdlFileName);
}
/**
@@ -159,7 +155,7 @@ public class PutFile extends RPCRequest {
* @return String - a String value representing a file reference name
*/
public String getSdlFileName() {
- return (String) parameters.get(KEY_SDL_FILE_NAME);
+ return getString(KEY_SDL_FILE_NAME);
}
/**
@@ -169,11 +165,7 @@ public class PutFile extends RPCRequest {
* a FileType value representing a selected file type
*/
public void setFileType(FileType fileType) {
- if (fileType != null) {
- parameters.put(KEY_FILE_TYPE, fileType);
- } else {
- parameters.remove(KEY_FILE_TYPE);
- }
+ setParameters(KEY_FILE_TYPE, fileType);
}
/**
@@ -182,13 +174,7 @@ public class PutFile extends RPCRequest {
* @return FileType -a FileType value representing a selected file type
*/
public FileType getFileType() {
- Object obj = parameters.get(KEY_FILE_TYPE);
- if (obj instanceof FileType) {
- return (FileType) obj;
- } else if (obj instanceof String) {
- return FileType.valueForString((String) obj);
- }
- return null;
+ return (FileType) getObject(FileType.class, KEY_FILE_TYPE);
}
/**
@@ -205,11 +191,7 @@ public class PutFile extends RPCRequest {
* a Boolean value
*/
public void setPersistentFile(Boolean persistentFile) {
- if (persistentFile != null) {
- parameters.put(KEY_PERSISTENT_FILE, persistentFile);
- } else {
- parameters.remove(KEY_PERSISTENT_FILE);
- }
+ setParameters(KEY_PERSISTENT_FILE, persistentFile);
}
/**
@@ -220,7 +202,7 @@ public class PutFile extends RPCRequest {
* persist between sessions / ignition cycles
*/
public Boolean getPersistentFile() {
- return (Boolean) parameters.get(KEY_PERSISTENT_FILE);
+ return getBoolean(KEY_PERSISTENT_FILE);
}
public void setFileData(byte[] fileData) {
setBulkData(fileData);
@@ -242,15 +224,11 @@ public class PutFile extends RPCRequest {
}
public void setOffset(Long offset) {
- if (offset != null) {
- parameters.put(KEY_OFFSET, offset);
- } else {
- parameters.remove(KEY_OFFSET);
- }
+ setParameters(KEY_OFFSET, offset);
}
public Long getOffset() {
- final Object o = parameters.get(KEY_OFFSET);
+ final Object o = getParameters(KEY_OFFSET);
if (o == null){
return null;
}
@@ -277,15 +255,11 @@ public class PutFile extends RPCRequest {
}
public void setLength(Long length) {
- if (length != null) {
- parameters.put(KEY_LENGTH, length);
- } else {
- parameters.remove(KEY_LENGTH);
- }
+ setParameters(KEY_LENGTH, length);
}
public Long getLength() {
- final Object o = parameters.get(KEY_LENGTH);
+ final Object o = getParameters(KEY_LENGTH);
if (o == null){
return null;
}
@@ -299,15 +273,11 @@ public class PutFile extends RPCRequest {
}
public void setSystemFile(Boolean systemFile) {
- if (systemFile != null) {
- parameters.put(KEY_SYSTEM_FILE, systemFile);
- } else {
- parameters.remove(KEY_SYSTEM_FILE);
- }
+ setParameters(KEY_SYSTEM_FILE, systemFile);
}
public Boolean getSystemFile() {
- final Object o = parameters.get(KEY_SYSTEM_FILE);
+ final Object o = getParameters(KEY_SYSTEM_FILE);
if (o instanceof Boolean) {
return (Boolean) o;
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java
index b9195981b..87425547a 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/PutFileResponse.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
+import java.util.Hashtable;
+
/**
* Put File Response is sent, when PutFile has been called
*
@@ -32,13 +32,9 @@ public class PutFileResponse extends RPCResponse {
super(hash);
}
public void setSpaceAvailable(Integer spaceAvailable) {
- if (spaceAvailable != null) {
- parameters.put(KEY_SPACE_AVAILABLE, spaceAvailable);
- } else {
- parameters.remove(KEY_SPACE_AVAILABLE);
- }
+ setParameters(KEY_SPACE_AVAILABLE, spaceAvailable);
}
public Integer getSpaceAvailable() {
- return (Integer) parameters.get(KEY_SPACE_AVAILABLE);
+ return getInteger(KEY_SPACE_AVAILABLE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlCapabilities.java
new file mode 100644
index 000000000..3acfe77a9
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlCapabilities.java
@@ -0,0 +1,236 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+
+/**
+ * Contains information about a radio control module's capabilities.
+ */
+public class RadioControlCapabilities extends RPCStruct{
+ public static final String KEY_MODULE_NAME= "moduleName";
+ public static final String KEY_RADIO_ENABLE_AVAILABLE= "radioEnableAvailable";
+ public static final String KEY_RADIO_BAND_AVAILABLE= "radioBandAvailable";
+ public static final String KEY_RADIO_FREQUENCY_AVAILABLE= "radioFrequencyAvailable";
+ public static final String KEY_HD_CHANNEL_AVAILABLE= "hdChannelAvailable";
+ public static final String KEY_RDS_DATA_AVAILABLE= "rdsDataAvailable";
+ public static final String KEY_AVAILABLE_HDS_AVAILABLE= "availableHDsAvailable";
+ public static final String KEY_STATE_AVAILABLE= "stateAvailable";
+ public static final String KEY_SIGNAL_STRENGTH_AVAILABLE= "signalStrengthAvailable";
+ public static final String KEY_SIGNAL_CHANGE_THRESHOLD_AVAILABLE= "signalChangeThresholdAvailable";
+
+ public RadioControlCapabilities() {
+ }
+
+ public RadioControlCapabilities(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the moduleName portion of the RadioControlCapabilities class
+ *
+ * @param moduleName
+ * The short friendly name of the climate control module.
+ * It should not be used to identify a module by mobile application.
+ */
+ public void setModuleName(String moduleName) {
+ setValue(KEY_MODULE_NAME, moduleName);
+ }
+
+ /**
+ * Gets the moduleName portion of the RadioControlCapabilities class
+ *
+ * @return String - Short friendly name of the climate control module.
+ */
+ public String getModuleName() {
+ return getString(KEY_MODULE_NAME);
+ }
+
+ /**
+ * Sets the radioEnableAvailable portion of the RadioControlCapabilities class
+ *
+ * @param radioEnableAvailable
+ * Availability of the control of enable/disable radio.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setRadioEnableAvailable(Boolean radioEnableAvailable) {
+ setValue(KEY_RADIO_ENABLE_AVAILABLE, radioEnableAvailable);
+ }
+
+ /**
+ * Gets the radioEnableAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of enable/disable radio.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getRadioEnableAvailable() {
+ return getBoolean(KEY_RADIO_ENABLE_AVAILABLE);
+ }
+
+ /**
+ * Sets the radioBandAvailable portion of the RadioControlCapabilities class
+ *
+ * @param radioBandAvailable
+ * Availability of the control of radio band.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setRadioBandAvailable(Boolean radioBandAvailable) {
+ setValue(KEY_RADIO_BAND_AVAILABLE, radioBandAvailable);
+ }
+
+ /**
+ * Gets the radioBandAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of radio band.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getRadioBandAvailable() {
+ return getBoolean(KEY_RADIO_BAND_AVAILABLE);
+ }
+
+ /**
+ * Sets the radioFrequencyAvailable portion of the RadioControlCapabilities class
+ *
+ * @param radioFrequencyAvailable
+ * Availability of the control of radio frequency.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setRadioFrequencyAvailable(Boolean radioFrequencyAvailable) {
+ setValue(KEY_RADIO_FREQUENCY_AVAILABLE, radioFrequencyAvailable);
+ }
+
+ /**
+ * Gets the radioFrequencyAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of radio frequency.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getRadioFrequencyAvailable() {
+ return getBoolean(KEY_RADIO_FREQUENCY_AVAILABLE);
+ }
+
+ /**
+ * Sets the hdChannelAvailable portion of the RadioControlCapabilities class
+ *
+ * @param hdChannelAvailable
+ * Availability of the control of HD radio channel.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setHdChannelAvailable(Boolean hdChannelAvailable) {
+ setValue(KEY_HD_CHANNEL_AVAILABLE, hdChannelAvailable);
+ }
+
+ /**
+ * Gets the hdChannelAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the control of HD radio channel.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getHdChannelAvailable() {
+ return getBoolean(KEY_HD_CHANNEL_AVAILABLE);
+ }
+
+ /**
+ * Sets the rdsDataAvailable portion of the RadioControlCapabilities class
+ *
+ * @param rdsDataAvailable
+ * Availability of the getting Radio Data System (RDS) data.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setRdsDataAvailable(Boolean rdsDataAvailable) {
+ setValue(KEY_RDS_DATA_AVAILABLE, rdsDataAvailable);
+ }
+
+ /**
+ * Gets the rdsDataAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the getting Radio Data System (RDS) data.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getRdsDataAvailable() {
+ return getBoolean(KEY_RDS_DATA_AVAILABLE);
+ }
+
+ /**
+ * Sets the availableHDsAvailable portion of the RadioControlCapabilities class
+ *
+ * @param availableHDsAvailable
+ * Availability of the getting the number of available HD channels.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setAvailableHDsAvailable(Boolean availableHDsAvailable) {
+ setValue(KEY_AVAILABLE_HDS_AVAILABLE, availableHDsAvailable);
+ }
+
+ /**
+ * Gets the availableHDsAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the getting the number of available HD channels.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getAvailableHDsAvailable() {
+ return getBoolean(KEY_AVAILABLE_HDS_AVAILABLE);
+ }
+
+ /**
+ * Sets the stateAvailable portion of the RadioControlCapabilities class
+ *
+ * @param stateAvailable
+ * Availability of the getting the Radio state.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setStateAvailable(Boolean stateAvailable) {
+ setValue(KEY_STATE_AVAILABLE, stateAvailable);
+ }
+
+ /**
+ * Gets the stateAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the getting the Radio state.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getStateAvailable() {
+ return getBoolean(KEY_STATE_AVAILABLE);
+ }
+
+ /**
+ * Sets the signalStrengthAvailable portion of the RadioControlCapabilities class
+ *
+ * @param signalStrengthAvailable
+ * Availability of the getting the signal strength.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setSignalStrengthAvailable(Boolean signalStrengthAvailable) {
+ setValue(KEY_SIGNAL_STRENGTH_AVAILABLE, signalStrengthAvailable);
+ }
+
+ /**
+ * Gets the signalStrengthAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the getting the signal strength.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getSignalStrengthAvailable() {
+ return getBoolean(KEY_SIGNAL_STRENGTH_AVAILABLE);
+ }
+
+ /**
+ * Sets the signalChangeThresholdAvailable portion of the RadioControlCapabilities class
+ *
+ * @param signalChangeThresholdAvailable
+ * Availability of the getting the signal Change Threshold.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public void setSignalChangeThresholdAvailable(Boolean signalChangeThresholdAvailable) {
+ setValue(KEY_SIGNAL_CHANGE_THRESHOLD_AVAILABLE, signalChangeThresholdAvailable);
+ }
+
+ /**
+ * Gets the signalChangeThresholdAvailable portion of the RadioControlCapabilities class
+ *
+ * @return Boolean - Availability of the getting the signal Change Threshold.
+ * True: Available, False: Not Available, Not present: Not Available.
+ */
+ public Boolean getSignalChangeThresholdAvailable() {
+ return getBoolean(KEY_SIGNAL_CHANGE_THRESHOLD_AVAILABLE);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlData.java
new file mode 100644
index 000000000..4744399ac
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RadioControlData.java
@@ -0,0 +1,223 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.RadioBand;
+import com.smartdevicelink.proxy.rpc.enums.RadioState;
+import java.util.Hashtable;
+
+/**
+ * Include information (both read-only and changeable data) about a
+ * remote control radio module.
+ */
+public class RadioControlData extends RPCStruct{
+ public static final String KEY_FREQUENCY_INTEGER= "frequencyInteger";
+ public static final String KEY_FREQUENCY_FRACTION= "frequencyFraction";
+ public static final String KEY_BAND= "band";
+ public static final String KEY_RDS_DATA= "rdsData";
+ public static final String KEY_AVAILABLE_HDS= "availableHDs";
+ public static final String KEY_HD_CHANNEL= "hdChannel";
+ public static final String KEY_SIGNAL_STRENGTH= "signalStrength";
+ public static final String KEY_SIGNAL_CHANGE_THRESHOLD= "signalChangeThreshold";
+ public static final String KEY_RADIO_ENABLE= "radioEnable";
+ public static final String KEY_STATE= "state";
+
+ public RadioControlData() {
+ }
+
+ public RadioControlData(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the frequencyInteger portion of the RadioControlData class
+ *
+ * @param frequencyInteger
+ * The integer part of the frequency i.e. for 101.7 this value should be 101
+ */
+ public void setFrequencyInteger(Integer frequencyInteger) {
+ setValue(KEY_FREQUENCY_INTEGER, frequencyInteger);
+ }
+
+ /**
+ * Gets the frequencyInteger portion of the RadioControlData class
+ *
+ * @return Integer - The integer part of the frequency i.e. for 101.7 this value should be 101.
+ */
+ public Integer getFrequencyInteger() {
+ return getInteger(KEY_FREQUENCY_INTEGER);
+ }
+
+ /**
+ * Sets the frequencyFraction portion of the RadioControlData class
+ *
+ * @param frequencyFraction
+ * The fractional part of the frequency i.e. for 101.7 is 7.
+ */
+ public void setFrequencyFraction(Integer frequencyFraction) {
+ setValue(KEY_FREQUENCY_FRACTION, frequencyFraction);
+ }
+
+ /**
+ * Gets the frequencyFraction portion of the RadioControlData class
+ *
+ * @return Integer - The fractional part of the frequency i.e. for 101.7 is 7.
+ */
+ public Integer getFrequencyFraction() {
+ return getInteger(KEY_FREQUENCY_FRACTION);
+ }
+
+ /**
+ * Sets the band portion of the RadioControlData class
+ *
+ * @param band
+ * The radio band (AM|FM|XM) of the radio tuner.
+ */
+ public void setBand(RadioBand band) {
+ setValue(KEY_BAND, band);
+ }
+
+ /**
+ * Gets the band portion of the RadioControlData class
+ *
+ * @return RadioBand - The radio band (AM|FM|XM) of the radio tuner.
+ */
+ public RadioBand getBand() {
+ return (RadioBand) getObject(RadioBand.class, KEY_BAND);
+ }
+
+ /**
+ * Sets the rdsData portion of the RadioControlData class
+ *
+ * @param rdsData
+ * Read only parameter. See RdsData data type for details.
+ */
+ public void setRdsData(RdsData rdsData) {
+ setValue(KEY_RDS_DATA, rdsData);
+ }
+
+ /**
+ * Gets the rdsData portion of the RadioControlData class
+ *
+ * @return RdsData - Read only parameter. See RdsData data type for details.
+ */
+ public RdsData getRdsData() {
+ return (RdsData) getObject(RdsData.class, KEY_RDS_DATA);
+ }
+
+ /**
+ * Sets the availableHDs portion of the RadioControlData class
+ *
+ * @param availableHDs
+ * Number of HD sub-channels if available.
+ */
+ public void setAvailableHDs(Integer availableHDs) {
+ setValue(KEY_AVAILABLE_HDS, availableHDs);
+ }
+
+ /**
+ * Gets the availableHDs portion of the RadioControlData class
+ *
+ * @return Integer - Number of HD sub-channels if available.
+ */
+ public Integer getAvailableHDs() {
+ return getInteger(KEY_AVAILABLE_HDS);
+ }
+
+ /**
+ * Sets the hdChannel portion of the RadioControlData class
+ *
+ * @param hdChannel
+ * Current HD sub-channel if available.
+ */
+ public void setHdChannel(Integer hdChannel) {
+ setValue(KEY_HD_CHANNEL, hdChannel);
+ }
+
+ /**
+ * Gets the hdChannel portion of the RadioControlData class
+ *
+ * @return Integer - Current HD sub-channel if available.
+ */
+ public Integer getHdChannel() {
+ return getInteger(KEY_HD_CHANNEL);
+ }
+
+ /**
+ * Sets the signalStrength portion of the RadioControlData class
+ *
+ * @param signalStrength
+ * Read only parameter. Indicates the strength of receiving radio signal in current frequency.
+ */
+ public void setSignalStrength(Integer signalStrength) {
+ setValue(KEY_SIGNAL_STRENGTH, signalStrength);
+ }
+
+ /**
+ * Gets the signalStrength portion of the RadioControlData class
+ *
+ * @return Integer - Read only parameter. Indicates the strength of receiving radio signal in current frequency.
+ */
+ public Integer getSignalStrength() {
+ return getInteger(KEY_SIGNAL_STRENGTH);
+ }
+
+ /**
+ * Sets the signalChangeThreshold portion of the RadioControlData class
+ *
+ * @param signalChangeThreshold
+ * If the signal strength falls below the set value for this parameter, the radio will tune to an alternative frequency.
+ */
+ public void setSignalChangeThreshold(Integer signalChangeThreshold) {
+ setValue(KEY_SIGNAL_CHANGE_THRESHOLD, signalChangeThreshold);
+ }
+
+ /**
+ * Gets the signalChangeThreshold portion of the RadioControlData class
+ *
+ * @return Integer - If the signal strength falls below the set value for this parameter, the radio will tune to an alternative frequency.
+ */
+ public Integer getSignalChangeThreshold() {
+ return getInteger(KEY_SIGNAL_CHANGE_THRESHOLD);
+ }
+
+ /**
+ * Sets the radioEnable portion of the RadioControlData class
+ * <br><b>Note: </b> If this is set to false, no other data will be included.
+ * <br><b>Note: </b> This setting is normally a <b>READ-ONLY</b> setting.
+ *
+ * @param radioEnable
+ * True if the radio is on, false is the radio is off.
+ */
+ public void setRadioEnable(Boolean radioEnable) {
+ setValue(KEY_RADIO_ENABLE, radioEnable);
+ }
+
+ /**
+ * Gets the radioEnable portion of the RadioControlData class
+ * <br><b>Note: </b> If this is set to false, no other data will be included.
+ *
+ * @return Boolean - True if the radio is on, false is the radio is off.
+ */
+ public Boolean getRadioEnable() {
+ return getBoolean(KEY_RADIO_ENABLE);
+ }
+
+ /**
+ * Sets the state portion of the RadioControlData class
+ *
+ * @param state
+ * Read only parameter. See RadioState data type for details.
+ */
+ public void setState(RadioState state) {
+ setValue(KEY_STATE, state);
+ }
+
+ /**
+ * Gets the state portion of the RadioControlData class
+ *
+ * @return RadioState - Read only parameter. See RadioState data type for details.
+ */
+ public RadioState getState() {
+ return (RadioState) getObject(RadioState.class, KEY_STATE);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RdsData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RdsData.java
new file mode 100644
index 000000000..2ed934865
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RdsData.java
@@ -0,0 +1,180 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
+
+/**
+ * Include the data defined in Radio Data System, which is a communications protocol standard
+ * for embedding small amounts of digital information in conventional FM radio broadcasts.
+ */
+public class RdsData extends RPCStruct{
+ public static final String KEY_PS= "PS";
+ public static final String KEY_RT= "RT";
+ public static final String KEY_CT= "CT";
+ public static final String KEY_PI= "PI";
+ public static final String KEY_PTY= "PTY";
+ public static final String KEY_TP= "TP";
+ public static final String KEY_TA= "TA";
+ public static final String KEY_REG= "REG";
+
+ public RdsData() {
+ }
+
+ public RdsData(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the programService portion of the RdsData class
+ *
+ * @param programService
+ * Program Service Name.
+ */
+ public void setProgramService(String programService) {
+ setValue(KEY_PS, programService);
+ }
+
+ /**
+ * Gets the programService portion of the RdsData class
+ *
+ * @return String - Program Service Name.
+ */
+ public String getProgramService() {
+ return getString(KEY_PS);
+ }
+
+ /**
+ * Sets the radioText portion of the RdsData class
+ *
+ * @param radioText
+ * Radio Text.
+ */
+ public void setRadioText(String radioText) {
+ setValue(KEY_RT, radioText);
+ }
+
+ /**
+ * Gets the radioText portion of the RdsData class
+ *
+ * @return String - Radio Text.
+ */
+ public String getRadioText() {
+ return getString(KEY_RT);
+ }
+
+ /**
+ * Sets the clockText portion of the RdsData class
+ *
+ * @param clockText
+ * The clock text in UTC format as YYYY-MM-DDThh:mm:ss.sTZD.
+ */
+ public void setClockText(String clockText) {
+ setValue(KEY_CT, clockText);
+ }
+
+ /**
+ * Gets the clockText portion of the RdsData class
+ *
+ * @return String - The clock text in UTC format as YYYY-MM-DDThh:mm:ss.sTZD.
+ */
+ public String getClockText() {
+ return getString(KEY_CT);
+ }
+
+ /**
+ * Sets the programIdentification portion of the RdsData class
+ *
+ * @param programIdentification
+ * Program Identification - the call sign for the radio station.
+ */
+ public void setProgramIdentification(String programIdentification) {
+ setValue(KEY_PI, programIdentification);
+ }
+
+ /**
+ * Gets the programIdentification portion of the RdsData class
+ *
+ * @return String - Program Identification - the call sign for the radio station.
+ */
+ public String getProgramIdentification() {
+ return getString(KEY_PI);
+ }
+
+ /**
+ * Sets the region portion of the RdsData class
+ *
+ * @param region
+ * Region.
+ */
+ public void setRegion(String region) {
+ setValue(KEY_REG, region);
+ }
+
+ /**
+ * Gets the region portion of the RdsData class
+ *
+ * @return String - Region.
+ */
+ public String getRegion() {
+ return getString(KEY_REG);
+ }
+
+ /**
+ * Sets the trafficProgram portion of the RdsData class
+ *
+ * @param trafficProgram
+ * Traffic Program Identification - Identifies a station that offers traffic.
+ */
+ public void setTrafficProgram(Boolean trafficProgram) {
+ setValue(KEY_TP, trafficProgram);
+ }
+
+ /**
+ * Gets the trafficProgram portion of the RdsData class
+ *
+ * @return Boolean - Traffic Program Identification - Identifies a station that offers traffic.
+ */
+ public Boolean getTrafficProgram() {
+ return getBoolean(KEY_TP);
+ }
+
+ /**
+ * Sets the trafficAnnouncement portion of the RdsData class
+ *
+ * @param trafficAnnouncement
+ * Traffic Announcement Identification - Indicates an ongoing traffic announcement.
+ */
+ public void setTrafficAnnouncement(Boolean trafficAnnouncement) {
+ setValue(KEY_TA, trafficAnnouncement);
+ }
+
+ /**
+ * Gets the trafficAnnouncement portion of the RdsData class
+ *
+ * @return Boolean - Traffic Announcement Identification - Indicates an ongoing traffic announcement.
+ */
+ public Boolean getTrafficAnnouncement() {
+ return getBoolean(KEY_TA);
+ }
+
+ /**
+ * Sets the programType portion of the RdsData class
+ *
+ * @param programType
+ * The program type - The region should be used to differentiate between EU and North America program types.
+ */
+ public void setProgramType(Integer programType) {
+ setValue(KEY_PTY, programType);
+ }
+
+ /**
+ * Gets the programType portion of the RdsData class
+ *
+ * @return Integer - The program type.
+ * The region should be used to differentiate between EU and North America program types.
+ */
+ public Integer getProgramType() {
+ return getInteger(KEY_PTY);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java
index 285416881..ec198e54c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDID.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-import java.util.List;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* <p>Non periodic vehicle data read request. This is an RPC to get diagnostics
* data from certain vehicle modules. DIDs of a certain module might differ from
@@ -98,11 +98,7 @@ public class ReadDID extends RPCRequest {
* <b>Notes: </b>Minvalue:0; Maxvalue:65535
*/
public void setEcuName(Integer ecuName) {
- if (ecuName != null) {
- parameters.put(KEY_ECU_NAME, ecuName);
- } else {
- parameters.remove(KEY_ECU_NAME);
- }
+ setParameters(KEY_ECU_NAME, ecuName);
}
/**
@@ -112,7 +108,7 @@ public class ReadDID extends RPCRequest {
* module
*/
public Integer getEcuName() {
- return (Integer) parameters.get(KEY_ECU_NAME);
+ return getInteger(KEY_ECU_NAME);
}
/**
@@ -129,11 +125,7 @@ public class ReadDID extends RPCRequest {
* </ul>
*/
public void setDidLocation(List<Integer> didLocation) {
- if (didLocation != null) {
- parameters.put(KEY_DID_LOCATION, didLocation);
- } else {
- parameters.remove(KEY_DID_LOCATION);
- }
+ setParameters(KEY_DID_LOCATION, didLocation);
}
/**
@@ -144,15 +136,6 @@ public class ReadDID extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<Integer> getDidLocation() {
- 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;
- }
- }
- }
- return null;
+ return (List<Integer>) getObject(Integer.class, KEY_DID_LOCATION);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java
index b21395b48..e0633198c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ReadDIDResponse.java
@@ -1,12 +1,11 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* Read DID Response is sent, when ReadDID has been called
*
@@ -22,29 +21,10 @@ public class ReadDIDResponse extends RPCResponse {
super(hash);
}
public void setDidResult(List<DIDResult> didResult) {
- if (didResult != null) {
- parameters.put(KEY_DID_RESULT, didResult);
- } else {
- parameters.remove(KEY_DID_RESULT);
- }
+ setParameters(KEY_DID_RESULT, didResult);
}
@SuppressWarnings("unchecked")
public List<DIDResult> getDidResult() {
- 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;
- }
- }
- }
- return null;
+ return (List<DIDResult>) getObject(DIDResult.class, KEY_DID_RESULT);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java
new file mode 100644
index 000000000..e0d50e073
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Rectangle.java
@@ -0,0 +1,109 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
+/*
+ * Copyright (c) 2017 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Defines Rectangle for each user control object for video streaming application
+ * @since SmartDeviceLink 4.5.0
+ */
+
+public class Rectangle extends RPCStruct {
+ public static final String KEY_X = "x";
+ public static final String KEY_Y = "y";
+ public static final String KEY_WIDTH = "width";
+ public static final String KEY_HEIGHT = "height";
+
+ public Rectangle() {}
+ public Rectangle(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Set the X-coordinate pixel in of the user control that starts in the upper left corner
+ */
+ public void setX(Float x) {
+ setValue(KEY_X, x);
+ }
+
+ /**
+ * @return the X-coordinate pixel of the user control that starts in the upper left corner
+ */
+ public Float getX() {
+ return getFloat(KEY_X);
+ }
+
+ /**
+ * Set the Y-coordinate pixel of the user control that starts in the upper left corner
+ */
+ public void setY(Float y) {
+ setValue(KEY_Y, y);
+ }
+
+ /**
+ * @return the Y-coordinate pixel of the user control that starts in the upper left corner
+ */
+ public Float getY() {
+ return getFloat(KEY_Y);
+ }
+
+ /**
+ * Set the width in pixels of the user control's bounding rectangle in pixels
+ */
+ public void setWidth(Float width) {
+ setValue(KEY_WIDTH, width);
+ }
+
+ /**
+ * @return the width in pixels of the user control's bounding rectangle in pixels
+ */
+ public Float getWidth() {
+ return getFloat(KEY_WIDTH);
+ }
+
+ /**
+ * The height in pixels of the user control's bounding rectangle
+ */
+ public void setHeight(Float height) {
+ setValue(KEY_HEIGHT, height);
+ }
+
+ /**
+ * @return the width in pixels of the user control's bounding rectangle in pixels
+ */
+ public Float getHeight() {
+ return getFloat(KEY_HEIGHT);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java
index 99bcba01a..0f02ecca0 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterface.java
@@ -1,13 +1,12 @@
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 java.util.Hashtable;
+import java.util.List;
/**
* Registers the application's interface with SDL&reg;, declaring properties of
* the registration, including the messaging interface version, the app name,
@@ -252,13 +251,7 @@ public class RegisterAppInterface extends RPCRequest {
*/
@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;
+ return (SdlMsgVersion) getObject(SdlMsgVersion.class, KEY_SDL_MSG_VERSION);
}
/**
* Sets the version of the SDL&reg; SmartDeviceLink interface
@@ -280,30 +273,16 @@ public class RegisterAppInterface extends RPCRequest {
* 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);
- }
+ setParameters(KEY_SDL_MSG_VERSION, sdlMsgVersion);
}
@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;
+ return (DeviceInfo) getObject(DeviceInfo.class, KEY_DEVICE_INFO);
}
public void setDeviceInfo(DeviceInfo deviceInfo) {
- if (deviceInfo != null) {
- parameters.put(KEY_DEVICE_INFO, deviceInfo);
- } else {
- parameters.remove(KEY_DEVICE_INFO);
- }
+ setParameters(KEY_DEVICE_INFO, deviceInfo);
}
/**
* Gets Mobile Application's Name
@@ -311,7 +290,7 @@ public class RegisterAppInterface extends RPCRequest {
* @return String -a String representing the Mobile Application's Name
*/
public String getAppName() {
- return (String) parameters.get(KEY_APP_NAME);
+ return getString(KEY_APP_NAME);
}
/**
* Sets Mobile Application's Name, This name is displayed in the SDL&reg;
@@ -330,11 +309,7 @@ public class RegisterAppInterface extends RPCRequest {
* </ul>
*/
public void setAppName(String appName) {
- if (appName != null) {
- parameters.put(KEY_APP_NAME, appName);
- } else {
- parameters.remove(KEY_APP_NAME);
- }
+ setParameters(KEY_APP_NAME, appName);
}
/**
@@ -345,22 +320,7 @@ public class RegisterAppInterface extends RPCRequest {
*/
@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;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_TTS_NAME);
}
/**
@@ -382,11 +342,7 @@ public class RegisterAppInterface extends RPCRequest {
* @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);
- }
+ setParameters(KEY_TTS_NAME, ttsName);
}
/**
* Gets a String representing an abbreviated version of the mobile
@@ -397,7 +353,7 @@ public class RegisterAppInterface extends RPCRequest {
* mobile applincation's name
*/
public String getNgnMediaScreenAppName() {
- return (String) parameters.get(KEY_NGN_MEDIA_SCREEN_APP_NAME);
+ return getString(KEY_NGN_MEDIA_SCREEN_APP_NAME);
}
/**
* Sets a String representing an abbreviated version of the mobile
@@ -416,11 +372,7 @@ public class RegisterAppInterface extends RPCRequest {
* </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);
- }
+ setParameters(KEY_NGN_MEDIA_SCREEN_APP_NAME, ngnMediaScreenAppName);
}
/**
* Gets the List<String> representing the an array of 1-100 elements, each
@@ -432,16 +384,7 @@ public class RegisterAppInterface 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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_VR_SYNONYMS);
}
/**
* Sets a vrSynonyms representing the an array of 1-100 elements, each
@@ -461,11 +404,7 @@ public class RegisterAppInterface extends RPCRequest {
* </ul>
*/
public void setVrSynonyms(List<String> vrSynonyms) {
- if (vrSynonyms != null) {
- parameters.put(KEY_VR_SYNONYMS, vrSynonyms);
- } else {
- parameters.remove(KEY_VR_SYNONYMS);
- }
+ setParameters(KEY_VR_SYNONYMS, vrSynonyms);
}
/**
* Gets a Boolean representing MediaApplication
@@ -474,7 +413,7 @@ public class RegisterAppInterface extends RPCRequest {
* a media application or not
*/
public Boolean getIsMediaApplication() {
- return (Boolean) parameters.get(KEY_IS_MEDIA_APPLICATION);
+ return getBoolean(KEY_IS_MEDIA_APPLICATION);
}
/**
* Sets a Boolean to indicate a mobile application that is a media
@@ -484,11 +423,7 @@ public class RegisterAppInterface extends RPCRequest {
* 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);
- }
+ setParameters(KEY_IS_MEDIA_APPLICATION, isMediaApplication);
}
/**
* Gets a Language enumeration indicating what language the application
@@ -497,13 +432,7 @@ public class RegisterAppInterface extends RPCRequest {
* @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;
+ return (Language) getObject(Language.class, KEY_LANGUAGE_DESIRED);
}
/**
* Sets an enumeration indicating what language the application intends to
@@ -515,11 +444,7 @@ public class RegisterAppInterface extends RPCRequest {
*
*/
public void setLanguageDesired(Language languageDesired) {
- if (languageDesired != null) {
- parameters.put(KEY_LANGUAGE_DESIRED, languageDesired);
- } else {
- parameters.remove(KEY_LANGUAGE_DESIRED);
- }
+ setParameters(KEY_LANGUAGE_DESIRED, languageDesired);
}
/**
@@ -532,13 +457,7 @@ public class RegisterAppInterface extends RPCRequest {
* @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;
+ return (Language) getObject(Language.class, KEY_HMI_DISPLAY_LANGUAGE_DESIRED);
}
/**
@@ -549,11 +468,7 @@ public class RegisterAppInterface extends RPCRequest {
* @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);
- }
+ setParameters(KEY_HMI_DISPLAY_LANGUAGE_DESIRED, hmiDisplayLanguageDesired);
}
/**
@@ -568,26 +483,7 @@ public class RegisterAppInterface extends RPCRequest {
*/
@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 = AppHMIType.valueForString(strFormat);
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<AppHMIType>) getObject(AppHMIType.class, KEY_APP_HMI_TYPE);
}
/**
@@ -606,23 +502,15 @@ public class RegisterAppInterface extends RPCRequest {
* @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);
- }
+ setParameters(KEY_APP_HMI_TYPE, appHMIType);
}
public String getHashID() {
- return (String) parameters.get(KEY_HASH_ID);
+ return getString(KEY_HASH_ID);
}
public void setHashID(String hashID) {
- if (hashID != null) {
- parameters.put(KEY_HASH_ID, hashID);
- } else {
- parameters.remove(KEY_HASH_ID);
- }
+ setParameters(KEY_HASH_ID, hashID);
}
/**
@@ -633,7 +521,7 @@ public class RegisterAppInterface extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public String getAppID() {
- return (String) parameters.get(KEY_APP_ID);
+ return getString(KEY_APP_ID);
}
/**
@@ -647,10 +535,6 @@ public class RegisterAppInterface extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setAppID(String appID) {
- if (appID != null) {
- parameters.put(KEY_APP_ID, appID);
- } else {
- parameters.remove(KEY_APP_ID);
- }
+ setParameters(KEY_APP_ID, appID);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java
index f89e1a8b8..df5c3f531 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RegisterAppInterfaceResponse.java
@@ -1,9 +1,5 @@
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;
@@ -13,6 +9,9 @@ import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* Register AppInterface Response is sent, when RegisterAppInterface has been called
*
@@ -65,13 +64,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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;
+ return (SdlMsgVersion) getObject(SdlMsgVersion.class, KEY_SDL_MSG_VERSION);
}
/**
@@ -94,11 +87,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
* 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);
- }
+ setParameters(KEY_SDL_MSG_VERSION, sdlMsgVersion);
}
/**
@@ -108,13 +97,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
* @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;
+ return (Language) getObject(Language.class, KEY_LANGUAGE);
}
/**
@@ -127,11 +110,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*
*/
public void setLanguage(Language language) {
- if (language != null) {
- parameters.put(KEY_LANGUAGE, language);
- } else {
- parameters.remove(KEY_LANGUAGE);
- }
+ setParameters(KEY_LANGUAGE, language);
}
/**
@@ -144,13 +123,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
* @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;
+ return (Language) getObject(Language.class, KEY_HMI_DISPLAY_LANGUAGE);
}
/**
@@ -161,11 +134,7 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
* @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);
- }
+ setParameters(KEY_HMI_DISPLAY_LANGUAGE, hmiDisplayLanguage);
}
/**
@@ -175,24 +144,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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;
+ return (DisplayCapabilities) getObject(DisplayCapabilities.class, KEY_DISPLAY_CAPABILITIES);
}
/**
* 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);
- }
+ setParameters(KEY_DISPLAY_CAPABILITIES, displayCapabilities);
}
/**
@@ -202,33 +161,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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;
+ return (List<ButtonCapabilities>) getObject(ButtonCapabilities.class, KEY_BUTTON_CAPABILITIES);
}
/**
* 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);
- }
+ setParameters(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
}
/**
* Gets getSoftButtonCapabilities set when application interface is registered.
@@ -237,33 +177,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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;
+ return (List<SoftButtonCapabilities>) getObject(SoftButtonCapabilities.class, KEY_SOFT_BUTTON_CAPABILITIES);
}
/**
* 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);
- }
+ setParameters(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities);
}
/**
@@ -273,24 +194,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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;
+ return (PresetBankCapabilities) getObject(PresetBankCapabilities.class, KEY_PRESET_BANK_CAPABILITIES);
}
/**
* 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);
- }
+ setParameters(KEY_PRESET_BANK_CAPABILITIES, presetBankCapabilities);
}
/**
@@ -300,37 +211,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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 = HmiZoneCapabilities.valueForString(strFormat);
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<HmiZoneCapabilities>) getObject(HmiZoneCapabilities.class, KEY_HMI_ZONE_CAPABILITIES);
}
/**
* 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);
- }
+ setParameters(KEY_HMI_ZONE_CAPABILITIES, hmiZoneCapabilities);
}
/**
@@ -340,70 +228,24 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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 = SpeechCapabilities.valueForString(strFormat);
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<SpeechCapabilities>) getObject(SpeechCapabilities.class, KEY_SPEECH_CAPABILITIES);
}
/**
* 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);
- }
+ setParameters(KEY_SPEECH_CAPABILITIES, speechCapabilities);
}
@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 = PrerecordedSpeech.valueForString(strFormat);
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<PrerecordedSpeech>) getObject(PrerecordedSpeech.class, KEY_PRERECORDED_SPEECH);
}
public void setPrerecordedSpeech(List<PrerecordedSpeech> prerecordedSpeech) {
- if (prerecordedSpeech != null) {
- parameters.put(KEY_PRERECORDED_SPEECH, prerecordedSpeech);
- } else {
- parameters.remove(KEY_PRERECORDED_SPEECH);
- }
+ setParameters(KEY_PRERECORDED_SPEECH, prerecordedSpeech);
}
@@ -414,37 +256,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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 = VrCapabilities.valueForString(strFormat);
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<VrCapabilities>) getObject(VrCapabilities.class, KEY_VR_CAPABILITIES);
}
/**
* 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);
- }
+ setParameters(KEY_VR_CAPABILITIES, vrCapabilities);
}
/**
@@ -454,24 +273,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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;
+ return (VehicleType) getObject(VehicleType.class, KEY_VEHICLE_TYPE);
}
/**
* Sets vehicleType
* @param vehicleType
*/
public void setVehicleType(VehicleType vehicleType) {
- if (vehicleType != null) {
- parameters.put(KEY_VEHICLE_TYPE, vehicleType);
- } else {
- parameters.remove(KEY_VEHICLE_TYPE);
- }
+ setParameters(KEY_VEHICLE_TYPE, vehicleType);
}
/**
@@ -481,33 +290,14 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
*/
@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;
+ return (List<AudioPassThruCapabilities>) getObject(AudioPassThruCapabilities.class, KEY_AUDIO_PASS_THRU_CAPABILITIES);
}
/**
* 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);
- }
+ setParameters(KEY_AUDIO_PASS_THRU_CAPABILITIES, audioPassThruCapabilities);
}
public String getProxyVersionInfo() {
if (Version.VERSION != null)
@@ -516,70 +306,36 @@ public class RegisterAppInterfaceResponse extends RPCResponse {
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);
- }
+ setParameters(KEY_SUPPORTED_DIAG_MODES, supportedDiagModes);
}
@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;
+ return (List<Integer>) getObject(Integer.class, KEY_SUPPORTED_DIAG_MODES);
}
public void setHmiCapabilities(HMICapabilities hmiCapabilities) {
- if (hmiCapabilities != null) {
- parameters.put(KEY_HMI_CAPABILITIES, hmiCapabilities);
- }else{
- parameters.remove(KEY_HMI_CAPABILITIES);
- }
+ setParameters(KEY_HMI_CAPABILITIES, hmiCapabilities);
}
@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;
+ return (HMICapabilities) getObject(HMICapabilities.class, KEY_HMI_CAPABILITIES);
}
public void setSdlVersion(String sdlVersion) {
- if (sdlVersion != null) {
- parameters.put(KEY_SDL_VERSION, sdlVersion);
- }else{
- parameters.remove(KEY_SDL_VERSION);
- }
+ setParameters(KEY_SDL_VERSION, sdlVersion);
}
public String getSdlVersion() {
- return (String) parameters.get(KEY_SDL_VERSION);
+ return getString(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);
- }
+ setParameters(KEY_SYSTEM_SOFTWARE_VERSION, systemSoftwareVersion);
}
public String getSystemSoftwareVersion() {
- return (String) parameters.get(KEY_SYSTEM_SOFTWARE_VERSION);
+ return getString(KEY_SYSTEM_SOFTWARE_VERSION);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RemoteControlCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RemoteControlCapabilities.java
new file mode 100644
index 000000000..ec51aa633
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/RemoteControlCapabilities.java
@@ -0,0 +1,82 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+import java.util.List;
+
+public class RemoteControlCapabilities extends RPCStruct{
+ public static final String KEY_CLIMATE_CONTROL_CAPABILITIES= "climateControlCapabilities";
+ public static final String KEY_RADIO_CONTROL_CAPABILITIES = "radioControlCapabilities";
+ public static final String KEY_BUTTON_CAPABILITIES = "buttonCapabilities";
+
+ public RemoteControlCapabilities() {
+ }
+
+ public RemoteControlCapabilities(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the climateControlCapabilities portion of the RemoteControlCapabilities class
+ *
+ * @param climateControlCapabilities
+ * If included, the platform supports RC climate controls.
+ * For this baseline version, maxsize=1. i.e. only one climate control module is supported.
+ */
+ public void setClimateControlCapabilities(List<ClimateControlCapabilities> climateControlCapabilities) {
+ setValue(KEY_CLIMATE_CONTROL_CAPABILITIES, climateControlCapabilities);
+ }
+
+ /**
+ * Gets the climateControlCapabilities portion of the RemoteControlCapabilities class
+ *
+ * @return List<ClimateControlCapabilities>
+ * If included, the platform supports RC climate controls.
+ * For this baseline version, maxsize=1. i.e. only one climate control module is supported.
+ */
+ public List<ClimateControlCapabilities> getClimateControlCapabilities() {
+ return (List<ClimateControlCapabilities>) getObject(ClimateControlCapabilities.class, KEY_CLIMATE_CONTROL_CAPABILITIES);
+ }
+
+ /**
+ * Sets the radioControlCapabilities portion of the RemoteControlCapabilities class
+ *
+ * @param radioControlCapabilities
+ * If included, the platform supports RC climate controls.
+ * For this baseline version, maxsize=1. i.e. only one radio control module is supported.
+ */
+ public void setRadioControlCapabilities(List<RadioControlCapabilities> radioControlCapabilities) {
+ setValue(KEY_RADIO_CONTROL_CAPABILITIES, radioControlCapabilities);
+ }
+
+ /**
+ * Gets the radioControlCapabilities portion of the RemoteControlCapabilities class
+ *
+ * @return List<RadioControlCapabilities>
+ * If included, the platform supports RC climate controls.
+ * For this baseline version, maxsize=1. i.e. only one radio control module is supported.
+ */
+ public List<RadioControlCapabilities> getRadioControlCapabilities() {
+ return (List<RadioControlCapabilities>) getObject(RadioControlCapabilities.class, KEY_RADIO_CONTROL_CAPABILITIES);
+ }
+
+ /**
+ * Sets the buttonCapabilities portion of the RemoteControlCapabilities class
+ *
+ * @param buttonCapabilities
+ * If included, the platform supports RC button controls with the included button names.
+ */
+ public void setButtonCapabilities(List<ButtonCapabilities> buttonCapabilities) {
+ setValue(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
+ }
+
+ /**
+ * Gets the buttonCapabilities portion of the RemoteControlCapabilities class
+ *
+ * @return List<ButtonCapabilities>
+ * If included, the platform supports RC button controls with the included button names.
+ */
+ public List<ButtonCapabilities> getButtonCapabilities() {
+ return (List<ButtonCapabilities>) getObject(ButtonCapabilities.class, KEY_BUTTON_CAPABILITIES);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java
index 4a9f18d7f..664eb33a9 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ResetGlobalProperties.java
@@ -1,12 +1,12 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* Resets the passed global properties to their default values as defined by
* SDL
@@ -85,26 +85,7 @@ public class ResetGlobalProperties extends RPCRequest {
*/
@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 = GlobalProperty.valueForString(strFormat);
- if (toAdd != null) {
- newList.add(toAdd);
- }
- }
- return newList;
- }
- }
- }
- return null;
+ return (List<GlobalProperty>) getObject(GlobalProperty.class, KEY_PROPERTIES);
}
/**
* Sets an array of one or more GlobalProperty enumeration elements
@@ -118,10 +99,6 @@ public class ResetGlobalProperties extends RPCRequest {
* <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);
- }
+ setParameters(KEY_PROPERTIES, properties);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java
index fe2c626a0..a821264e6 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScreenParams.java
@@ -1,11 +1,8 @@
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.DebugTool;
+
+import java.util.Hashtable;
/** The resolution of the prescribed screen area.
*
* <p><b>Parameter List</b></p>
@@ -64,46 +61,16 @@ public class ScreenParams extends RPCStruct {
@SuppressWarnings("unchecked")
public ImageResolution getImageResolution() {
- Object obj = store.get(KEY_RESOLUTION);
- if (obj instanceof ImageResolution) {
- return (ImageResolution) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new ImageResolution((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RESOLUTION, e);
- }
- }
- return null;
+ return (ImageResolution) getObject(ImageResolution.class, KEY_RESOLUTION);
}
public void setImageResolution( ImageResolution resolution ) {
- if (resolution != null) {
- store.put(KEY_RESOLUTION, resolution );
- }
- else {
- store.remove(KEY_RESOLUTION);
- }
+ setValue(KEY_RESOLUTION, resolution);
}
@SuppressWarnings("unchecked")
public TouchEventCapabilities getTouchEventAvailable() {
- Object obj = store.get(KEY_TOUCH_EVENT_AVAILABLE);
- if (obj instanceof TouchEventCapabilities) {
- return (TouchEventCapabilities) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new TouchEventCapabilities((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TOUCH_EVENT_AVAILABLE, e);
- }
- }
- return null;
+ return (TouchEventCapabilities) getObject(TouchEventCapabilities.class, KEY_TOUCH_EVENT_AVAILABLE);
}
public void setTouchEventAvailable( TouchEventCapabilities touchEventAvailable ) {
- if (touchEventAvailable != null) {
- store.put(KEY_TOUCH_EVENT_AVAILABLE, touchEventAvailable );
- }
- else {
- store.remove(KEY_TOUCH_EVENT_AVAILABLE);
- }
+ setValue(KEY_TOUCH_EVENT_AVAILABLE, touchEventAvailable);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java
index 2fae92ec5..971b68712 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ScrollableMessage.java
@@ -1,12 +1,13 @@
package com.smartdevicelink.proxy.rpc;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+import com.smartdevicelink.proxy.rpc.enums.Language;
+
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.RPCRequest;
-
/**
* Creates a full screen overlay containing a large block of formatted text that
* can be scrolled with up to 8 SoftButtons defined
@@ -101,11 +102,7 @@ public class ScrollableMessage extends RPCRequest {
* <b>Notes: </b>Maxlength=500
*/
public void setScrollableMessageBody(String scrollableMessageBody) {
- if (scrollableMessageBody != null) {
- parameters.put(KEY_SCROLLABLE_MESSAGE_BODY, scrollableMessageBody);
- } else {
- parameters.remove(KEY_SCROLLABLE_MESSAGE_BODY);
- }
+ setParameters(KEY_SCROLLABLE_MESSAGE_BODY, scrollableMessageBody);
}
/**
@@ -114,7 +111,7 @@ public class ScrollableMessage extends RPCRequest {
* @return String -a String value
*/
public String getScrollableMessageBody() {
- return (String) parameters.get(KEY_SCROLLABLE_MESSAGE_BODY);
+ return getString(KEY_SCROLLABLE_MESSAGE_BODY);
}
/**
@@ -127,11 +124,7 @@ public class ScrollableMessage extends RPCRequest {
* <b>Notes</b>:Minval=0; Maxval=65535;Default=30000
*/
public void setTimeout(Integer timeout) {
- if (timeout != null) {
- parameters.put(KEY_TIMEOUT, timeout);
- } else {
- parameters.remove(KEY_TIMEOUT);
- }
+ setParameters(KEY_TIMEOUT, timeout);
}
/**
@@ -140,7 +133,7 @@ public class ScrollableMessage extends RPCRequest {
* @return Integer -an Integer value representing an App defined timeout
*/
public Integer getTimeout() {
- return (Integer) parameters.get(KEY_TIMEOUT);
+ return getInteger(KEY_TIMEOUT);
}
/**
@@ -154,11 +147,7 @@ public class ScrollableMessage extends RPCRequest {
* <b>Notes: </b>Minsize=0, Maxsize=8
*/
public void setSoftButtons(List<SoftButton> softButtons) {
- if (softButtons != null) {
- parameters.put(KEY_SOFT_BUTTONS, softButtons);
- } else {
- parameters.remove(KEY_SOFT_BUTTONS);
- }
+ setParameters(KEY_SOFT_BUTTONS, softButtons);
}
/**
@@ -167,21 +156,6 @@ public class ScrollableMessage extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<SoftButton> getSoftButtons() {
- if (parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTONS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof SoftButton) {
- return (List<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;
- }
- }
- }
- return null;
+ return (List<SoftButton>) getObject(SoftButton.class, KEY_SOFT_BUTTONS);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java
index cb5df057d..2221972c1 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SdlMsgVersion.java
@@ -1,9 +1,9 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+
/**
* Specifies the version number of the SDL V4 interface. This is used by both the application and SDL to declare what interface version each is using.
* <p><b> Parameter List</b></p>
@@ -42,6 +42,7 @@ import com.smartdevicelink.proxy.RPCStruct;
public class SdlMsgVersion extends RPCStruct {
public static final String KEY_MAJOR_VERSION = "majorVersion";
public static final String KEY_MINOR_VERSION = "minorVersion";
+ public static final String KEY_PATCH_VERSION = "patchVersion";
/**
* Constructs a newly allocated SdlMsgVersion object
@@ -63,7 +64,7 @@ public class SdlMsgVersion extends RPCStruct {
* @return the major version
*/
public Integer getMajorVersion() {
- return (Integer) store.get( KEY_MAJOR_VERSION );
+ return getInteger( KEY_MAJOR_VERSION );
}
/**
* Set major version
@@ -74,11 +75,7 @@ public class SdlMsgVersion extends RPCStruct {
* @param majorVersion minvalue="1" and maxvalue="10"
*/
public void setMajorVersion( Integer majorVersion ) {
- if (majorVersion != null) {
- store.put(KEY_MAJOR_VERSION, majorVersion );
- } else {
- store.remove(KEY_MAJOR_VERSION);
- }
+ setValue(KEY_MAJOR_VERSION, majorVersion);
}
/**
* Get minor version
@@ -89,7 +86,7 @@ public class SdlMsgVersion extends RPCStruct {
* @return the minor version
*/
public Integer getMinorVersion() {
- return (Integer) store.get( KEY_MINOR_VERSION );
+ return getInteger( KEY_MINOR_VERSION );
}
/**
* Set minor version
@@ -100,10 +97,30 @@ public class SdlMsgVersion extends RPCStruct {
* @param minorVersion min: 0; max: 1000
*/
public void setMinorVersion( Integer minorVersion ) {
- if (minorVersion != null) {
- store.put(KEY_MINOR_VERSION, minorVersion );
- } else {
- store.remove(KEY_MINOR_VERSION);
- }
+ setValue(KEY_MINOR_VERSION, minorVersion);
+ }
+
+ /**
+ * Get patch version
+ * <ul>
+ * <li>minvalue="0"</li>
+ * <li>maxvalue="1000"</li>
+ * </ul>
+ * @return the patch version
+ */
+ public Integer getPatchVersion() {
+ return getInteger( KEY_PATCH_VERSION );
+ }
+ /**
+ * Set patch version
+ * <ul>
+ * <li>minvalue="0"</li>
+ * <li>maxvalue="1000"</li>
+ * </ul>
+ * @param patchVersion min: 0; max: 1000
+ */
+ public void setPatchVersion( Integer patchVersion ) {
+ setValue(KEY_PATCH_VERSION, patchVersion);
}
+
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java
new file mode 100644
index 000000000..a93fd2b98
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticData.java
@@ -0,0 +1,86 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+
+import java.util.Hashtable;
+import java.util.List;
+
+/*
+ * Copyright (c) 2017 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Request to describe UI elements boundaries to a connected modules.
+ * @since SmartDeviceLink 4.5.0
+ */
+public class SendHapticData extends RPCRequest {
+
+ public static final String KEY_HAPTIC_RECT_DATA = "hapticRectData";
+
+ /**
+ * Constructs a new SendHapticData object
+ */
+ public SendHapticData(){
+ super(FunctionID.SEND_HAPTIC_DATA.toString());
+ }
+
+ /**
+ * <p>
+ * Send the spatial data gathered from SDLCarWindow or VirtualDisplayEncoder to the HMI.
+ * This data will be utilized by the HMI to determine how and when haptic events should occur
+ * </p>
+ *
+ * @param hash The Hashtable to use
+ */
+ public SendHapticData(Hashtable<String, Object> hash){
+ super(hash);
+ }
+
+ /**
+ * Array of spatial data structures that represent the locations of all user controls present on the app's layout.
+ * This data should be updated if/when the application presents a new screen.
+ * When a request is sent, if successful, it will replace all spatial data previously sent through RPC.
+ * If an empty array is sent, the existing spatial data will be cleared
+ */
+ public void setHapticRectData(List<HapticRect> hapticRectData) {
+ setParameters(KEY_HAPTIC_RECT_DATA, hapticRectData);
+ }
+
+ @SuppressWarnings("unchecked")
+ /**
+ * @return array of spatial data structures that represent the locations of all user controls present on the app's layout.
+ */
+ public List<HapticRect> getHapticRectData() {
+ return (List<HapticRect>) getObject(HapticRect.class, KEY_HAPTIC_RECT_DATA);
+ }
+
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticDataResponse.java
new file mode 100644
index 000000000..e7c0c7d30
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendHapticDataResponse.java
@@ -0,0 +1,54 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCResponse;
+
+import java.util.Hashtable;
+
+/*
+ * Copyright (c) 2017 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Response to request that described UI elements boundaries to a connected modules.
+ * @since SmartDeviceLink 4.5.0
+ */
+
+public class SendHapticDataResponse extends RPCResponse {
+
+ public SendHapticDataResponse(){
+ super(FunctionID.SEND_HAPTIC_DATA.toString());
+ }
+
+ public SendHapticDataResponse(Hashtable<String, Object> hash){
+ super(hash);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java
index 2a9108e47..c25f57648 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SendLocation.java
@@ -1,14 +1,13 @@
package com.smartdevicelink.proxy.rpc;
-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.DeliveryMode;
-import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.SdlDataTypeConverter;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* Sends a location to the head-unit to display on a map or list.
@@ -59,7 +58,7 @@ public class SendLocation extends RPCRequest{
* @return The longitude of the location
*/
public Double getLongitudeDegrees(){
- Object value = parameters.get(KEY_LON_DEGREES);
+ Object value = getParameters(KEY_LON_DEGREES);
return SdlDataTypeConverter.objectToDouble(value);
}
@@ -68,12 +67,7 @@ public class SendLocation extends RPCRequest{
* @param longitudeDegrees
*/
public void setLongitudeDegrees(Double longitudeDegrees){
- if(longitudeDegrees != null){
- parameters.put(KEY_LON_DEGREES, longitudeDegrees);
- }
- else{
- parameters.remove(KEY_LON_DEGREES);
- }
+ setParameters(KEY_LON_DEGREES, longitudeDegrees);
}
/**
@@ -87,7 +81,7 @@ public class SendLocation extends RPCRequest{
* @return The latitude of the location
*/
public Double getLatitudeDegrees(){
- Object value = parameters.get(KEY_LAT_DEGREES);
+ Object value = getParameters(KEY_LAT_DEGREES);
return SdlDataTypeConverter.objectToDouble(value);
}
@@ -96,12 +90,7 @@ public class SendLocation extends RPCRequest{
* @param latitudeDegrees
*/
public void setLatitudeDegrees(Double latitudeDegrees){
- if(latitudeDegrees != null){
- parameters.put(KEY_LAT_DEGREES, latitudeDegrees);
- }
- else{
- parameters.remove(KEY_LAT_DEGREES);
- }
+ setParameters(KEY_LAT_DEGREES, latitudeDegrees);
}
/**
@@ -109,7 +98,7 @@ public class SendLocation extends RPCRequest{
* @return The name of the location
*/
public String getLocationName(){
- return (String) parameters.get(KEY_LOCATION_NAME);
+ return getString(KEY_LOCATION_NAME);
}
/**
@@ -117,12 +106,7 @@ public class SendLocation extends RPCRequest{
* @param locationName The name of the location
*/
public void setLocationName(String locationName){
- if(locationName != null){
- parameters.put(KEY_LOCATION_NAME, locationName);
- }
- else{
- parameters.remove(KEY_LOCATION_NAME);
- }
+ setParameters(KEY_LOCATION_NAME, locationName);
}
/**
@@ -130,7 +114,7 @@ public class SendLocation extends RPCRequest{
* @return The description of the location to send
*/
public String getLocationDescription(){
- return (String) parameters.get(KEY_LOCATION_DESCRIPTION);
+ return getString(KEY_LOCATION_DESCRIPTION);
}
/**
@@ -138,12 +122,7 @@ public class SendLocation extends RPCRequest{
* @param locationDescription The description of the location
*/
public void setLocationDescription(String locationDescription){
- if(locationDescription != null){
- parameters.put(KEY_LOCATION_DESCRIPTION, locationDescription);
- }
- else{
- parameters.remove(KEY_LOCATION_DESCRIPTION);
- }
+ setParameters(KEY_LOCATION_DESCRIPTION, locationDescription);
}
/**
@@ -151,7 +130,7 @@ public class SendLocation extends RPCRequest{
* @return
*/
public String getPhoneNumber(){
- return (String) parameters.get(KEY_PHONE_NUMBER);
+ return getString(KEY_PHONE_NUMBER);
}
/**
@@ -159,12 +138,7 @@ public class SendLocation extends RPCRequest{
* @param phoneNumber The phone number of the location
*/
public void setPhoneNumber(String phoneNumber){
- if(phoneNumber != null){
- parameters.put(KEY_PHONE_NUMBER, phoneNumber);
- }
- else{
- parameters.remove(KEY_PHONE_NUMBER);
- }
+ setParameters(KEY_PHONE_NUMBER, phoneNumber);
}
/**
@@ -173,16 +147,7 @@ public class SendLocation extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public List<String> getAddressLines(){
- if(parameters.get(KEY_ADDRESS_LINES) instanceof List<?>){
- List<?> list = (List<?>) parameters.get(KEY_ADDRESS_LINES);
- if(list != null && list.size() > 0){
- Object obj = list.get(0);
- if(obj instanceof String){
- return (List<String>) list;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_ADDRESS_LINES);
}
/**
@@ -190,12 +155,7 @@ public class SendLocation extends RPCRequest{
* @param addressLines The address lines of the location
*/
public void setAddressLines(List<String> addressLines){
- if(addressLines != null){
- parameters.put(KEY_ADDRESS_LINES, addressLines);
- }
- else{
- parameters.remove(KEY_ADDRESS_LINES);
- }
+ setParameters(KEY_ADDRESS_LINES, addressLines);
}
/**
@@ -204,13 +164,7 @@ public class SendLocation extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public Image getLocationImage(){
- Object obj = parameters.get(KEY_LOCATION_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- return new Image((Hashtable<String, Object>) obj);
- }
- return null;
+ return (Image) getObject(Image.class, KEY_LOCATION_IMAGE);
}
/**
@@ -218,75 +172,32 @@ public class SendLocation extends RPCRequest{
* @param locationImage The image of the location to send
*/
public void setLocationImage(Image locationImage){
- if(locationImage != null){
- parameters.put(KEY_LOCATION_IMAGE, locationImage);
- }
- else{
- parameters.remove(KEY_LOCATION_IMAGE);
- }
+ setParameters(KEY_LOCATION_IMAGE, locationImage);
}
public DeliveryMode getDeliveryMode() {
- Object obj = parameters.get(KEY_DELIVERY_MODE);
- if (obj instanceof DeliveryMode) {
- return (DeliveryMode) obj;
- } else if (obj instanceof String) {
- return DeliveryMode.valueForString((String) obj);
- }
- return null;
+ return (DeliveryMode) getObject(DeliveryMode.class, KEY_DELIVERY_MODE);
}
public void setDeliveryMode(DeliveryMode deliveryMode) {
- if (deliveryMode != null) {
- parameters.put(KEY_DELIVERY_MODE, deliveryMode);
- } else {
- parameters.remove(KEY_DELIVERY_MODE);
- }
+ setParameters(KEY_DELIVERY_MODE, deliveryMode);
}
@SuppressWarnings("unchecked")
public DateTime getTimeStamp() {
- Object obj = parameters.get(KEY_TIME_STAMP);
- if (obj instanceof DateTime) {
- return (DateTime) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new DateTime((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIME_STAMP, e);
- }
- }
- return null;
+ return (DateTime) getObject(DateTime.class, KEY_TIME_STAMP);
}
public void setTimeStamp(DateTime timeStamp) {
- if (timeStamp != null) {
- parameters.put(KEY_TIME_STAMP, timeStamp);
- } else {
- parameters.remove(KEY_TIME_STAMP);
- }
+ setParameters(KEY_TIME_STAMP, timeStamp);
}
@SuppressWarnings("unchecked")
public OasisAddress getAddress() {
- Object obj = parameters.get(KEY_ADDRESS);
- if (obj instanceof OasisAddress) {
- return (OasisAddress) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new OasisAddress((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ADDRESS, e);
- }
- }
- return null;
+ return (OasisAddress) getObject(OasisAddress.class, KEY_ADDRESS);
}
public void setAddress(OasisAddress address) {
- if (address != null) {
- parameters.put(KEY_ADDRESS, address);
- } else {
- parameters.remove(KEY_ADDRESS);
- }
+ setParameters(KEY_ADDRESS, address);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java
index 2cb5aef31..2063303d9 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetAppIcon.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* Used to set existing local file on SDL as the app's icon. Not supported on
* first generation SDL vehicles
@@ -71,14 +71,10 @@ public class SetAppIcon extends RPCRequest {
* @param sdlFileName
* a String value representing a file reference name
* <p></p>
- * <b>Notes: </b>Maxlength=500
+ * <b>Notes: </b>Maxlength=500, however the max file name length may vary based on remote filesystem limitations
*/
public void setSdlFileName(String sdlFileName) {
- if (sdlFileName != null) {
- parameters.put(KEY_SDL_FILE_NAME, sdlFileName);
- } else {
- parameters.remove(KEY_SDL_FILE_NAME);
- }
+ setParameters(KEY_SDL_FILE_NAME, sdlFileName);
}
/**
@@ -86,6 +82,6 @@ public class SetAppIcon extends RPCRequest {
* @return String -a String value
*/
public String getSdlFileName() {
- return (String) parameters.get(KEY_SDL_FILE_NAME);
+ return getString(KEY_SDL_FILE_NAME);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java
index 2a3fd9d4b..e137e7f5b 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayout.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* Used to set an alternate display layout. If not sent, default screen for
* given platform will be shown
@@ -73,17 +73,13 @@ public class SetDisplayLayout extends RPCRequest {
* a String value representing a diaply layout
*/
public void setDisplayLayout(String displayLayout) {
- if (displayLayout != null) {
- parameters.put(KEY_DISPLAY_LAYOUT, displayLayout);
- } else {
- parameters.remove(KEY_DISPLAY_LAYOUT);
- }
+ setParameters(KEY_DISPLAY_LAYOUT, displayLayout);
}
/**
* Gets a display layout.
*/
public String getDisplayLayout() {
- return (String) parameters.get(KEY_DISPLAY_LAYOUT);
+ return getString(KEY_DISPLAY_LAYOUT);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java
index b9947a4ac..36e9fb7db 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetDisplayLayoutResponse.java
@@ -1,12 +1,11 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* Set Display Layout Response is sent, when SetDisplayLayout has been called
*
@@ -39,96 +38,38 @@ public class SetDisplayLayoutResponse extends RPCResponse {
@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;
+ return (DisplayCapabilities) getObject(DisplayCapabilities.class, KEY_DISPLAY_CAPABILITIES);
}
public void setDisplayCapabilities(DisplayCapabilities displayCapabilities) {
- if (displayCapabilities != null) {
- parameters.put(KEY_DISPLAY_CAPABILITIES, displayCapabilities);
- } else {
- parameters.remove(KEY_DISPLAY_CAPABILITIES);
- }
+ setParameters(KEY_DISPLAY_CAPABILITIES, displayCapabilities);
}
@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;
+ return (List<ButtonCapabilities>) getObject(ButtonCapabilities.class, KEY_BUTTON_CAPABILITIES);
}
public void setButtonCapabilities(List<ButtonCapabilities> buttonCapabilities) {
- if (buttonCapabilities != null) {
- parameters.put(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
- } else {
- parameters.remove(KEY_BUTTON_CAPABILITIES);
- }
+ setParameters(KEY_BUTTON_CAPABILITIES, buttonCapabilities);
}
@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;
+ return (List<SoftButtonCapabilities>) getObject(SoftButtonCapabilities.class, KEY_SOFT_BUTTON_CAPABILITIES);
}
public void setSoftButtonCapabilities(List<SoftButtonCapabilities> softButtonCapabilities) {
- if (softButtonCapabilities != null) {
- parameters.put(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities);
- } else {
- parameters.remove(KEY_SOFT_BUTTON_CAPABILITIES);
- }
+ setParameters(KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilities);
}
@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;
+ return (PresetBankCapabilities) getObject(PresetBankCapabilities.class, KEY_PRESET_BANK_CAPABILITIES);
}
public void setPresetBankCapabilities(PresetBankCapabilities presetBankCapabilities) {
- if (presetBankCapabilities != null) {
- parameters.put(KEY_PRESET_BANK_CAPABILITIES, presetBankCapabilities);
- } else {
- parameters.remove(KEY_PRESET_BANK_CAPABILITIES);
- }
+ setParameters(KEY_PRESET_BANK_CAPABILITIES, presetBankCapabilities);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java
index 7f597cafe..edd943494 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetGlobalProperties.java
@@ -1,12 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.ArrayList;
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+
import java.util.Hashtable;
import java.util.List;
-import com.smartdevicelink.protocol.enums.FunctionID;
-import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.util.DebugTool;
/**
* Sets value(s) for the specified global property(ies)
*
@@ -141,22 +140,7 @@ public class SetGlobalProperties extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getHelpPrompt() {
- 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;
- }
- }
- }
- return null;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_HELP_PROMPT);
}
/**
* Sets a List<TTSChunk> for Help Prompt that Array of one or more
@@ -173,11 +157,7 @@ public class SetGlobalProperties extends RPCRequest {
* </ul>
*/
public void setHelpPrompt(List<TTSChunk> helpPrompt) {
- if (helpPrompt != null) {
- parameters.put(KEY_HELP_PROMPT, helpPrompt);
- } else {
- parameters.remove(KEY_HELP_PROMPT);
- }
+ setParameters(KEY_HELP_PROMPT, helpPrompt);
}
/**
* Gets a List<TTSChunk> for Timeout Prompt representing Array of one or
@@ -189,22 +169,7 @@ public class SetGlobalProperties extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getTimeoutPrompt() {
- 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;
- }
- }
- }
- return null;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_TIMEOUT_PROMPT);
}
/**
* Sets a List<TTSChunk> for Timeout Prompt representing Array of one or
@@ -213,11 +178,7 @@ public class SetGlobalProperties extends RPCRequest {
*
*/
public void setTimeoutPrompt(List<TTSChunk> timeoutPrompt) {
- if (timeoutPrompt != null) {
- parameters.put(KEY_TIMEOUT_PROMPT, timeoutPrompt);
- } else {
- parameters.remove(KEY_TIMEOUT_PROMPT);
- }
+ setParameters(KEY_TIMEOUT_PROMPT, timeoutPrompt);
}
/**
@@ -228,7 +189,7 @@ public class SetGlobalProperties extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public String getVrHelpTitle() {
- return (String) parameters.get(KEY_VR_HELP_TITLE);
+ return getString(KEY_VR_HELP_TITLE);
}
/**
@@ -248,11 +209,7 @@ public class SetGlobalProperties extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setVrHelpTitle(String vrHelpTitle) {
- if (vrHelpTitle != null) {
- parameters.put(KEY_VR_HELP_TITLE, vrHelpTitle);
- } else {
- parameters.remove(KEY_VR_HELP_TITLE);
- }
+ setParameters(KEY_VR_HELP_TITLE, vrHelpTitle);
}
/**
@@ -265,22 +222,7 @@ public class SetGlobalProperties extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<VrHelpItem> getVrHelp() {
- 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;
- }
- }
- }
- return null;
+ return (List<VrHelpItem>) getObject(VrHelpItem.class, KEY_VR_HELP);
}
/**
@@ -305,69 +247,33 @@ public class SetGlobalProperties extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setVrHelp(List<VrHelpItem> vrHelp) {
- if (vrHelp != null) {
- parameters.put(KEY_VR_HELP, vrHelp);
- } else {
- parameters.remove(KEY_VR_HELP);
- }
+ setParameters(KEY_VR_HELP, vrHelp);
}
public String getMenuTitle() {
- return (String) parameters.get(KEY_MENU_TITLE);
+ return getString(KEY_MENU_TITLE);
}
public void setMenuTitle(String menuTitle) {
- if (menuTitle != null) {
- parameters.put(KEY_MENU_TITLE, menuTitle);
- } else {
- parameters.remove(KEY_MENU_TITLE);
- }
+ setParameters(KEY_MENU_TITLE, menuTitle);
}
public void setMenuIcon(Image menuIcon) {
- if (menuIcon != null) {
- parameters.put(KEY_MENU_ICON, menuIcon);
- } else {
- parameters.remove(KEY_MENU_ICON);
- }
+ setParameters(KEY_MENU_ICON, menuIcon);
}
@SuppressWarnings("unchecked")
public Image getMenuIcon() {
- Object obj = parameters.get(KEY_MENU_ICON);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MENU_ICON, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_MENU_ICON);
}
public void setKeyboardProperties(KeyboardProperties keyboardProperties) {
- if (keyboardProperties != null) {
- parameters.put(KEY_KEYBOARD_PROPERTIES, keyboardProperties);
- } else {
- parameters.remove(KEY_KEYBOARD_PROPERTIES);
- }
+ setParameters(KEY_KEYBOARD_PROPERTIES, keyboardProperties);
}
@SuppressWarnings("unchecked")
public KeyboardProperties getKeyboardProperties() {
- Object obj = parameters.get(KEY_KEYBOARD_PROPERTIES);
- if (obj instanceof KeyboardProperties) {
- return (KeyboardProperties) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new KeyboardProperties((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_KEYBOARD_PROPERTIES, e);
- }
- }
- return null;
+ return (KeyboardProperties) getObject(KeyboardProperties.class, KEY_KEYBOARD_PROPERTIES);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleData.java
new file mode 100644
index 000000000..75077e3cb
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleData.java
@@ -0,0 +1,51 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCRequest;
+
+import java.util.Hashtable;
+
+/**
+ * This function allows a remote control type mobile application change the settings
+ * of a specific remote control module.
+ */
+public class SetInteriorVehicleData extends RPCRequest {
+ public static final String KEY_MODULE_DATA = "moduleData";
+
+ /**
+ * Constructs a new SetInteriorVehicleData object
+ */
+ public SetInteriorVehicleData() {
+ super(FunctionID.SET_INTERIOR_VEHICLE_DATA.toString());
+ }
+
+ /**
+ * <p>Constructs a new SetInteriorVehicleData object indicated by the
+ * Hashtable parameter</p>
+ *
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public SetInteriorVehicleData(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the moduleData
+ *
+ * @param moduleData
+ */
+ public void setModuleData(ModuleData moduleData) {
+ setParameters(KEY_MODULE_DATA, moduleData);
+ }
+
+ /**
+ * Gets the moduleData
+ *
+ * @return ModuleData
+ */
+ public ModuleData getModuleData() {
+ return (ModuleData) getObject(ModuleData.class, KEY_MODULE_DATA);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java
new file mode 100644
index 000000000..6a7079735
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetInteriorVehicleDataResponse.java
@@ -0,0 +1,47 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.protocol.enums.FunctionID;
+import com.smartdevicelink.proxy.RPCResponse;
+
+import java.util.Hashtable;
+
+public class SetInteriorVehicleDataResponse extends RPCResponse {
+ public static final String KEY_MODULE_DATA = "moduleData";
+
+ /**
+ * Constructs a new SetInteriorVehicleDataResponse object
+ */
+ public SetInteriorVehicleDataResponse() {
+ super(FunctionID.SET_INTERIOR_VEHICLE_DATA.toString());
+ }
+
+ /**
+ * <p>Constructs a new SetInteriorVehicleDataResponse object indicated by the
+ * Hashtable parameter</p>
+ *
+ *
+ * @param hash
+ * The Hashtable to use
+ */
+ public SetInteriorVehicleDataResponse(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Gets the moduleData
+ *
+ * @return ModuleData
+ */
+ public ModuleData getModuleData() {
+ return (ModuleData) getObject(ModuleData.class, KEY_MODULE_DATA);
+ }
+
+ /**
+ * Sets the moduleData
+ *
+ * @param moduleData
+ */
+ public void setModuleData(ModuleData moduleData) {
+ setParameters(KEY_MODULE_DATA, moduleData);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java
index bd6bac324..bcef52745 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SetMediaClockTimer.java
@@ -1,10 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
+
+import java.util.Hashtable;
+
/**
* Sets the media clock/timer value and the update method (e.g.count-up,
* count-down, etc.)
@@ -98,13 +99,7 @@ public class SetMediaClockTimer extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public StartTime getStartTime() {
- Object obj = parameters.get(KEY_START_TIME);
- if (obj instanceof StartTime) {
- return (StartTime)obj;
- } else if (obj instanceof Hashtable) {
- return new StartTime((Hashtable<String, Object>)obj);
- }
- return null;
+ return (StartTime) getObject(StartTime.class, KEY_START_TIME);
}
/**
* Sets a Start Time with specifying hour, minute, second values
@@ -120,30 +115,16 @@ public class SetMediaClockTimer extends RPCRequest {
* </ul>
*/
public void setStartTime( StartTime startTime ) {
- if (startTime != null) {
- parameters.put(KEY_START_TIME, startTime );
- } else {
- parameters.remove(KEY_START_TIME);
- }
+ setParameters(KEY_START_TIME, startTime);
}
@SuppressWarnings("unchecked")
public StartTime getEndTime() {
- Object obj = parameters.get(KEY_END_TIME);
- if (obj instanceof StartTime) {
- return (StartTime)obj;
- } else if (obj instanceof Hashtable) {
- return new StartTime((Hashtable<String, Object>)obj);
- }
- return null;
+ return (StartTime) getObject(StartTime.class, KEY_END_TIME);
}
public void setEndTime( StartTime endTime ) {
- if (endTime != null) {
- parameters.put(KEY_END_TIME, endTime );
- } else {
- parameters.remove(KEY_END_TIME);
- }
+ setParameters(KEY_END_TIME, endTime);
}
/**
@@ -152,13 +133,7 @@ public class SetMediaClockTimer extends RPCRequest {
* @return UpdateMode -a Enumeration value (COUNTUP/COUNTDOWN/PAUSE/RESUME)
*/
public UpdateMode getUpdateMode() {
- Object obj = parameters.get(KEY_UPDATE_MODE);
- if (obj instanceof UpdateMode) {
- return (UpdateMode) obj;
- } else if (obj instanceof String) {
- return UpdateMode.valueForString((String) obj);
- }
- return null;
+ return (UpdateMode) getObject(UpdateMode.class, KEY_UPDATE_MODE);
}
/**
* Sets the media clock/timer update mode (COUNTUP/COUNTDOWN/PAUSE/RESUME)
@@ -175,10 +150,6 @@ public class SetMediaClockTimer extends RPCRequest {
* </ul>
*/
public void setUpdateMode( UpdateMode updateMode ) {
- if (updateMode != null) {
- parameters.put(KEY_UPDATE_MODE, updateMode );
- } else {
- parameters.remove(KEY_UPDATE_MODE);
- }
+ setParameters(KEY_UPDATE_MODE, updateMode);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Show.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Show.java
index 24307c9de..6a42fe1a8 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Show.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Show.java
@@ -1,13 +1,11 @@
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.TextAlignment;
-import com.smartdevicelink.util.DebugTool;
+
+import java.util.Hashtable;
+import java.util.List;
/**
* Updates the application's display text area, regardless of whether or not
@@ -166,6 +164,7 @@ public class Show extends RPCRequest {
public static final String KEY_MEDIA_TRACK = "mediaTrack";
public static final String KEY_SECONDARY_GRAPHIC = "secondaryGraphic";
public static final String KEY_SOFT_BUTTONS = "softButtons";
+ public static final String KEY_METADATA_TAGS = "metadataTags";
/**
* Constructs a new Show object
*/
@@ -191,7 +190,7 @@ public class Show extends RPCRequest {
* display
*/
public String getMainField1() {
- return (String) parameters.get(KEY_MAIN_FIELD_1);
+ return getString(KEY_MAIN_FIELD_1);
}
/**
* Sets the text displayed in a single-line display, or in the upper display
@@ -211,11 +210,7 @@ public class Show extends RPCRequest {
* </ul>
*/
public void setMainField1(String mainField1) {
- if (mainField1 != null) {
- parameters.put(KEY_MAIN_FIELD_1, mainField1);
- } else {
- parameters.remove(KEY_MAIN_FIELD_1);
- }
+ setParameters(KEY_MAIN_FIELD_1, mainField1);
}
/**
* Gets the text displayed on the second display line of a two-line display
@@ -224,7 +219,7 @@ public class Show extends RPCRequest {
* second display line of a two-line display
*/
public String getMainField2() {
- return (String) parameters.get(KEY_MAIN_FIELD_2);
+ return getString(KEY_MAIN_FIELD_2);
}
/**
* Sets the text displayed on the second display line of a two-line display
@@ -245,11 +240,7 @@ public class Show extends RPCRequest {
* </ul>
*/
public void setMainField2(String mainField2) {
- if (mainField2 != null) {
- parameters.put(KEY_MAIN_FIELD_2, mainField2);
- } else {
- parameters.remove(KEY_MAIN_FIELD_2);
- }
+ setParameters(KEY_MAIN_FIELD_2, mainField2);
}
/**
@@ -260,7 +251,7 @@ public class Show extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public String getMainField3() {
- return (String) parameters.get(KEY_MAIN_FIELD_3);
+ return getString(KEY_MAIN_FIELD_3);
}
/**
@@ -283,11 +274,7 @@ public class Show extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setMainField3(String mainField3) {
- if (mainField3 != null) {
- parameters.put(KEY_MAIN_FIELD_3, mainField3);
- } else {
- parameters.remove(KEY_MAIN_FIELD_3);
- }
+ setParameters(KEY_MAIN_FIELD_3, mainField3);
}
/**
@@ -298,7 +285,7 @@ public class Show extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public String getMainField4() {
- return (String) parameters.get(KEY_MAIN_FIELD_4);
+ return getString(KEY_MAIN_FIELD_4);
}
/**
@@ -321,11 +308,7 @@ public class Show extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setMainField4(String mainField4) {
- if (mainField4 != null) {
- parameters.put(KEY_MAIN_FIELD_4, mainField4);
- } else {
- parameters.remove(KEY_MAIN_FIELD_4);
- }
+ setParameters(KEY_MAIN_FIELD_4, mainField4);
}
/**
* Gets the alignment that Specifies how mainField1 and mainField2 text
@@ -334,13 +317,7 @@ public class Show extends RPCRequest {
* @return TextAlignment -an Enumeration value
*/
public TextAlignment getAlignment() {
- Object obj = parameters.get(KEY_ALIGNMENT);
- if (obj instanceof TextAlignment) {
- return (TextAlignment) obj;
- } else if (obj instanceof String) {
- return TextAlignment.valueForString((String) obj);
- }
- return null;
+ return (TextAlignment) getObject(TextAlignment.class, KEY_ALIGNMENT);
}
/**
* Sets the alignment that Specifies how mainField1 and mainField2 text
@@ -359,11 +336,7 @@ public class Show extends RPCRequest {
* </ul>
*/
public void setAlignment(TextAlignment alignment) {
- if (alignment != null) {
- parameters.put(KEY_ALIGNMENT, alignment);
- } else {
- parameters.remove(KEY_ALIGNMENT);
- }
+ setParameters(KEY_ALIGNMENT, alignment);
}
/**
* Gets text in the Status Bar
@@ -371,7 +344,7 @@ public class Show extends RPCRequest {
* @return String -the value in the Status Bar
*/
public String getStatusBar() {
- return (String) parameters.get(KEY_STATUS_BAR);
+ return getString(KEY_STATUS_BAR);
}
/**
* Sets text in the Status Bar
@@ -392,11 +365,7 @@ public class Show extends RPCRequest {
* </ul>
*/
public void setStatusBar(String statusBar) {
- if (statusBar != null) {
- parameters.put(KEY_STATUS_BAR, statusBar);
- } else {
- parameters.remove(KEY_STATUS_BAR);
- }
+ setParameters(KEY_STATUS_BAR, statusBar);
}
/**
* Gets the String value of the MediaClock
@@ -405,7 +374,7 @@ public class Show extends RPCRequest {
*/
@Deprecated
public String getMediaClock() {
- return (String) parameters.get(KEY_MEDIA_CLOCK);
+ return getString(KEY_MEDIA_CLOCK);
}
/**
* Sets the value for the MediaClock field using a format described in the
@@ -425,11 +394,7 @@ public class Show extends RPCRequest {
*/
@Deprecated
public void setMediaClock(String mediaClock) {
- if (mediaClock != null) {
- parameters.put(KEY_MEDIA_CLOCK, mediaClock);
- } else {
- parameters.remove(KEY_MEDIA_CLOCK);
- }
+ setParameters(KEY_MEDIA_CLOCK, mediaClock);
}
/**
* Gets the text in the track field
@@ -437,7 +402,7 @@ public class Show extends RPCRequest {
* @return String -a String displayed in the track field
*/
public String getMediaTrack() {
- return (String) parameters.get(KEY_MEDIA_TRACK);
+ return getString(KEY_MEDIA_TRACK);
}
/**
* Sets the text in the track field
@@ -453,11 +418,7 @@ public class Show extends RPCRequest {
* </ul>
*/
public void setMediaTrack(String mediaTrack) {
- if (mediaTrack != null) {
- parameters.put(KEY_MEDIA_TRACK, mediaTrack);
- } else {
- parameters.remove(KEY_MEDIA_TRACK);
- }
+ setParameters(KEY_MEDIA_TRACK, mediaTrack);
}
/**
@@ -471,11 +432,7 @@ public class Show extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setGraphic(Image graphic) {
- if (graphic != null) {
- parameters.put(KEY_GRAPHIC, graphic);
- } else {
- parameters.remove(KEY_GRAPHIC);
- }
+ setParameters(KEY_GRAPHIC, graphic);
}
/**
@@ -487,42 +444,18 @@ public class Show extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public Image getGraphic() {
- Object obj = parameters.get(KEY_GRAPHIC);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GRAPHIC, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_GRAPHIC);
}
public void setSecondaryGraphic(Image secondaryGraphic) {
- if (secondaryGraphic != null) {
- parameters.put(KEY_SECONDARY_GRAPHIC, secondaryGraphic);
- } else {
- parameters.remove(KEY_SECONDARY_GRAPHIC);
- }
+ setParameters(KEY_SECONDARY_GRAPHIC, secondaryGraphic);
}
@SuppressWarnings("unchecked")
public Image getSecondaryGraphic() {
- Object obj = parameters.get(KEY_SECONDARY_GRAPHIC);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SECONDARY_GRAPHIC, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_SECONDARY_GRAPHIC);
}
@@ -535,22 +468,7 @@ public class Show extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<SoftButton> getSoftButtons() {
- if (parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTONS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof SoftButton) {
- return (List<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;
- }
- }
- }
- return null;
+ return (List<SoftButton>) getObject(SoftButton.class, KEY_SOFT_BUTTONS);
}
/**
@@ -571,11 +489,7 @@ 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);
- }
+ setParameters(KEY_SOFT_BUTTONS, softButtons);
}
/**
@@ -587,16 +501,7 @@ public class Show extends RPCRequest {
*/
@SuppressWarnings("unchecked")
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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_CUSTOM_PRESETS);
}
/**
@@ -614,10 +519,31 @@ public class Show extends RPCRequest {
* @since SmartDeviceLink 2.0
*/
public void setCustomPresets(List<String> customPresets) {
- if (customPresets != null) {
- parameters.put(KEY_CUSTOM_PRESETS, customPresets);
- } else {
- parameters.remove(KEY_CUSTOM_PRESETS);
- }
+ setParameters(KEY_CUSTOM_PRESETS, customPresets);
}
+
+ /**
+ * Sets text field metadata defined by the App
+ *
+ * @param metadataTags
+ * A Struct containing metadata pertaining to the main text fields
+ * <p></p>
+ * <ul>
+ * @since SmartDeviceLink 4.5.0
+ */
+ public void setMetadataTags(MetadataTags metadataTags){
+ setParameters(KEY_METADATA_TAGS, metadataTags);
+ }
+
+ /**
+ * Gets text field metadata defined by the App
+ *
+ * @return metadataTags - App defined metadata information. See MetadataTags. Uses mainField1, mainField2, mainField3, mainField4.
+ * If omitted on supported displays, the currently set metadata tags will not change.
+ * If any text field contains no tags or the none tag, the metadata tag for that textfield should be removed.
+ * @since SmartDeviceLink 4.5.0
+ */
+ public MetadataTags getMetadataTags() {
+ return (MetadataTags) getObject(MetadataTags.class, KEY_METADATA_TAGS);
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java
index f65e1a100..6a44b9068 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/ShowConstantTbt.java
@@ -1,12 +1,11 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* <p>This RPC is used to update the user with navigation information for the constantly shown screen (base screen), but
* also for the alert type screen</p>
@@ -61,12 +60,7 @@ public class ShowConstantTbt extends RPCRequest{
* <b>Notes: </b>Maxlength=500
*/
public void setNavigationText1(String navigationText1){
- if(navigationText1 != null){
- parameters.put(KEY_TEXT1, navigationText1);
- }
- else{
- parameters.remove(KEY_TEXT1);
- }
+ setParameters(KEY_TEXT1, navigationText1);
}
/**
@@ -75,7 +69,7 @@ public class ShowConstantTbt extends RPCRequest{
* @return String -a String value representing a text for navigation text field 1
*/
public String getNavigationText1(){
- return (String) parameters.get(KEY_TEXT1);
+ return getString(KEY_TEXT1);
}
/**
@@ -87,12 +81,7 @@ public class ShowConstantTbt extends RPCRequest{
* <b>Notes: </b>Maxlength=500
*/
public void setNavigationText2(String navigationText2){
- if(navigationText2 != null){
- parameters.put(KEY_TEXT2, navigationText2);
- }
- else{
- parameters.remove(KEY_TEXT2);
- }
+ setParameters(KEY_TEXT2, navigationText2);
}
/**
@@ -101,7 +90,7 @@ public class ShowConstantTbt extends RPCRequest{
* @return String -a String value representing a text for navigation text field 2
*/
public String getNavigationText2(){
- return (String) parameters.get(KEY_TEXT2);
+ return getString(KEY_TEXT2);
}
/**
@@ -113,12 +102,7 @@ public class ShowConstantTbt extends RPCRequest{
* <b>Notes: </b>Maxlength=500
*/
public void setEta(String eta){
- if(eta != null){
- parameters.put(KEY_ETA, eta);
- }
- else{
- parameters.remove(KEY_ETA);
- }
+ setParameters(KEY_ETA, eta);
}
/**
@@ -127,7 +111,7 @@ public class ShowConstantTbt extends RPCRequest{
* @return String -a String value representing a text field for estimated time of arrival
*/
public String getEta(){
- return (String) parameters.get(KEY_ETA);
+ return getString(KEY_ETA);
}
/**
@@ -139,12 +123,7 @@ public class ShowConstantTbt extends RPCRequest{
* <b>Notes: </b>Maxlength=500
*/
public void setTotalDistance(String totalDistance){
- if(totalDistance != null){
- parameters.put(KEY_TOTAL_DISTANCE, totalDistance);
- }
- else{
- parameters.remove(KEY_TOTAL_DISTANCE);
- }
+ setParameters(KEY_TOTAL_DISTANCE, totalDistance);
}
/**
@@ -153,7 +132,7 @@ public class ShowConstantTbt extends RPCRequest{
* @return String -a String value representing a text field for total distance
*/
public String getTotalDistance(){
- return (String) parameters.get(KEY_TOTAL_DISTANCE);
+ return getString(KEY_TOTAL_DISTANCE);
}
/**
@@ -163,12 +142,7 @@ public class ShowConstantTbt extends RPCRequest{
* an Image value
*/
public void setTurnIcon(Image turnIcon){
- if(turnIcon != null){
- parameters.put(KEY_MANEUVER_IMAGE, turnIcon);
- }
- else{
- parameters.remove(KEY_MANEUVER_IMAGE);
- }
+ setParameters(KEY_MANEUVER_IMAGE, turnIcon);
}
/**
@@ -178,13 +152,7 @@ public class ShowConstantTbt extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public Image getTurnIcon(){
- Object obj = parameters.get(KEY_MANEUVER_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- return new Image((Hashtable<String, Object>) obj);
- }
- return null;
+ return (Image) getObject(Image.class, KEY_MANEUVER_IMAGE);
}
/**
@@ -194,12 +162,7 @@ public class ShowConstantTbt extends RPCRequest{
* an Image value
*/
public void setNextTurnIcon(Image nextTurnIcon){
- if(nextTurnIcon != null){
- parameters.put(KEY_NEXT_MANEUVER_IMAGE, nextTurnIcon);
- }
- else{
- parameters.remove(KEY_NEXT_MANEUVER_IMAGE);
- }
+ setParameters(KEY_NEXT_MANEUVER_IMAGE, nextTurnIcon);
}
/**
@@ -209,13 +172,7 @@ public class ShowConstantTbt extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public Image getNextTurnIcon(){
- Object obj = parameters.get(KEY_NEXT_MANEUVER_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- return new Image((Hashtable<String, Object>) obj);
- }
- return null;
+ return (Image) getObject(Image.class, KEY_NEXT_MANEUVER_IMAGE);
}
/**
@@ -227,12 +184,7 @@ public class ShowConstantTbt extends RPCRequest{
* <b>Notes: </b>Minvalue=0; Maxvalue=1000000000
*/
public void setDistanceToManeuver(Double distanceToManeuver){
- if(distanceToManeuver != null){
- parameters.put(KEY_MANEUVER_DISTANCE, distanceToManeuver);
- }
- else{
- parameters.remove(KEY_MANEUVER_DISTANCE);
- }
+ setParameters(KEY_MANEUVER_DISTANCE, distanceToManeuver);
}
/**
@@ -241,7 +193,7 @@ public class ShowConstantTbt extends RPCRequest{
* @return Double -a Double value representing a Fraction of distance till next maneuver
*/
public Double getDistanceToManeuver(){
- return (Double) parameters.get(KEY_MANEUVER_DISTANCE);
+ return getDouble(KEY_MANEUVER_DISTANCE);
}
/**
@@ -253,12 +205,7 @@ public class ShowConstantTbt extends RPCRequest{
* <b>Notes: </b>Minvalue=0; Maxvalue=1000000000
*/
public void setDistanceToManeuverScale(Double distanceToManeuverScale){
- if(distanceToManeuverScale != null){
- parameters.put(KEY_MANEUVER_DISTANCE_SCALE, distanceToManeuverScale);
- }
- else{
- parameters.remove(KEY_MANEUVER_DISTANCE_SCALE);
- }
+ setParameters(KEY_MANEUVER_DISTANCE_SCALE, distanceToManeuverScale);
}
/**
@@ -267,7 +214,7 @@ public class ShowConstantTbt extends RPCRequest{
* @return Double -a Double value representing a Distance till next maneuver (starting from) from previous maneuver
*/
public Double getDistanceToManeuverScale(){
- return (Double) parameters.get(KEY_MANEUVER_DISTANCE_SCALE);
+ return getDouble(KEY_MANEUVER_DISTANCE_SCALE);
}
/**
@@ -280,12 +227,7 @@ public class ShowConstantTbt extends RPCRequest{
* a Boolean value
*/
public void setManeuverComplete(Boolean maneuverComplete){
- if(maneuverComplete != null){
- parameters.put(KEY_MANEUVER_COMPLETE, maneuverComplete);
- }
- else{
- parameters.remove(KEY_MANEUVER_COMPLETE);
- }
+ setParameters(KEY_MANEUVER_COMPLETE, maneuverComplete);
}
/**
@@ -294,7 +236,7 @@ public class ShowConstantTbt extends RPCRequest{
* @return Boolean -a Boolean value
*/
public Boolean getManeuverComplete(){
- return (Boolean) parameters.get(KEY_MANEUVER_COMPLETE);
+ return getBoolean(KEY_MANEUVER_COMPLETE);
}
/**
@@ -307,12 +249,7 @@ 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);
- }
+ setParameters(KEY_SOFT_BUTTONS, softButtons);
}
/**
@@ -323,34 +260,14 @@ public class ShowConstantTbt extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public List<SoftButton> getSoftButtons(){
- if (parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_SOFT_BUTTONS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof SoftButton) {
- return (List<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;
- }
- }
- }
- return null;
+ return (List<SoftButton>) getObject(SoftButton.class, KEY_SOFT_BUTTONS);
}
public void setTimeToDestination(String timeToDestination){
- if(timeToDestination != null){
- parameters.put(KEY_TIME_TO_DESTINATION, timeToDestination);
- }
- else{
- parameters.remove(KEY_TIME_TO_DESTINATION);
- }
+ setParameters(KEY_TIME_TO_DESTINATION, timeToDestination);
}
public String getTimeToDestination(){
- return (String) parameters.get(KEY_TIME_TO_DESTINATION);
+ return getString(KEY_TIME_TO_DESTINATION);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java
index ab30ff365..4b8722ea5 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SingleTireStatus.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus;
+import java.util.Hashtable;
+
/**
* Tire pressure status of a single tire.
* <p><b>Parameter List</b></p>
@@ -47,11 +47,7 @@ public class SingleTireStatus extends RPCStruct {
* @param status the volume status of a single tire
*/
public void setStatus(ComponentVolumeStatus status) {
- if (status != null) {
- store.put(KEY_STATUS, status);
- } else {
- store.remove(KEY_STATUS);
- }
+ setValue(KEY_STATUS, status);
}
/**
@@ -59,12 +55,6 @@ public class SingleTireStatus extends RPCStruct {
* @return the volume status of a single tire
*/
public ComponentVolumeStatus getStatus() {
- Object obj = store.get(KEY_STATUS);
- if (obj instanceof ComponentVolumeStatus) {
- return (ComponentVolumeStatus) obj;
- } else if (obj instanceof String) {
- return ComponentVolumeStatus.valueForString((String) obj);
- }
- return null;
+ return (ComponentVolumeStatus) getObject(ComponentVolumeStatus.class, KEY_STATUS);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java
index 16da80dcb..31fb55b1e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Slider.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-import java.util.List;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* <p>Creates a full screen or pop-up overlay (depending on platform) with a single
* user controlled slider.</p>
@@ -119,11 +119,7 @@ public class Slider extends RPCRequest {
* <b>Notes: </b>Minvalue=2; Maxvalue=26
*/
public void setNumTicks(Integer numTicks) {
- if (numTicks != null) {
- parameters.put(KEY_NUM_TICKS, numTicks);
- } else {
- parameters.remove(KEY_NUM_TICKS);
- }
+ setParameters(KEY_NUM_TICKS, numTicks);
}
/**
@@ -133,7 +129,7 @@ public class Slider extends RPCRequest {
* items on a horizontal axis
*/
public Integer getNumTicks() {
- return (Integer) parameters.get(KEY_NUM_TICKS);
+ return getInteger(KEY_NUM_TICKS);
}
/**
@@ -146,11 +142,7 @@ public class Slider extends RPCRequest {
* <b>Notes: </b>Minvalue=1; Maxvalue=26
*/
public void setPosition(Integer position) {
- if (position != null) {
- parameters.put(KEY_POSITION, position);
- } else {
- parameters.remove(KEY_POSITION);
- }
+ setParameters(KEY_POSITION, position);
}
/**
@@ -160,7 +152,7 @@ public class Slider extends RPCRequest {
* slider control
*/
public Integer getPosition() {
- return (Integer) parameters.get(KEY_POSITION);
+ return getInteger(KEY_POSITION);
}
/**
@@ -172,11 +164,7 @@ public class Slider extends RPCRequest {
* <b>Notes: </b>Maxlength=500
*/
public void setSliderHeader(String sliderHeader) {
- if (sliderHeader != null) {
- parameters.put(KEY_SLIDER_HEADER, sliderHeader);
- } else {
- parameters.remove(KEY_SLIDER_HEADER);
- }
+ setParameters(KEY_SLIDER_HEADER, sliderHeader);
}
/**
@@ -185,7 +173,7 @@ public class Slider extends RPCRequest {
* @return String -a String value representing a text header to display
*/
public String getSliderHeader() {
- return (String) parameters.get(KEY_SLIDER_HEADER);
+ return getString(KEY_SLIDER_HEADER);
}
/**
@@ -197,11 +185,7 @@ public class Slider extends RPCRequest {
* <b>Notes: </b>Maxlength=500; Minvalue=1; Maxvalue=26
*/
public void setSliderFooter(List<String> sliderFooter) {
- if (sliderFooter != null) {
- parameters.put(KEY_SLIDER_FOOTER, sliderFooter);
- } else {
- parameters.remove(KEY_SLIDER_FOOTER);
- }
+ setParameters(KEY_SLIDER_FOOTER, sliderFooter);
}
/**
@@ -211,16 +195,7 @@ public class Slider extends RPCRequest {
*/
@SuppressWarnings("unchecked")
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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_SLIDER_FOOTER);
}
/**
@@ -232,11 +207,7 @@ public class Slider extends RPCRequest {
* <b>Notes: </b>Minvalue=0; Maxvalue=65535; Defvalue=10000
*/
public void setTimeout(Integer timeout) {
- if (timeout != null) {
- parameters.put(KEY_TIMEOUT, timeout);
- } else {
- parameters.remove(KEY_TIMEOUT);
- }
+ setParameters(KEY_TIMEOUT, timeout);
}
/**
@@ -244,6 +215,6 @@ public class Slider extends RPCRequest {
* @return Integer -an Integer value representing an App defined timeout
*/
public Integer getTimeout() {
- return (Integer) parameters.get(KEY_TIMEOUT);
+ return getInteger(KEY_TIMEOUT);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java
index 0d8487d12..8d226d72c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SliderResponse.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
+import java.util.Hashtable;
+
/**
* Slider Response is sent, when Slider has been called
*
@@ -36,17 +36,13 @@ public class SliderResponse extends RPCResponse {
* @param sliderPosition
*/
public void setSliderPosition(Integer sliderPosition) {
- if (sliderPosition != null) {
- parameters.put(KEY_SLIDER_POSITION, sliderPosition);
- } else {
- parameters.remove(KEY_SLIDER_POSITION);
- }
+ setParameters(KEY_SLIDER_POSITION, sliderPosition);
}
/**
* Gets an Initial position of slider control
* @return Integer
*/
public Integer getSliderPosition() {
- return (Integer) parameters.get(KEY_SLIDER_POSITION);
+ return getInteger(KEY_SLIDER_POSITION);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java
index e010a08da..23e31316d 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButton.java
@@ -95,86 +95,40 @@ public class SoftButton extends RPCStruct {
super(hash);
}
public void setType(SoftButtonType type) {
- if (type != null) {
- store.put(KEY_TYPE, type);
- } else {
- store.remove(KEY_TYPE);
- }
+ setValue(KEY_TYPE, type);
}
public SoftButtonType getType() {
- Object obj = store.get(KEY_TYPE);
- if (obj instanceof SoftButtonType) {
- return (SoftButtonType) obj;
- } else if (obj instanceof String) {
- return SoftButtonType.valueForString((String) obj);
- }
- return null;
+ return (SoftButtonType) getObject(SoftButtonType.class, KEY_TYPE);
}
public void setText(String text) {
- if (text != null) {
- store.put(KEY_TEXT, text);
- } else {
- store.remove(KEY_TEXT);
- }
+ setValue(KEY_TEXT, text);
}
public String getText() {
- return (String) store.get(KEY_TEXT);
+ return getString(KEY_TEXT);
}
public void setImage(Image image) {
- if (image != null) {
- store.put(KEY_IMAGE, image);
- } else {
- store.remove(KEY_IMAGE);
- }
+ setValue(KEY_IMAGE, image);
}
@SuppressWarnings("unchecked")
public Image getImage() {
- Object obj = store.get(KEY_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_IMAGE);
}
public void setIsHighlighted(Boolean isHighlighted) {
- if (isHighlighted != null) {
- store.put(KEY_IS_HIGHLIGHTED, isHighlighted);
- } else {
- store.remove(KEY_IS_HIGHLIGHTED);
- }
+ setValue(KEY_IS_HIGHLIGHTED, isHighlighted);
}
public Boolean getIsHighlighted() {
- return (Boolean) store.get(KEY_IS_HIGHLIGHTED);
+ return getBoolean(KEY_IS_HIGHLIGHTED);
}
public void setSoftButtonID(Integer softButtonID) {
- if (softButtonID != null) {
- store.put(KEY_SOFT_BUTTON_ID, softButtonID);
- } else {
- store.remove(KEY_SOFT_BUTTON_ID);
- }
+ setValue(KEY_SOFT_BUTTON_ID, softButtonID);
}
public Integer getSoftButtonID() {
- return (Integer) store.get(KEY_SOFT_BUTTON_ID);
+ return getInteger(KEY_SOFT_BUTTON_ID);
}
public void setSystemAction(SystemAction systemAction) {
- if (systemAction != null) {
- store.put(KEY_SYSTEM_ACTION, systemAction);
- } else {
- store.remove(KEY_SYSTEM_ACTION);
- }
+ setValue(KEY_SYSTEM_ACTION, systemAction);
}
public SystemAction getSystemAction() {
- Object obj = store.get(KEY_SYSTEM_ACTION);
- if (obj instanceof SystemAction) {
- return (SystemAction) obj;
- } else if (obj instanceof String) {
- return SystemAction.valueForString((String) obj);
- }
- return null;
+ return (SystemAction) getObject(SystemAction.class, KEY_SYSTEM_ACTION);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java
index e2849086c..205dfe74c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SoftButtonCapabilities.java
@@ -1,9 +1,9 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+
/**
* <p>Contains information about a SoftButton's capabilities.</p>
* <p><b>Parameter List</b></p>
@@ -72,11 +72,7 @@ public class SoftButtonCapabilities extends RPCStruct {
* @param shortPressAvailable whether the button supports a short press.
*/
public void setShortPressAvailable(Boolean shortPressAvailable) {
- if (shortPressAvailable != null) {
- store.put(KEY_SHORT_PRESS_AVAILABLE, shortPressAvailable);
- } else {
- store.remove(KEY_SHORT_PRESS_AVAILABLE);
- }
+ setValue(KEY_SHORT_PRESS_AVAILABLE, shortPressAvailable);
}
/**
@@ -84,7 +80,7 @@ public class SoftButtonCapabilities extends RPCStruct {
* @return whether the button supports a short press
*/
public Boolean getShortPressAvailable() {
- return (Boolean) store.get( KEY_SHORT_PRESS_AVAILABLE);
+ return getBoolean( KEY_SHORT_PRESS_AVAILABLE);
}
/**
@@ -92,11 +88,7 @@ public class SoftButtonCapabilities extends RPCStruct {
* @param longPressAvailable whether the button supports a long press
*/
public void setLongPressAvailable(Boolean longPressAvailable) {
- if (longPressAvailable != null) {
- store.put(KEY_LONG_PRESS_AVAILABLE, longPressAvailable);
- } else {
- store.remove(KEY_LONG_PRESS_AVAILABLE);
- }
+ setValue(KEY_LONG_PRESS_AVAILABLE, longPressAvailable);
}
/**
@@ -104,7 +96,7 @@ public class SoftButtonCapabilities extends RPCStruct {
* @return whether the button supports a LONG press
*/
public Boolean getLongPressAvailable() {
- return (Boolean) store.get( KEY_LONG_PRESS_AVAILABLE);
+ return getBoolean( KEY_LONG_PRESS_AVAILABLE);
}
/**
@@ -112,11 +104,7 @@ public class SoftButtonCapabilities extends RPCStruct {
* @param upDownAvailable the button supports "button down" and "button up".
*/
public void setUpDownAvailable(Boolean upDownAvailable) {
- if (upDownAvailable != null) {
- store.put(KEY_UP_DOWN_AVAILABLE, upDownAvailable);
- } else {
- store.remove(KEY_UP_DOWN_AVAILABLE);
- }
+ setValue(KEY_UP_DOWN_AVAILABLE, upDownAvailable);
}
/**
@@ -124,7 +112,7 @@ public class SoftButtonCapabilities extends RPCStruct {
* @return the button supports "button down" and "button up".
*/
public Boolean getUpDownAvailable() {
- return (Boolean) store.get( KEY_UP_DOWN_AVAILABLE);
+ return getBoolean( KEY_UP_DOWN_AVAILABLE);
}
/**
@@ -132,11 +120,7 @@ public class SoftButtonCapabilities extends RPCStruct {
* @param imageSupported whether the button supports referencing a static or dynamic image.
*/
public void setImageSupported(Boolean imageSupported) {
- if (imageSupported != null) {
- store.put(KEY_IMAGE_SUPPORTED, imageSupported);
- } else {
- store.remove(KEY_IMAGE_SUPPORTED);
- }
+ setValue(KEY_IMAGE_SUPPORTED, imageSupported);
}
/**
@@ -144,6 +128,6 @@ public class SoftButtonCapabilities extends RPCStruct {
* @return the button supports referencing a static or dynamic image.
*/
public Boolean getImageSupported() {
- return (Boolean) store.get( KEY_IMAGE_SUPPORTED);
+ return getBoolean( KEY_IMAGE_SUPPORTED);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java
index b5e775f06..347960731 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Speak.java
@@ -1,12 +1,11 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* Speaks a phrase over the vehicle audio system using SDL's TTS
* (text-to-speech) engine. The provided text to be spoken can be simply a text
@@ -135,22 +134,7 @@ public class Speak extends RPCRequest {
*/
@SuppressWarnings("unchecked")
public List<TTSChunk> getTtsChunks() {
- if (parameters.get(KEY_TTS_CHUNKS) instanceof List<?>) {
- List<?> list = (List<?>)parameters.get(KEY_TTS_CHUNKS);
- if (list != null && list.size() > 0) {
- Object obj = list.get(0);
- if (obj instanceof TTSChunk) {
- return (List<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;
+ return (List<TTSChunk>) getObject(TTSChunk.class, KEY_TTS_CHUNKS);
}
/**
* Sets a List<TTSChunk> representing an array of 1-100 TTSChunk structs
@@ -169,10 +153,6 @@ public class Speak extends RPCRequest {
* </ul>
*/
public void setTtsChunks( List<TTSChunk> ttsChunks ) {
- if (ttsChunks != null) {
- parameters.put(KEY_TTS_CHUNKS, ttsChunks );
- } else {
- parameters.remove(KEY_TTS_CHUNKS);
- }
+ setParameters(KEY_TTS_CHUNKS, ttsChunks);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java
index bce0b9fc1..ec515ad46 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StartTime.java
@@ -1,9 +1,9 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+
/**
* Describes the hour, minute and second values used to set the media clock.
* <p><b> Parameter List</b></p>
@@ -59,7 +59,7 @@ public class StartTime extends RPCStruct {
* @return hours Minvalue="0", maxvalue="59"
*/
public Integer getHours() {
- return (Integer) store.get( KEY_HOURS );
+ return getInteger( KEY_HOURS );
}
/**
* Set the hour. Minvalue="0", maxvalue="59"
@@ -67,46 +67,34 @@ public class StartTime extends RPCStruct {
* @param hours min: 0; max: 59
*/
public void setHours( Integer hours ) {
- if (hours != null) {
- store.put(KEY_HOURS, hours );
- } else {
- store.remove(KEY_HOURS);
- }
+ setValue(KEY_HOURS, hours);
}
/**
* Get the minute. Minvalue="0", maxvalue="59".
* @return minutes Minvalue="0", maxvalue="59"
*/
public Integer getMinutes() {
- return (Integer) store.get( KEY_MINUTES );
+ return getInteger( KEY_MINUTES );
}
/**
* Set the minute. Minvalue="0", maxvalue="59".
* @param minutes min: 0; max: 59
*/
public void setMinutes( Integer minutes ) {
- if (minutes != null) {
- store.put(KEY_MINUTES, minutes );
- } else {
- store.remove(KEY_MINUTES);
- }
+ setValue(KEY_MINUTES, minutes);
}
/**
* Get the second. Minvalue="0", maxvalue="59".
* @return seconds. Minvalue="0", maxvalue="59".
*/
public Integer getSeconds() {
- return (Integer) store.get( KEY_SECONDS );
+ return getInteger( KEY_SECONDS );
}
/**
* Set the second. Minvalue="0", maxvalue="59".
* @param seconds min: 0 max: 59
*/
public void setSeconds( Integer seconds ) {
- if (seconds != null) {
- store.put(KEY_SECONDS, seconds );
- } else {
- store.remove(KEY_SECONDS);
- }
+ setValue(KEY_SECONDS, seconds);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java
index bd75bef6d..d1de24993 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/StreamRPCResponse.java
@@ -1,10 +1,10 @@
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 StreamRPCResponse extends RPCResponse {
public static final String KEY_FILENAME = "fileName";
public static final String KEY_FILESIZE = "fileSize";
@@ -17,25 +17,17 @@ public class StreamRPCResponse extends RPCResponse {
}
public void setFileName(String fileName) {
- if (fileName != null) {
- parameters.put(KEY_FILENAME, fileName);
- } else {
- parameters.remove(KEY_FILENAME);
- }
+ setParameters(KEY_FILENAME, fileName);
}
public String getFileName() {
- return (String) parameters.get(KEY_FILENAME);
+ return getString(KEY_FILENAME);
}
public void setFileSize(Long fileSize) {
- if (fileSize != null) {
- parameters.put(KEY_FILESIZE, fileSize);
- } else {
- parameters.remove(KEY_FILESIZE);
- }
+ setParameters(KEY_FILESIZE, fileSize);
}
public Long getFileSize() {
- return (Long) parameters.get(KEY_FILESIZE);
+ return getLong(KEY_FILESIZE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java
index 7f1f92bae..4eedfcb47 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeButton.java
@@ -1,10 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
+
+import java.util.Hashtable;
+
/**
*<p> Establishes a subscription to button notifications for HMI buttons. Buttons
* are not necessarily physical buttons, but can also be "soft" buttons on a
@@ -98,23 +99,13 @@ public class SubscribeButton extends RPCRequest {
* @return ButtonName -an enum value, see <i>{@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonName}</i>
*/
public ButtonName getButtonName() {
- Object obj = parameters.get(KEY_BUTTON_NAME);
- if (obj instanceof ButtonName) {
- return (ButtonName) obj;
- } else if (obj instanceof String) {
- return ButtonName.valueForString((String) obj);
- }
- return null;
+ return (ButtonName) getObject(ButtonName.class, KEY_BUTTON_NAME);
}
/**
* Sets a name of the button to subscribe to
* @param buttonName a <i>{@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonName}</i> value
*/
public void setButtonName( ButtonName buttonName ) {
- if (buttonName != null) {
- parameters.put(KEY_BUTTON_NAME, buttonName );
- } else {
- parameters.remove(KEY_BUTTON_NAME);
- }
+ setParameters(KEY_BUTTON_NAME, buttonName);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java
index 6b934ef21..ddbf54c4a 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleData.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
+import java.util.Hashtable;
+
/**
* Subscribes for specific published vehicle data items. The data will be only
* sent, if it has changed. The application will be notified by the
@@ -289,11 +289,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setGps(Boolean gps) {
- if (gps != null) {
- parameters.put(KEY_GPS, gps);
- } else {
- parameters.remove(KEY_GPS);
- }
+ setParameters(KEY_GPS, gps);
}
/**
@@ -303,7 +299,7 @@ public class SubscribeVehicleData extends RPCRequest {
* subscribed.
*/
public Boolean getGps() {
- return (Boolean) parameters.get(KEY_GPS);
+ return getBoolean(KEY_GPS);
}
/**
@@ -313,11 +309,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setSpeed(Boolean speed) {
- if (speed != null) {
- parameters.put(KEY_SPEED, speed);
- } else {
- parameters.remove(KEY_SPEED);
- }
+ setParameters(KEY_SPEED, speed);
}
/**
@@ -327,7 +319,7 @@ public class SubscribeVehicleData extends RPCRequest {
* subscribed.
*/
public Boolean getSpeed() {
- return (Boolean) parameters.get(KEY_SPEED);
+ return getBoolean(KEY_SPEED);
}
/**
@@ -337,11 +329,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setRpm(Boolean rpm) {
- if (rpm != null) {
- parameters.put(KEY_RPM, rpm);
- } else {
- parameters.remove(KEY_RPM);
- }
+ setParameters(KEY_RPM, rpm);
}
/**
@@ -351,7 +339,7 @@ public class SubscribeVehicleData extends RPCRequest {
* subscribed.
*/
public Boolean getRpm() {
- return (Boolean) parameters.get(KEY_RPM);
+ return getBoolean(KEY_RPM);
}
/**
@@ -361,11 +349,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setFuelLevel(Boolean fuelLevel) {
- if (fuelLevel != null) {
- parameters.put(KEY_FUEL_LEVEL, fuelLevel);
- } else {
- parameters.remove(KEY_FUEL_LEVEL);
- }
+ setParameters(KEY_FUEL_LEVEL, fuelLevel);
}
/**
@@ -376,7 +360,7 @@ public class SubscribeVehicleData extends RPCRequest {
* been subscribed.
*/
public Boolean getFuelLevel() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL);
+ return getBoolean(KEY_FUEL_LEVEL);
}
/**
@@ -409,11 +393,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setFuelLevelState(Boolean fuelLevelState) {
- if (fuelLevelState != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevelState);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState);
}
/**
@@ -424,7 +404,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getFuelLevelState() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL_STATE);
+ return getBoolean(KEY_FUEL_LEVEL_STATE);
}
/**
@@ -434,11 +414,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setInstantFuelConsumption(Boolean instantFuelConsumption) {
- if (instantFuelConsumption != null) {
- parameters.put(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
- } else {
- parameters.remove(KEY_INSTANT_FUEL_CONSUMPTION);
- }
+ setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
}
/**
@@ -449,7 +425,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getInstantFuelConsumption() {
- return (Boolean) parameters.get(KEY_INSTANT_FUEL_CONSUMPTION);
+ return getBoolean(KEY_INSTANT_FUEL_CONSUMPTION);
}
/**
@@ -459,11 +435,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setExternalTemperature(Boolean externalTemperature) {
- if (externalTemperature != null) {
- parameters.put(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
- } else {
- parameters.remove(KEY_EXTERNAL_TEMPERATURE);
- }
+ setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
}
/**
@@ -474,7 +446,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getExternalTemperature() {
- return (Boolean) parameters.get(KEY_EXTERNAL_TEMPERATURE);
+ return getBoolean(KEY_EXTERNAL_TEMPERATURE);
}
/**
@@ -484,11 +456,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setPrndl(Boolean prndl) {
- if (prndl != null) {
- parameters.put(KEY_PRNDL, prndl);
- } else {
- parameters.remove(KEY_PRNDL);
- }
+ setParameters(KEY_PRNDL, prndl);
}
/**
@@ -499,7 +467,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getPrndl() {
- return (Boolean) parameters.get(KEY_PRNDL);
+ return getBoolean(KEY_PRNDL);
}
/**
@@ -509,11 +477,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setTirePressure(Boolean tirePressure) {
- if (tirePressure != null) {
- parameters.put(KEY_TIRE_PRESSURE, tirePressure);
- } else {
- parameters.remove(KEY_TIRE_PRESSURE);
- }
+ setParameters(KEY_TIRE_PRESSURE, tirePressure);
}
/**
@@ -524,7 +488,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getTirePressure() {
- return (Boolean) parameters.get(KEY_TIRE_PRESSURE);
+ return getBoolean(KEY_TIRE_PRESSURE);
}
/**
@@ -534,11 +498,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setOdometer(Boolean odometer) {
- if (odometer != null) {
- parameters.put(KEY_ODOMETER, odometer);
- } else {
- parameters.remove(KEY_ODOMETER);
- }
+ setParameters(KEY_ODOMETER, odometer);
}
/**
@@ -549,7 +509,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getOdometer() {
- return (Boolean) parameters.get(KEY_ODOMETER);
+ return getBoolean(KEY_ODOMETER);
}
/**
@@ -559,11 +519,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setBeltStatus(Boolean beltStatus) {
- if (beltStatus != null) {
- parameters.put(KEY_BELT_STATUS, beltStatus);
- } else {
- parameters.remove(KEY_BELT_STATUS);
- }
+ setParameters(KEY_BELT_STATUS, beltStatus);
}
/**
@@ -574,7 +530,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getBeltStatus() {
- return (Boolean) parameters.get(KEY_BELT_STATUS);
+ return getBoolean(KEY_BELT_STATUS);
}
/**
@@ -584,11 +540,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setBodyInformation(Boolean bodyInformation) {
- if (bodyInformation != null) {
- parameters.put(KEY_BODY_INFORMATION, bodyInformation);
- } else {
- parameters.remove(KEY_BODY_INFORMATION);
- }
+ setParameters(KEY_BODY_INFORMATION, bodyInformation);
}
/**
@@ -599,7 +551,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getBodyInformation() {
- return (Boolean) parameters.get(KEY_BODY_INFORMATION);
+ return getBoolean(KEY_BODY_INFORMATION);
}
/**
@@ -609,11 +561,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setDeviceStatus(Boolean deviceStatus) {
- if (deviceStatus != null) {
- parameters.put(KEY_DEVICE_STATUS, deviceStatus);
- } else {
- parameters.remove(KEY_DEVICE_STATUS);
- }
+ setParameters(KEY_DEVICE_STATUS, deviceStatus);
}
/**
@@ -624,7 +572,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getDeviceStatus() {
- return (Boolean) parameters.get(KEY_DEVICE_STATUS);
+ return getBoolean(KEY_DEVICE_STATUS);
}
/**
@@ -634,11 +582,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setDriverBraking(Boolean driverBraking) {
- if (driverBraking != null) {
- parameters.put(KEY_DRIVER_BRAKING, driverBraking);
- } else {
- parameters.remove(KEY_DRIVER_BRAKING);
- }
+ setParameters(KEY_DRIVER_BRAKING, driverBraking);
}
/**
@@ -649,7 +593,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getDriverBraking() {
- return (Boolean) parameters.get(KEY_DRIVER_BRAKING);
+ return getBoolean(KEY_DRIVER_BRAKING);
}
/**
@@ -659,11 +603,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setWiperStatus(Boolean wiperStatus) {
- if (wiperStatus != null) {
- parameters.put(KEY_WIPER_STATUS, wiperStatus);
- } else {
- parameters.remove(KEY_WIPER_STATUS);
- }
+ setParameters(KEY_WIPER_STATUS, wiperStatus);
}
/**
@@ -674,7 +614,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getWiperStatus() {
- return (Boolean) parameters.get(KEY_WIPER_STATUS);
+ return getBoolean(KEY_WIPER_STATUS);
}
/**
@@ -684,11 +624,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setHeadLampStatus(Boolean headLampStatus) {
- if (headLampStatus != null) {
- parameters.put(KEY_HEAD_LAMP_STATUS, headLampStatus);
- } else {
- parameters.remove(KEY_HEAD_LAMP_STATUS);
- }
+ setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus);
}
/**
@@ -699,7 +635,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getHeadLampStatus() {
- return (Boolean) parameters.get(KEY_HEAD_LAMP_STATUS);
+ return getBoolean(KEY_HEAD_LAMP_STATUS);
}
/**
@@ -709,11 +645,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setEngineTorque(Boolean engineTorque) {
- if (engineTorque != null) {
- parameters.put(KEY_ENGINE_TORQUE, engineTorque);
- } else {
- parameters.remove(KEY_ENGINE_TORQUE);
- }
+ setParameters(KEY_ENGINE_TORQUE, engineTorque);
}
/**
@@ -724,7 +656,7 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getEngineTorque() {
- return (Boolean) parameters.get(KEY_ENGINE_TORQUE);
+ return getBoolean(KEY_ENGINE_TORQUE);
}
/**
@@ -734,11 +666,7 @@ public class SubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setAccPedalPosition(Boolean accPedalPosition) {
- if (accPedalPosition != null) {
- parameters.put(KEY_ACC_PEDAL_POSITION, accPedalPosition);
- } else {
- parameters.remove(KEY_ACC_PEDAL_POSITION);
- }
+ setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition);
}
/**
@@ -749,69 +677,45 @@ public class SubscribeVehicleData extends RPCRequest {
* has been subscribed.
*/
public Boolean getAccPedalPosition() {
- return (Boolean) parameters.get(KEY_ACC_PEDAL_POSITION);
+ return getBoolean(KEY_ACC_PEDAL_POSITION);
}
public void setSteeringWheelAngle(Boolean steeringWheelAngle) {
- if (steeringWheelAngle != null) {
- parameters.put(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
- } else {
- parameters.remove(KEY_STEERING_WHEEL_ANGLE);
- }
+ setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
}
public Boolean getSteeringWheelAngle() {
- return (Boolean) parameters.get(KEY_STEERING_WHEEL_ANGLE);
+ return getBoolean(KEY_STEERING_WHEEL_ANGLE);
}
public void setECallInfo(Boolean eCallInfo) {
- if (eCallInfo != null) {
- parameters.put(KEY_E_CALL_INFO, eCallInfo);
- } else {
- parameters.remove(KEY_E_CALL_INFO);
- }
+ setParameters(KEY_E_CALL_INFO, eCallInfo);
}
public Boolean getECallInfo() {
- return (Boolean) parameters.get(KEY_E_CALL_INFO);
+ return getBoolean(KEY_E_CALL_INFO);
}
public void setAirbagStatus(Boolean airbagStatus) {
- if (airbagStatus != null) {
- parameters.put(KEY_AIRBAG_STATUS, airbagStatus);
- } else {
- parameters.remove(KEY_AIRBAG_STATUS);
- }
+ setParameters(KEY_AIRBAG_STATUS, airbagStatus);
}
public Boolean getAirbagStatus() {
- return (Boolean) parameters.get(KEY_AIRBAG_STATUS);
+ return getBoolean(KEY_AIRBAG_STATUS);
}
public void setEmergencyEvent(Boolean emergencyEvent) {
- if (emergencyEvent != null) {
- parameters.put(KEY_EMERGENCY_EVENT, emergencyEvent);
- } else {
- parameters.remove(KEY_EMERGENCY_EVENT);
- }
+ setParameters(KEY_EMERGENCY_EVENT, emergencyEvent);
}
public Boolean getEmergencyEvent() {
- return (Boolean) parameters.get(KEY_EMERGENCY_EVENT);
+ return getBoolean(KEY_EMERGENCY_EVENT);
}
public void setClusterModeStatus(Boolean clusterModeStatus) {
- if (clusterModeStatus != null) {
- parameters.put(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
- } else {
- parameters.remove(KEY_CLUSTER_MODE_STATUS);
- }
+ setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
}
public Boolean getClusterModeStatus() {
- return (Boolean) parameters.get(KEY_CLUSTER_MODE_STATUS);
+ return getBoolean(KEY_CLUSTER_MODE_STATUS);
}
public void setMyKey(Boolean myKey) {
- if (myKey != null) {
- parameters.put(KEY_MY_KEY, myKey);
- } else {
- parameters.remove(KEY_MY_KEY);
- }
+ setParameters(KEY_MY_KEY, myKey);
}
public Boolean getMyKey() {
- return (Boolean) parameters.get(KEY_MY_KEY);
+ return getBoolean(KEY_MY_KEY);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java
index f8092cae8..3c2a245ee 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SubscribeVehicleDataResponse.java
@@ -1,10 +1,9 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
-import com.smartdevicelink.util.DebugTool;
+
+import java.util.Hashtable;
/**
* Subscribe Vehicle Data Response is sent, when SubscribeVehicleData has been called
@@ -60,11 +59,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
* @param gps
*/
public void setGps(VehicleDataResult gps) {
- if (gps != null) {
- parameters.put(KEY_GPS, gps);
- } else {
- parameters.remove(KEY_GPS);
- }
+ setParameters(KEY_GPS, gps);
}
/**
* Gets gps
@@ -72,28 +67,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getGps() {
- Object obj = parameters.get(KEY_GPS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_GPS);
}
/**
* Sets speed
* @param speed
*/
public void setSpeed(VehicleDataResult speed) {
- if (speed != null) {
- parameters.put(KEY_SPEED, speed);
- } else {
- parameters.remove(KEY_SPEED);
- }
+ setParameters(KEY_SPEED, speed);
}
/**
* Gets speed
@@ -101,28 +82,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getSpeed() {
- Object obj = parameters.get(KEY_SPEED);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEED, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_SPEED);
}
/**
* Sets rpm
* @param rpm
*/
public void setRpm(VehicleDataResult rpm) {
- if (rpm != null) {
- parameters.put(KEY_RPM, rpm);
- } else {
- parameters.remove(KEY_RPM);
- }
+ setParameters(KEY_RPM, rpm);
}
/**
* Gets rpm
@@ -130,28 +97,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getRpm() {
- Object obj = parameters.get(KEY_RPM);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RPM, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_RPM);
}
/**
* Sets Fuel Level
* @param fuelLevel
*/
public void setFuelLevel(VehicleDataResult fuelLevel) {
- if (fuelLevel != null) {
- parameters.put(KEY_FUEL_LEVEL, fuelLevel);
- } else {
- parameters.remove(KEY_FUEL_LEVEL);
- }
+ setParameters(KEY_FUEL_LEVEL, fuelLevel);
}
/**
* Gets Fuel Level
@@ -159,17 +112,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getFuelLevel() {
- Object obj = parameters.get(KEY_FUEL_LEVEL);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_LEVEL);
}
/**
* Sets Fuel Level State
@@ -192,11 +135,7 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
* @param fuelLevelState
*/
public void setFuelLevelState(VehicleDataResult fuelLevelState) {
- if (fuelLevelState != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevelState);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState);
}
/**
* Gets Fuel Level State
@@ -204,24 +143,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getFuelLevelState() {
- Object obj = parameters.get(KEY_FUEL_LEVEL_STATE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_LEVEL_STATE);
}
/**
* Sets Instant Fuel Comsumption
* @param instantFuelConsumption
*/
public void setInstantFuelConsumption(VehicleDataResult instantFuelConsumption) {
- if (instantFuelConsumption != null) {
- parameters.put(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
- } else {
- parameters.remove(KEY_INSTANT_FUEL_CONSUMPTION);
- }
+ setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
}
/**
* Gets Instant Fuel Consumption
@@ -229,28 +158,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getInstantFuelConsumption() {
- Object obj = parameters.get(KEY_INSTANT_FUEL_CONSUMPTION);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INSTANT_FUEL_CONSUMPTION, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_INSTANT_FUEL_CONSUMPTION);
}
/**
* Sets External Temperature
* @param externalTemperature
*/
public void setExternalTemperature(VehicleDataResult externalTemperature) {
- if (externalTemperature != null) {
- parameters.put(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
- } else {
- parameters.remove(KEY_EXTERNAL_TEMPERATURE);
- }
+ setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
}
/**
* Gets External Temperature
@@ -258,28 +173,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getExternalTemperature() {
- Object obj = parameters.get(KEY_EXTERNAL_TEMPERATURE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EXTERNAL_TEMPERATURE, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_EXTERNAL_TEMPERATURE);
}
/**
* Sets currently selected gear data
* @param prndl
*/
public void setPrndl(VehicleDataResult prndl) {
- if (prndl != null) {
- parameters.put(KEY_PRNDL, prndl);
- } else {
- parameters.remove(KEY_PRNDL);
- }
+ setParameters(KEY_PRNDL, prndl);
}
/**
* Gets currently selected gear data
@@ -287,28 +188,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getPrndl() {
- Object obj = parameters.get(KEY_PRNDL);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRNDL, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_PRNDL);
}
/**
* Sets Tire Pressure
* @param tirePressure
*/
public void setTirePressure(VehicleDataResult tirePressure) {
- if (tirePressure != null) {
- parameters.put(KEY_TIRE_PRESSURE, tirePressure);
- } else {
- parameters.remove(KEY_TIRE_PRESSURE);
- }
+ setParameters(KEY_TIRE_PRESSURE, tirePressure);
}
/**
* Gets Tire Pressure
@@ -316,28 +203,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getTirePressure() {
- Object obj = parameters.get(KEY_TIRE_PRESSURE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_TIRE_PRESSURE);
}
/**
* Sets Odometer
* @param odometer
*/
public void setOdometer(VehicleDataResult odometer) {
- if (odometer != null) {
- parameters.put(KEY_ODOMETER, odometer);
- } else {
- parameters.remove(KEY_ODOMETER);
- }
+ setParameters(KEY_ODOMETER, odometer);
}
/**
* Gets Odometer
@@ -345,28 +218,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getOdometer() {
- Object obj = parameters.get(KEY_ODOMETER);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ODOMETER, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ODOMETER);
}
/**
* Sets Belt Status
* @param beltStatus
*/
public void setBeltStatus(VehicleDataResult beltStatus) {
- if (beltStatus != null) {
- parameters.put(KEY_BELT_STATUS, beltStatus);
- } else {
- parameters.remove(KEY_BELT_STATUS);
- }
+ setParameters(KEY_BELT_STATUS, beltStatus);
}
/**
* Gets Belt Status
@@ -374,28 +233,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getBeltStatus() {
- Object obj = parameters.get(KEY_BELT_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_BELT_STATUS);
}
/**
* Sets Body Information
* @param bodyInformation
*/
public void setBodyInformation(VehicleDataResult bodyInformation) {
- if (bodyInformation != null) {
- parameters.put(KEY_BODY_INFORMATION, bodyInformation);
- } else {
- parameters.remove(KEY_BODY_INFORMATION);
- }
+ setParameters(KEY_BODY_INFORMATION, bodyInformation);
}
/**
* Gets Body Information
@@ -403,28 +248,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getBodyInformation() {
- Object obj = parameters.get(KEY_BODY_INFORMATION);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_BODY_INFORMATION);
}
/**
* Sets Device Status
* @param deviceStatus
*/
public void setDeviceStatus(VehicleDataResult deviceStatus) {
- if (deviceStatus != null) {
- parameters.put(KEY_DEVICE_STATUS, deviceStatus);
- } else {
- parameters.remove(KEY_DEVICE_STATUS);
- }
+ setParameters(KEY_DEVICE_STATUS, deviceStatus);
}
/**
* Gets Device Status
@@ -432,28 +263,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getDeviceStatus() {
- Object obj = parameters.get(KEY_DEVICE_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_DEVICE_STATUS);
}
/**
* Sets Driver Barking
* @param driverBraking
*/
public void setDriverBraking(VehicleDataResult driverBraking) {
- if (driverBraking != null) {
- parameters.put(KEY_DRIVER_BRAKING, driverBraking);
- } else {
- parameters.remove(KEY_DRIVER_BRAKING);
- }
+ setParameters(KEY_DRIVER_BRAKING, driverBraking);
}
/**
* Gets Driver Barking
@@ -461,28 +278,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getDriverBraking() {
- Object obj = parameters.get(KEY_DRIVER_BRAKING);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BRAKING, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_DRIVER_BRAKING);
}
/**
* Sets wiper Status
* @param wiperStatus
*/
public void setWiperStatus(VehicleDataResult wiperStatus) {
- if (wiperStatus != null) {
- parameters.put(KEY_WIPER_STATUS, wiperStatus);
- } else {
- parameters.remove(KEY_WIPER_STATUS);
- }
+ setParameters(KEY_WIPER_STATUS, wiperStatus);
}
/**
* Gets Wiper Status
@@ -490,28 +293,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getWiperStatus() {
- Object obj = parameters.get(KEY_WIPER_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_WIPER_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_WIPER_STATUS);
}
/**
* Sets Head Lamp Status
* @param headLampStatus
*/
public void setHeadLampStatus(VehicleDataResult headLampStatus) {
- if (headLampStatus != null) {
- parameters.put(KEY_HEAD_LAMP_STATUS, headLampStatus);
- } else {
- parameters.remove(KEY_HEAD_LAMP_STATUS);
- }
+ setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus);
}
/**
* Gets Head Lamp Status
@@ -519,28 +308,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getHeadLampStatus() {
- Object obj = parameters.get(KEY_HEAD_LAMP_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_HEAD_LAMP_STATUS);
}
/**
* Sets Engine Torque
* @param engineTorque
*/
public void setEngineTorque(VehicleDataResult engineTorque) {
- if (engineTorque != null) {
- parameters.put(KEY_ENGINE_TORQUE, engineTorque);
- } else {
- parameters.remove(KEY_ENGINE_TORQUE);
- }
+ setParameters(KEY_ENGINE_TORQUE, engineTorque);
}
/**
* Gets Engine Torque
@@ -548,28 +323,14 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getEngineTorque() {
- Object obj = parameters.get(KEY_ENGINE_TORQUE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ENGINE_TORQUE, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ENGINE_TORQUE);
}
/**
* Sets AccPedal Position
* @param accPedalPosition
*/
public void setAccPedalPosition(VehicleDataResult accPedalPosition) {
- if (accPedalPosition != null) {
- parameters.put(KEY_ACC_PEDAL_POSITION, accPedalPosition);
- } else {
- parameters.remove(KEY_ACC_PEDAL_POSITION);
- }
+ setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition);
}
/**
* Gets AccPedal Position
@@ -577,145 +338,51 @@ public class SubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getAccPedalPosition() {
- Object obj = parameters.get(KEY_ACC_PEDAL_POSITION);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ACC_PEDAL_POSITION, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ACC_PEDAL_POSITION);
}
public void setSteeringWheelAngle(VehicleDataResult steeringWheelAngle) {
- if (steeringWheelAngle != null) {
- parameters.put(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
- } else {
- parameters.remove(KEY_STEERING_WHEEL_ANGLE);
- }
+ setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getSteeringWheelAngle() {
- Object obj = parameters.get(KEY_STEERING_WHEEL_ANGLE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_STEERING_WHEEL_ANGLE, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_STEERING_WHEEL_ANGLE);
}
public void setECallInfo(VehicleDataResult eCallInfo) {
- if (eCallInfo != null) {
- parameters.put(KEY_E_CALL_INFO, eCallInfo);
- } else {
- parameters.remove(KEY_E_CALL_INFO);
- }
+ setParameters(KEY_E_CALL_INFO, eCallInfo);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getECallInfo() {
- Object obj = parameters.get(KEY_E_CALL_INFO);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_E_CALL_INFO);
}
public void setAirbagStatus(VehicleDataResult airbagStatus) {
- if (airbagStatus != null) {
- parameters.put(KEY_AIRBAG_STATUS, airbagStatus);
- } else {
- parameters.remove(KEY_AIRBAG_STATUS);
- }
+ setParameters(KEY_AIRBAG_STATUS, airbagStatus);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getAirbagStatus() {
- Object obj = parameters.get(KEY_AIRBAG_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_AIRBAG_STATUS);
}
public void setEmergencyEvent(VehicleDataResult emergencyEvent) {
- if (emergencyEvent != null) {
- parameters.put(KEY_EMERGENCY_EVENT, emergencyEvent);
- } else {
- parameters.remove(KEY_EMERGENCY_EVENT);
- }
+ setParameters(KEY_EMERGENCY_EVENT, emergencyEvent);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getEmergencyEvent() {
- Object obj = parameters.get(KEY_EMERGENCY_EVENT);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_EMERGENCY_EVENT);
}
public void setClusterModeStatus(VehicleDataResult clusterModeStatus) {
- if (clusterModeStatus != null) {
- parameters.put(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
- } else {
- parameters.remove(KEY_CLUSTER_MODE_STATUS);
- }
+ setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getClusterModeStatus() {
- Object obj = parameters.get(KEY_CLUSTER_MODE_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_CLUSTER_MODE_STATUS);
}
public void setMyKey(VehicleDataResult myKey) {
- if (myKey != null) {
- parameters.put(KEY_MY_KEY, myKey);
- } else {
- parameters.remove(KEY_MY_KEY);
- }
+ setParameters(KEY_MY_KEY, myKey);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getMyKey() {
- Object obj = parameters.get(KEY_MY_KEY);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_MY_KEY);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java
new file mode 100644
index 000000000..386f28b45
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemCapability.java
@@ -0,0 +1,67 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
+
+import java.util.Hashtable;
+
+/**
+ * Struct that indicates the a SystemCapabilityType and houses different structs to describe particular capabilities
+ */
+
+public class SystemCapability extends RPCStruct {
+ public static final String KEY_SYSTEM_CAPABILITY_TYPE = "systemCapabilityType";
+ public static final String KEY_NAVIGATION_CAPABILITY = "navigationCapability";
+ public static final String KEY_PHONE_CAPABILITY = "phoneCapability";
+ public static final String KEY_VIDEO_STREAMING_CAPABILITY = "videoStreamingCapability";
+ public static final String KEY_REMOTE_CONTROL_CAPABILITY = "remoteControlCapability";
+
+ public SystemCapability(){}
+
+ public SystemCapability(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ *
+ * @return The SystemCapabilityType that indicates which type of data should be changed and identifies which data object exists in this struct. For example, if the SystemCapability Type is NAVIGATION then a "navigationCapability" should exist
+ */
+ public SystemCapabilityType getSystemCapabilityType(){
+ return (SystemCapabilityType) getObject(SystemCapabilityType.class, KEY_SYSTEM_CAPABILITY_TYPE);
+ }
+
+ /**
+ * @param value Set the SystemCapabilityType that indicates which type of data should be changed and identifies which data object exists in this struct.
+ */
+ public void setSystemCapabilityType(SystemCapabilityType value){
+ setValue(KEY_SYSTEM_CAPABILITY_TYPE, value);
+ }
+
+ public RPCStruct getCapabilityForType(SystemCapabilityType type) {
+ if (type.equals(SystemCapabilityType.NAVIGATION)) {
+ return (RPCStruct) getObject(NavigationCapability.class, KEY_NAVIGATION_CAPABILITY);
+ } else if (type.equals(SystemCapabilityType.PHONE_CALL)) {
+ return (RPCStruct) getObject(PhoneCapability.class, KEY_PHONE_CAPABILITY);
+ } else if (type.equals(SystemCapabilityType.VIDEO_STREAMING)){
+ return (RPCStruct) getObject(VideoStreamingCapability.class, KEY_VIDEO_STREAMING_CAPABILITY);
+ }else if(type.equals(SystemCapabilityType.REMOTE_CONTROL)){
+ return (RPCStruct) getObject(RemoteControlCapabilities.class, KEY_REMOTE_CONTROL_CAPABILITY);
+ }else{
+ return null;
+ }
+ }
+
+ public void setCapabilityForType(SystemCapabilityType type, RPCStruct capability){
+ if(type.equals(SystemCapabilityType.NAVIGATION)){
+ setValue(KEY_NAVIGATION_CAPABILITY, capability);
+ }else if(type.equals(SystemCapabilityType.PHONE_CALL)){
+ setValue(KEY_PHONE_CAPABILITY, capability);
+ }else if(type.equals(SystemCapabilityType.VIDEO_STREAMING)){
+ setValue(KEY_VIDEO_STREAMING_CAPABILITY, capability);
+ }else if(type.equals(SystemCapabilityType.REMOTE_CONTROL)){
+ setValue(KEY_REMOTE_CONTROL_CAPABILITY, capability);
+ }else{
+ return;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java
index 14164b964..154907419 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/SystemRequest.java
@@ -1,11 +1,12 @@
package com.smartdevicelink.proxy.rpc;
-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;
+
+import java.util.Hashtable;
+import java.util.List;
+
/** An asynchronous request from the device; binary data can be included in hybrid part of message for some requests (such as HTTP, Proprietary, or Authentication requests)
*
* <p><b>Parameter List</b></p>
@@ -64,53 +65,26 @@ public class SystemRequest extends RPCRequest {
@SuppressWarnings("unchecked")
public List<String> getLegacyData() {
- 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;
- }
- }
- }
- return null;
+ return (List<String>) getObject(String.class, KEY_DATA);
}
public void setLegacyData( List<String> data ) {
- if ( data!= null) {
- parameters.put(KEY_DATA, data );
- } else {
- parameters.remove(KEY_DATA);
- }
+ setParameters(KEY_DATA, data);
}
public String getFileName() {
- return (String) parameters.get(KEY_FILE_NAME);
+ return getString(KEY_FILE_NAME);
}
public void setFileName(String fileName) {
- if (fileName != null) {
- parameters.put(KEY_FILE_NAME, fileName);
- } else {
- parameters.remove(KEY_FILE_NAME);
- }
+ setParameters(KEY_FILE_NAME, fileName);
}
public RequestType getRequestType() {
- Object obj = parameters.get(KEY_REQUEST_TYPE);
- if (obj instanceof RequestType) {
- return (RequestType) obj;
- } else if (obj instanceof String) {
- return RequestType.valueForString((String) obj);
- }
- return null;
+ return (RequestType) getObject(RequestType.class, KEY_REQUEST_TYPE);
}
public void setRequestType(RequestType requestType) {
- if (requestType != null) {
- parameters.put(KEY_REQUEST_TYPE, requestType);
- } else {
- parameters.remove(KEY_REQUEST_TYPE);
- }
+ setParameters(KEY_REQUEST_TYPE, requestType);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java
index 97f865903..d98bb8a5c 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TTSChunk.java
@@ -1,10 +1,10 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
+import java.util.Hashtable;
+
/**
* <p>Specifies what is to be spoken. This can be simply a text phrase, which SDL will speak according to its own rules.
* It can also be phonemes from either the Microsoft SAPI phoneme set, or from the LHPLUS phoneme set.
@@ -56,41 +56,27 @@ public class TTSChunk extends RPCStruct {
* @return text to be spoken, or a phoneme specification, or the name of a pre-recorded sound
*/
public String getText() {
- return (String) store.get( KEY_TEXT );
+ return getString( KEY_TEXT );
}
/**
* Set the text to be spoken, or a phoneme specification, or the name of a pre-recorded sound. The contents of this field are indicated by the "type" field.
* @param text to be spoken, or a phoneme specification, or the name of a pre-recorded sound.
*/
public void setText( String text ) {
- if (text != null) {
- store.put(KEY_TEXT, text );
- } else {
- store.remove(KEY_TEXT);
- }
+ setValue(KEY_TEXT, text);
}
/**
* Get the type of information in the "text" field (e.g. phrase to be spoken, phoneme specification, name of pre-recorded sound).
* @return the type of information in the "text" field
*/
public SpeechCapabilities getType() {
- Object obj = store.get(KEY_TYPE);
- if (obj instanceof SpeechCapabilities) {
- return (SpeechCapabilities) obj;
- } else if (obj instanceof String) {
- return SpeechCapabilities.valueForString((String) obj);
- }
- return null;
+ return (SpeechCapabilities) getObject(SpeechCapabilities.class, KEY_TYPE);
}
/**
* Set the type of information in the "text" field (e.g. phrase to be spoken, phoneme specification, name of pre-recorded sound).
* @param type the type of information in the "text" field
*/
public void setType( SpeechCapabilities type ) {
- if (type != null) {
- store.put(KEY_TYPE, type );
- } else {
- store.remove(KEY_TYPE);
- }
+ setValue(KEY_TYPE, type);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Temperature.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Temperature.java
new file mode 100644
index 000000000..29fea734f
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Temperature.java
@@ -0,0 +1,56 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.TemperatureUnit;
+import com.smartdevicelink.util.SdlDataTypeConverter;
+
+import java.util.Hashtable;
+
+public class Temperature extends RPCStruct{
+ public static final String KEY_UNIT = "unit";
+ public static final String KEY_VALUE = "value";
+
+ public Temperature() { }
+ public Temperature(Hashtable<String, Object> hash) {
+ super(hash);
+ }
+
+ /**
+ * Sets the unit portion of the Temperature class
+ *
+ * @param unit
+ * Temperature Unit.
+ */
+ public void setUnit(TemperatureUnit unit) {
+ setValue(KEY_UNIT, unit);
+ }
+
+ /**
+ * Gets the unit portion of the Temperature class
+ *
+ * @return TemperatureUnit - Temperature Unit.
+ */
+ public TemperatureUnit getUnit() {
+ return (TemperatureUnit) getObject(TemperatureUnit.class, KEY_UNIT);
+ }
+
+ /**
+ * Gets the value portion of the Temperature class
+ *
+ * @return Float - Temperature Value in TemperatureUnit specified unit. Range depends on OEM and is not checked by SDL.
+ */
+ public Float getValue() {
+ Object value = getValue(KEY_VALUE);
+ return SdlDataTypeConverter.objectToFloat(value);
+ }
+
+ /**
+ * Sets the value portion of the Temperature class
+ *
+ * @param value
+ * Temperature Value in TemperatureUnit specified unit. Range depends on OEM and is not checked by SDL.
+ */
+ public void setValue(Float value) {
+ setValue(KEY_VALUE, value);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java
index 918f0eb2f..28e283e9f 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TextField.java
@@ -6,6 +6,8 @@ import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.CharacterSet;
import com.smartdevicelink.proxy.rpc.enums.TextFieldName;
+import static com.smartdevicelink.proxy.rpc.TireStatus.KEY_INNER_RIGHT_REAR;
+
/**
* Struct defining the characteristics of a displayed field on the HMI.
* <p><b> Parameter List</b></p>
@@ -83,48 +85,28 @@ public class TextField extends RPCStruct {
* @return the name of TextField
*/
public TextFieldName getName() {
- Object obj = store.get(KEY_NAME);
- if (obj instanceof TextFieldName) {
- return (TextFieldName) obj;
- } else if (obj instanceof String) {
- return TextFieldName.valueForString((String) obj);
- }
- return null;
+ return (TextFieldName) getObject(TextFieldName.class, KEY_NAME);
}
/**
* Set the enumeration identifying the field.
* @param name the name of TextField
*/
public void setName( TextFieldName name ) {
- if (name != null) {
- store.put(KEY_NAME, name );
- } else {
- store.remove(KEY_NAME);
- }
+ setValue(KEY_NAME, name);
}
/**
* Get the character set that is supported in this field.
* @return the character set
*/
public CharacterSet getCharacterSet() {
- Object obj = store.get(KEY_CHARACTER_SET);
- if (obj instanceof CharacterSet) {
- return (CharacterSet) obj;
- } else if (obj instanceof String) {
- return CharacterSet.valueForString((String) obj);
- }
- return null;
+ return (CharacterSet) getObject(CharacterSet.class, KEY_CHARACTER_SET);
}
/**
* Set the character set that is supported in this field.
* @param characterSet - the character set
*/
public void setCharacterSet( CharacterSet characterSet ) {
- if (characterSet != null) {
- store.put(KEY_CHARACTER_SET, characterSet );
- } else {
- store.remove(KEY_CHARACTER_SET);
- }
+ setValue(KEY_CHARACTER_SET, characterSet);
}
/**
* Get the number of characters in one row of this field.
@@ -135,7 +117,7 @@ public class TextField extends RPCStruct {
* @return the number of characters in one row of this field
*/
public Integer getWidth() {
- return (Integer) store.get( KEY_WIDTH );
+ return getInteger( KEY_WIDTH );
}
/**
* Set the number of characters in one row of this field.
@@ -146,11 +128,7 @@ public class TextField extends RPCStruct {
* @param width the number of characters in one row of this field
*/
public void setWidth( Integer width ) {
- if (width != null) {
- store.put(KEY_WIDTH, width );
- } else {
- store.remove(KEY_WIDTH);
- }
+ setValue(KEY_WIDTH, width);
}
/**
*Get the number of rows for this text field.
@@ -161,13 +139,9 @@ public class TextField extends RPCStruct {
* @return the number of rows for this text field
*/
public Integer getRows() {
- return (Integer) store.get( KEY_ROWS );
+ return getInteger( KEY_ROWS );
}
public void setRows( Integer rows ) {
- if (rows != null) {
- store.put(KEY_ROWS, rows );
- } else {
- store.remove(KEY_ROWS);
- }
+ setValue(KEY_ROWS, rows);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java
index f853d673c..4b2169215 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TireStatus.java
@@ -1,10 +1,14 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataNotificationStatus;
import com.smartdevicelink.proxy.rpc.enums.WarningLightStatus;
import com.smartdevicelink.util.DebugTool;
+
+import java.util.Hashtable;
+
+import static com.smartdevicelink.proxy.rpc.ECallInfo.KEY_E_CALL_NOTIFICATION_STATUS;
+
/** <p>The status and pressure of the tires.</p>
* <p><b> Parameter List:</b></p>
*
@@ -89,145 +93,51 @@ public class TireStatus extends RPCStruct {
super(hash);
}
public void setPressureTellTale(WarningLightStatus pressureTellTale) {
- if (pressureTellTale != null) {
- store.put(KEY_PRESSURE_TELL_TALE, pressureTellTale);
- } else {
- store.remove(KEY_PRESSURE_TELL_TALE);
- }
+ setValue(KEY_PRESSURE_TELL_TALE, pressureTellTale);
}
public WarningLightStatus getPressureTellTale() {
- Object obj = store.get(KEY_PRESSURE_TELL_TALE);
- if (obj instanceof WarningLightStatus) {
- return (WarningLightStatus) obj;
- } else if (obj instanceof String) {
- return WarningLightStatus.valueForString((String) obj);
- }
- return null;
+ return (WarningLightStatus) getObject(WarningLightStatus.class, KEY_PRESSURE_TELL_TALE);
}
public void setLeftFront(SingleTireStatus leftFront) {
- if (leftFront != null) {
- store.put(KEY_LEFT_FRONT, leftFront);
- } else {
- store.remove(KEY_LEFT_FRONT);
- }
+ setValue(KEY_LEFT_FRONT, leftFront);
}
@SuppressWarnings("unchecked")
public SingleTireStatus getLeftFront() {
- Object obj = store.get(KEY_LEFT_FRONT);
- if (obj instanceof SingleTireStatus) {
- return (SingleTireStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new SingleTireStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LEFT_FRONT, e);
- }
- }
- return null;
+ return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_LEFT_FRONT);
}
public void setRightFront(SingleTireStatus rightFront) {
- if (rightFront != null) {
- store.put(KEY_RIGHT_FRONT, rightFront);
- } else {
- store.remove(KEY_RIGHT_FRONT);
- }
+ setValue(KEY_RIGHT_FRONT, rightFront);
}
@SuppressWarnings("unchecked")
public SingleTireStatus getRightFront() {
- Object obj = store.get(KEY_RIGHT_FRONT);
- if (obj instanceof SingleTireStatus) {
- return (SingleTireStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new SingleTireStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_FRONT, e);
- }
- }
- return null;
+ return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_RIGHT_FRONT);
}
public void setLeftRear(SingleTireStatus leftRear) {
- if (leftRear != null) {
- store.put(KEY_LEFT_REAR, leftRear);
- } else {
- store.remove(KEY_LEFT_REAR);
- }
+ setValue(KEY_LEFT_REAR, leftRear);
}
@SuppressWarnings("unchecked")
public SingleTireStatus getLeftRear() {
- Object obj = store.get(KEY_LEFT_REAR);
- if (obj instanceof SingleTireStatus) {
- return (SingleTireStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new SingleTireStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_LEFT_REAR, e);
- }
- }
- return null;
+ return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_LEFT_REAR);
}
public void setRightRear(SingleTireStatus rightRear) {
- if (rightRear != null) {
- store.put(KEY_RIGHT_REAR, rightRear);
- } else {
- store.remove(KEY_RIGHT_REAR);
- }
+ setValue(KEY_RIGHT_REAR, rightRear);
}
@SuppressWarnings("unchecked")
public SingleTireStatus getRightRear() {
- Object obj = store.get(KEY_RIGHT_REAR);
- if (obj instanceof SingleTireStatus) {
- return (SingleTireStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new SingleTireStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RIGHT_REAR, e);
- }
- }
- return null;
+ return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_RIGHT_REAR);
}
public void setInnerLeftRear(SingleTireStatus innerLeftRear) {
- if (innerLeftRear != null) {
- store.put(KEY_INNER_LEFT_REAR, innerLeftRear);
- } else {
- store.remove(KEY_INNER_LEFT_REAR);
- }
+ setValue(KEY_INNER_LEFT_REAR, innerLeftRear);
}
@SuppressWarnings("unchecked")
public SingleTireStatus getInnerLeftRear() {
- Object obj = store.get(KEY_INNER_LEFT_REAR);
- if (obj instanceof SingleTireStatus) {
- return (SingleTireStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new SingleTireStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INNER_LEFT_REAR, e);
- }
- }
- return null;
+ return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_INNER_LEFT_REAR);
}
public void setInnerRightRear(SingleTireStatus innerRightRear) {
- if (innerRightRear != null) {
- store.put(KEY_INNER_RIGHT_REAR, innerRightRear);
- } else {
- store.remove(KEY_INNER_RIGHT_REAR);
- }
+ setValue(KEY_INNER_RIGHT_REAR, innerRightRear);
}
@SuppressWarnings("unchecked")
public SingleTireStatus getInnerRightRear() {
- Object obj = store.get(KEY_INNER_RIGHT_REAR);
- if (obj instanceof SingleTireStatus) {
- return (SingleTireStatus) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new SingleTireStatus((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INNER_RIGHT_REAR, e);
- }
- }
- return null;
+ return (SingleTireStatus) getObject(SingleTireStatus.class, KEY_INNER_RIGHT_REAR);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java
index 95f793fe6..2c0a1a260 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchCoord.java
@@ -60,27 +60,19 @@ public class TouchCoord extends RPCStruct {
}
public void setX(Integer x) {
- if (x != null) {
- store.put(KEY_X, x);
- } else {
- store.remove(KEY_X);
- }
+ setValue(KEY_X, x);
}
public Integer getX() {
- return (Integer) store.get(KEY_X);
+ return getInteger(KEY_X);
}
public void setY(Integer y) {
- if (y != null) {
- store.put(KEY_Y, y);
- } else {
- store.remove(KEY_Y);
- }
+ setValue(KEY_Y, y);
}
public Integer getY() {
- return (Integer) store.get(KEY_Y);
+ return getInteger(KEY_Y);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java
index 76e3c4207..f99b0a8e2 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEvent.java
@@ -1,10 +1,11 @@
package com.smartdevicelink.proxy.rpc;
+import com.smartdevicelink.proxy.RPCStruct;
+
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
-import com.smartdevicelink.proxy.RPCStruct;
/**
* <p>For touchscreen interactions, the mode of how the choices are presented.</p>
*
@@ -73,15 +74,11 @@ public class TouchEvent extends RPCStruct {
}
public void setId(Integer id) {
- if (id != null) {
- store.put(KEY_ID, id);
- } else {
- store.remove(KEY_ID);
- }
+ setValue(KEY_ID, id);
}
public Integer getId() {
- return (Integer) store.get(KEY_ID);
+ return getInteger(KEY_ID);
}
/**
@@ -96,8 +93,8 @@ public class TouchEvent extends RPCStruct {
@SuppressWarnings("unchecked")
public List<Long> getTimestamps() {
- if(store.get(KEY_TS) instanceof List<?>){
- List<?> list = (List<?>)store.get(KEY_TS);
+ if(getValue(KEY_TS) instanceof List<?>){
+ List<?> list = (List<?>) getValue(KEY_TS);
if(list != null && list.size()>0){
Object obj = list.get(0);
if(obj instanceof Integer){ //Backwards case
@@ -117,11 +114,7 @@ public class TouchEvent extends RPCStruct {
}
public void setTimestamps(List<Long> ts){
- if (ts != null) {
- store.put(KEY_TS, ts);
- } else {
- store.remove(KEY_TS);
- }
+ setValue(KEY_TS, ts);
}
/**
@@ -143,24 +136,9 @@ public class TouchEvent extends RPCStruct {
public List<TouchCoord> getC() {
return getTouchCoordinates();
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
public List<TouchCoord> getTouchCoordinates() {
- 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;
- }
- }
- }
- return null;
+ return (List<TouchCoord>) getObject(TouchCoord.class, KEY_C);
}
/**
@@ -174,10 +152,6 @@ public class TouchEvent extends RPCStruct {
}
public void setTouchCoordinates( List<TouchCoord> c ) {
- if (c != null) {
- store.put(KEY_C, c );
- } else {
- store.remove(KEY_C);
- }
+ setValue(KEY_C, c);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java
index b67e5b61a..668c81e0d 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/TouchEventCapabilities.java
@@ -54,38 +54,26 @@ public class TouchEventCapabilities extends RPCStruct {
}
public void setPressAvailable(Boolean pressAvailable) {
- if (pressAvailable != null) {
- store.put(KEY_PRESS_AVAILABLE, pressAvailable);
- } else {
- store.remove(KEY_PRESS_AVAILABLE);
- }
+ setValue(KEY_PRESS_AVAILABLE, pressAvailable);
}
public Boolean getPressAvailable() {
- return (Boolean) store.get(KEY_PRESS_AVAILABLE);
+ return getBoolean(KEY_PRESS_AVAILABLE);
}
public void setMultiTouchAvailable(Boolean multiTouchAvailable) {
- if (multiTouchAvailable != null) {
- store.put(KEY_MULTI_TOUCH_AVAILABLE, multiTouchAvailable);
- } else {
- store.remove(KEY_MULTI_TOUCH_AVAILABLE);
- }
+ setValue(KEY_MULTI_TOUCH_AVAILABLE, multiTouchAvailable);
}
public Boolean getMultiTouchAvailable() {
- return (Boolean) store.get(KEY_MULTI_TOUCH_AVAILABLE);
+ return getBoolean(KEY_MULTI_TOUCH_AVAILABLE);
}
public void setDoublePressAvailable(Boolean doublePressAvailable) {
- if (doublePressAvailable != null) {
- store.put(KEY_DOUBLE_PRESS_AVAILABLE, doublePressAvailable);
- } else {
- store.remove(KEY_DOUBLE_PRESS_AVAILABLE);
- }
+ setValue(KEY_DOUBLE_PRESS_AVAILABLE, doublePressAvailable);
}
public Boolean getDoublePressAvailable() {
- return (Boolean) store.get(KEY_DOUBLE_PRESS_AVAILABLE);
+ return getBoolean(KEY_DOUBLE_PRESS_AVAILABLE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java
index 437e176a5..6cebac7f1 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/Turn.java
@@ -1,8 +1,9 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode;
+
+import java.util.Hashtable;
/**
* Describes a navigation turn including an optional icon
@@ -51,12 +52,7 @@ public class Turn extends RPCStruct{
* the text to describe the turn (e.g. streetname)
*/
public void setNavigationText(String navigationText){
- if(navigationText != null){
- store.put(KEY_NAVIGATION_TEXT, navigationText);
- }
- else{
- store.remove(KEY_NAVIGATION_TEXT);
- }
+ setValue(KEY_NAVIGATION_TEXT, navigationText);
}
/**
@@ -65,7 +61,7 @@ public class Turn extends RPCStruct{
* @return the text to describe the turn (e.g. streetname)
*/
public String getNavigationText(){
- return (String) store.get(KEY_NAVIGATION_TEXT);
+ return getString(KEY_NAVIGATION_TEXT);
}
/**
@@ -75,11 +71,7 @@ public class Turn extends RPCStruct{
* the image to be shown for a turn
*/
public void setTurnIcon(Image turnIcon){
- if (turnIcon != null) {
- store.put(KEY_TURN_IMAGE, turnIcon);
- } else {
- store.remove(KEY_TURN_IMAGE);
- }
+ setValue(KEY_TURN_IMAGE, turnIcon);
}
/**
@@ -89,13 +81,7 @@ public class Turn extends RPCStruct{
*/
@SuppressWarnings("unchecked")
public Image getTurnIcon(){
- Object obj = store.get(KEY_TURN_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- return new Image((Hashtable<String, Object>) obj);
- }
- return null;
+ return (Image) getObject(Image.class, KEY_TURN_IMAGE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java
index 33567a8af..521800426 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeButton.java
@@ -1,11 +1,11 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCRequest;
import com.smartdevicelink.proxy.rpc.enums.ButtonName;
+import java.util.Hashtable;
+
/**
* Deletes a subscription to button notifications for the specified button. For
* more information about button subscriptions, see {@linkplain SubscribeButton}
@@ -76,13 +76,7 @@ public class UnsubscribeButton extends RPCRequest {
* {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonName}</i>
*/
public ButtonName getButtonName() {
- Object obj = parameters.get(KEY_BUTTON_NAME);
- if (obj instanceof ButtonName) {
- return (ButtonName) obj;
- } else if (obj instanceof String) {
- return ButtonName.valueForString((String) obj);
- }
- return null;
+ return (ButtonName) getObject(ButtonName.class, KEY_BUTTON_NAME);
}
/**
* Sets the name of the button to unsubscribe from
@@ -92,10 +86,6 @@ public class UnsubscribeButton extends RPCRequest {
* {@linkplain com.smartdevicelink.proxy.rpc.enums.ButtonName}</i>
*/
public void setButtonName( ButtonName buttonName ) {
- if (buttonName != null) {
- parameters.put(KEY_BUTTON_NAME, buttonName );
- } else {
- parameters.remove(KEY_BUTTON_NAME);
- }
+ setParameters(KEY_BUTTON_NAME, buttonName);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java
index 668b31fd9..8a50ec286 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleData.java
@@ -283,11 +283,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setGps(Boolean gps) {
- if (gps != null) {
- parameters.put(KEY_GPS, gps);
- } else {
- parameters.remove(KEY_GPS);
- }
+ setParameters(KEY_GPS, gps);
}
/**
@@ -297,7 +293,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* unsubscribed.
*/
public Boolean getGps() {
- return (Boolean) parameters.get(KEY_GPS);
+ return getBoolean(KEY_GPS);
}
/**
@@ -307,11 +303,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setSpeed(Boolean speed) {
- if (speed != null) {
- parameters.put(KEY_SPEED, speed);
- } else {
- parameters.remove(KEY_SPEED);
- }
+ setParameters(KEY_SPEED, speed);
}
/**
@@ -321,7 +313,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* unsubscribed.
*/
public Boolean getSpeed() {
- return (Boolean) parameters.get(KEY_SPEED);
+ return getBoolean(KEY_SPEED);
}
/**
@@ -331,11 +323,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setRpm(Boolean rpm) {
- if (rpm != null) {
- parameters.put(KEY_RPM, rpm);
- } else {
- parameters.remove(KEY_RPM);
- }
+ setParameters(KEY_RPM, rpm);
}
/**
@@ -345,7 +333,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* unsubscribed.
*/
public Boolean getRpm() {
- return (Boolean) parameters.get(KEY_RPM);
+ return getBoolean(KEY_RPM);
}
/**
@@ -355,11 +343,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setFuelLevel(Boolean fuelLevel) {
- if (fuelLevel != null) {
- parameters.put(KEY_FUEL_LEVEL, fuelLevel);
- } else {
- parameters.remove(KEY_FUEL_LEVEL);
- }
+ setParameters(KEY_FUEL_LEVEL, fuelLevel);
}
/**
@@ -370,7 +354,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* been unsubscribed.
*/
public Boolean getFuelLevel() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL);
+ return getBoolean(KEY_FUEL_LEVEL);
}
/**
@@ -403,11 +387,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setFuelLevelState(Boolean fuelLevelState) {
- if (fuelLevelState != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevelState);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState);
}
/**
@@ -418,7 +398,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getFuelLevelState() {
- return (Boolean) parameters.get(KEY_FUEL_LEVEL_STATE);
+ return getBoolean(KEY_FUEL_LEVEL_STATE);
}
/**
@@ -428,11 +408,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setInstantFuelConsumption(Boolean instantFuelConsumption) {
- if (instantFuelConsumption != null) {
- parameters.put(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
- } else {
- parameters.remove(KEY_INSTANT_FUEL_CONSUMPTION);
- }
+ setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
}
/**
@@ -443,7 +419,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getInstantFuelConsumption() {
- return (Boolean) parameters.get(KEY_INSTANT_FUEL_CONSUMPTION);
+ return getBoolean(KEY_INSTANT_FUEL_CONSUMPTION);
}
/**
@@ -453,11 +429,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setExternalTemperature(Boolean externalTemperature) {
- if (externalTemperature != null) {
- parameters.put(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
- } else {
- parameters.remove(KEY_EXTERNAL_TEMPERATURE);
- }
+ setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
}
/**
@@ -468,7 +440,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getExternalTemperature() {
- return (Boolean) parameters.get(KEY_EXTERNAL_TEMPERATURE);
+ return getBoolean(KEY_EXTERNAL_TEMPERATURE);
}
/**
@@ -478,11 +450,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setPrndl(Boolean prndl) {
- if (prndl != null) {
- parameters.put(KEY_PRNDL, prndl);
- } else {
- parameters.remove(KEY_PRNDL);
- }
+ setParameters(KEY_PRNDL, prndl);
}
/**
@@ -493,7 +461,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getPrndl() {
- return (Boolean) parameters.get(KEY_PRNDL);
+ return getBoolean(KEY_PRNDL);
}
/**
@@ -503,11 +471,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setTirePressure(Boolean tirePressure) {
- if (tirePressure != null) {
- parameters.put(KEY_TIRE_PRESSURE, tirePressure);
- } else {
- parameters.remove(KEY_TIRE_PRESSURE);
- }
+ setParameters(KEY_TIRE_PRESSURE, tirePressure);
}
/**
@@ -518,7 +482,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getTirePressure() {
- return (Boolean) parameters.get(KEY_TIRE_PRESSURE);
+ return getBoolean(KEY_TIRE_PRESSURE);
}
/**
@@ -528,11 +492,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setOdometer(Boolean odometer) {
- if (odometer != null) {
- parameters.put(KEY_ODOMETER, odometer);
- } else {
- parameters.remove(KEY_ODOMETER);
- }
+ setParameters(KEY_ODOMETER, odometer);
}
/**
@@ -543,7 +503,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getOdometer() {
- return (Boolean) parameters.get(KEY_ODOMETER);
+ return getBoolean(KEY_ODOMETER);
}
/**
@@ -553,11 +513,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setBeltStatus(Boolean beltStatus) {
- if (beltStatus != null) {
- parameters.put(KEY_BELT_STATUS, beltStatus);
- } else {
- parameters.remove(KEY_BELT_STATUS);
- }
+ setParameters(KEY_BELT_STATUS, beltStatus);
}
/**
@@ -568,7 +524,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getBeltStatus() {
- return (Boolean) parameters.get(KEY_BELT_STATUS);
+ return getBoolean(KEY_BELT_STATUS);
}
/**
@@ -578,11 +534,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setBodyInformation(Boolean bodyInformation) {
- if (bodyInformation != null) {
- parameters.put(KEY_BODY_INFORMATION, bodyInformation);
- } else {
- parameters.remove(KEY_BODY_INFORMATION);
- }
+ setParameters(KEY_BODY_INFORMATION, bodyInformation);
}
/**
@@ -593,7 +545,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getBodyInformation() {
- return (Boolean) parameters.get(KEY_BODY_INFORMATION);
+ return getBoolean(KEY_BODY_INFORMATION);
}
/**
@@ -603,11 +555,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setDeviceStatus(Boolean deviceStatus) {
- if (deviceStatus != null) {
- parameters.put(KEY_DEVICE_STATUS, deviceStatus);
- } else {
- parameters.remove(KEY_DEVICE_STATUS);
- }
+ setParameters(KEY_DEVICE_STATUS, deviceStatus);
}
/**
@@ -618,7 +566,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getDeviceStatus() {
- return (Boolean) parameters.get(KEY_DEVICE_STATUS);
+ return getBoolean(KEY_DEVICE_STATUS);
}
/**
@@ -628,11 +576,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setDriverBraking(Boolean driverBraking) {
- if (driverBraking != null) {
- parameters.put(KEY_DRIVER_BRAKING, driverBraking);
- } else {
- parameters.remove(KEY_DRIVER_BRAKING);
- }
+ setParameters(KEY_DRIVER_BRAKING, driverBraking);
}
/**
@@ -643,7 +587,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getDriverBraking() {
- return (Boolean) parameters.get(KEY_DRIVER_BRAKING);
+ return getBoolean(KEY_DRIVER_BRAKING);
}
/**
@@ -653,11 +597,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setWiperStatus(Boolean wiperStatus) {
- if (wiperStatus != null) {
- parameters.put(KEY_WIPER_STATUS, wiperStatus);
- } else {
- parameters.remove(KEY_WIPER_STATUS);
- }
+ setParameters(KEY_WIPER_STATUS, wiperStatus);
}
/**
@@ -668,7 +608,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getWiperStatus() {
- return (Boolean) parameters.get(KEY_WIPER_STATUS);
+ return getBoolean(KEY_WIPER_STATUS);
}
/**
@@ -678,11 +618,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setHeadLampStatus(Boolean headLampStatus) {
- if (headLampStatus != null) {
- parameters.put(KEY_HEAD_LAMP_STATUS, headLampStatus);
- } else {
- parameters.remove(KEY_HEAD_LAMP_STATUS);
- }
+ setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus);
}
/**
@@ -693,7 +629,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getHeadLampStatus() {
- return (Boolean) parameters.get(KEY_HEAD_LAMP_STATUS);
+ return getBoolean(KEY_HEAD_LAMP_STATUS);
}
/**
@@ -703,11 +639,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setEngineTorque(Boolean engineTorque) {
- if (engineTorque != null) {
- parameters.put(KEY_ENGINE_TORQUE, engineTorque);
- } else {
- parameters.remove(KEY_ENGINE_TORQUE);
- }
+ setParameters(KEY_ENGINE_TORQUE, engineTorque);
}
/**
@@ -718,7 +650,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getEngineTorque() {
- return (Boolean) parameters.get(KEY_ENGINE_TORQUE);
+ return getBoolean(KEY_ENGINE_TORQUE);
}
/**
@@ -728,11 +660,7 @@ public class UnsubscribeVehicleData extends RPCRequest {
* a boolean value
*/
public void setAccPedalPosition(Boolean accPedalPosition) {
- if (accPedalPosition != null) {
- parameters.put(KEY_ACC_PEDAL_POSITION, accPedalPosition);
- } else {
- parameters.remove(KEY_ACC_PEDAL_POSITION);
- }
+ setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition);
}
/**
@@ -743,69 +671,45 @@ public class UnsubscribeVehicleData extends RPCRequest {
* has been unsubscribed.
*/
public Boolean getAccPedalPosition() {
- return (Boolean) parameters.get(KEY_ACC_PEDAL_POSITION);
+ return getBoolean(KEY_ACC_PEDAL_POSITION);
}
public void setSteeringWheelAngle(Boolean steeringWheelAngle) {
- if (steeringWheelAngle != null) {
- parameters.put(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
- } else {
- parameters.remove(KEY_STEERING_WHEEL_ANGLE);
- }
+ setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
}
public Boolean getSteeringWheelAngle() {
- return (Boolean) parameters.get(KEY_STEERING_WHEEL_ANGLE);
+ return getBoolean(KEY_STEERING_WHEEL_ANGLE);
}
public void setECallInfo(Boolean eCallInfo) {
- if (eCallInfo != null) {
- parameters.put(KEY_E_CALL_INFO, eCallInfo);
- } else {
- parameters.remove(KEY_E_CALL_INFO);
- }
+ setParameters(KEY_E_CALL_INFO, eCallInfo);
}
public Boolean getECallInfo() {
- return (Boolean) parameters.get(KEY_E_CALL_INFO);
+ return getBoolean(KEY_E_CALL_INFO);
}
public void setAirbagStatus(Boolean airbagStatus) {
- if (airbagStatus != null) {
- parameters.put(KEY_AIRBAG_STATUS, airbagStatus);
- } else {
- parameters.remove(KEY_AIRBAG_STATUS);
- }
+ setParameters(KEY_AIRBAG_STATUS, airbagStatus);
}
public Boolean getAirbagStatus() {
- return (Boolean) parameters.get(KEY_AIRBAG_STATUS);
+ return getBoolean(KEY_AIRBAG_STATUS);
}
public void setEmergencyEvent(Boolean emergencyEvent) {
- if (emergencyEvent != null) {
- parameters.put(KEY_EMERGENCY_EVENT, emergencyEvent);
- } else {
- parameters.remove(KEY_EMERGENCY_EVENT);
- }
+ setParameters(KEY_EMERGENCY_EVENT, emergencyEvent);
}
public Boolean getEmergencyEvent() {
- return (Boolean) parameters.get(KEY_EMERGENCY_EVENT);
+ return getBoolean(KEY_EMERGENCY_EVENT);
}
public void setClusterModeStatus(Boolean clusterModeStatus) {
- if (clusterModeStatus != null) {
- parameters.put(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
- } else {
- parameters.remove(KEY_CLUSTER_MODE_STATUS);
- }
+ setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
}
public Boolean getClusterModeStatus() {
- return (Boolean) parameters.get(KEY_CLUSTER_MODE_STATUS);
+ return getBoolean(KEY_CLUSTER_MODE_STATUS);
}
public void setMyKey(Boolean myKey) {
- if (myKey != null) {
- parameters.put(KEY_MY_KEY, myKey);
- } else {
- parameters.remove(KEY_MY_KEY);
- }
+ setParameters(KEY_MY_KEY, myKey);
}
public Boolean getMyKey() {
- return (Boolean) parameters.get(KEY_MY_KEY);
+ return getBoolean(KEY_MY_KEY);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java
index 92d9a46df..af3c94444 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UnsubscribeVehicleDataResponse.java
@@ -6,6 +6,8 @@ import com.smartdevicelink.protocol.enums.FunctionID;
import com.smartdevicelink.proxy.RPCResponse;
import com.smartdevicelink.util.DebugTool;
+import static android.provider.Contacts.SettingsColumns.KEY;
+
/**
* Unsubscribe Vehicle Data Response is sent, when UnsubscribeVehicleData has been called.
*
@@ -60,11 +62,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
* @param gps
*/
public void setGps(VehicleDataResult gps) {
- if (gps != null) {
- parameters.put(KEY_GPS, gps);
- } else {
- parameters.remove(KEY_GPS);
- }
+ setParameters(KEY_GPS, gps);
}
/**
* Gets Gps
@@ -72,28 +70,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getGps() {
- Object obj = parameters.get(KEY_GPS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_GPS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_GPS);
}
/**
* Sets Speed
* @param speed
*/
public void setSpeed(VehicleDataResult speed) {
- if (speed != null) {
- parameters.put(KEY_SPEED, speed);
- } else {
- parameters.remove(KEY_SPEED);
- }
+ setParameters(KEY_SPEED, speed);
}
/**
* Gets Speed
@@ -101,28 +85,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getSpeed() {
- Object obj = parameters.get(KEY_SPEED);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_SPEED, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_SPEED);
}
/**
* Sets rpm
* @param rpm
*/
public void setRpm(VehicleDataResult rpm) {
- if (rpm != null) {
- parameters.put(KEY_RPM, rpm);
- } else {
- parameters.remove(KEY_RPM);
- }
+ setParameters(KEY_RPM, rpm);
}
/**
* Gets rpm
@@ -130,28 +100,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getRpm() {
- Object obj = parameters.get(KEY_RPM);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_RPM, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_RPM);
}
/**
* Sets Fuel Level
* @param fuelLevel
*/
public void setFuelLevel(VehicleDataResult fuelLevel) {
- if (fuelLevel != null) {
- parameters.put(KEY_FUEL_LEVEL, fuelLevel);
- } else {
- parameters.remove(KEY_FUEL_LEVEL);
- }
+ setParameters(KEY_FUEL_LEVEL, fuelLevel);
}
/**
* Gets Fuel Level
@@ -159,17 +115,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getFuelLevel() {
- Object obj = parameters.get(KEY_FUEL_LEVEL);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_FUEL_LEVEL, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_LEVEL);
}
/**
* Sets Fuel Level State
@@ -192,11 +138,7 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
* @param fuelLevel_State
*/
public void setFuelLevelState(VehicleDataResult fuelLevelState) {
- if (fuelLevelState != null) {
- parameters.put(KEY_FUEL_LEVEL_STATE, fuelLevelState);
- } else {
- parameters.remove(KEY_FUEL_LEVEL_STATE);
- }
+ setParameters(KEY_FUEL_LEVEL_STATE, fuelLevelState);
}
/**
* Gets Fuel Level State
@@ -204,24 +146,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getFuelLevelState() {
- Object obj = parameters.get(KEY_FUEL_LEVEL_STATE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_FUEL_LEVEL_STATE);
}
/**
* Sets Instant Fuel Comsumption
* @param instantFuelConsumption
*/
public void setInstantFuelConsumption(VehicleDataResult instantFuelConsumption) {
- if (instantFuelConsumption != null) {
- parameters.put(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
- } else {
- parameters.remove(KEY_INSTANT_FUEL_CONSUMPTION);
- }
+ setParameters(KEY_INSTANT_FUEL_CONSUMPTION, instantFuelConsumption);
}
/**
* Gets Instant Fuel Comsumption
@@ -229,28 +161,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getInstantFuelConsumption() {
- Object obj = parameters.get(KEY_INSTANT_FUEL_CONSUMPTION);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_INSTANT_FUEL_CONSUMPTION, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_INSTANT_FUEL_CONSUMPTION);
}
/**
* Sets External Temperature
* @param externalTemperature
*/
public void setExternalTemperature(VehicleDataResult externalTemperature) {
- if (externalTemperature != null) {
- parameters.put(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
- } else {
- parameters.remove(KEY_EXTERNAL_TEMPERATURE);
- }
+ setParameters(KEY_EXTERNAL_TEMPERATURE, externalTemperature);
}
/**
* Gets External Temperature
@@ -258,28 +176,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getExternalTemperature() {
- Object obj = parameters.get(KEY_EXTERNAL_TEMPERATURE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EXTERNAL_TEMPERATURE, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_EXTERNAL_TEMPERATURE);
}
/**
* Gets currently selected gear data
* @param prndl
*/
public void setPrndl(VehicleDataResult prndl) {
- if (prndl != null) {
- parameters.put(KEY_PRNDL, prndl);
- } else {
- parameters.remove(KEY_PRNDL);
- }
+ setParameters(KEY_PRNDL, prndl);
}
/**
* Gets currently selected gear data
@@ -287,28 +191,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getPrndl() {
- Object obj = parameters.get(KEY_PRNDL);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_PRNDL, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_PRNDL);
}
/**
* Sets Tire Pressure
* @param tirePressure
*/
public void setTirePressure(VehicleDataResult tirePressure) {
- if (tirePressure != null) {
- parameters.put(KEY_TIRE_PRESSURE, tirePressure);
- } else {
- parameters.remove(KEY_TIRE_PRESSURE);
- }
+ setParameters(KEY_TIRE_PRESSURE, tirePressure);
}
/**
* Gets Tire Pressure
@@ -316,28 +206,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getTirePressure() {
- Object obj = parameters.get(KEY_TIRE_PRESSURE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_TIRE_PRESSURE, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_TIRE_PRESSURE);
}
/**
* Sets Odometer
* @param odometer
*/
public void setOdometer(VehicleDataResult odometer) {
- if (odometer != null) {
- parameters.put(KEY_ODOMETER, odometer);
- } else {
- parameters.remove(KEY_ODOMETER);
- }
+ setParameters(KEY_ODOMETER, odometer);
}
/**
* Gets Odometer
@@ -345,28 +221,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getOdometer() {
- Object obj = parameters.get(KEY_ODOMETER);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ODOMETER, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ODOMETER);
}
/**
* Sets Belt Status
* @param beltStatus
*/
public void setBeltStatus(VehicleDataResult beltStatus) {
- if (beltStatus != null) {
- parameters.put(KEY_BELT_STATUS, beltStatus);
- } else {
- parameters.remove(KEY_BELT_STATUS);
- }
+ setParameters(KEY_BELT_STATUS, beltStatus);
}
/**
* Gets Belt Status
@@ -374,28 +236,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getBeltStatus() {
- Object obj = parameters.get(KEY_BELT_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BELT_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_BELT_STATUS);
}
/**
* Sets Body Information
* @param bodyInformation
*/
public void setBodyInformation(VehicleDataResult bodyInformation) {
- if (bodyInformation != null) {
- parameters.put(KEY_BODY_INFORMATION, bodyInformation);
- } else {
- parameters.remove(KEY_BODY_INFORMATION);
- }
+ setParameters(KEY_BODY_INFORMATION, bodyInformation);
}
/**
* Gets Body Information
@@ -403,28 +251,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getBodyInformation() {
- Object obj = parameters.get(KEY_BODY_INFORMATION);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_BODY_INFORMATION, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_BODY_INFORMATION);
}
/**
* Sets Device Status
* @param deviceStatus
*/
public void setDeviceStatus(VehicleDataResult deviceStatus) {
- if (deviceStatus != null) {
- parameters.put(KEY_DEVICE_STATUS, deviceStatus);
- } else {
- parameters.remove(KEY_DEVICE_STATUS);
- }
+ setParameters(KEY_DEVICE_STATUS, deviceStatus);
}
/**
* Gets Device Status
@@ -432,28 +266,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getDeviceStatus() {
- Object obj = parameters.get(KEY_DEVICE_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DEVICE_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_DEVICE_STATUS);
}
/**
* Sets Driver Braking
* @param driverBraking
*/
public void setDriverBraking(VehicleDataResult driverBraking) {
- if (driverBraking != null) {
- parameters.put(KEY_DRIVER_BRAKING, driverBraking);
- } else {
- parameters.remove(KEY_DRIVER_BRAKING);
- }
+ setParameters(KEY_DRIVER_BRAKING, driverBraking);
}
/**
* Gets Driver Braking
@@ -461,28 +281,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getDriverBraking() {
- Object obj = parameters.get(KEY_DRIVER_BRAKING);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_DRIVER_BRAKING, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_DRIVER_BRAKING);
}
/**
* Sets Wiper Status
* @param wiperStatus
*/
public void setWiperStatus(VehicleDataResult wiperStatus) {
- if (wiperStatus != null) {
- parameters.put(KEY_WIPER_STATUS, wiperStatus);
- } else {
- parameters.remove(KEY_WIPER_STATUS);
- }
+ setParameters(KEY_WIPER_STATUS, wiperStatus);
}
/**
* Gets Wiper Status
@@ -490,28 +296,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getWiperStatus() {
- Object obj = parameters.get(KEY_WIPER_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_WIPER_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_WIPER_STATUS);
}
/**
* Sets Head Lamp Status
* @param headLampStatus
*/
public void setHeadLampStatus(VehicleDataResult headLampStatus) {
- if (headLampStatus != null) {
- parameters.put(KEY_HEAD_LAMP_STATUS, headLampStatus);
- } else {
- parameters.remove(KEY_HEAD_LAMP_STATUS);
- }
+ setParameters(KEY_HEAD_LAMP_STATUS, headLampStatus);
}
/**
* Gets Head Lamp Status
@@ -519,28 +311,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getHeadLampStatus() {
- Object obj = parameters.get(KEY_HEAD_LAMP_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_HEAD_LAMP_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_HEAD_LAMP_STATUS);
}
/**
* Sets Engine Torque
* @param engineTorque
*/
public void setEngineTorque(VehicleDataResult engineTorque) {
- if (engineTorque != null) {
- parameters.put(KEY_ENGINE_TORQUE, engineTorque);
- } else {
- parameters.remove(KEY_ENGINE_TORQUE);
- }
+ setParameters(KEY_ENGINE_TORQUE, engineTorque);
}
/**
* Gets Engine Torque
@@ -548,28 +326,14 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getEngineTorque() {
- Object obj = parameters.get(KEY_ENGINE_TORQUE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ENGINE_TORQUE, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ENGINE_TORQUE);
}
/**
* Sets AccPedal Position
* @param accPedalPosition
*/
public void setAccPedalPosition(VehicleDataResult accPedalPosition) {
- if (accPedalPosition != null) {
- parameters.put(KEY_ACC_PEDAL_POSITION, accPedalPosition);
- } else {
- parameters.remove(KEY_ACC_PEDAL_POSITION);
- }
+ setParameters(KEY_ACC_PEDAL_POSITION, accPedalPosition);
}
/**
* Gets AccPedal Position
@@ -577,145 +341,51 @@ public class UnsubscribeVehicleDataResponse extends RPCResponse {
*/
@SuppressWarnings("unchecked")
public VehicleDataResult getAccPedalPosition() {
- Object obj = parameters.get(KEY_ACC_PEDAL_POSITION);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_ACC_PEDAL_POSITION, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_ACC_PEDAL_POSITION);
}
public void setSteeringWheelAngle(VehicleDataResult steeringWheelAngle) {
- if (steeringWheelAngle != null) {
- parameters.put(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
- } else {
- parameters.remove(KEY_STEERING_WHEEL_ANGLE);
- }
+ setParameters(KEY_STEERING_WHEEL_ANGLE, steeringWheelAngle);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getSteeringWheelAngle() {
- Object obj = parameters.get(KEY_STEERING_WHEEL_ANGLE);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_STEERING_WHEEL_ANGLE, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_STEERING_WHEEL_ANGLE);
}
public void setECallInfo(VehicleDataResult eCallInfo) {
- if (eCallInfo != null) {
- parameters.put(KEY_E_CALL_INFO, eCallInfo);
- } else {
- parameters.remove(KEY_E_CALL_INFO);
- }
+ setParameters(KEY_E_CALL_INFO, eCallInfo);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getECallInfo() {
- Object obj = parameters.get(KEY_E_CALL_INFO);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_E_CALL_INFO, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_E_CALL_INFO);
}
public void setAirbagStatus(VehicleDataResult airbagStatus) {
- if (airbagStatus != null) {
- parameters.put(KEY_AIRBAG_STATUS, airbagStatus);
- } else {
- parameters.remove(KEY_AIRBAG_STATUS);
- }
+ setParameters(KEY_AIRBAG_STATUS, airbagStatus);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getAirbagStatus() {
- Object obj = parameters.get(KEY_AIRBAG_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_AIRBAG_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_AIRBAG_STATUS);
}
public void setEmergencyEvent(VehicleDataResult emergencyEvent) {
- if (emergencyEvent != null) {
- parameters.put(KEY_EMERGENCY_EVENT, emergencyEvent);
- } else {
- parameters.remove(KEY_EMERGENCY_EVENT);
- }
+ setParameters(KEY_EMERGENCY_EVENT, emergencyEvent);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getEmergencyEvent() {
- Object obj = parameters.get(KEY_EMERGENCY_EVENT);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_EMERGENCY_EVENT, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_EMERGENCY_EVENT);
}
public void setClusterModeStatus(VehicleDataResult clusterModeStatus) {
- if (clusterModeStatus != null) {
- parameters.put(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
- } else {
- parameters.remove(KEY_CLUSTER_MODE_STATUS);
- }
+ setParameters(KEY_CLUSTER_MODE_STATUS, clusterModeStatus);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getClusterModeStatus() {
- Object obj = parameters.get(KEY_CLUSTER_MODE_STATUS);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_CLUSTER_MODE_STATUS, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_CLUSTER_MODE_STATUS);
}
public void setMyKey(VehicleDataResult myKey) {
- if (myKey != null) {
- parameters.put(KEY_MY_KEY, myKey);
- } else {
- parameters.remove(KEY_MY_KEY);
- }
+ setParameters(KEY_MY_KEY, myKey);
}
@SuppressWarnings("unchecked")
public VehicleDataResult getMyKey() {
- Object obj = parameters.get(KEY_MY_KEY);
- if (obj instanceof VehicleDataResult) {
- return (VehicleDataResult) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new VehicleDataResult((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_MY_KEY, e);
- }
- }
- return null;
+ return (VehicleDataResult) getObject(VehicleDataResult.class, KEY_MY_KEY);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java
index ad2b41163..cb1dde7e4 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/UpdateTurnList.java
@@ -1,12 +1,11 @@
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 java.util.Hashtable;
+import java.util.List;
+
/**
* Updates the list of next maneuvers, which can be requested by the user pressing the softbutton "Turns" on the
* Navigation base screen. Three softbuttons are predefined by the system: Up, Down, Close
@@ -52,12 +51,7 @@ public class UpdateTurnList extends RPCRequest{
* <b>Notes: </b>Minsize=1; Maxsize=100</p>
*/
public void setTurnList(List<Turn> turnList){
- if(turnList != null){
- parameters.put(KEY_TURN_LIST, turnList);
- }
- else{
- parameters.remove(KEY_TURN_LIST);
- }
+ setParameters(KEY_TURN_LIST, turnList);
}
/**
@@ -67,23 +61,7 @@ public class UpdateTurnList extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public List<Turn> getTurnList(){
- 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;
- }
- }
- }
- return null;
+ return (List<Turn>) getObject(Turn.class, KEY_TURN_LIST);
}
/**
@@ -94,23 +72,7 @@ public class UpdateTurnList extends RPCRequest{
*/
@SuppressWarnings("unchecked")
public List<SoftButton> getSoftButtons(){
- if(parameters.get(KEY_SOFT_BUTTONS) instanceof List<?>){
- List<?> list = (List<?>) parameters.get(KEY_SOFT_BUTTONS);
- if(list != null && list.size() > 0){
- Object obj = list.get(0);
- if(obj instanceof SoftButton){
- return (List<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;
- }
- }
- }
- return null;
+ return (List<SoftButton>) getObject(SoftButton.class, KEY_SOFT_BUTTONS);
}
/**
@@ -129,12 +91,7 @@ public class UpdateTurnList extends RPCRequest{
*/
public void setSoftButtons(List<SoftButton> softButtons){
- if(softButtons != null){
- parameters.put(KEY_SOFT_BUTTONS, softButtons);
- }
- else{
- parameters.remove(KEY_SOFT_BUTTONS);
- }
+ setParameters(KEY_SOFT_BUTTONS, softButtons);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java
index ef466d727..c0965cd39 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleDataResult.java
@@ -57,35 +57,15 @@ public class VehicleDataResult extends RPCStruct {
super(hash);
}
public void setDataType(VehicleDataType dataType) {
- if (dataType != null) {
- store.put(KEY_DATA_TYPE, dataType);
- } else {
- store.remove(KEY_DATA_TYPE);
- }
+ setValue(KEY_DATA_TYPE, dataType);
}
public VehicleDataType getDataType() {
- Object obj = store.get(KEY_DATA_TYPE);
- if (obj instanceof VehicleDataType) {
- return (VehicleDataType) obj;
- } else if (obj instanceof String) {
- return VehicleDataType.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataType) getObject(VehicleDataType.class, KEY_DATA_TYPE);
}
public void setResultCode(VehicleDataResultCode resultCode) {
- if (resultCode != null) {
- store.put(KEY_RESULT_CODE, resultCode);
- } else {
- store.remove(KEY_RESULT_CODE);
- }
+ setValue(KEY_RESULT_CODE, resultCode);
}
public VehicleDataResultCode getResultCode() {
- Object obj = store.get(KEY_RESULT_CODE);
- if (obj instanceof VehicleDataResultCode) {
- return (VehicleDataResultCode) obj;
- } else if (obj instanceof String) {
- return VehicleDataResultCode.valueForString((String) obj);
- }
- return null;
+ return (VehicleDataResultCode) getObject(VehicleDataResultCode.class, KEY_RESULT_CODE);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java
index 3f30774c4..e6f860007 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VehicleType.java
@@ -1,9 +1,9 @@
package com.smartdevicelink.proxy.rpc;
-import java.util.Hashtable;
-
import com.smartdevicelink.proxy.RPCStruct;
+import java.util.Hashtable;
+
/**
* Describes the type of vehicle the mobile phone is connected with.
* <p><b>Parameter List</b></p>
@@ -81,7 +81,7 @@ public class VehicleType extends RPCStruct {
* @return the make of the vehicle
*/
public String getMake() {
- return (String) store.get(KEY_MAKE);
+ return getString(KEY_MAKE);
}
/**
@@ -89,11 +89,7 @@ public class VehicleType extends RPCStruct {
*@param make the make of the vehicle
*/
public void setMake(String make) {
- if (make != null) {
- store.put(KEY_MAKE, make);
- } else {
- store.remove(KEY_MAKE);
- }
+ setValue(KEY_MAKE, make);
}
/**
@@ -101,7 +97,7 @@ public class VehicleType extends RPCStruct {
* @return the model of the vehicle
*/
public String getModel() {
- return (String) store.get(KEY_MODEL);
+ return getString(KEY_MODEL);
}
/**
@@ -109,11 +105,7 @@ public class VehicleType extends RPCStruct {
* @param model the model of the vehicle
*/
public void setModel(String model) {
- if (model != null) {
- store.put(KEY_MODEL, model);
- } else {
- store.remove(KEY_MODEL);
- }
+ setValue(KEY_MODEL, model);
}
/**
@@ -121,7 +113,7 @@ public class VehicleType extends RPCStruct {
* @return the model year of the vehicle
*/
public String getModelYear() {
- return (String) store.get(KEY_MODEL_YEAR);
+ return getString(KEY_MODEL_YEAR);
}
/**
@@ -129,11 +121,7 @@ public class VehicleType extends RPCStruct {
* @param modelYear the model year of the vehicle
*/
public void setModelYear(String modelYear) {
- if (modelYear != null) {
- store.put(KEY_MODEL_YEAR, modelYear);
- } else {
- store.remove(KEY_MODEL_YEAR);
- }
+ setValue(KEY_MODEL_YEAR, modelYear);
}
/**
@@ -141,7 +129,7 @@ public class VehicleType extends RPCStruct {
* @return the trim of the vehicle
*/
public String getTrim() {
- return (String) store.get(KEY_TRIM);
+ return getString(KEY_TRIM);
}
/**
@@ -149,10 +137,6 @@ public class VehicleType extends RPCStruct {
* @param trim the trim of the vehicle
*/
public void setTrim(String trim) {
- if (trim != null) {
- store.put(KEY_TRIM, trim);
- } else {
- store.remove(KEY_TRIM);
- }
+ setValue(KEY_TRIM, trim);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java
new file mode 100644
index 000000000..6600cf38d
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingCapability.java
@@ -0,0 +1,52 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+
+import java.util.Hashtable;
+import java.util.List;
+
+/**
+ * Contains information about this system's video streaming capabilities.
+ */
+
+public class VideoStreamingCapability extends RPCStruct {
+ public static final String KEY_PREFERRED_RESOLUTION = "preferredResolution";
+ public static final String KEY_MAX_BITRATE = "maxBitrate";
+ public static final String KEY_SUPPORTED_FORMATS = "supportedFormats";
+ public static final String KEY_HAPTIC_SPATIAL_DATA_SUPPORTED = "hapticSpatialDataSupported";
+
+ public VideoStreamingCapability(){}
+ public VideoStreamingCapability(Hashtable<String, Object> hash){super(hash);}
+
+ public void setPreferredResolution(ImageResolution res){
+ setValue(KEY_PREFERRED_RESOLUTION, res);
+ }
+
+ public ImageResolution getPreferredResolution(){
+ return (ImageResolution) getObject(ImageResolution.class, KEY_PREFERRED_RESOLUTION);
+ }
+
+ public void setMaxBitrate(Integer maxBitrate){
+ setValue(KEY_MAX_BITRATE, maxBitrate);
+ }
+
+ public Integer getMaxBitrate(){
+ return getInteger(KEY_MAX_BITRATE);
+ }
+
+ public void setSupportedFormats(List<VideoStreamingFormat> formats){
+ setValue(KEY_SUPPORTED_FORMATS, formats);
+ }
+
+ public List<VideoStreamingFormat> getSupportedFormats(){
+ return (List<VideoStreamingFormat>) getObject(VideoStreamingFormat.class, KEY_SUPPORTED_FORMATS);
+ }
+
+ public Boolean getIsHapticSpatialDataSupported() {
+ return getBoolean(KEY_HAPTIC_SPATIAL_DATA_SUPPORTED);
+ }
+
+ public void setIsHapticSpatialDataSupported(Boolean hapticSpatialDataSupported) {
+ setValue(KEY_HAPTIC_SPATIAL_DATA_SUPPORTED, hapticSpatialDataSupported);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingFormat.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingFormat.java
new file mode 100644
index 000000000..8f88b3ea8
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VideoStreamingFormat.java
@@ -0,0 +1,46 @@
+package com.smartdevicelink.proxy.rpc;
+
+import com.smartdevicelink.proxy.RPCStruct;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
+
+import java.util.Hashtable;
+
+/**
+ * Video streaming formats and their specifications.
+ */
+
+public class VideoStreamingFormat extends RPCStruct {
+ public static final String KEY_PROTOCOL = "protocol";
+ public static final String KEY_CODEC = "codec";
+
+ public VideoStreamingFormat(){}
+ public VideoStreamingFormat(Hashtable<String, Object> hash){super(hash);}
+
+ public VideoStreamingFormat(VideoStreamingCodec codec,VideoStreamingProtocol protocol){
+ setCodec(codec);
+ setProtocol(protocol);
+ }
+
+ public void setProtocol(VideoStreamingProtocol protocol){
+ setValue(KEY_PROTOCOL, protocol);
+ }
+
+ public VideoStreamingProtocol getProtocol(){
+ return (VideoStreamingProtocol) getObject(VideoStreamingProtocol.class, KEY_PROTOCOL);
+ }
+
+ public void setCodec(VideoStreamingCodec codec){
+ setValue(KEY_CODEC, codec);
+ }
+
+ public VideoStreamingCodec getCodec(){
+ return (VideoStreamingCodec) getObject(VideoStreamingCodec.class, KEY_CODEC);
+ }
+
+ @Override
+ public String toString() {
+ return "codec=" + String.valueOf(getCodec()) +
+ ", protocol=" + String.valueOf(getProtocol());
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java
index f195b4cae..00474cd06 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/VrHelpItem.java
@@ -65,44 +65,22 @@ public class VrHelpItem extends RPCStruct {
super(hash);
}
public void setText(String text) {
- if (text != null) {
- store.put(KEY_TEXT, text);
- } else {
- store.remove(KEY_TEXT);
- }
+ setValue(KEY_TEXT, text);
}
public String getText() {
- return (String) store.get(KEY_TEXT);
+ return getString(KEY_TEXT);
}
public void setImage(Image image) {
- if (image != null) {
- store.put(KEY_IMAGE, image);
- } else {
- store.remove(KEY_IMAGE);
- }
+ setValue(KEY_IMAGE, image);
}
@SuppressWarnings("unchecked")
public Image getImage() {
- Object obj = store.get(KEY_IMAGE);
- if (obj instanceof Image) {
- return (Image) obj;
- } else if (obj instanceof Hashtable) {
- try {
- return new Image((Hashtable<String, Object>) obj);
- } catch (Exception e) {
- DebugTool.logError("Failed to parse " + getClass().getSimpleName() + "." + KEY_IMAGE, e);
- }
- }
- return null;
+ return (Image) getObject(Image.class, KEY_IMAGE);
}
public void setPosition(Integer position) {
- if (position != null) {
- store.put(KEY_POSITION, position);
- } else {
- store.remove(KEY_POSITION);
- }
+ setValue(KEY_POSITION, position);
}
public Integer getPosition() {
- return (Integer) store.get(KEY_POSITION);
+ return getInteger(KEY_POSITION);
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/AppHMIType.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/AppHMIType.java
index a6aed67d9..0a4f56255 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/AppHMIType.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/AppHMIType.java
@@ -39,9 +39,18 @@ public enum AppHMIType {
*/
TESTING,
/**
+ * Custom App Interfaces
+ */
+ PROJECTION,
+ /**
* System App
*/
- SYSTEM;
+ SYSTEM,
+ /**
+ * Remote Control
+ */
+ REMOTE_CONTROL,
+ ;
/**
* Convert String to AppHMIType
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ButtonName.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ButtonName.java
index 1391a9d44..f478a78ee 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ButtonName.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ButtonName.java
@@ -115,7 +115,28 @@ public enum ButtonName{
*
* @since SmartDeviceLink 1.0
*/
- PRESET_9, CUSTOM_BUTTON, SEARCH;
+ PRESET_9,
+ CUSTOM_BUTTON,
+ SEARCH,
+ AC_MAX,
+ AC,
+ RECIRCULATE,
+ FAN_UP,
+ FAN_DOWN,
+ TEMP_UP,
+ TEMP_DOWN,
+ DEFROST_MAX,
+ DEFROST,
+ DEFROST_REAR,
+ UPPER_VENT,
+ LOWER_VENT,
+ VOLUME_UP,
+ VOLUME_DOWN,
+ EJECT,
+ SOURCE,
+ SHUFFLE,
+ REPEAT,
+ ;
public static ButtonName valueForString(String value) {
try{
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/DefrostZone.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/DefrostZone.java
new file mode 100644
index 000000000..4c6b15e85
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/DefrostZone.java
@@ -0,0 +1,17 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+public enum DefrostZone {
+ FRONT,
+ REAR,
+ ALL,
+ NONE,
+ ;
+
+ public static DefrostZone valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Language.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Language.java
index 5f0a0b88f..4ac4f6264 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Language.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Language.java
@@ -11,6 +11,83 @@ import java.util.EnumSet;
*/
public enum Language {
/**
+ * English - SA
+ */
+
+ EN_SA("EN-SA"),
+
+ /**
+ * Hebrew - IL
+ */
+
+ HE_IL("HE-IL"),
+
+ /**
+ * Romanian - RO
+ */
+
+ RO_RO("RO-RO"),
+
+ /**
+ * Ukrainian - UA
+ */
+
+ UK_UA("UK-UA"),
+
+ /**
+ * Indonesian - ID
+ */
+
+ ID_ID("ID-ID"),
+
+ /**
+ * Vietnamese - VN
+ */
+
+ VI_VN("VI-VN"),
+
+ /**
+ * Malay - MY
+ */
+
+ MS_MY("MS-MY"),
+
+ /**
+ * Hindi - IN
+ */
+
+ HI_IN("HI-IN"),
+
+ /**
+ * Dutch - BE
+ */
+
+ NL_BE("NL-BE"),
+
+ /**
+ * Greek - GR
+ */
+
+ EL_GR("EL-GR"),
+
+ /**
+ * Hungarian - HU
+ */
+
+ HU_HU("HU-HU"),
+
+ /**
+ * Finnish - FI
+ */
+
+ FI_FI("FI-FI"),
+
+ /**
+ * Slovak - SK
+ */
+
+ SK_SK("SK-SK"),
+ /**
* English - US
*/
@@ -129,7 +206,17 @@ public enum Language {
* Norwegian - Norway
*/
- NO_NO("NO-NO");
+ NO_NO("NO-NO"),
+ /**
+ * English - India
+ */
+
+ EN_IN("EN-IN"),
+ /**
+ * Thai - Thailand
+ */
+
+ TH_TH("TH-TH");
private final String INTERNAL_NAME;
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/MetadataType.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/MetadataType.java
new file mode 100644
index 000000000..9f51a6437
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/MetadataType.java
@@ -0,0 +1,96 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+import java.util.EnumSet;
+
+/**
+ * Defines the metadata types that can be applied to text fields
+ *
+ */
+public enum MetadataType {
+
+ /**
+ * The data in this field contains the title of the currently playing audio track.
+ */
+ MEDIA_TITLE("mediaTitle"),
+
+ /**
+ * The data in this field contains the artist or creator of the currently playing audio track.
+ */
+ MEDIA_ARTIST("mediaArtist"),
+
+ /**
+ * The data in this field contains the album title of the currently playing audio track.
+ */
+ MEDIA_ALBUM("mediaAlbum"),
+
+ /**
+ * The data in this field contains the creation year of the currently playing audio track.
+ */
+ MEDIA_YEAR("mediaYear"),
+
+ /**
+ * The data in this field contains the genre of the currently playing audio track.
+ */
+ MEDIA_GENRE("mediaGenre"),
+
+ /**
+ * The data in this field contains the name of the current source for the media.
+ */
+ MEDIA_STATION("mediaStation"),
+
+ /**
+ * The data in this field is a rating.
+ */
+ RATING("rating"),
+
+ /**
+ * The data in this field is the current temperature.
+ */
+ CURRENT_TEMPERATURE("currentTemperature"),
+
+ /**
+ * The data in this field is the maximum temperature for the day.
+ */
+ MAXIMUM_TEMPERATURE("maximumTemperature"),
+
+ /**
+ * The data in this field is the minimum temperature for the day.
+ */
+ MINIMUM_TEMPERATURE("minimumTemperature"),
+
+ /**
+ * The data in this field describes the current weather (ex. cloudy, clear, etc.).
+ */
+ WEATHER_TERM("weatherTerm"),
+
+ /**
+ * The data in this field describes the current humidity value.
+ */
+ HUMIDITY("humidity"),
+
+
+ ;
+
+ private final String internalName;
+
+ private MetadataType(String internalName) {
+ this.internalName = internalName;
+ }
+
+ public String toString() {
+ return this.internalName;
+ }
+
+ public static MetadataType valueForString(String value) {
+ if(value == null){
+ return null;
+ }
+
+ for (MetadataType anEnum : EnumSet.allOf(MetadataType.class)) {
+ if (anEnum.toString().equals(value)) {
+ return anEnum;
+ }
+ }
+ return null;
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ModuleType.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ModuleType.java
new file mode 100644
index 000000000..faef92d36
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/ModuleType.java
@@ -0,0 +1,15 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+public enum ModuleType {
+ CLIMATE,
+ RADIO,
+ ;
+
+ public static ModuleType valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RadioBand.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RadioBand.java
new file mode 100644
index 000000000..2b2c862d8
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RadioBand.java
@@ -0,0 +1,16 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+public enum RadioBand {
+ AM,
+ FM,
+ XM,
+ ;
+
+ public static RadioBand valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RadioState.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RadioState.java
new file mode 100644
index 000000000..533c86dca
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/RadioState.java
@@ -0,0 +1,20 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+/**
+ * List possible states of a remote control radio module.
+ */
+public enum RadioState {
+ ACQUIRING,
+ ACQUIRED,
+ MULTICAST,
+ NOT_FOUND,
+ ;
+
+ public static RadioState valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java
index 870e4115e..c0a15f235 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/Result.java
@@ -168,7 +168,16 @@ public enum Result {
/**
* 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;
+ RESUME_FAILED,
+ /**
+ * The requested data is not available on this vehicle or is not published for the connected app.
+ */
+ DATA_NOT_AVAILABLE,
+ /**
+ * The requested data is read only thus cannot be change via remote control
+ */
+ READ_ONLY,
+ ;
/**
* Convert String to Result
* @param value String
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java
new file mode 100644
index 000000000..4ab61102d
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/SystemCapabilityType.java
@@ -0,0 +1,400 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+/**
+ * <p>The SystemCapabilityType indicates which type of capability information exists in a SystemCapability struct.</p>
+ *
+ * <p><b>Enum List</b></p>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>NAVIGATION</td>
+ * <td>NavigationCapability</td>
+ * <td>Returns Navigation Capabilities</td>
+ * <td align=center>Y</td>
+ * <td>Call is synchronous <strong>after</strong> initial call</td>
+ * </tr>
+ * <tr>
+ * <td>PHONE_CALL</td>
+ * <td>PhoneCapability</td>
+ * <td>Returns Phone Capabilities</td>
+ * <td align=center>Y</td>
+ * <td>Call is synchronous <strong>after</strong> initial call</td>
+ * </tr>
+ * <tr>
+ * <td>VIDEO_STREAMING</td>
+ * <td>VideoStreamingCapability</td>
+ * <td>Returns Video Streaming Capabilities</td>
+ * <td align=center>Y</td>
+ * <td>Call is synchronous <strong>after</strong> initial call</td>
+ * </tr>
+ * <tr>
+ * <td>REMOTE_CONTROL</td>
+ * <td>RemoteControlCapabilities</td>
+ * <td>Returns Remote Control Capabilities</td>
+ * <td align=center>Y</td>
+ * <td>Call is synchronous <strong>after</strong> initial call</td>
+ * </tr>
+ * <tr>
+ * <td>HMI</td>
+ * <td>HMICapabilities</td>
+ * <td>Returns HMI Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * <tr>
+ * <td>DISPLAY</td>
+ * <td>DisplayCapabilities</td>
+ * <td>Returns Display Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * <tr>
+ * <td>AUDIO_PASSTHROUGH</td>
+ * <td>List<AudioPassThruCapabilities></td>
+ * <td>Returns a List of AudioPassThruCapabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response. @SuppressWarnings("unchecked") may be needed when casting depending on implementation</td>
+ * </tr>
+ * <tr>
+ * <td>BUTTON</td>
+ * <td>List<ButtonCapabilities></td>
+ * <td>Returns a List of ButtonCapabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response. @SuppressWarnings("unchecked") may be needed when casting depending on implementation</td>
+ * </tr>
+ * <tr>
+ * <td>HMI_ZONE</td>
+ * <td>HmiZoneCapabilities</td>
+ * <td>Returns HmiZone Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * <tr>
+ * <td>PRESET_BANK</td>
+ * <td>PresetBankCapabilities</td>
+ * <td>Returns PresetBank Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * <tr>
+ * <td>SOFTBUTTON</td>
+ * <td>List<SoftButtonCapabilities></td>
+ * <td>Returns a List of SoftButtonCapabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response. @SuppressWarnings("unchecked") may be needed when casting depending on implementation</td>
+ * </tr>
+ * <tr>
+ * <td>SPEECH</td>
+ * <td>SpeechCapabilities</td>
+ * <td>Returns Speech Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * <tr>
+ * <td>VOICE_RECOGNITION</td>
+ * <td>VrCapabilities</td>
+ * <td>Returns VOICE_RECOGNITION</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * </table>
+ *
+ */
+
+public enum SystemCapabilityType {
+
+ /**
+ * <strong>Requires</strong> initial asynchronous call, then available synchronously after successful call. <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>NAVIGATION</td>
+ * <td>NavigationCapability</td>
+ * <td>Returns Navigation Capabilities</td>
+ * <td align=center>Y</td>
+ * <td>Call is synchronous <strong>after</strong> initial call</td>
+ * </tr>
+ * </table>
+ */
+ NAVIGATION,
+
+ /**
+ * <strong>Requires</strong> initial asynchronous call, then available synchronously after successful call. <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>PHONE_CALL</td>
+ * <td>PhoneCapability</td>
+ * <td>Returns Phone Capabilities</td>
+ * <td align=center>Y</td>
+ * <td>Call is synchronous <strong>after</strong> initial call</td>
+ * </tr>
+ * </table>
+ */
+ PHONE_CALL,
+
+ /**
+ * <strong>Requires</strong> initial asynchronous call, then available synchronously after successful call. <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>VIDEO_STREAMING</td>
+ * <td>VideoStreamingCapability</td>
+ * <td>Returns Video Streaming Capabilities</td>
+ * <td align=center>Y</td>
+ * <td>Call is synchronous <strong>after</strong> initial call</td>
+ * </tr>
+ * </table>
+ */
+ VIDEO_STREAMING,
+
+ /**
+ * <strong>Requires</strong> initial asynchronous call, then available synchronously after successful call. <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <td>REMOTE_CONTROL</td>
+ * <td>RemoteControlCapabilities</td>
+ * <td>Returns Remote Control Capabilities</td>
+ * <td align=center>Y</td>
+ * <td>Call is synchronous <strong>after</strong> initial call</td>
+ * </tr>
+ * </table>
+ *
+ */
+ REMOTE_CONTROL,
+
+ /* These below are not part of the RPC spec. Only for Internal Proxy use */
+
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>HMI</td>
+ * <td>HMICapabilities</td>
+ * <td>Returns HMI Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * </table>
+ */
+ HMI,
+
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * Returns: DisplayCapabilities
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>DISPLAY</td>
+ * <td>DisplayCapabilities</td>
+ * <td>Returns Display Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response received</td>
+ * </tr>
+ * </table>
+ */
+ DISPLAY,
+
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * <b>Note:</b> @SuppressWarnings("unchecked") may be needed when casting depending on implementation
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>AUDIO_PASSTHROUGH</td>
+ * <td>List<AudioPassThruCapabilities></td>
+ * <td>Returns a List of AudioPassThruCapabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response. @SuppressWarnings("unchecked") may be needed when casting depending on implementation</td>
+ * </tr>
+ * </table>
+ */
+ AUDIO_PASSTHROUGH,
+
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * <b>Note:</b> @SuppressWarnings("unchecked") may be needed when casting depending on implementation
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>BUTTON</td>
+ * <td>List<ButtonCapabilities></td>
+ * <td>Returns a List of ButtonCapabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response. @SuppressWarnings("unchecked") may be needed when casting depending on implementation</td>
+ * </tr>
+ * </table>
+ */
+ BUTTON,
+
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>HMI_ZONE</td>
+ * <td>HmiZoneCapabilities</td>
+ * <td>Returns HmiZone Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * </table>
+ */
+ HMI_ZONE,
+
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>PRESET_BANK</td>
+ * <td>PresetBankCapabilities</td>
+ * <td>Returns PresetBank Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * </table>
+ */
+ PRESET_BANK,
+
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * Returns: List<SoftButtonCapabilities> <br>
+ * Note: @SuppressWarnings("unchecked") may be needed when casting depending on implementation
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>SOFTBUTTON</td>
+ * <td>List<SoftButtonCapabilities></td>
+ * <td>Returns a List of SoftButtonCapabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response. @SuppressWarnings("unchecked") may be needed when casting depending on implementation</td>
+ * </tr>
+ * </table>
+ */
+ SOFTBUTTON,
+
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>SPEECH</td>
+ * <td>SpeechCapabilities</td>
+ * <td>Returns Speech Capabilities</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * </table>
+ */
+ SPEECH,
+ /**
+ * Available Synchronously after Register App Interface response <br>
+ * <table border="1" rules="all">
+ * <tr>
+ * <th>Enum Name</th>
+ * <th>Return Type</th>
+ * <th>Description</th>
+ * <th>Requires Async?</th>
+ * <th>Notes</th>
+ * </tr>
+ * <tr>
+ * <td>VOICE_RECOGNITION</td>
+ * <td>VrCapabilities</td>
+ * <td>Returns VOICE_RECOGNITION</td>
+ * <td align=center>N</td>
+ * <td>Available Synchronously <strong>after</strong> Register App Interface response</td>
+ * </tr>
+ * </table>
+ */
+ VOICE_RECOGNITION,
+
+ ;
+
+ public static SystemCapabilityType valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TemperatureUnit.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TemperatureUnit.java
new file mode 100644
index 000000000..6c9b04875
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TemperatureUnit.java
@@ -0,0 +1,14 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+public enum TemperatureUnit {
+ CELSIUS,
+ FAHRENHEIT;
+
+ public static TemperatureUnit valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TouchType.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TouchType.java
index 952904915..7cc259aa4 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TouchType.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/TouchType.java
@@ -20,7 +20,11 @@ public enum TouchType {
*
*/
- END;
+ END,
+ /** The user has made a cancellation gesture.
+ *
+ */
+ CANCEL;
/**
* Convert String to TouchType
* @param value String
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VentilationMode.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VentilationMode.java
new file mode 100644
index 000000000..b7a2ae9a2
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VentilationMode.java
@@ -0,0 +1,17 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+public enum VentilationMode {
+ UPPER,
+ LOWER,
+ BOTH,
+ NONE,
+ ;
+
+ public static VentilationMode valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VideoStreamingCodec.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VideoStreamingCodec.java
new file mode 100644
index 000000000..a41c1d064
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VideoStreamingCodec.java
@@ -0,0 +1,50 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+/**
+ * Enum for each type of video streaming codec.
+ */
+
+public enum VideoStreamingCodec {
+ /**
+ * A block-oriented motion-compensation-based video compression standard. As of 2014 it is one
+ * of the most commonly used formats for the recording, compression, and distribution of video
+ * content.
+ */
+ H264,
+ /**
+ * High Efficiency Video Coding (HEVC), also known as H.265 and MPEG-H Part 2, is a video
+ * compression standard, one of several potential successors to the widely used AVC
+ * (H.264 or MPEG-4 Part 10). In comparison to AVC, HEVC offers about double the data
+ * compression ratio at the same level of video quality, or substantially improved video quality
+ * at the same bit rate. It supports resolutions up to 8192x4320, including 8K UHD.
+ */
+ H265,
+ /**
+ * Theora is derived from the formerly proprietary VP3 codec, released into the public domain by
+ * On2 Technologies. It is broadly comparable in design and bitrate efficiency to MPEG-4 Part 2,
+ * early versions of Windows Media Video, and RealVideo while lacking some of the features
+ * present in some of these other codecs. It is comparable in open standards philosophy to the
+ * BBC's Dirac codec.
+ */
+ Theora,
+ /**
+ * VP8 can be multiplexed into the Matroska-based container format WebM along with Vorbis and
+ * Opus audio. The image format WebP is based on VP8's intra-frame coding. VP8's direct
+ * successor, VP9, and the emerging royalty-free internet video format AV1 from the Alliance
+ * for Open Media (AOMedia) are based on VP8.
+ */
+ VP8,
+ /**
+ * Similar to VP8, but VP9 is customized for video resolutions beyond high-definition video
+ * (UHD) and also enables lossless compression.
+ */
+ VP9;
+
+ public static VideoStreamingCodec valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VideoStreamingProtocol.java b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VideoStreamingProtocol.java
new file mode 100644
index 000000000..412badcac
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/proxy/rpc/enums/VideoStreamingProtocol.java
@@ -0,0 +1,44 @@
+package com.smartdevicelink.proxy.rpc.enums;
+
+/**
+ * Enum for each type of video streaming protocol type.
+ */
+
+public enum VideoStreamingProtocol {
+ /**
+ * Raw stream bytes that contains no timestamp data and is the lowest supported video streaming
+ */
+ RAW,
+ /**
+ * RTP facilitates the transfer of real-time data. Information provided by this protocol include
+ * timestamps (for synchronization), sequence numbers (for packet loss and reordering detection)
+ * and the payload format which indicates the encoded format of the data.
+ */
+ RTP,
+ /**
+ * The transmission of streaming data itself is not a task of RTSP. Most RTSP servers use the
+ * Real-time Transport Protocol (RTP) in conjunction with Real-time Control Protocol (RTCP) for
+ * media stream delivery. However, some vendors implement proprietary transport protocols.
+ */
+ RTSP,
+ /**
+ * Real-Time Messaging Protocol (RTMP) was initially a proprietary protocol developed by
+ * Macromedia for streaming audio, video and data over the Internet, between a Flash player and
+ * a server. Macromedia is now owned by Adobe, which has released an incomplete version of the
+ * specification of the protocol for public use.
+ */
+ RTMP,
+ /**
+ * The WebM container is based on a profile of Matroska. WebM initially supported VP8 video and
+ * Vorbis audio streams. In 2013 it was updated to accommodate VP9 video and Opus audio.
+ */
+ WEBM;
+
+ public static VideoStreamingProtocol valueForString(String value) {
+ try{
+ return valueOf(value);
+ }catch(Exception e){
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java b/sdl_android/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java
index 81dbdd0b0..722fa54f9 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/streaming/AbstractPacketizer.java
@@ -11,7 +11,7 @@ abstract public class AbstractPacketizer {
protected IStreamListener _streamListener = null;
protected byte _rpcSessionID = 0;
-
+
protected SessionType _serviceType = null;
protected SdlSession _session = null;
protected InputStream is = null;
@@ -20,31 +20,39 @@ abstract public class AbstractPacketizer {
protected boolean upts = false;
protected RPCRequest _request = null;
protected byte _wiproVersion = 1;
-
+
//protected long ts = 0, intervalBetweenReports = 5000, delta = 0;
protected long intervalBetweenReports = 5000, delta = 0;
- public AbstractPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID, SdlSession session) throws IOException {
- this._streamListener = streamListener;
+ public AbstractPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID, SdlSession session) throws IOException, IllegalArgumentException {
+ this._streamListener = streamListener;
this.is = is;
_rpcSessionID = rpcSessionID;
_serviceType = sType;
this._session = session;
- bufferSize = this._session.getMtu();
- buffer = new byte[bufferSize];
+ if (this._session != null) {
+ bufferSize = this._session.getMtu();
+ buffer = new byte[bufferSize];
+ }else{
+ throw new IllegalArgumentException("Session variable is null");
+ }
}
-
- public AbstractPacketizer(IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, SdlSession session) throws IOException {
- this._streamListener = streamListener;
+
+ public AbstractPacketizer(IStreamListener streamListener, InputStream is, RPCRequest request, SessionType sType, byte rpcSessionID, byte wiproVersion, SdlSession session) throws IOException, IllegalArgumentException {
+ this._streamListener = streamListener;
this.is = is;
_rpcSessionID = rpcSessionID;
_serviceType = sType;
_request = request;
_wiproVersion = wiproVersion;
this._session = session;
- bufferSize = this._session.getMtu();
- buffer = new byte[bufferSize];
- }
+ if (this._session != null) {
+ bufferSize = this._session.getMtu();
+ buffer = new byte[bufferSize];
+ }else{
+ throw new IllegalArgumentException("Session variable is null");
+ }
+ }
public abstract void start() throws IOException;
@@ -53,4 +61,4 @@ abstract public class AbstractPacketizer {
public abstract void pause();
public abstract void resume();
-}
+} \ No newline at end of file
diff --git a/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java b/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java
index 525d94739..f6a668279 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java
@@ -2,35 +2,57 @@ package com.smartdevicelink.streaming;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
import com.smartdevicelink.SdlConnection.SdlConnection;
import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.protocol.ProtocolMessage;
import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.interfaces.IAudioStreamListener;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
-public class StreamPacketizer extends AbstractPacketizer implements Runnable{
+public class StreamPacketizer extends AbstractPacketizer implements IVideoStreamListener, IAudioStreamListener, Runnable{
public final static String TAG = "StreamPacketizer";
private Thread t = null;
- private final static int BUFF_READ_SIZE = 1024;
+
+ private final static int TLS_MAX_RECORD_SIZE = 16384;
+ private final static int TLS_RECORD_HEADER_SIZE = 5;
+ private final static int TLS_RECORD_MES_AUTH_CDE_SIZE = 32;
+ private final static int TLS_MAX_RECORD_PADDING_SIZE = 256;
+
+
+ private final static int BUFF_READ_SIZE = TLS_MAX_RECORD_SIZE - TLS_RECORD_HEADER_SIZE - TLS_RECORD_MES_AUTH_CDE_SIZE - TLS_MAX_RECORD_PADDING_SIZE;
+
+ // Approximate size of data that mOutputQueue can hold in bytes.
+ // By adding a buffer, we accept underlying transport being stuck for a short time. By setting
+ // a limit of the buffer size, we avoid buffer overflows when underlying transport is too slow.
+ private static final int MAX_QUEUE_SIZE = 256 * 1024;
public SdlConnection sdlConnection = null;
private Object mPauseLock;
private boolean mPaused;
private boolean isServiceProtected = false;
-
+ private BlockingQueue<ByteBuffer> mOutputQueue;
+
public StreamPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID, SdlSession session) throws IOException {
super(streamListener, is, sType, rpcSessionID, session);
mPauseLock = new Object();
mPaused = false;
isServiceProtected = _session.isServiceProtected(_serviceType);
+ if (bufferSize == 0) {
+ // fail safe
+ bufferSize = BUFF_READ_SIZE;
+ }
if(isServiceProtected){ //If our service is encrypted we can only use 1024 as the max buffer size.
bufferSize = BUFF_READ_SIZE;
buffer = new byte[bufferSize];
}
-
+ mOutputQueue = new LinkedBlockingQueue<ByteBuffer>(MAX_QUEUE_SIZE / bufferSize);
}
public void start() throws IOException {
@@ -68,20 +90,48 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
}
}
- length = is.read(buffer, 0, bufferSize);
-
- if (length >= 0)
- {
- ProtocolMessage pm = new ProtocolMessage();
- pm.setSessionID(_rpcSessionID);
- pm.setSessionType(_serviceType);
- pm.setFunctionID(0);
- pm.setCorrID(0);
- pm.setData(buffer, length);
- pm.setPayloadProtected(isServiceProtected);
-
- if (t != null && !t.isInterrupted())
- _streamListener.sendStreamPacket(pm);
+ if (is != null) { // using InputStream interface
+ length = is.read(buffer, 0, bufferSize);
+
+ if (length >= 0) {
+ ProtocolMessage pm = new ProtocolMessage();
+ pm.setSessionID(_rpcSessionID);
+ pm.setSessionType(_serviceType);
+ pm.setFunctionID(0);
+ pm.setCorrID(0);
+ pm.setData(buffer, length);
+ pm.setPayloadProtected(isServiceProtected);
+
+ if (t != null && !t.isInterrupted()) {
+ _streamListener.sendStreamPacket(pm);
+ }
+ }
+ } else { // using sendFrame interface
+ ByteBuffer frame;
+ try {
+ frame = mOutputQueue.take();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ break;
+ }
+
+ while (frame.hasRemaining()) {
+ int len = frame.remaining() > bufferSize ? bufferSize : frame.remaining();
+
+ ProtocolMessage pm = new ProtocolMessage();
+ pm.setSessionID(_rpcSessionID);
+ pm.setSessionType(_serviceType);
+ pm.setFunctionID(0);
+ pm.setCorrID(0);
+ pm.setData(frame.array(), frame.arrayOffset() + frame.position(), len);
+ pm.setPayloadProtected(isServiceProtected);
+
+ if (t != null && !t.isInterrupted()) {
+ _streamListener.sendStreamPacket(pm);
+ }
+
+ frame.position(frame.position() + len);
+ }
}
}
} catch (IOException e)
@@ -112,4 +162,82 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
mPauseLock.notifyAll();
}
}
+
+ /**
+ * Called by the app.
+ *
+ * @see com.smartdevicelink.proxy.interfaces.IVideoStreamListener#sendFrame(byte[], int, int, long)
+ */
+ @Override
+ public void sendFrame(byte[] data, int offset, int length, long presentationTimeUs)
+ throws ArrayIndexOutOfBoundsException {
+ sendArrayData(data, offset, length);
+ }
+
+ /**
+ * Called by the app.
+ *
+ * @see com.smartdevicelink.proxy.interfaces.IVideoStreamListener#sendFrame(ByteBuffer, long)
+ */
+ @Override
+ public void sendFrame(ByteBuffer data, long presentationTimeUs) {
+ sendByteBufferData(data);
+ }
+
+ /**
+ * Called by the app.
+ *
+ * @see com.smartdevicelink.proxy.interfaces.IAudioStreamListener#sendAudio(byte[], int, int, long)
+ */
+ @Override
+ public void sendAudio(byte[] data, int offset, int length, long presentationTimeUs)
+ throws ArrayIndexOutOfBoundsException {
+ sendArrayData(data, offset, length);
+ }
+
+ /**
+ * Called by the app.
+ *
+ * @see com.smartdevicelink.proxy.interfaces.IAudioStreamListener#sendAudio(ByteBuffer, long)
+ */
+ @Override
+ public void sendAudio(ByteBuffer data, long presentationTimeUs) {
+ sendByteBufferData(data);
+ }
+
+ private void sendArrayData(byte[] data, int offset, int length)
+ throws ArrayIndexOutOfBoundsException {
+ if (offset < 0 || offset > data.length || length <= 0 || offset + length > data.length) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ // StreamPacketizer does not need to split a video frame into NAL units
+ ByteBuffer buffer = ByteBuffer.allocate(length);
+ buffer.put(data, offset, length);
+ buffer.flip();
+
+ try {
+ mOutputQueue.put(buffer);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ private void sendByteBufferData(ByteBuffer data) {
+ if (data == null || data.remaining() == 0) {
+ return;
+ }
+
+ // copy the whole buffer, so that even if the app modifies original ByteBuffer after
+ // sendFrame() or sendAudio() call, our buffer will stay intact
+ ByteBuffer buffer = ByteBuffer.allocate(data.remaining());
+ buffer.put(data);
+ buffer.flip();
+
+ try {
+ mOutputQueue.put(buffer);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingCodec.java b/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingCodec.java
new file mode 100644
index 000000000..bf69a792b
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingCodec.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.streaming.audio;
+
+/**
+ * Enum for each type of audio streaming codec.
+ */
+public enum AudioStreamingCodec {
+ /**
+ * Linear-PCM without any compression.
+ */
+ LPCM;
+
+ public static AudioStreamingCodec valueForString(String value) {
+ try {
+ return valueOf(value);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingLPCMParams.java b/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingLPCMParams.java
new file mode 100644
index 000000000..bde6abc4c
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingLPCMParams.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.streaming.audio;
+
+/**
+ * A struct to hold LPCM specific audio format information.
+ */
+public class AudioStreamingLPCMParams extends AudioStreamingParams {
+ /**
+ * Sample format of linear PCM data.
+ */
+ public enum SampleFormat {
+ /**
+ * LPCM data is represented by 8-bit unsigned integers. Centerpoint is 128.
+ */
+ LPCM_8BIT_UNSIGNED,
+
+ /**
+ * LPCM data is represented by 16-bit signed integers, in little endian.
+ */
+ LPCM_16BIT_SIGNED_LITTLE_ENDIAN,
+ }
+
+ /**
+ * Sample format in which app will provide LPCM data to
+ * IAudioStreamListener.sendAudio()
+ * <p>
+ * This is reserved for future and not used right now.
+ */
+ public SampleFormat sampleFormat;
+
+ public AudioStreamingLPCMParams(SampleFormat sampleFormat, int samplingRate, int channels) {
+ super(samplingRate, channels);
+ this.sampleFormat = sampleFormat;
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingParams.java b/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingParams.java
new file mode 100644
index 000000000..fe0f7a981
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/streaming/audio/AudioStreamingParams.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.streaming.audio;
+
+/**
+ * A struct to hold audio format information that are common to codecs.
+ */
+public class AudioStreamingParams {
+ /**
+ * Sampling rate in Hz, e.g. 44100
+ * <p>
+ * This is reserved for future and not used right now.
+ */
+ public int samplingRate;
+
+ /**
+ * Number of channels in the audio stream
+ * <p>
+ * This is reserved for future and not used right now.
+ */
+ public int channels;
+
+ public AudioStreamingParams(int samplingRate, int channels) {
+ this.samplingRate = samplingRate;
+ this.channels = channels;
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/streaming/video/RTPH264Packetizer.java b/sdl_android/src/main/java/com/smartdevicelink/streaming/video/RTPH264Packetizer.java
new file mode 100644
index 000000000..6946d1fbb
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/streaming/video/RTPH264Packetizer.java
@@ -0,0 +1,507 @@
+/*
+ * Copyright (c) 2017, Xevo Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.streaming.video;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Random;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import com.smartdevicelink.SdlConnection.SdlConnection;
+import com.smartdevicelink.SdlConnection.SdlSession;
+import com.smartdevicelink.protocol.ProtocolMessage;
+import com.smartdevicelink.protocol.enums.SessionType;
+import com.smartdevicelink.proxy.interfaces.IVideoStreamListener;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
+import com.smartdevicelink.streaming.AbstractPacketizer;
+import com.smartdevicelink.streaming.IStreamListener;
+
+/*
+ * Note for testing.
+ * The RTP stream generated by this packetizer can be tested with GStreamer (1.4 or later).
+ * Assuming that "VideoStreamPort" is configured as 5050 in smartDeviceLink.ini, here is the
+ * GStreamer pipeline that receives the stream, decode it and render it:
+ *
+ * $ gst-launch-1.0 souphttpsrc location=http://127.0.0.1:5050 ! "application/x-rtp-stream" ! rtpstreamdepay ! "application/x-rtp,media=(string)video,clock-rate=90000,encoding-name=(string)H264" ! rtph264depay ! "video/x-h264, stream-format=(string)avc, alignment=(string)au" ! avdec_h264 ! autovideosink sync=false
+ */
+
+/**
+ * This class receives H.264 byte stream (in Annex-B format), parses it, construct RTP packets
+ * from it based on RFC 6184, then frame the packets based on RFC 4571.
+ * The primary purpose of using RTP is to carry timestamp information along with the data.
+ *
+ * @author Sho Amano
+ */
+public class RTPH264Packetizer extends AbstractPacketizer implements IVideoStreamListener, Runnable {
+
+ // Approximate size of data that mOutputQueue can hold in bytes.
+ // By adding a buffer, we accept underlying transport being stuck for a short time. By setting
+ // a limit of the buffer size, we avoid buffer overflows when underlying transport is too slow.
+ private static final int MAX_QUEUE_SIZE = 256 * 1024;
+
+ private static final int FRAME_LENGTH_LEN = 2;
+ private static final int MAX_RTP_PACKET_SIZE = 65535; // because length field is two bytes (RFC 4571)
+ private static final int RTP_HEADER_LEN = 12;
+ private static final byte DEFAULT_RTP_PAYLOAD_TYPE = 96;
+ private static final int FU_INDICATOR_LEN = 1;
+ private static final int FU_HEADER_LEN = 1;
+ private static final byte TYPE_FU_A = 28;
+
+ // To align with StreamPacketizer class
+ private final static int TLS_MAX_RECORD_SIZE = 16384;
+ private final static int TLS_RECORD_HEADER_SIZE = 5;
+ private final static int TLS_RECORD_MES_AUTH_CDE_SIZE = 32;
+ private final static int TLS_MAX_RECORD_PADDING_SIZE = 256;
+
+ private final static int MAX_DATA_SIZE_FOR_ENCRYPTED_SERVICE =
+ TLS_MAX_RECORD_SIZE - TLS_RECORD_HEADER_SIZE - TLS_RECORD_MES_AUTH_CDE_SIZE- TLS_MAX_RECORD_PADDING_SIZE;
+
+ private boolean mServiceProtected;
+ private Thread mThread;
+ private BlockingQueue<ByteBuffer> mOutputQueue;
+ private volatile boolean mPaused;
+ private boolean mWaitForIDR;
+ private NALUnitReader mNALUnitReader;
+ private byte mPayloadType = 0;
+ private int mSSRC = 0;
+ private char mSequenceNum = 0;
+ private int mInitialPTS = 0;
+
+ /**
+ * Constructor
+ *
+ * @param streamListener The listener which this packetizer outputs SDL frames to
+ * @param serviceType The value of "Service Type" field in SDL frames
+ * @param sessionID The value of "Session ID" field in SDL frames
+ * @param session The SdlSession instance that this packetizer belongs to
+ */
+ public RTPH264Packetizer(IStreamListener streamListener,
+ SessionType serviceType, byte sessionID, SdlSession session) throws IOException {
+
+ super(streamListener, null, serviceType, sessionID, session);
+
+ mServiceProtected = session.isServiceProtected(_serviceType);
+
+ bufferSize = (int)this._session.getMtu(SessionType.NAV);
+ if (bufferSize == 0) {
+ // fail safe
+ bufferSize = MAX_DATA_SIZE_FOR_ENCRYPTED_SERVICE;
+ }
+ if (mServiceProtected && bufferSize > MAX_DATA_SIZE_FOR_ENCRYPTED_SERVICE) {
+ bufferSize = MAX_DATA_SIZE_FOR_ENCRYPTED_SERVICE;
+ }
+
+ mOutputQueue = new LinkedBlockingQueue<ByteBuffer>(MAX_QUEUE_SIZE / bufferSize);
+ mNALUnitReader = new NALUnitReader();
+ mPayloadType = DEFAULT_RTP_PAYLOAD_TYPE;
+
+ Random r = new Random();
+ mSSRC = r.nextInt();
+
+ // initial value of the sequence number and timestamp should be random ([5.1] in RFC3550)
+ mSequenceNum = (char)r.nextInt(65536);
+ mInitialPTS = r.nextInt();
+ }
+
+ /**
+ * Sets the Payload Type (PT) of RTP header field.
+ *
+ * Use this method if PT needs to be specified. The value should be between 0 and 127.
+ * Otherwise, a default value (96) is used.
+ *
+ * @param type A value indicating the Payload Type
+ */
+ public void setPayloadType(byte type) {
+ if (type >= 0 && type <= 127) {
+ mPayloadType = type;
+ } else {
+ mPayloadType = DEFAULT_RTP_PAYLOAD_TYPE;
+ }
+ }
+
+ /**
+ * Sets the SSRC of RTP header field.
+ *
+ * Use this method if SSRC needs to be specified. Otherwise, a random value is generated and
+ * used.
+ *
+ * @param ssrc An integer value representing SSRC
+ */
+ public void setSSRC(int ssrc) {
+ mSSRC = ssrc;
+ }
+
+ /**
+ * Starts this packetizer.
+ *
+ * It is recommended that the video encoder is started after the packetizer is started.
+ */
+ @Override
+ public void start() throws IOException {
+ if (mThread != null) {
+ return;
+ }
+
+ mThread = new Thread(this);
+ mThread.start();
+ }
+
+ /**
+ * Stops this packetizer.
+ *
+ * It is recommended that the video encoder is stopped prior to the packetizer.
+ */
+ @Override
+ public void stop() {
+ if (mThread == null) {
+ return;
+ }
+
+ mThread.interrupt();
+ mThread = null;
+
+ mPaused = false;
+ mWaitForIDR = false;
+ mOutputQueue.clear();
+ }
+
+ /**
+ * Pauses this packetizer.
+ *
+ * This pauses the packetizer but does not pause the video encoder.
+ */
+ @Override
+ public void pause() {
+ mPaused = true;
+ }
+
+ /**
+ * Resumes this packetizer.
+ */
+ @Override
+ public void resume() {
+ mWaitForIDR = true;
+ mPaused = false;
+ }
+
+ /**
+ * The thread routine.
+ */
+ public void run() {
+ SdlConnection connection = _session.getSdlConnection();
+
+ while (mThread != null && !mThread.isInterrupted()) {
+ ByteBuffer frame;
+ try {
+ frame = mOutputQueue.take();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ break;
+ }
+
+ while (frame.hasRemaining()) {
+ int len = frame.remaining() > bufferSize ? bufferSize : frame.remaining();
+
+ ProtocolMessage pm = new ProtocolMessage();
+ pm.setSessionID(_rpcSessionID);
+ pm.setSessionType(_serviceType);
+ pm.setFunctionID(0);
+ pm.setCorrID(0);
+ pm.setData(frame.array(), frame.arrayOffset() + frame.position(), len);
+ pm.setPayloadProtected(mServiceProtected);
+
+ _streamListener.sendStreamPacket(pm);
+
+ frame.position(frame.position() + len);
+ }
+ }
+
+ // XXX: This is added to sync with StreamPacketizer. Actually it shouldn't be here since
+ // it's confusing that a packetizer takes care of End Service request.
+ if (connection != null) {
+ connection.endService(_serviceType, _rpcSessionID);
+ }
+ }
+
+ /**
+ * Called by the app and encoder.
+ *
+ * @see com.smartdevicelink.proxy.interfaces.IVideoStreamListener#sendFrame(byte[], int, int, long)
+ */
+ @Override
+ public void sendFrame(byte[] data, int offset, int length, long presentationTimeUs)
+ throws ArrayIndexOutOfBoundsException {
+ mNALUnitReader.init(data, offset, length);
+ onEncoderOutput(mNALUnitReader, presentationTimeUs);
+ }
+
+ /**
+ * Called by the app and encoder.
+ *
+ * @see com.smartdevicelink.proxy.interfaces.IVideoStreamListener#sendFrame(ByteBuffer, long)
+ */
+ @Override
+ public void sendFrame(ByteBuffer data, long presentationTimeUs) {
+ mNALUnitReader.init(data);
+ onEncoderOutput(mNALUnitReader, presentationTimeUs);
+ }
+
+ private void onEncoderOutput(NALUnitReader nalUnitReader, long ptsInUs) {
+ if (mPaused) {
+ return;
+ }
+
+ ByteBuffer nalUnit;
+
+ while ((nalUnit = nalUnitReader.getNalUnit()) != null) {
+ if (mWaitForIDR) {
+ if (isIDR(nalUnit)) {
+ mWaitForIDR = false;
+ } else {
+ continue;
+ }
+ }
+ outputRTPFrames(nalUnit, ptsInUs, nalUnitReader.hasConsumedAll());
+ }
+ }
+
+ private boolean outputRTPFrames(ByteBuffer nalUnit, long ptsInUs, boolean isLast) {
+ if (RTP_HEADER_LEN + nalUnit.remaining() > MAX_RTP_PACKET_SIZE) {
+ // Split into multiple Fragmentation Units ([5.8] in RFC 6184)
+ byte firstByte = nalUnit.get();
+ boolean firstFragment = true;
+ boolean lastFragment = false;
+
+ while (nalUnit.remaining() > 0) {
+ int payloadLength = MAX_RTP_PACKET_SIZE - (RTP_HEADER_LEN + FU_INDICATOR_LEN + FU_HEADER_LEN);
+ if (nalUnit.remaining() <= payloadLength) {
+ payloadLength = nalUnit.remaining();
+ lastFragment = true;
+ }
+
+ ByteBuffer frame = allocateRTPFrame(FU_INDICATOR_LEN + FU_HEADER_LEN + payloadLength,
+ false, isLast, ptsInUs);
+ // FU indicator
+ frame.put((byte)((firstByte & 0xE0) | TYPE_FU_A));
+ // FU header
+ frame.put((byte)((firstFragment ? 0x80 : lastFragment ? 0x40 : 0) | (firstByte & 0x1F)));
+ // FU payload
+ frame.put(nalUnit.array(), nalUnit.position(), payloadLength);
+ nalUnit.position(nalUnit.position() + payloadLength);
+ frame.flip();
+
+ try {
+ mOutputQueue.put(frame);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+
+ firstFragment = false;
+ }
+ } else {
+ // Use Single NAL Unit Packet ([5.6] in RFC 6184)
+ ByteBuffer frame = allocateRTPFrame(nalUnit.remaining(), false, isLast, ptsInUs);
+ frame.put(nalUnit);
+ frame.flip();
+
+ try {
+ mOutputQueue.put(frame);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private ByteBuffer allocateRTPFrame(int rtpPayloadLen,
+ boolean hasPadding, boolean isLast, long ptsInUs) {
+ if (rtpPayloadLen <= 0) {
+ throw new IllegalArgumentException("Invalid rtpPayloadLen value: " + rtpPayloadLen);
+ }
+ if (ptsInUs < 0) {
+ throw new IllegalArgumentException("Invalid ptsInUs value: " + ptsInUs);
+ }
+
+ int packetLength = RTP_HEADER_LEN + rtpPayloadLen;
+ if (packetLength > MAX_RTP_PACKET_SIZE) {
+ throw new IllegalArgumentException("Invalid rtpPayloadLen value: " + rtpPayloadLen);
+ }
+ int ptsIn90kHz = (int)(ptsInUs * 9 / 100) + mInitialPTS;
+
+ ByteBuffer frame = ByteBuffer.allocate(FRAME_LENGTH_LEN + packetLength);
+ frame.order(ByteOrder.BIG_ENDIAN);
+ frame.putShort((short)packetLength);
+
+ // Version = 2, Padding = hasPadding, Extension = 0, CSRC count = 0
+ frame.put((byte)(0x80 | (hasPadding ? 0x20 : 0)))
+ // Marker = isLast, Payload type = mPayloadType
+ .put((byte)((isLast ? 0x80 : 0) | (mPayloadType & 0x7F)))
+ .putChar(mSequenceNum)
+ .putInt(ptsIn90kHz)
+ .putInt(mSSRC);
+
+ if (frame.position() != FRAME_LENGTH_LEN + RTP_HEADER_LEN) {
+ throw new RuntimeException("Data size in ByteBuffer mismatch");
+ }
+
+ mSequenceNum++;
+ return frame;
+ }
+
+ private static boolean isIDR(ByteBuffer nalUnit) {
+ if (nalUnit == null || !nalUnit.hasRemaining()) {
+ throw new IllegalArgumentException("Invalid nalUnit arg");
+ }
+
+ byte nalUnitType = (byte)(nalUnit.get(nalUnit.position()) & 0x1F);
+ return nalUnitType == 5;
+ }
+
+
+ private static int SKIP_TABLE[] = new int[256];
+ static {
+ // Sunday's quick search algorithm is used to find the start code.
+ // Prepare the table (SKIP_TABLE[0] = 2, SKIP_TABLE[1] = 1 and other elements will be 4).
+ byte[] NAL_UNIT_START_CODE = {0, 0, 1};
+ int searchStringLen = NAL_UNIT_START_CODE.length;
+ for (int i = 0; i < SKIP_TABLE.length; i++) {
+ SKIP_TABLE[i] = searchStringLen + 1;
+ }
+ for (int i = 0; i < searchStringLen; i++) {
+ SKIP_TABLE[NAL_UNIT_START_CODE[i] & 0xFF] = searchStringLen - i;
+ }
+ }
+
+ private class NALUnitReader {
+ private byte[] mData;
+ private int mOffset;
+ private int mLimit;
+
+ NALUnitReader() {
+ }
+
+ void init(byte[] data) {
+ mData = data;
+ mOffset = 0;
+ mLimit = data.length;
+ }
+
+ void init(byte[] data, int offset, int length) throws ArrayIndexOutOfBoundsException {
+ if (offset < 0 || offset > data.length || length <= 0 || offset + length > data.length) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ mData = data;
+ mOffset = offset;
+ mLimit = offset + length;
+ }
+
+ void init(ByteBuffer data) {
+ if (data == null || data.remaining() == 0) {
+ mData = null;
+ mOffset = 0;
+ mLimit = 0;
+ return;
+ }
+
+ if (data.hasArray()) {
+ mData = data.array();
+ mOffset = data.position() + data.arrayOffset();
+ mLimit = mOffset + data.remaining();
+
+ // mark the buffer as consumed
+ data.position(data.position() + data.remaining());
+ } else {
+ byte[] buffer = new byte[data.remaining()];
+ data.get(buffer);
+
+ mData = buffer;
+ mOffset = 0;
+ mLimit = buffer.length;
+ }
+ }
+
+ ByteBuffer getNalUnit() {
+ if (hasConsumedAll()) {
+ return null;
+ }
+
+ int pos = mOffset;
+ int start = -1;
+
+ while (mLimit - pos >= 3) {
+ if (mData[pos] == 0 && mData[pos+1] == 0 && mData[pos+2] == 1) {
+ if (start != -1) {
+ // We've found a start code, a NAL unit and then another start code.
+ mOffset = pos;
+ // remove 0x00s in front of the start code
+ while (pos > start && mData[pos-1] == 0) {
+ pos--;
+ }
+ if (pos > start) {
+ return ByteBuffer.wrap(mData, start, pos - start);
+ } else {
+ // No NAL unit between two start codes?! Forget it and search for
+ // another start code.
+ pos = mOffset;
+ }
+ }
+ // This is the first start code.
+ pos += 3;
+ start = pos;
+ } else {
+ try {
+ pos += SKIP_TABLE[mData[pos+3] & 0xFF];
+ } catch (ArrayIndexOutOfBoundsException e) {
+ break;
+ }
+ }
+ }
+
+ mOffset = mLimit;
+ if (start != -1 && mLimit > start) {
+ // We've found a start code and then reached to the end of array.
+ return ByteBuffer.wrap(mData, start, mLimit - start);
+ }
+ // A start code was not found
+ return null;
+ }
+
+ boolean hasConsumedAll() {
+ return (mData == null) || (mLimit - mOffset < 4);
+ }
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java b/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java
new file mode 100644
index 000000000..8af6b1c59
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2017 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.streaming.video;
+
+import android.annotation.TargetApi;
+import android.app.Presentation;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.util.Log;
+import android.view.Display;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+
+import java.lang.reflect.Constructor;
+import java.util.concurrent.Callable;
+
+/**
+ * SdlRemoteDisplay is an abstract class that should be extended by developers to creat their remote displays.
+ * All logic for UI events can be stored in their extension.
+ *
+ * <br><br> <b>NOTE:</b> When the UI changes (buttons appear, layouts change, etc) the developer should call {@link #invalidate()} to alert any
+ * other interfaces that are listening for those types of events.
+ */
+@TargetApi(17)
+public abstract class SdlRemoteDisplay extends Presentation {
+ private static final String TAG = "SdlRemoteDisplay";
+ private static final int REFRESH_RATE_MS = 50;
+
+ protected Window w;
+ protected View mainView;
+ protected Handler handler = new Handler();
+ protected Handler uiHandler = new Handler(Looper.getMainLooper());
+ protected Callback callback;
+
+ public SdlRemoteDisplay(Context context, Display display) {
+ super(context, display);
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setTitle(TAG);
+
+ w = getWindow();
+
+ startRefreshTask();
+
+ w.setType(WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION);
+ }
+
+ protected void startRefreshTask() {
+ handler.postDelayed(mStartRefreshTaskCallback, REFRESH_RATE_MS);
+ }
+
+ protected void stopRefreshTask() {
+ handler.removeCallbacks(mStartRefreshTaskCallback);
+ }
+
+ protected Runnable mStartRefreshTaskCallback = new Runnable() {
+ public void run() {
+ if(mainView == null){
+ mainView = w.getDecorView().findViewById(android.R.id.content);
+ }
+ if (mainView != null) {
+ mainView.invalidate();
+ }
+
+ handler.postDelayed(this, REFRESH_RATE_MS);
+ }
+ };
+
+ @SuppressWarnings("unused")
+ public View getMainView(){
+ if(mainView == null){
+ mainView = w.getDecorView().findViewById(android.R.id.content);
+ }
+ return this.mainView;
+ }
+
+ @SuppressWarnings("unused")
+ public void invalidate(){
+ // let listeners know the view has been invalidated
+ if(callback != null){
+ callback.onInvalidated(this);
+ }
+ }
+
+ public void handleMotionEvent(final MotionEvent motionEvent){
+ uiHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mainView.dispatchTouchEvent(motionEvent);
+ }
+ });
+ }
+
+ public void stop(){
+ stopRefreshTask();
+ dismissPresentation();
+ }
+
+ public void dismissPresentation() {
+ uiHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ dismiss();
+ }
+ });
+ }
+ public interface Callback{
+ void onCreated(SdlRemoteDisplay remoteDisplay);
+ void onInvalidated(SdlRemoteDisplay remoteDisplay);
+ }
+
+ public static class Creator implements Callable<Boolean> {
+ private Context context;
+ private Display mDisplay;
+ boolean presentationShowError = false;
+ SdlRemoteDisplay remoteDisplay;
+ Class<? extends SdlRemoteDisplay> remoteDisplayClass;
+ private Handler uiHandler = new Handler(Looper.getMainLooper());
+ private Callback callback;
+
+
+ public Creator(Context context, Display display, SdlRemoteDisplay remoteDisplay, Class<? extends SdlRemoteDisplay> remoteDisplayClass, Callback callback){
+ this.context = context;
+ this.mDisplay = display;
+ this.remoteDisplay = remoteDisplay;
+ this.remoteDisplayClass = remoteDisplayClass;
+ this.callback = callback;
+ }
+
+ @Override
+ public Boolean call() {
+
+ uiHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ // Want to create presentation on UI thread so it finds the right Looper
+ // when setting up the Dialog.
+ if ((remoteDisplay == null) && (mDisplay != null))
+ {
+ try {
+ Constructor constructor = remoteDisplayClass.getConstructor(Context.class, Display.class);
+ remoteDisplay = (SdlRemoteDisplay) constructor.newInstance(context, mDisplay);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Log.e(TAG, "Unable to create Presentation Class");
+ presentationShowError = true;
+ return;
+ }
+
+ try {
+ remoteDisplay.show();
+ remoteDisplay.callback = callback;
+ if(callback!=null){
+ callback.onCreated(remoteDisplay);
+ }
+
+ } catch (WindowManager.InvalidDisplayException ex) {
+ Log.e(TAG, "Couldn't show presentation! Display was removed in the meantime.", ex);
+ remoteDisplay = null;
+ presentationShowError = true;
+ }
+ }
+ }
+ });
+
+ return presentationShowError;
+ }
+
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java b/sdl_android/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java
new file mode 100644
index 000000000..f565a22dc
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2017 Livio, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the Livio Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.smartdevicelink.streaming.video;
+
+import android.util.DisplayMetrics;
+
+import com.smartdevicelink.proxy.rpc.ImageResolution;
+import com.smartdevicelink.proxy.rpc.VideoStreamingCapability;
+import com.smartdevicelink.proxy.rpc.VideoStreamingFormat;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec;
+import com.smartdevicelink.proxy.rpc.enums.VideoStreamingProtocol;
+
+import java.util.List;
+
+@SuppressWarnings("FieldCanBeLocal")
+public class VideoStreamingParameters {
+ private final VideoStreamingProtocol DEFAULT_PROTOCOL = VideoStreamingProtocol.RAW;
+ private final VideoStreamingCodec DEFAULT_CODEC = VideoStreamingCodec.H264;
+ private final int DEFAULT_WIDTH = 1024;
+ private final int DEFAULT_HEIGHT = 576;
+ private final int DEFAULT_DENSITY = DisplayMetrics.DENSITY_HIGH;
+ private final int DEFAULT_FRAMERATE = 30;
+ private final int DEFAULT_BITRATE = 512000;
+ private final int DEFAULT_INTERVAL = 5;
+
+
+ private int displayDensity;
+ private int frameRate;
+ private int bitrate;
+ private int interval;
+ private ImageResolution resolution;
+ private VideoStreamingFormat format;
+
+ public VideoStreamingParameters(){
+ displayDensity = DEFAULT_DENSITY;
+ frameRate = DEFAULT_FRAMERATE;
+ bitrate = DEFAULT_BITRATE;
+ interval = DEFAULT_INTERVAL;
+ resolution = new ImageResolution();
+ resolution.setResolutionWidth(DEFAULT_WIDTH);
+ resolution.setResolutionHeight(DEFAULT_HEIGHT);
+ format = new VideoStreamingFormat();
+ format.setProtocol(DEFAULT_PROTOCOL);
+ format.setCodec(DEFAULT_CODEC);
+ }
+
+ public VideoStreamingParameters(int displayDensity, int frameRate, int bitrate, int interval,
+ ImageResolution resolution, VideoStreamingFormat format){
+ this.displayDensity = displayDensity;
+ this.frameRate = frameRate;
+ this.bitrate = bitrate;
+ this.interval = interval;
+ this.resolution = resolution;
+ this.format = format;
+ }
+
+ /**
+ * Will only copy values that are not null or are greater than 0
+ * @param params VideoStreamingParameters that should be copied into this new instants
+ */
+ @SuppressWarnings("unused")
+ public VideoStreamingParameters(VideoStreamingParameters params){
+ update(params);
+ }
+
+ /**
+ * Will only copy values that are not null or are greater than 0
+ * @param params VideoStreamingParameters that should be copied into this new instants
+ */
+ public void update(VideoStreamingParameters params){
+ if(params!=null) {
+ if (params.displayDensity > 0) {
+ this.displayDensity = params.displayDensity;
+ }
+ if (params.frameRate > 0) {
+ this.frameRate = params.frameRate;
+ }
+ if (params.bitrate > 0) {
+ this.bitrate = params.bitrate;
+ }
+ if (params.interval > 0) {
+ this.interval = params.interval;
+ }
+ if (params.resolution != null) {
+ if (params.resolution.getResolutionHeight() != null && params.resolution.getResolutionHeight() > 0) {
+ this.resolution.setResolutionHeight(params.resolution.getResolutionHeight());
+ }
+ if (params.resolution.getResolutionWidth() != null && params.resolution.getResolutionWidth() > 0) {
+ this.resolution.setResolutionWidth(params.resolution.getResolutionWidth());
+ }
+ }
+ if (params.format != null) {
+ this.format = params.format;
+ }
+ }
+ }
+
+ /**
+ * Update the values contained in the capability that should have been returned through the SystemCapabilityManager.
+ * This update will use the most preferred streaming format from the module.
+ * @param capability the video streaming capability returned from the SystemCapabilityManager
+ * @see com.smartdevicelink.proxy.SystemCapabilityManager
+ * @see VideoStreamingCapability
+ */
+ public void update(VideoStreamingCapability capability){
+ if(capability.getMaxBitrate()!=null){ this.bitrate = capability.getMaxBitrate(); }
+ ImageResolution resolution = capability.getPreferredResolution();
+ if(resolution!=null){
+ if(resolution.getResolutionHeight()!=null && resolution.getResolutionHeight() > 0){ this.resolution.setResolutionHeight(resolution.getResolutionHeight()); }
+ if(resolution.getResolutionWidth()!=null && resolution.getResolutionWidth() > 0){ this.resolution.setResolutionWidth(resolution.getResolutionWidth()); }
+ }
+ List<VideoStreamingFormat> formats = capability.getSupportedFormats();
+ if(formats != null && formats.size()>0){
+ this.format = formats.get(0);
+ }
+
+ }
+
+ @SuppressWarnings("unused")
+ public void setDisplayDensity(int displayDensity) {
+ this.displayDensity = displayDensity;
+ }
+
+ public int getDisplayDensity() {
+ return displayDensity;
+ }
+
+ public void setFrameRate(int frameRate) {
+ this.frameRate = frameRate;
+ }
+
+ public int getFrameRate() {
+ return frameRate;
+ }
+
+ public void setBitrate(int bitrate) {
+ this.bitrate = bitrate;
+ }
+
+ public int getBitrate() {
+ return bitrate;
+ }
+
+ public void setInterval(int interval) {
+ this.interval = interval;
+ }
+
+ public int getInterval() {
+ return interval;
+ }
+
+ public void setFormat(VideoStreamingFormat format){
+ this.format = format;
+ }
+
+ public VideoStreamingFormat getFormat(){
+ return format;
+ }
+
+ public void setResolution(ImageResolution resolution){
+ this.resolution = resolution;
+ }
+
+ public ImageResolution getResolution() {
+ return resolution;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("VideoStreamingParams - format: {");
+ builder.append(format.toString());
+ builder.append("}, resolution: {");
+ builder.append(resolution.getResolutionHeight());
+ builder.append(" , ");
+ builder.append(resolution.getResolutionWidth());
+ builder.append("}, frame rate {");
+ builder.append(frameRate);
+ builder.append("}, displayDensity{ ");
+ builder.append(displayDensity);
+ builder.append("}, bitrate");
+ builder.append(bitrate);
+ builder.append("}, IFrame interval{ ");
+ builder.append(interval);
+ builder.append("}");
+ return builder.toString();
+ }
+} \ No newline at end of file
diff --git a/sdl_android/src/main/java/com/smartdevicelink/trace/DiagLevel.java b/sdl_android/src/main/java/com/smartdevicelink/trace/DiagLevel.java
index b77b34486..26dfdebff 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/trace/DiagLevel.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/trace/DiagLevel.java
@@ -14,29 +14,38 @@ public class DiagLevel {
}
public static void setAllLevels(DetailLevel thisDetail) {
- for (int i=0; i < levels.length; i++) {
- levels[i] = thisDetail; //
+ if (thisDetail != null) {
+ for (int i = 0; i < levels.length; i++) {
+ levels[i] = thisDetail; //
+ }
}
}
public static void setLevel(Mod thisMod, DetailLevel thisDetail) {
- levels[thisMod.ordinal()] = thisDetail;
+ if (thisMod != null && thisDetail != null) {
+ levels[thisMod.ordinal()] = thisDetail;
+ }
}
public static DetailLevel getLevel(Mod thisMod) {
- return levels[thisMod.ordinal()];
+ if (thisMod != null) {
+ return levels[thisMod.ordinal()];
+ }
+ return null;
}
-
+
public static boolean isValidDetailLevel(String dtString) {
// Assume false
Boolean isValid = false;
-
- if (dtString.equalsIgnoreCase("verbose"))
- isValid = true;
- else if (dtString.equalsIgnoreCase("terse"))
- isValid = true;
- else if (dtString.equalsIgnoreCase("off"))
- isValid = true;
+
+ if (dtString != null) {
+ if (dtString.equalsIgnoreCase("verbose"))
+ isValid = true;
+ else if (dtString.equalsIgnoreCase("terse"))
+ isValid = true;
+ else if (dtString.equalsIgnoreCase("off"))
+ isValid = true;
+ }
return isValid;
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/trace/Mime.java b/sdl_android/src/main/java/com/smartdevicelink/trace/Mime.java
index 026f31721..799ac98f4 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/trace/Mime.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/trace/Mime.java
@@ -3,10 +3,18 @@ package com.smartdevicelink.trace;
// Borrowed from Dave Boll's infamous SdlLinkRelay.java
public class Mime {
-
- private static String m_base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
+
+ private static final String BASE_64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+ /**
+ * @param str A String to encode into base64 String.
+ * @return Base64 encoded String or a null String if input is null.
+ */
public static String base64Encode(String str) {
+ if(str == null){
+ return null;
+ }
+
String b64String = "";
try {
byte[] strBytes = str.getBytes("US-ASCII");
@@ -17,49 +25,76 @@ public class Mime {
return b64String;
}
+ /**
+ * @param bytesToEncode A byte array to encode into base64 String.
+ * @return Base64 encoded String or a null String if input array is null.
+ */
public static String base64Encode(byte bytesToEncode[]) {
- return base64Encode(bytesToEncode, 0, bytesToEncode.length);
+ if(bytesToEncode != null){
+ return base64Encode(bytesToEncode, 0, bytesToEncode.length);
+ }
+ return null;
}
+ /**
+ * @param bytesToEncode A byte array to encode into base64 String.
+ * @param offset Offset to begin at
+ * @param length Length to read
+ * @return Base64 encoded String or a null String if input array is null or the input range is out of bounds.
+ */
public static String base64Encode(byte bytesToEncode[], int offset, int length) {
+ if (bytesToEncode == null || bytesToEncode.length < length || bytesToEncode.length < offset + length) {
+ return null;
+ }
+
StringBuilder sb = new StringBuilder();
- int idxin = 0;
- int b64idx = 0;
+ int idxin = 0;
+ int b64idx = 0;
- for (idxin=offset;idxin < offset + length;idxin++) {
- switch ((idxin-offset) % 3) {
+ for (idxin = offset; idxin < offset + length; idxin++) {
+ switch ((idxin - offset) % 3) {
case 0:
b64idx = (bytesToEncode[idxin] >> 2) & 0x3f;
break;
case 1:
b64idx = (bytesToEncode[idxin] >> 4) & 0x0f;
- b64idx |= ((bytesToEncode[idxin-1] << 4)& 0x30);
+ 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 - 1] << 2) & 0x3c);
+ sb.append(getBase64Char(b64idx));
b64idx = bytesToEncode[idxin] & 0x3f;
break;
}
- sb.append(m_base64Chars.charAt(b64idx));
+ sb.append(getBase64Char(b64idx));
}
- switch ((idxin-offset) % 3) {
+ switch ((idxin - offset) % 3) {
case 0:
break;
case 1:
- b64idx = (bytesToEncode[idxin-1] << 4) & 0x30;
- sb.append(m_base64Chars.charAt(b64idx));
+ b64idx = (bytesToEncode[idxin - 1] << 4) & 0x30;
+ sb.append(getBase64Char(b64idx));
sb.append("==");
break;
case 2:
- b64idx = ((bytesToEncode[idxin-1] << 2)& 0x3c);
- sb.append(m_base64Chars.charAt(b64idx));
+ b64idx = ((bytesToEncode[idxin - 1] << 2) & 0x3c);
+ sb.append(getBase64Char(b64idx));
sb.append('=');
break;
- }
+ }
+
return sb.toString();
+
+ }
+
+ private static char getBase64Char(int b64idx){
+ if(b64idx >= 0 && b64idx < BASE_64_CHARS.length()) {
+ return BASE_64_CHARS.charAt(b64idx);
+ }else{
+ return 0x20;
+ }
}
} \ No newline at end of file
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java b/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java
index b4fea0e71..762c076a3 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java
@@ -50,10 +50,14 @@ public class MultiplexBluetoothTransport {
private static final UUID SERVER_UUID= new UUID(0x936DA01F9ABD4D9DL, 0x80C702AF85C822A8L);
// Name for the SDP record when creating server socket
private static final String NAME_SECURE =" SdlRouterService";
-
-
- protected static final String SHARED_PREFS = "sdl.bluetoothprefs";
+ // Key names received from the BluetoothSerialServer Handler
+ public static final String DEVICE_NAME = "device_name";
+ public static final String TOAST = "toast";
+ private static final long MS_TILL_TIMEOUT = 2500;
+ private static final int READ_BUFFER_SIZE = 4096;
+ private static final Object THREAD_LOCK = new Object();;
+ protected static final String SHARED_PREFS = "sdl.bluetoothprefs";
// Constants that indicate the current connection state
public static final int STATE_NONE = 0; // we're doing nothing
@@ -67,40 +71,24 @@ public class MultiplexBluetoothTransport {
private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
private final Handler mHandler;
private AcceptThread mSecureAcceptThread;
- private static Object threadLock = null;
private ConnectThread mConnectThread;
- private static ConnectedThread mConnectedThread; //I HATE ALL THIS STATIC CRAP, But it seems like the only way right now
- private static ConnectedWriteThread mConnectedWriteThread; //I HATE ALL THIS STATIC CRAP, But it seems like the only way right now
-
- private static int mState;
-
- // Key names received from the BluetoothSerialServer Handler
- public static final String DEVICE_NAME = "device_name";
- public static final String TOAST = "toast";
-
-
+ private ConnectedThread mConnectedThread;
+ private ConnectedWriteThread mConnectedWriteThread;
+ private int mState;
private int mBluetoothLevel = 0;
Handler timeOutHandler;
Runnable socketRunable;
- private static final long msTillTimeout = 2500;
-
- private static final int READ_BUFFER_SIZE = 4096;
+ boolean keepSocketAlive = true;
public static String currentlyConnectedDevice = null;
public static String currentlyConnectedDeviceAddress = null;
- private static MultiplexBluetoothTransport serverInstance = null;
- //private BluetoothServerSocket serverSocket= null;
- static boolean keepSocketAlive = true;
-
-
/**
* Constructor. Prepares a new BluetoothChat session.
- * @param context The UI Activity Context
* @param handler A Handler to send messages back to the UI Activity
*/
- private MultiplexBluetoothTransport(Handler handler) {
+ public MultiplexBluetoothTransport(Handler handler) {
//Log.w(TAG, "Creating Bluetooth Serial Adapter");
// mAdapter = BluetoothAdapter.getDefaultAdapter();
mState = STATE_NONE;
@@ -108,32 +96,41 @@ public class MultiplexBluetoothTransport {
//This will keep track of which method worked last night
mBluetoothLevel = SdlRouterService.getBluetoothPrefs(SHARED_PREFS);
- Object object = new Object();
- threadLock = object;
-
}
-
- /*
- * Let's use this method from now on to get bluetooth service
+ /**
+ * This method has been deprecated. It will return an instance of MultiplexBluetoothTransport but <b>should not</b> be used.
+ * @param handler for receiving status messages from the transport
+ * @return an instance of MultiplexBluetoothTransport
+ * @deprecated
*/
+ @Deprecated
public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(Handler handler){
- return getBluetoothSerialServerInstance(handler,true);
+ return new MultiplexBluetoothTransport(handler);
}
- /*
- * Let's use this method from now on to get bluetooth service
+ /**
+ * This method has been deprecated. It will return an instance of MultiplexBluetoothTransport but <b>should not</b> be used.
+ * @param handler for receiving status messages from the transport
+ * @param keepSocketAlive Flag for keeping the socket alive
+ * @return an instance of MultiplexBluetoothTransport
+ * @deprecated
*/
+ @Deprecated
public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(Handler handler, boolean keepSocketAlive){
-
- if(serverInstance==null){
- serverInstance = new MultiplexBluetoothTransport(handler);
- }
- MultiplexBluetoothTransport.keepSocketAlive = keepSocketAlive;
- return serverInstance;
+ MultiplexBluetoothTransport transport = new MultiplexBluetoothTransport(handler);
+ transport.setKeepSocketAlive(keepSocketAlive);
+ return transport;
}
+
+ /**
+ * This method has been deprecated. <b>It will always return null.</b>
+ * @return always null
+ * @deprecated
+ */
+ @Deprecated
public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(){
- return serverInstance;
+ return null;
}
//These methods are used so we can have a semi-static reference to the Accept Thread (Static reference inherited by housing class)
@@ -168,7 +165,7 @@ public class MultiplexBluetoothTransport {
}
public void setKeepSocketAlive(boolean keepSocketAlive){
- MultiplexBluetoothTransport.keepSocketAlive = keepSocketAlive;
+ this.keepSocketAlive = keepSocketAlive;
}
/**
@@ -177,7 +174,7 @@ public class MultiplexBluetoothTransport {
public synchronized void start() {
//Log.d(TAG, "Starting up Bluetooth Server to Listen");
// Cancel any thread attempting to make a connection
- if (serverInstance.mConnectThread != null) {serverInstance.mConnectThread.cancel(); serverInstance.mConnectThread = null;}
+ if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
// Cancel any thread currently running a connection
if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}
@@ -186,14 +183,14 @@ public class MultiplexBluetoothTransport {
// Start the thread to listen on a BluetoothServerSocket
- if (getBluetoothSerialServerInstance().getAcceptThread() == null
- && serverInstance.mAdapter != null
- && serverInstance.mAdapter.isEnabled()) {
+ if (getAcceptThread() == null
+ && mAdapter != null
+ && mAdapter.isEnabled()) {
//Log.d(TAG, "Secure thread was null, attempting to create new");
- getBluetoothSerialServerInstance().setAcceptThread(new AcceptThread(true));
- if(getBluetoothSerialServerInstance().getAcceptThread()!=null){
- getBluetoothSerialServerInstance().setState(STATE_LISTEN);
- getBluetoothSerialServerInstance().getAcceptThread().start();
+ setAcceptThread(new AcceptThread(true));
+ if(getAcceptThread()!=null){
+ setState(STATE_LISTEN);
+ getAcceptThread().start();
}
}
}
@@ -205,7 +202,7 @@ public class MultiplexBluetoothTransport {
public synchronized void connect(BluetoothDevice device) {
// Cancel any thread attempting to make a connection
if (mState == STATE_CONNECTING) {
- if (serverInstance.mConnectThread != null) {serverInstance.mConnectThread.cancel(); serverInstance.mConnectThread = null;}
+ if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}
}
// Cancel any thread currently running a connection
@@ -220,9 +217,9 @@ public class MultiplexBluetoothTransport {
}
// Start the thread to connect with the given device
- serverInstance.mConnectThread = new ConnectThread(device);
- serverInstance.mConnectThread.start();
- serverInstance.setState(STATE_CONNECTING);
+ mConnectThread = new ConnectThread(device);
+ mConnectThread.start();
+ setState(STATE_CONNECTING);
}
/**
@@ -232,9 +229,9 @@ public class MultiplexBluetoothTransport {
*/
public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {
// Cancel the thread that completed the connection
- if (getBluetoothSerialServerInstance().mConnectThread != null) {
- getBluetoothSerialServerInstance().mConnectThread.cancel();
- getBluetoothSerialServerInstance().mConnectThread = null;
+ if (mConnectThread != null) {
+ mConnectThread.cancel();
+ mConnectThread = null;
}
// Cancel any thread currently running a connection
@@ -247,9 +244,9 @@ public class MultiplexBluetoothTransport {
mConnectedWriteThread = null;
}
// Cancel the accept thread because we only want to connect to one device
- if (!keepSocketAlive && getBluetoothSerialServerInstance().mSecureAcceptThread != null) {
- getBluetoothSerialServerInstance().mSecureAcceptThread.cancel();
- getBluetoothSerialServerInstance().mSecureAcceptThread = null;
+ if (!keepSocketAlive && mSecureAcceptThread != null) {
+ mSecureAcceptThread.cancel();
+ mSecureAcceptThread = null;
}
// Start the thread to manage the connection and perform transmissions
@@ -259,32 +256,31 @@ public class MultiplexBluetoothTransport {
mConnectedWriteThread = new ConnectedWriteThread(socket);
mConnectedWriteThread.start();
- //Store a static name of the device that is connected. We can do this since the only time
- //we will access it will be when we receive a CONNECT packet from a device
- if(device!=null && device.getName()!=null && device.getName()!=""){
+ //Store a static name of the device that is connected.
+ if(device!=null){
currentlyConnectedDevice = device.getName();
}
// Send the name of the connected device back to the UI Activity
Message msg = mHandler.obtainMessage(SdlRouterService.MESSAGE_DEVICE_NAME);
Bundle bundle = new Bundle();
- bundle.putString(DEVICE_NAME, device.getName());
+ bundle.putString(DEVICE_NAME, currentlyConnectedDevice);
msg.setData(bundle);
- getBluetoothSerialServerInstance().mHandler.sendMessage(msg);
- getBluetoothSerialServerInstance().setState(STATE_CONNECTED);
+ mHandler.sendMessage(msg);
+ setState(STATE_CONNECTED);
}
/**
* Stop all threads
*/
public synchronized void stop() {
- getBluetoothSerialServerInstance().stop(STATE_NONE);
+ stop(STATE_NONE);
}
protected synchronized void stop(int stateToTransitionTo) {
//Log.d(TAG, "Attempting to close the bluetooth serial server");
- if (getBluetoothSerialServerInstance().mConnectThread != null) {
- getBluetoothSerialServerInstance().mConnectThread.cancel();
- getBluetoothSerialServerInstance().mConnectThread = null;
+ if (mConnectThread != null) {
+ mConnectThread.cancel();
+ mConnectThread = null;
}
if (mConnectedThread != null) {
@@ -298,7 +294,7 @@ public class MultiplexBluetoothTransport {
mSecureAcceptThread = null;
}
- getBluetoothSerialServerInstance().setState(stateToTransitionTo);
+ setState(stateToTransitionTo);
}
@@ -329,7 +325,7 @@ public class MultiplexBluetoothTransport {
Bundle bundle = new Bundle();
bundle.putString(TOAST, "Unable to connect device");
msg.setData(bundle);
- getBluetoothSerialServerInstance().mHandler.sendMessage(msg);
+ mHandler.sendMessage(msg);
// Start the service over to restart listening mode
// BluetoothSerialServer.this.start();
@@ -344,14 +340,14 @@ public class MultiplexBluetoothTransport {
Bundle bundle = new Bundle();
bundle.putString(TOAST, "Device connection was lost");
msg.setData(bundle);
- getBluetoothSerialServerInstance().mHandler.sendMessage(msg);
- getBluetoothSerialServerInstance().stop();
+ mHandler.sendMessage(msg);
+ stop();
}
private void timerDelayRemoveDialog(final BluetoothSocket sock){
- getBluetoothSerialServerInstance().timeOutHandler = new Handler();
- getBluetoothSerialServerInstance().socketRunable = new Runnable() {
+ timeOutHandler = new Handler();
+ socketRunable = new Runnable() {
public void run() {
//Log.e(TAG, "BLUETOOTH SOCKET CONNECT TIMEOUT - ATTEMPT TO CLOSE SOCKET");
try {
@@ -361,7 +357,7 @@ public class MultiplexBluetoothTransport {
}
}
};
- getBluetoothSerialServerInstance().timeOutHandler.postDelayed(socketRunable, msTillTimeout);
+ timeOutHandler.postDelayed(socketRunable, MS_TILL_TIMEOUT);
}
@@ -378,14 +374,14 @@ public class MultiplexBluetoothTransport {
@SuppressLint("NewApi")
public AcceptThread(boolean secure) {
- synchronized(threadLock){
+ synchronized(THREAD_LOCK){
//Log.d(TAG, "Creating an Accept Thread");
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
- tmp = getBluetoothSerialServerInstance().mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, SERVER_UUID);
+ tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, SERVER_UUID);
}
} catch (IOException e) {
//Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
@@ -402,7 +398,7 @@ public class MultiplexBluetoothTransport {
}
public void run() {
- synchronized(threadLock){
+ synchronized(THREAD_LOCK){
Log.d(TAG, "Socket Type: " + mSocketType +
" BEGIN mAcceptThread" + this);
setName("AcceptThread" + mSocketType);
@@ -415,7 +411,7 @@ public class MultiplexBluetoothTransport {
try {
if(listenAttempts>=5){
Log.e(TAG, "Complete failure in attempting to listen for Bluetooth connection, erroring out.");
- getBluetoothSerialServerInstance().stop(STATE_ERROR);
+ MultiplexBluetoothTransport.this.stop(STATE_ERROR);
return;
}
listenAttempts++;
@@ -430,12 +426,12 @@ public class MultiplexBluetoothTransport {
}
else{
Log.e(TAG, "Listening Socket was null, stopping the bluetooth serial server.");
- getBluetoothSerialServerInstance().stop(STATE_ERROR);
+ MultiplexBluetoothTransport.this.stop(STATE_ERROR);
return;
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "accept() failed");
- getBluetoothSerialServerInstance().stop(STATE_ERROR);
+ MultiplexBluetoothTransport.this.stop(STATE_ERROR);
return;
}
@@ -446,7 +442,7 @@ public class MultiplexBluetoothTransport {
case STATE_LISTEN:
case STATE_CONNECTING:
// Situation normal. Start the connected thread.
- getBluetoothSerialServerInstance().connected(socket, socket.getRemoteDevice());
+ connected(socket, socket.getRemoteDevice());
break;
case STATE_NONE:
@@ -454,9 +450,7 @@ public class MultiplexBluetoothTransport {
// Either not ready or already connected. Terminate new socket.
try {
Log.d(TAG, "Close unwanted socket");
- if(socket!=null){
- socket.close();
- }
+ socket.close();
} catch (IOException e) {
Log.e(TAG, "Could not close unwanted socket", e);
}
@@ -729,7 +723,7 @@ public class MultiplexBluetoothTransport {
// Exception during write
//OMG! WE MUST NOT BE CONNECTED ANYMORE! LET THE USER KNOW
Log.e(TAG, "Error sending bytes to connected device!");
- getBluetoothSerialServerInstance().connectionLost();
+ connectionLost();
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java b/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java
index ecb8281cc..c7cb0e59e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java
@@ -24,6 +24,7 @@ public class MultiplexTransport extends SdlTransport{
super(transportListener);
if(transportConfig == null){
this.handleTransportError("Transport config was null", null);
+ throw new IllegalArgumentException("Null transportConfig in MultiplexTransport constructor");
}
this.transportConfig = transportConfig;
brokerThread = new TransportBrokerThread(transportConfig.context, transportConfig.appId, transportConfig.service);
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java b/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java
index 6703232d5..92dce9dbe 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java
@@ -22,6 +22,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
+import android.os.Build;
import android.util.Log;
import com.smartdevicelink.util.HttpRequestTask;
@@ -117,18 +118,29 @@ public class RouterServiceValidator {
if(this.service != null){
Log.d(TAG, "Supplied service name of " + this.service.getClassName());
- if(!isServiceRunning(context,this.service)){
+ if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O && !isServiceRunning(context,this.service)){
//This means our service isn't actually running, so set to null. Hopefully we can find a real router service after this.
service = null;
Log.w(TAG, "Supplied service is not actually running.");
+ } else {
+ // If the running router service is created by this app, the validation is good by default
+ if (this.service.getPackageName().equals(context.getPackageName())) {
+ return true;
+ }
}
}
if(this.service == null){
- this.service= componentNameForServiceRunning(pm); //Change this to an array if multiple services are started?
- if(this.service == null){ //if this is still null we know there is no service running so we can return false
+ if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ) {
+ this.service = componentNameForServiceRunning(pm); //Change this to an array if multiple services are started?
+ if (this.service == null) { //if this is still null we know there is no service running so we can return false
+ wakeUpRouterServices();
+ return false;
+ }
+ }else{
wakeUpRouterServices();
return false;
}
+
}
//Log.d(TAG, "Checking app package: " + service.getClassName());
@@ -351,7 +363,7 @@ public class RouterServiceValidator {
List<SdlApp> apps = new ArrayList<SdlApp>();
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent();
- intent.setAction("sdl.router.startservice");
+ intent.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
List<ResolveInfo> infoList = packageManager.queryBroadcastReceivers(intent, 0);
//We want to sort our list so that we know it's the same everytime
Collections.sort(infoList,new Comparator<ResolveInfo>() {
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java
index 6a5cda6b7..94bb3c51e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java
@@ -1,22 +1,39 @@
package com.smartdevicelink.transport;
-import java.util.List;
-import java.util.Locale;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import com.smartdevicelink.util.AndroidTools;
-import com.smartdevicelink.transport.RouterServiceValidator.TrustedListCallback;
-
+import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
+import android.app.usage.UsageStats;
+import android.app.usage.UsageStatsManager;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.os.Build;
import android.util.Log;
+import com.smartdevicelink.transport.RouterServiceValidator.TrustedListCallback;
+import com.smartdevicelink.util.AndroidTools;
+import com.smartdevicelink.util.ServiceFinder;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Vector;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import static com.smartdevicelink.transport.TransportConstants.BIND_LOCATION_CLASS_NAME_EXTRA;
+import static com.smartdevicelink.transport.TransportConstants.BIND_LOCATION_PACKAGE_NAME_EXTRA;
+import static com.smartdevicelink.transport.TransportConstants.FOREGROUND_EXTRA;
+import static com.smartdevicelink.transport.TransportConstants.SEND_PACKET_TO_APP_LOCATION_EXTRA_NAME;
+
public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
private static final String TAG = "Sdl Broadcast Receiver";
@@ -74,8 +91,10 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
return;
}
- boolean didStart = false;
- localRouterClass = defineLocalSdlRouterClass();
+ boolean didStart = false;
+ if (localRouterClass == null){
+ localRouterClass = defineLocalSdlRouterClass();
+ }
//This will only be true if we are being told to reopen our SDL service because SDL is enabled
if(action.equalsIgnoreCase(TransportConstants.START_ROUTER_SERVICE_ACTION)){
@@ -93,9 +112,6 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
//List obtained. Let's start our service
queuedService = componentName;
finalIntent.setAction("com.sdl.noaction"); //Replace what's there so we do go into some unintended loop
- //Validate the router service so the service knows if this is a trusted router service
- RouterServiceValidator vlad = new RouterServiceValidator(finalContext,componentName);
- finalIntent.putExtra(TransportConstants.ROUTER_SERVICE_VALIDATED, vlad.validate());
onSdlEnabled(finalContext, finalIntent);
}
@@ -130,10 +146,10 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
return;
}
}
-
+ Log.d(TAG, "Check for local router");
if(localRouterClass!=null){ //If there is a supplied router service lets run some logic regarding starting one
- if(!didStart){
+ if(!didStart){Log.d(TAG, "attempting to wake up router service");
didStart = wakeUpRouterService(context, true,false);
}
@@ -148,42 +164,109 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
context.sendBroadcast(restart);
}
}
-
- private boolean wakeUpRouterService(Context context, boolean ping, boolean altTransportWake){
- if(!isRouterServiceRunning(context, ping)){
- //If there isn't a service running we should try to start one
- //The under class should have implemented this....
-
- //So let's start up our service since no copy is running
- Intent serviceIntent = new Intent(context, localRouterClass);
- if(altTransportWake){
- serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
- }
- try {
- context.startService(serviceIntent);
- }catch (SecurityException e){
- Log.e(TAG, "Security exception, process is bad");
- return false; // Let's exit, we can't start the service
- }
- return true;
- }else{
- if(altTransportWake && runningBluetoothServicePackage!=null && runningBluetoothServicePackage.size()>0){
- Intent serviceIntent = new Intent();
- serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
- //context.startService(serviceIntent);
- for(ComponentName compName: runningBluetoothServicePackage){
- serviceIntent.setComponent(compName);
- context.startService(serviceIntent);
- }
- return true;
- }
- return false;
- }
+ @TargetApi(Build.VERSION_CODES.O)
+ private boolean wakeUpRouterService(final Context context, final boolean ping, final boolean altTransportWake){
+ if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ if (!isRouterServiceRunning(context, ping)) {
+ //If there isn't a service running we should try to start one
+ //The under class should have implemented this....
+ Log.d(TAG, "No router service running, starting ours");
+ //So let's start up our service since no copy is running
+ Intent serviceIntent = new Intent(context, localRouterClass);
+ if (altTransportWake) {
+ serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
+ }
+ try {
+ context.startService(serviceIntent);
+ } catch (SecurityException e) {
+ Log.e(TAG, "Security exception, process is bad");
+ return false; // Let's exit, we can't start the service
+ }
+ return true;
+ } else {
+ if (altTransportWake && runningBluetoothServicePackage != null && runningBluetoothServicePackage.size() > 0) {
+ wakeRouterServiceAltTransport(context);
+ return true;
+ }
+ return false;
+ }
+ }else{ //We are android Oreo or newer
+ ServiceFinder finder = new ServiceFinder(context, context.getPackageName(), new ServiceFinder.ServiceFinderCallback() {
+ @Override
+ public void onComplete(Vector<ComponentName> routerServices) {
+ runningBluetoothServicePackage = new Vector<ComponentName>();
+ runningBluetoothServicePackage.addAll(routerServices);
+ if (runningBluetoothServicePackage.isEmpty()) {
+ //If there isn't a service running we should try to start one
+ //We will try to sort the SDL enabled apps and find the one that's been installed the longest
+ Intent serviceIntent;
+ final PackageManager packageManager = context.getPackageManager();
+ Vector<ResolveInfo> apps = new Vector(AndroidTools.getSdlEnabledApps(context, "").values()); //we want our package
+ if (apps != null && !apps.isEmpty()) {
+ Collections.sort(apps, new Comparator<ResolveInfo>() {
+ @Override
+ public int compare(ResolveInfo resolveInfo, ResolveInfo t1) {
+ try {
+ PackageInfo thisPack = packageManager.getPackageInfo(resolveInfo.activityInfo.packageName, 0);
+ PackageInfo itPack = packageManager.getPackageInfo(t1.activityInfo.packageName, 0);
+ if (thisPack.lastUpdateTime < itPack.lastUpdateTime) {
+ return -1;
+ } else if (thisPack.lastUpdateTime > itPack.lastUpdateTime) {
+ return 1;
+ }
+
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ return 0;
+ }
+ });
+ String packageName = apps.get(0).activityInfo.packageName;
+ serviceIntent = new Intent();
+ serviceIntent.setComponent(new ComponentName(packageName, packageName +".SdlRouterService"));
+ } else{
+ Log.d(TAG, "No router service running, starting ours");
+ //So let's start up our service since no copy is running
+ serviceIntent = new Intent(context, localRouterClass);
+
+ }
+ if (altTransportWake) {
+ serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
+ }
+ try {
+ serviceIntent.putExtra(FOREGROUND_EXTRA, true);
+ context.startForegroundService(serviceIntent);
+
+ } catch (SecurityException e) {
+ Log.e(TAG, "Security exception, process is bad");
+ }
+ } else {
+ if (altTransportWake && runningBluetoothServicePackage != null && runningBluetoothServicePackage.size() > 0) {
+ wakeRouterServiceAltTransport(context);
+ return;
+ }
+ return;
+ }
+ }
+ });
+ return true;
+ }
+ }
+
+ private void wakeRouterServiceAltTransport(Context context){
+ Intent serviceIntent = new Intent();
+ serviceIntent.setAction(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT);
+ for (ComponentName compName : runningBluetoothServicePackage) {
+ serviceIntent.setComponent(compName);
+ context.startService(serviceIntent);
+
+ }
}
/**
- * Determines if an instance of the Router Service is currently running on the device.
+ * Determines if an instance of the Router Service is currently running on the device.<p>
+ * <b>Note:</b> This method no longer works on Android Oreo or newer
* @param context A context to access Android system services through.
* @param pingService Set this to true if you want to make sure the service is up and listening to bluetooth
* @return True if a SDL Router Service is currently running, false otherwise.
@@ -193,31 +276,30 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
Log.e(TAG, "Can't look for router service, context supplied was null");
return false;
}
- ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- if(runningBluetoothServicePackage==null){
+ if (runningBluetoothServicePackage == null) {
runningBluetoothServicePackage = new Vector<ComponentName>();
- }else{
+ } else {
runningBluetoothServicePackage.clear();
}
+ ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ manager.getRunningAppProcesses();
List<RunningServiceInfo> runningServices = null;
- try{
+ try {
runningServices = manager.getRunningServices(Integer.MAX_VALUE);
- }catch(NullPointerException e){
+ } catch (NullPointerException e) {
Log.e(TAG, "Can't get list of running services");
return false;
}
- for (RunningServiceInfo service : runningServices) {
+ for (RunningServiceInfo service : runningServices) {
//We will check to see if it contains this name, should be pretty specific
- //Log.d(TAG, "Found Service: "+ service.service.getClassName());
- if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SDL_ROUTER_SERVICE_CLASS_NAME) && AndroidTools.isServiceExported(context, service.service)) {
-
- runningBluetoothServicePackage.add(service.service); //Store which instance is running
- if(pingService){
+ //Log.d(TAG, "Found Service: "+ service.service.getClassName());
+ if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SDL_ROUTER_SERVICE_CLASS_NAME) && AndroidTools.isServiceExported(context, service.service)) {
+ runningBluetoothServicePackage.add(service.service); //Store which instance is running
+ if (pingService) {
pingRouterService(context, service.service.getPackageName(), service.service.getClassName());
- }
- }
- }
-
+ }
+ }
+ }
return runningBluetoothServicePackage.size() > 0;
}
@@ -242,33 +324,46 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
// This service could not be started
}
}
-
+
/**
* This call will reach out to all SDL related router services to check if they're connected. If a the router service is connected, it will react by pinging all clients. This receiver will then
* receive that ping and if the router service is trusted, the onSdlEnabled method will be called.
* @param context
*/
- public static void queryForConnectedService(Context context){
+ public static void queryForConnectedService(final Context context){
//Leverage existing call. Include ping bit
- requestTransportStatus(context,null,true);
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
+ ServiceFinder finder = new ServiceFinder(context, context.getPackageName(), new ServiceFinder.ServiceFinderCallback() {
+ @Override
+ public void onComplete(Vector<ComponentName> routerServices) {
+ runningBluetoothServicePackage = new Vector<ComponentName>();
+ runningBluetoothServicePackage.addAll(routerServices);
+ requestTransportStatus(context,null,true,false);
+ }
+ });
+
+ }else{
+ requestTransportStatus(context,null,true,true);
+ }
}
/**
* If a Router Service is running, this method determines if that service is connected to a device over some form of transport.
* @param context A context to access Android system services through. If null is passed, this will always return false
* @param callback Use this callback to find out if the router service is connected or not.
*/
+ @Deprecated
public static void requestTransportStatus(Context context, final SdlRouterStatusProvider.ConnectedStatusCallback callback){
- requestTransportStatus(context,callback,false);
+ requestTransportStatus(context,callback,false, true);
}
- private static void requestTransportStatus(Context context, final SdlRouterStatusProvider.ConnectedStatusCallback callback, final boolean triggerRouterServicePing){
+ private static void requestTransportStatus(Context context, final SdlRouterStatusProvider.ConnectedStatusCallback callback, final boolean triggerRouterServicePing, final boolean lookForServices){
if(context == null){
if(callback!=null){
callback.onConnectionStatusUpdate(false, null,context);
}
return;
}
- if(isRouterServiceRunning(context,false) && !runningBluetoothServicePackage.isEmpty()){ //So there is a service up, let's see if it's connected
+ if((!lookForServices || isRouterServiceRunning(context,false)) && !runningBluetoothServicePackage.isEmpty()){ //So there is a service up, let's see if it's connected
final ConcurrentLinkedQueue<ComponentName> list = new ConcurrentLinkedQueue<ComponentName>(runningBluetoothServicePackage);
final SdlRouterStatusProvider.ConnectedStatusCallback sdlBrCallback = new SdlRouterStatusProvider.ConnectedStatusCallback() {
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlPsm.java b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlPsm.java
index ed86cbb69..1fc40bda4 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlPsm.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlPsm.java
@@ -76,7 +76,7 @@ public class SdlPsm{
frameType = rawByte&(byte)FRAME_TYPE_MASK;
//Log.trace(TAG, rawByte + " = Frame Type: " + frameType);
- if((version < 1 || version > 4) //These are known versions supported by this library.
+ if((version < 1 || version > 5) //These are known versions supported by this library.
&& frameType!=SdlPacket.FRAME_TYPE_CONTROL){
return ERROR_STATE;
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
index 2bae96e27..5ca8cec0e 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
@@ -22,11 +22,14 @@ import org.json.JSONException;
import org.json.JSONObject;
import android.Manifest;
+
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
@@ -71,6 +74,30 @@ import com.smartdevicelink.transport.utl.ByteAraryMessageAssembler;
import com.smartdevicelink.transport.utl.ByteArrayMessageSpliter;
import com.smartdevicelink.util.AndroidTools;
import com.smartdevicelink.util.BitConverter;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.lang.ref.WeakReference;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+import java.util.Vector;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import static com.smartdevicelink.transport.TransportConstants.CONNECTED_DEVICE_STRING_EXTRA_NAME;
+import static com.smartdevicelink.transport.TransportConstants.FOREGROUND_EXTRA;
+import static com.smartdevicelink.transport.TransportConstants.FORMED_PACKET_EXTRA_NAME;
+import static com.smartdevicelink.transport.TransportConstants.HARDWARE_DISCONNECTED;
+import static com.smartdevicelink.transport.TransportConstants.SDL_NOTIFICATION_CHANNEL_ID;
+import static com.smartdevicelink.transport.TransportConstants.SDL_NOTIFICATION_CHANNEL_NAME;
+import static com.smartdevicelink.transport.TransportConstants.SEND_PACKET_TO_APP_LOCATION_EXTRA_NAME;
/**
* <b>This class should not be modified by anyone outside of the approved contributors of the SmartDeviceLink project.</b>
* This service is a central point of communication between hardware and the registered clients. It will multiplex a single transport
@@ -93,8 +120,12 @@ public class SdlRouterService extends Service{
private static final long CLIENT_PING_DELAY = 1000;
public static final String REGISTER_NEWER_SERVER_INSTANCE_ACTION = "com.sdl.android.newservice";
+ /**
+ * @deprecated use {@link TransportConstants#START_ROUTER_SERVICE_ACTION} instead
+ */
+ @Deprecated
public static final String START_SERVICE_ACTION = "sdl.router.startservice";
- public static final String REGISTER_WITH_ROUTER_ACTION = "com.sdl.android.register";
+ public static final String REGISTER_WITH_ROUTER_ACTION = "com.sdl.android.register";
/** Message types sent from the BluetoothReadService Handler */
public static final int MESSAGE_STATE_CHANGE = 1;
@@ -105,7 +136,7 @@ public class SdlRouterService extends Service{
private final int UNREGISTER_APP_INTERFACE_CORRELATION_ID = 65530;
- private static MultiplexBluetoothTransport mSerialService = null;
+ private MultiplexBluetoothTransport mSerialService = null;
private static boolean connectAsClient = false;
private static boolean closing = false;
@@ -167,7 +198,7 @@ public class SdlRouterService extends Service{
{
//Let's grab where to reply to this intent at. We will keep it temp right now because we may have to deny registration
String action =intent.getStringExtra(SEND_PACKET_TO_APP_LOCATION_EXTRA_NAME);
- sendBroadcast(prepareRegistrationIntent(action));
+ sendBroadcast(prepareRegistrationIntent(action));
}
};
@@ -176,6 +207,7 @@ public class SdlRouterService extends Service{
registrationIntent.setAction(action);
registrationIntent.putExtra(TransportConstants.BIND_LOCATION_PACKAGE_NAME_EXTRA, this.getPackageName());
registrationIntent.putExtra(TransportConstants.BIND_LOCATION_CLASS_NAME_EXTRA, this.getClass().getName());
+ registrationIntent.setFlags((Intent.FLAG_RECEIVER_FOREGROUND));
return registrationIntent;
}
@@ -192,16 +224,8 @@ public class SdlRouterService extends Service{
Log.e(TAG, "Serial service not initliazed while registering app");
//Maybe we should try to do a connect here instead
Log.d(TAG, "Serial service being restarted");
- if(mSerialService ==null){
- Log.e(TAG, "Local copy of BT Server is null");
- mSerialService = MultiplexBluetoothTransport.getBluetoothSerialServerInstance();
- if(mSerialService==null){
- Log.e(TAG, "Local copy of BT Server is still null and so is global");
- mSerialService = MultiplexBluetoothTransport.getBluetoothSerialServerInstance(mHandlerBT);
+ initBluetoothSerialService();
- }
- }
- mSerialService.start();
}
}
@@ -216,7 +240,7 @@ public class SdlRouterService extends Service{
BroadcastReceiver registerAnInstanceOfSerialServer = new BroadcastReceiver() {
final Object COMPARE_LOCK = new Object();
@Override
- public void onReceive(Context context, Intent intent)
+ public void onReceive(Context context, Intent intent)
{
LocalRouterService tempService = intent.getParcelableExtra(SdlBroadcastReceiver.LOCAL_ROUTER_SERVICE_EXTRA);
synchronized(COMPARE_LOCK){
@@ -303,7 +327,7 @@ public class SdlRouterService extends Service{
*********************************************** Handlers for bound clients **************************************************************
****************************************************************************************************************************************/
-
+
/**
* Target we publish for clients to send messages to RouterHandler.
*/
@@ -318,7 +342,7 @@ public class SdlRouterService extends Service{
public RouterHandler(SdlRouterService provider){
this.provider = new WeakReference<SdlRouterService>(provider);
}
-
+
@Override
public void handleMessage(Message msg) {
if(this.provider.get() == null){
@@ -609,20 +633,20 @@ public class SdlRouterService extends Service{
case TransportConstants.ROUTER_RECEIVED_PACKET:
if(receivedBundle!=null){
receivedBundle.setClassLoader(loader);//We do this because loading a custom parceable object isn't possible without it
- }else{
- Log.e(TAG, "Bundle was null while sending packet to router service from alt transport");
- }
- if(receivedBundle.containsKey(TransportConstants.FORMED_PACKET_EXTRA_NAME)){
- SdlPacket packet = receivedBundle.getParcelable(TransportConstants.FORMED_PACKET_EXTRA_NAME);
- if(packet!=null){
- service.onPacketRead(packet);
- }else{
- Log.w(TAG, "Received null packet from alt transport service");
- }
- }else{
- Log.w(TAG, "Flase positive packet reception");
- }
- break;
+ if(receivedBundle.containsKey(TransportConstants.FORMED_PACKET_EXTRA_NAME)){
+ SdlPacket packet = receivedBundle.getParcelable(TransportConstants.FORMED_PACKET_EXTRA_NAME);
+ if(packet!=null){
+ service.onPacketRead(packet);
+ }else{
+ Log.w(TAG, "Received null packet from alt transport service");
+ }
+ }else{
+ Log.w(TAG, "Flase positive packet reception");
+ }
+ }else{
+ Log.e(TAG, "Bundle was null while sending packet to router service from alt transport");
+ }
+ break;
default:
super.handleMessage(msg);
}
@@ -839,7 +863,7 @@ public class SdlRouterService extends Service{
}
HashMap<String,ResolveInfo> sdlMultiList ;
public void startVersionCheck(){
- Intent intent = new Intent(START_SERVICE_ACTION);
+ Intent intent = new Intent(TransportConstants.START_ROUTER_SERVICE_ACTION);
List<ResolveInfo> infos = getPackageManager().queryBroadcastReceivers(intent, 0);
sdlMultiList = new HashMap<String,ResolveInfo>();
for(ResolveInfo info: infos){
@@ -892,6 +916,9 @@ public class SdlRouterService extends Service{
}
}
if(intent != null ){
+ if(intent.getBooleanExtra(FOREGROUND_EXTRA, false)){
+ enterForeground();
+ }
if(intent.hasExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA)){
//Make sure we are listening on RFCOMM
if(startSequenceComplete){ //We only check if we are sure we are already through the start up process
@@ -1032,18 +1059,37 @@ public class SdlRouterService extends Service{
notification = builder.getNotification();
}else{
+ if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O) {
+ //Now we need to add a notification channel
+ NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ String channelId = SDL_NOTIFICATION_CHANNEL_ID;
+ CharSequence channelName = SDL_NOTIFICATION_CHANNEL_NAME;
+ int importance = NotificationManager.IMPORTANCE_DEFAULT;
+ NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName, importance);
+ notificationChannel.enableLights(false);
+ notificationChannel.enableVibration(false);
+ notificationManager.createNotificationChannel(notificationChannel);
+ builder.setChannelId(channelId);
+
+ }
notification = builder.build();
}
if(notification == null){
Log.e(TAG, "Notification was null");
+ return;
}
startForeground(FOREGROUND_SERVICE_ID, notification);
isForeground = true;
}
-
+
private void exitForeground(){
if(isForeground){
+ if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.O){
+ NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.deleteNotificationChannel(TransportConstants.SDL_NOTIFICATION_CHANNEL_ID);
+ }
+
this.stopForeground(true);
}
}
@@ -1117,18 +1163,16 @@ public class SdlRouterService extends Service{
Log.d(TAG, "Not starting own bluetooth during legacy mode");
return;
}
- Log.i(TAG, "Iniitializing bluetooth transport");
//init serial service
- if(mSerialService ==null){
- mSerialService = MultiplexBluetoothTransport.getBluetoothSerialServerInstance();
- if(mSerialService==null){
- mSerialService = MultiplexBluetoothTransport.getBluetoothSerialServerInstance(mHandlerBT);
- }
+ if(mSerialService == null || mSerialService.getState() == MultiplexBluetoothTransport.STATE_ERROR){
+ Log.i(TAG, "Initializing bluetooth transport");
+ mSerialService = new MultiplexBluetoothTransport(mHandlerBT);
}
if (mSerialService != null) {
// Only if the state is STATE_NONE, do we know that we haven't started already
- if (mSerialService.getState() == MultiplexBluetoothTransport.STATE_NONE || mSerialService.getState() == MultiplexBluetoothTransport.STATE_ERROR) {
+ if (mSerialService.getState() == MultiplexBluetoothTransport.STATE_NONE) {
// Start the Bluetooth services
+ Log.i(TAG, "Starting bluetooth transport");
mSerialService.start();
}
@@ -1148,12 +1192,24 @@ public class SdlRouterService extends Service{
connectedTransportType = type;
Intent startService = new Intent();
- startService.setAction(START_SERVICE_ACTION);
+ startService.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
+ //Perform our query prior to adding any extras or flags
+ List<ResolveInfo> sdlApps = getPackageManager().queryBroadcastReceivers(startService, 0);
+
startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA, true);
startService.putExtra(TransportConstants.FORCE_TRANSPORT_CONNECTED, true);
startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE, getBaseContext().getPackageName());
startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME, new ComponentName(this, this.getClass()));
- sendBroadcast(startService);
+ startService.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+
+ //Iterate through all apps that we know are listening for this intent with an explicit intent (neccessary for Android O SDK 26)
+ if(sdlApps != null && sdlApps.size()>0){
+ for(ResolveInfo app: sdlApps){
+ startService.setClassName(app.activityInfo.applicationInfo.packageName, app.activityInfo.name);
+ sendBroadcast(startService);
+ }
+ }
+
//HARDWARE_CONNECTED
if(!(registeredApps== null || registeredApps.isEmpty())){
//If we have clients
@@ -1289,10 +1345,10 @@ public class SdlRouterService extends Service{
return false;
}
if(mSerialService !=null && mSerialService.getState()==MultiplexBluetoothTransport.STATE_CONNECTED){
- byte[] packet = bundle.getByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME);
- int offset = bundle.getInt(TransportConstants.BYTES_TO_SEND_EXTRA_OFFSET, 0); //If nothing, start at the begining of the array
- int count = bundle.getInt(TransportConstants.BYTES_TO_SEND_EXTRA_COUNT, packet.length); //In case there isn't anything just send the whole packet.
+ byte[] packet = bundle.getByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME);
if(packet!=null){
+ int offset = bundle.getInt(TransportConstants.BYTES_TO_SEND_EXTRA_OFFSET, 0); //If nothing, start at the begining of the array
+ int count = bundle.getInt(TransportConstants.BYTES_TO_SEND_EXTRA_COUNT, packet.length); //In case there isn't anything just send the whole packet.
mSerialService.write(packet,offset,count);
return true;
}
@@ -1576,7 +1632,7 @@ public class SdlRouterService extends Service{
Log.d(TAG,"Connecting to device: " + device.getName().toString());
if(mSerialService == null || !mSerialService.isConnected())
{ // Set up the Bluetooth serial object
- mSerialService = MultiplexBluetoothTransport.getBluetoothSerialServerInstance(mHandlerBT);
+ mSerialService = new MultiplexBluetoothTransport(mHandlerBT);
}
// We've been given a device - let's connect to it
if(mSerialService.getState()!=MultiplexBluetoothTransport.STATE_CONNECTING){//mSerialService.stop();
@@ -1669,7 +1725,7 @@ public class SdlRouterService extends Service{
//Log.v(TAG, "Self service info " + self);
//Log.v(TAG, "Newest compare to service info " + newestServiceReceived);
if(newestServiceReceived!=null && self.isNewer(newestServiceReceived)){
- if(SdlRouterService.mSerialService!=null && SdlRouterService.mSerialService.isConnected()){ //We are currently connected. Wait for next connection
+ if(SdlRouterService.this.mSerialService!=null && SdlRouterService.this.mSerialService.isConnected()){ //We are currently connected. Wait for next connection
return;
}
Log.d(TAG, "There is a newer version "+newestServiceReceived.version+" of the Router Service, starting it up");
@@ -1734,7 +1790,7 @@ public class SdlRouterService extends Service{
}
}
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean removeAllSessionsWithAppId(String appId){
synchronized(SESSION_LOCK){
if(sessionMap!=null){
@@ -1935,7 +1991,7 @@ public class SdlRouterService extends Service{
private void initPingIntent(){
pingIntent = new Intent();
- pingIntent.setAction(START_SERVICE_ACTION);
+ pingIntent.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA, true);
pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE, getBaseContext().getPackageName());
pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME, new ComponentName(SdlRouterService.this, SdlRouterService.this.getClass()));
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java b/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java
index 89187d524..1d1b3b792 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java
@@ -7,6 +7,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -488,7 +489,7 @@ public class TransportBroker {
}
//Make sure we know where to bind to
if(this.routerService==null){
- if(!isRouterServiceRunning(getContext())){//We should be able to ignore this case because of the validation now
+ if((Build.VERSION.SDK_INT < Build.VERSION_CODES.O) && !isRouterServiceRunning(getContext())){//We should be able to ignore this case because of the validation now
Log.d(TAG,whereToReply + " found no router service. Shutting down.");
this.onHardwareDisconnected(null);
return false;
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java b/sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java
index 29cdea035..8db44f500 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/TransportConstants.java
@@ -10,6 +10,7 @@ package com.smartdevicelink.transport;
*/
public class TransportConstants {
public static final String START_ROUTER_SERVICE_ACTION ="sdl.router.startservice";
+ public static final String FOREGROUND_EXTRA = "foreground";
public static final String BIND_LOCATION_PACKAGE_NAME_EXTRA = "BIND_LOCATION_PACKAGE_NAME_EXTRA";
public static final String BIND_LOCATION_CLASS_NAME_EXTRA = "BIND_LOCATION_CLASS_NAME_EXTRA";
@@ -51,9 +52,15 @@ public class TransportConstants {
public static final String BIND_REQUEST_TYPE_ALT_TRANSPORT = "BIND_REQUEST_TYPE_ALT_TRANSPORT";
public static final String BIND_REQUEST_TYPE_STATUS = "BIND_REQUEST_TYPE_STATUS";
-
+
public static final String PING_ROUTER_SERVICE_EXTRA = "ping.router.service";
-
+
+ public static final String SDL_NOTIFICATION_CHANNEL_ID = "sdl_notification_channel";
+ public static final String SDL_NOTIFICATION_CHANNEL_NAME = "SmartDeviceLink";
+
+
+
+
/**
* This class houses all important router service versions
*/
diff --git a/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java b/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
index ff8819ec3..bc55dcb07 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/util/AndroidTools.java
@@ -2,9 +2,16 @@ package com.smartdevicelink.util;
import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.pm.ServiceInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+
+import com.smartdevicelink.transport.TransportConstants;
+
+import java.util.HashMap;
+import java.util.List;
public class AndroidTools {
/**
@@ -22,4 +29,24 @@ public class AndroidTools {
}
return false;
}
+ /**
+ * Get all SDL enabled apps. If the package name is null, it will return all apps. However, if the package name is included, the
+ * resulting hash map will not include the app with that package name.
+ * @param context
+ * @param myPackageName
+ * @return
+ */
+ public static HashMap<String,ResolveInfo> getSdlEnabledApps(Context context, String myPackageName){
+ Intent intent = new Intent(TransportConstants.START_ROUTER_SERVICE_ACTION);
+ List<ResolveInfo> infos = context.getPackageManager().queryBroadcastReceivers(intent, 0);
+ HashMap<String,ResolveInfo> sdlMultiList = new HashMap<String,ResolveInfo>();
+ for(ResolveInfo info: infos){
+ if(info.activityInfo.applicationInfo.packageName.equals(myPackageName)){
+ continue; //Ignoring my own package
+ }
+ sdlMultiList.put(info.activityInfo.packageName, info);
+ }
+ return sdlMultiList;
+ }
+
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/util/BitConverter.java b/sdl_android/src/main/java/com/smartdevicelink/util/BitConverter.java
index c844e49a4..a681a75a8 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/util/BitConverter.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/util/BitConverter.java
@@ -1,10 +1,21 @@
package com.smartdevicelink.util;
public class BitConverter {
+ /**
+ * @param bytes byte array that will be converted to hex
+ * @return the String containing converted hex values or null if byte array is null
+ */
public static String bytesToHex(byte [] bytes) {
+ if (bytes == null) { return null; }
return bytesToHex(bytes, 0, bytes.length);
} // end-method
+ /**
+ * @param bytes byte array that will be converted to hex
+ * @param offset int representing the offset to begin conversion at
+ * @param length int representing number of bytes in array to convert
+ * @return the String containing converted hex values or null if byte array is null
+ */
public static String bytesToHex(byte[] bytes, int offset, int length) {
if (bytes == null) { return null; }
final char[] HexDigits = new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
@@ -24,6 +35,10 @@ public class BitConverter {
return new String(hexChars);
} // end-method
+ /**
+ * @param hexString the String containing converted hex values
+ * @return byte array converted from input String or null if String is null
+ */
public static byte [] hexToBytes(String hexString) {
if (hexString == null) { return null; }
if (hexString.length() % 2 != 0) {
@@ -45,8 +60,13 @@ public class BitConverter {
(byte)(value >>> 8),
(byte)value};
}
-
+
+ /**
+ * @param sizeBuf byte array that will be converted to int
+ * @return int converted from byte array or -1 if byte array is null
+ */
public static int intFromByteArray(byte[] sizeBuf, int offset) {
+ if (sizeBuf == null) { return -1; }
int ret = 0;
for (int i = offset; i < offset + 4; i++) {
ret <<= 8;
@@ -60,8 +80,13 @@ public class BitConverter {
(byte)(value >>> 8),
(byte)value};
}
-
+
+ /**
+ * @param sizeBuf byte array that will be converted to short
+ * @return short converted from byte array or -1 if byte array is null
+ */
public static short shortFromByteArray(byte[] sizeBuf, int offset) {
+ if (sizeBuf == null) { return -1; }
short ret = 0;
for (int i = offset; i < offset + 2; i++) {
ret <<= 8;
@@ -72,11 +97,12 @@ public class BitConverter {
/**
* Converts the byte array into a string of hex values.
- * @param bytes
+ * @param bytes byte array that will be converted to hex
* @param end EXCLUSIVE so if it it receives 10 it will print 0-9
- * @return
+ * @return the String containing converted hex values or null if byte array is null
*/
public static String bytesToHex(byte[] bytes,int end){
+ if (bytes == null) { return null; }
if(bytes.length<end){
end = bytes.length;
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java b/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java
new file mode 100644
index 000000000..c115d046c
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java
@@ -0,0 +1,141 @@
+package com.smartdevicelink.util;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.ResolveInfo;
+import android.os.Handler;
+import android.util.Log;
+
+import com.smartdevicelink.transport.SdlRouterService;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+import static com.smartdevicelink.transport.TransportConstants.BIND_LOCATION_CLASS_NAME_EXTRA;
+import static com.smartdevicelink.transport.TransportConstants.BIND_LOCATION_PACKAGE_NAME_EXTRA;
+import static com.smartdevicelink.transport.TransportConstants.SEND_PACKET_TO_APP_LOCATION_EXTRA_NAME;
+
+/**
+ * Created by Joey Grover on 8/18/17.
+ */
+
+public class ServiceFinder {
+ public static final String TAG = ServiceFinder.class.getSimpleName();
+
+ private static final int TIMEOUT = 1000;
+ final String receiverLocation;
+ final Context context;
+ final ServiceFinderCallback callback;
+ final Vector<ComponentName> services;
+ final HashMap<String, ResolveInfo> sdlMultiMap;
+ final Handler timeoutHandler;
+ final Runnable timeoutRunnable;
+
+
+ public ServiceFinder(Context context, String packageName, final ServiceFinderCallback callback) {
+ this.receiverLocation = packageName + ".ServiceFinder";
+ this.context = context.getApplicationContext();
+ this.callback = callback;
+ this.services = new Vector<>();
+
+ this.sdlMultiMap = AndroidTools.getSdlEnabledApps(context, packageName);
+
+ this.context.registerReceiver(mainServiceReceiver, new IntentFilter(this.receiverLocation));
+
+ timeoutRunnable = new Runnable() {
+ @Override
+ public void run() {
+ onFinished();
+ }
+ };
+ timeoutHandler = new Handler();
+ timeoutHandler.postDelayed(timeoutRunnable, TIMEOUT + (50 * packageName.length()));
+
+ //Send out our broadcast
+ context.sendBroadcast(createQueryIntent(this.receiverLocation));
+
+
+ }
+
+ BroadcastReceiver mainServiceReceiver = new BroadcastReceiver() {
+ private final Object LIST_LOCK = new Object();
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "Received intent " + intent);
+ if (intent != null) {
+ String packageName = intent.getStringExtra(BIND_LOCATION_PACKAGE_NAME_EXTRA);
+ String className = intent.getStringExtra(BIND_LOCATION_CLASS_NAME_EXTRA);
+ Log.d(TAG, "Received intent from package: " + packageName + ". Classname: " + className);
+ synchronized (LIST_LOCK) {
+ //Add to running services
+ services.add(new ComponentName(packageName, className));
+ //Remove from our waiting for response list
+ sdlMultiMap.remove(packageName);
+
+ //If list is empty, return to callback and unregister
+ if (sdlMultiMap.isEmpty() && callback != null) {
+ timeoutHandler.removeCallbacks(timeoutRunnable);
+ onFinished();
+ }
+ }
+ }
+ }
+ };
+
+ private void onFinished() {
+ if (callback != null) {
+ callback.onComplete(services);
+ }
+ context.unregisterReceiver(mainServiceReceiver);
+
+ }
+
+// /**
+// * Get all SDL enabled apps. If the package name is null, it will return all apps. However, if the package name is included, the
+// * resulting hash map will not include the app with that package name.
+// *
+// * @param context
+// * @param packageName
+// * @return
+// */
+// public static HashMap<String, ResolveInfo> getSdlEnabledApps(Context context, String packageName) {
+// Intent intent = new Intent(TransportConstants.START_ROUTER_SERVICE_ACTION);
+// PackageManager manager = context.getPackageManager();
+// List<ResolveInfo> infos = manager.queryBroadcastReceivers(intent, 0);
+// HashMap<String, ResolveInfo> sdlMultiMap = new HashMap<String, ResolveInfo>();
+// for (ResolveInfo info : infos) {
+// //Log.d(TAG, "Sdl enabled app: " + info.activityInfo.packageName);
+// if (info.activityInfo.applicationInfo.packageName.equals(packageName)) {
+// //Log.d(TAG, "Ignoring my own package");
+// continue;
+// }
+//
+// sdlMultiMap.put(info.activityInfo.packageName, info);
+// try {
+// ServiceInfo[] services = manager.getPackageInfo(info.activityInfo.applicationInfo.packageName, PackageManager.GET_SERVICES).services;
+// for (int i = 0; i < services.length; i++) {
+// Log.d(TAG, "Found : " + services[i].name);
+// }
+// } catch (PackageManager.NameNotFoundException e) {
+// e.printStackTrace();
+// }
+// }
+// return sdlMultiMap;
+// }
+
+ private static Intent createQueryIntent(String receiverLocation) {
+ Intent intent = new Intent();
+ intent.setAction(SdlRouterService.REGISTER_WITH_ROUTER_ACTION);
+ intent.putExtra(SEND_PACKET_TO_APP_LOCATION_EXTRA_NAME, receiverLocation);
+ intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ return intent;
+ }
+
+ public interface ServiceFinderCallback {
+ void onComplete(Vector<ComponentName> routerServices);
+ }
+}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/util/Version.java b/sdl_android/src/main/java/com/smartdevicelink/util/Version.java
new file mode 100644
index 000000000..8621c8cfd
--- /dev/null
+++ b/sdl_android/src/main/java/com/smartdevicelink/util/Version.java
@@ -0,0 +1,47 @@
+package com.smartdevicelink.util;
+
+
+public class Version {
+
+ int major,minor,patch;
+
+ public Version(){
+ major = 0;
+ minor = 0;
+ patch = 0;
+ }
+
+ public Version(String versionString){
+ String[] versions = versionString.split("\\.");
+ if(versions.length!=3){
+ throw new IllegalArgumentException("Incorrect version string format");
+ }
+ major = Integer.valueOf(versions[0]);
+ minor = Integer.valueOf(versions[1]);
+ patch = Integer.valueOf(versions[2]);
+
+ }
+
+ public int getMajor() {
+ return major;
+ }
+
+ public int getMinor() {
+ return minor;
+ }
+
+ public int getPatch() {
+ return patch;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(major);
+ builder.append(".");
+ builder.append(minor);
+ builder.append(".");
+ builder.append(patch);
+ return builder.toString();
+ }
+}
diff --git a/sdl_android/src/test/java/com/smartdevicelink/haptic/HapticInterfaceManagerTest.java b/sdl_android/src/test/java/com/smartdevicelink/haptic/HapticInterfaceManagerTest.java
new file mode 100644
index 000000000..87c547bb1
--- /dev/null
+++ b/sdl_android/src/test/java/com/smartdevicelink/haptic/HapticInterfaceManagerTest.java
@@ -0,0 +1,169 @@
+/***************************************************************************************************
+ * Copyright © 2017 Xevo Inc.
+ * Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
+ * and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
+ * conditions and the following disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
+ * endorse or promote products derived from this software without specific prior written
+ * permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+ * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ **************************************************************************************************/
+package com.smartdevicelink.haptic;
+
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.smartdevicelink.proxy.interfaces.ISdl;
+import com.smartdevicelink.proxy.rpc.HapticRect;
+import com.smartdevicelink.proxy.rpc.Rectangle;
+import com.smartdevicelink.proxy.rpc.SendHapticData;
+
+import junit.framework.TestCase;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * Created on 9/26/2017.
+ */
+@RunWith(MockitoJUnitRunner.Strict.class)
+public class HapticInterfaceManagerTest extends TestCase {
+ @Mock
+ private ISdl mockProxy;
+
+ @Captor
+ private ArgumentCaptor<SendHapticData> captor;
+
+ private HapticInterfaceManager hapticMgr;
+
+ @Before
+ public void setUp() throws Exception {
+ hapticMgr = new HapticInterfaceManager(mockProxy);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ hapticMgr = null;
+ }
+
+ @Test
+ public void testSetHapticData() throws Exception {
+ List<HapticRect> rects = new ArrayList<>();
+ Rectangle rect = new Rectangle();
+ rect.setX(10f);
+ rect.setY(10f);
+ rect.setWidth(50f);
+ rect.setHeight(20f);
+ HapticRect hRect = new HapticRect();
+ hRect.setRect(rect);
+ rects.add(hRect);
+ hapticMgr.setHapticData(rects);
+ verify(mockProxy).sendRPCRequest(any(SendHapticData.class));
+ }
+
+ @Test
+ public void testRefreshHapticData() throws Exception {
+ View root = createViews();
+ hapticMgr.refreshHapticData(root);
+ verify(mockProxy).sendRPCRequest(captor.capture());
+ SendHapticData data = captor.getValue();
+ assertNotNull("SendHapticData RPC", data);
+ List<HapticRect> list = data.getHapticRectData();
+ assertNotNull("List", list);
+ assertEquals("Haptic Rects", 4, list.size());
+ }
+
+ @Test
+ public void testRefreshHapticDataNull() throws Exception {
+ hapticMgr.refreshHapticData(null);
+ verify(mockProxy).sendRPCRequest(captor.capture());
+ SendHapticData data = captor.getValue();
+ assertNotNull("SendHapticData RPC", data);
+ List<HapticRect> list = data.getHapticRectData();
+ assertNull("List", list);
+ }
+
+ @Test
+ public void testRefreshWithUserData() throws Exception {
+ List<HapticRect> rects = new ArrayList<>();
+ Rectangle rect = new Rectangle();
+ rect.setX(10f);
+ rect.setY(10f);
+ rect.setWidth(50f);
+ rect.setHeight(20f);
+ HapticRect hRect = new HapticRect();
+ hRect.setRect(rect);
+ rects.add(hRect);
+ hapticMgr.setHapticData(rects);
+ verify(mockProxy).sendRPCRequest(any(SendHapticData.class));
+
+ View root = createViews();
+ hapticMgr.refreshHapticData(root);
+ verify(mockProxy, times(1)).sendRPCRequest(any(SendHapticData.class));
+ }
+
+ private View createViews() {
+
+ View view = mock(View.class);
+
+ ViewGroup parent1 = mock(ViewGroup.class);
+ ViewGroup parent2 = mock(ViewGroup.class);
+
+ when(parent1.getChildCount()).thenReturn(5);
+
+ when(parent1.getChildAt(0)).thenReturn(view);
+ when(parent1.getChildAt(1)).thenReturn(view);
+ when(parent1.getChildAt(2)).thenReturn(view);
+ when(parent1.getChildAt(3)).thenReturn(parent2);
+ when(parent1.getChildAt(4)).thenReturn(view);
+
+ when(parent2.getChildCount()).thenReturn(2);
+ when(parent2.getChildAt(0)).thenReturn(view);
+ when(parent2.getChildAt(1)).thenReturn(view);
+
+ when(view.isFocusable()).then(new Answer<Boolean>() {
+ private int count = 0;
+
+ @Override
+ public Boolean answer(InvocationOnMock invocation) throws Throwable {
+ int curCount = count++;
+ return (curCount == 1) || (curCount == 2) || (curCount == 3);
+ }
+ });
+ when(view.isClickable()).then(new Answer<Boolean>() {
+ private int count = 0;
+
+ @Override
+ public Boolean answer(InvocationOnMock invocation) throws Throwable {
+ int curCount = count++;
+ return (curCount == 0) || (curCount == 3);
+ }
+ });
+
+ return parent1;
+ }
+}