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 "AidlHalPropValue.h" 18 19 namespace android { 20 namespace frameworks { 21 namespace automotive { 22 namespace vhal { 23 24 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyStatus; 25 using ::aidl::android::hardware::automotive::vehicle::VehiclePropValue; 26 AidlHalPropValue(int32_t propId)27AidlHalPropValue::AidlHalPropValue(int32_t propId) : IHalPropValue() { 28 mPropValue = {}; 29 mPropValue.prop = propId; 30 } 31 AidlHalPropValue(int32_t propId,int32_t areaId)32AidlHalPropValue::AidlHalPropValue(int32_t propId, int32_t areaId) : IHalPropValue() { 33 mPropValue = {}; 34 mPropValue.prop = propId; 35 mPropValue.areaId = areaId; 36 } 37 AidlHalPropValue(VehiclePropValue && value)38AidlHalPropValue::AidlHalPropValue(VehiclePropValue&& value) : IHalPropValue() { 39 mPropValue = std::move(value); 40 } 41 getPropId() const42int32_t AidlHalPropValue::getPropId() const { 43 return mPropValue.prop; 44 } 45 getAreaId() const46int32_t AidlHalPropValue::getAreaId() const { 47 return mPropValue.areaId; 48 } 49 getTimestamp() const50int64_t AidlHalPropValue::getTimestamp() const { 51 return mPropValue.timestamp; 52 } 53 getStatus() const54VehiclePropertyStatus AidlHalPropValue::getStatus() const { 55 return mPropValue.status; 56 } 57 setInt32Values(const std::vector<int32_t> & values)58void AidlHalPropValue::setInt32Values(const std::vector<int32_t>& values) { 59 mPropValue.value.int32Values = values; 60 } 61 getInt32Values() const62std::vector<int32_t> AidlHalPropValue::getInt32Values() const { 63 return mPropValue.value.int32Values; 64 } 65 setInt64Values(const std::vector<int64_t> & values)66void AidlHalPropValue::setInt64Values(const std::vector<int64_t>& values) { 67 mPropValue.value.int64Values = values; 68 } 69 getInt64Values() const70std::vector<int64_t> AidlHalPropValue::getInt64Values() const { 71 return mPropValue.value.int64Values; 72 } 73 setFloatValues(const std::vector<float> & values)74void AidlHalPropValue::setFloatValues(const std::vector<float>& values) { 75 mPropValue.value.floatValues = values; 76 } 77 getFloatValues() const78std::vector<float> AidlHalPropValue::getFloatValues() const { 79 return mPropValue.value.floatValues; 80 } 81 setByteValues(const std::vector<uint8_t> & values)82void AidlHalPropValue::setByteValues(const std::vector<uint8_t>& values) { 83 mPropValue.value.byteValues = values; 84 } 85 getByteValues() const86std::vector<uint8_t> AidlHalPropValue::getByteValues() const { 87 return mPropValue.value.byteValues; 88 } 89 setStringValue(const std::string & value)90void AidlHalPropValue::setStringValue(const std::string& value) { 91 mPropValue.value.stringValue = value; 92 } 93 getStringValue() const94std::string AidlHalPropValue::getStringValue() const { 95 return mPropValue.value.stringValue; 96 } 97 toVehiclePropValue() const98const void* AidlHalPropValue::toVehiclePropValue() const { 99 return &mPropValue; 100 } 101 clone() const102std::unique_ptr<IHalPropValue> AidlHalPropValue::clone() const { 103 auto propValueCopy = mPropValue; 104 return std::make_unique<AidlHalPropValue>(std::move(propValueCopy)); 105 } 106 107 } // namespace vhal 108 } // namespace automotive 109 } // namespace frameworks 110 } // namespace android 111