• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "HidlHalPropValue.h"
18 
19 namespace android {
20 namespace frameworks {
21 namespace automotive {
22 namespace vhal {
23 
24 using ::android::hardware::automotive::vehicle::V2_0::VehiclePropValue;
25 
HidlHalPropValue(int32_t propId)26 HidlHalPropValue::HidlHalPropValue(int32_t propId) {
27     mPropValue = {};
28     mPropValue.prop = propId;
29 }
30 
HidlHalPropValue(int32_t propId,int32_t areaId)31 HidlHalPropValue::HidlHalPropValue(int32_t propId, int32_t areaId) {
32     mPropValue = {};
33     mPropValue.prop = propId;
34     mPropValue.areaId = areaId;
35 }
36 
HidlHalPropValue(VehiclePropValue && value)37 HidlHalPropValue::HidlHalPropValue(VehiclePropValue&& value) {
38     mPropValue = std::move(value);
39 }
40 
getPropId() const41 int32_t HidlHalPropValue::getPropId() const {
42     return mPropValue.prop;
43 }
44 
getAreaId() const45 int32_t HidlHalPropValue::getAreaId() const {
46     return mPropValue.areaId;
47 }
48 
getTimestamp() const49 int64_t HidlHalPropValue::getTimestamp() const {
50     return mPropValue.timestamp;
51 }
52 
setInt32Values(const std::vector<int32_t> & values)53 void HidlHalPropValue::setInt32Values(const std::vector<int32_t>& values) {
54     mPropValue.value.int32Values = values;
55 }
56 
getInt32Values() const57 std::vector<int32_t> HidlHalPropValue::getInt32Values() const {
58     return mPropValue.value.int32Values;
59 }
60 
setInt64Values(const std::vector<int64_t> & values)61 void HidlHalPropValue::setInt64Values(const std::vector<int64_t>& values) {
62     mPropValue.value.int64Values = values;
63 }
64 
getInt64Values() const65 std::vector<int64_t> HidlHalPropValue::getInt64Values() const {
66     return mPropValue.value.int64Values;
67 }
68 
setFloatValues(const std::vector<float> & values)69 void HidlHalPropValue::setFloatValues(const std::vector<float>& values) {
70     mPropValue.value.floatValues = values;
71 }
72 
getFloatValues() const73 std::vector<float> HidlHalPropValue::getFloatValues() const {
74     return mPropValue.value.floatValues;
75 }
76 
setByteValues(const std::vector<uint8_t> & values)77 void HidlHalPropValue::setByteValues(const std::vector<uint8_t>& values) {
78     mPropValue.value.bytes = values;
79 }
80 
getByteValues() const81 std::vector<uint8_t> HidlHalPropValue::getByteValues() const {
82     return mPropValue.value.bytes;
83 }
84 
setStringValue(const std::string & value)85 void HidlHalPropValue::setStringValue(const std::string& value) {
86     mPropValue.value.stringValue = value;
87 }
88 
getStringValue() const89 std::string HidlHalPropValue::getStringValue() const {
90     return mPropValue.value.stringValue;
91 }
92 
toVehiclePropValue() const93 const void* HidlHalPropValue::toVehiclePropValue() const {
94     return &mPropValue;
95 }
96 
97 }  // namespace vhal
98 }  // namespace automotive
99 }  // namespace frameworks
100 }  // namespace android
101