1 /* 2 * Copyright (C) 2021 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 #ifndef android_hardware_automotive_vehicle_utils_test_include_TestPropertyUtils_H_ 18 #define android_hardware_automotive_vehicle_utils_test_include_TestPropertyUtils_H_ 19 20 #include <VehicleHalTypes.h> 21 #include <VehicleUtils.h> 22 23 namespace android { 24 namespace hardware { 25 namespace automotive { 26 namespace vehicle { 27 28 namespace testpropertyutils_impl { 29 30 // These names are not part of the API since we only expose ints. 31 using ::aidl::android::hardware::automotive::vehicle::VehicleArea; 32 using ::aidl::android::hardware::automotive::vehicle::VehicleProperty; 33 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyGroup; 34 using ::aidl::android::hardware::automotive::vehicle::VehiclePropertyType; 35 36 } // namespace testpropertyutils_impl 37 38 #ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING 39 // Converts the system property to the vendor property. 40 // WARNING: This is only for the end-to-end testing, Should NOT include in the user build. toVendor(const aidl::android::hardware::automotive::vehicle::VehicleProperty & prop)41inline constexpr int32_t toVendor( 42 const aidl::android::hardware::automotive::vehicle::VehicleProperty& prop) { 43 return (toInt(prop) & ~toInt(testpropertyutils_impl::VehiclePropertyGroup::MASK)) | 44 toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR); 45 } 46 47 // These properties are used for the end-to-end testing of ClusterHomeService. 48 constexpr int32_t VENDOR_CLUSTER_SWITCH_UI = 49 toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_SWITCH_UI); 50 constexpr int32_t VENDOR_CLUSTER_DISPLAY_STATE = 51 toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_DISPLAY_STATE); 52 constexpr int32_t VENDOR_CLUSTER_REPORT_STATE = 53 toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_REPORT_STATE); 54 constexpr int32_t VENDOR_CLUSTER_REQUEST_DISPLAY = 55 toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_REQUEST_DISPLAY); 56 constexpr int32_t VENDOR_CLUSTER_NAVIGATION_STATE = 57 toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_NAVIGATION_STATE); 58 #endif // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING 59 60 // These properties are placeholder properties for developers to test new features without 61 // implementing a real property. 62 constexpr int32_t PLACEHOLDER_PROPERTY_INT = 63 0x2a11 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | 64 toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | 65 toInt(testpropertyutils_impl::VehiclePropertyType::INT32); 66 constexpr int32_t PLACEHOLDER_PROPERTY_FLOAT = 67 0x2a11 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | 68 toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | 69 toInt(testpropertyutils_impl::VehiclePropertyType::FLOAT); 70 constexpr int32_t PLACEHOLDER_PROPERTY_BOOLEAN = 71 0x2a11 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | 72 toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | 73 toInt(testpropertyutils_impl::VehiclePropertyType::BOOLEAN); 74 constexpr int32_t PLACEHOLDER_PROPERTY_STRING = 75 0x2a11 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | 76 toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | 77 toInt(testpropertyutils_impl::VehiclePropertyType::STRING); 78 79 // This property is used for testing LargeParcelable marshalling/unmarhsalling end to end. 80 // It acts as an regular property that stores the property value when setting and return the value 81 // when getting, except that all the byteValues used in the setValue response would be filled in 82 // the reverse order. 83 // 0x21702a12 84 constexpr int32_t ECHO_REVERSE_BYTES = 0x2a12 | 85 toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | 86 toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | 87 toInt(testpropertyutils_impl::VehiclePropertyType::BYTES); 88 89 // This property is used for test purpose. End to end tests use this property to test set and get 90 // method for MIXED type properties. 91 constexpr int32_t kMixedTypePropertyForTest = 92 0x1111 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | 93 toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | 94 toInt(testpropertyutils_impl::VehiclePropertyType::MIXED); 95 } // namespace vehicle 96 } // namespace automotive 97 } // namespace hardware 98 } // namespace android 99 100 #endif // android_hardware_automotive_vehicle_utils_test_include_TestPropertyUtils_H_ 101