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 "HidlHalPropConfig.h" 18 19 #include <VehicleUtils.h> 20 21 namespace android { 22 namespace frameworks { 23 namespace automotive { 24 namespace vhal { 25 26 using ::android::hardware::automotive::vehicle::V2_0::VehicleAreaConfig; 27 using ::android::hardware::automotive::vehicle::V2_0::VehiclePropConfig; 28 29 using ::android::hardware::automotive::vehicle::toInt; 30 HidlHalPropConfig(VehiclePropConfig && config)31HidlHalPropConfig::HidlHalPropConfig(VehiclePropConfig&& config) { 32 mPropConfig = std::move(config); 33 if (mPropConfig.areaConfigs.size() == 0) { 34 VehicleAreaConfig globalAreaConfig; 35 globalAreaConfig.areaId = 0; 36 mAreaConfigs.push_back(std::make_unique<HidlHalAreaConfig>(std::move(globalAreaConfig), 37 toInt(mPropConfig.access))); 38 } else { 39 for (VehicleAreaConfig& areaConfig : mPropConfig.areaConfigs) { 40 mAreaConfigs.push_back(std::make_unique<HidlHalAreaConfig>(std::move(areaConfig), 41 toInt(mPropConfig.access))); 42 } 43 } 44 } 45 getPropId() const46int32_t HidlHalPropConfig::getPropId() const { 47 return mPropConfig.prop; 48 } 49 getAccess() const50int32_t HidlHalPropConfig::getAccess() const { 51 return toInt(mPropConfig.access); 52 } 53 getChangeMode() const54int32_t HidlHalPropConfig::getChangeMode() const { 55 return toInt(mPropConfig.changeMode); 56 } 57 getAreaConfigSize() const58size_t HidlHalPropConfig::getAreaConfigSize() const { 59 return mAreaConfigs.size(); 60 } 61 getConfigArray() const62std::vector<int32_t> HidlHalPropConfig::getConfigArray() const { 63 return mPropConfig.configArray; 64 } 65 getConfigString() const66std::string HidlHalPropConfig::getConfigString() const { 67 return mPropConfig.configString; 68 } 69 getMinSampleRate() const70float HidlHalPropConfig::getMinSampleRate() const { 71 return mPropConfig.minSampleRate; 72 } 73 getMaxSampleRate() const74float HidlHalPropConfig::getMaxSampleRate() const { 75 return mPropConfig.maxSampleRate; 76 } 77 HidlHalAreaConfig(VehicleAreaConfig && areaConfig,int32_t access)78HidlHalAreaConfig::HidlHalAreaConfig(VehicleAreaConfig&& areaConfig, int32_t access) { 79 mAreaConfig = std::move(areaConfig); 80 mAccess = access; 81 } 82 getAreaId() const83int32_t HidlHalAreaConfig::getAreaId() const { 84 return mAreaConfig.areaId; 85 } 86 getAccess() const87int32_t HidlHalAreaConfig::getAccess() const { 88 return mAccess; 89 } 90 getMinInt32Value() const91int32_t HidlHalAreaConfig::getMinInt32Value() const { 92 return mAreaConfig.minInt32Value; 93 } 94 getMaxInt32Value() const95int32_t HidlHalAreaConfig::getMaxInt32Value() const { 96 return mAreaConfig.maxInt32Value; 97 } 98 getMinInt64Value() const99int64_t HidlHalAreaConfig::getMinInt64Value() const { 100 return mAreaConfig.minInt64Value; 101 } 102 getMaxInt64Value() const103int64_t HidlHalAreaConfig::getMaxInt64Value() const { 104 return mAreaConfig.maxInt64Value; 105 } 106 getMinFloatValue() const107float HidlHalAreaConfig::getMinFloatValue() const { 108 return mAreaConfig.minFloatValue; 109 } 110 getMaxFloatValue() const111float HidlHalAreaConfig::getMaxFloatValue() const { 112 return mAreaConfig.maxFloatValue; 113 } 114 115 // HIDL VHAL does not support VUR. isVariableUpdateRateSupported() const116bool HidlHalAreaConfig::isVariableUpdateRateSupported() const { 117 return false; 118 } 119 120 } // namespace vhal 121 } // namespace automotive 122 } // namespace frameworks 123 } // namespace android 124