• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // Converts the system property to the vendor property.
39 // 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)40 inline constexpr int32_t toVendor(
41         const aidl::android::hardware::automotive::vehicle::VehicleProperty& prop) {
42     return (toInt(prop) & ~toInt(testpropertyutils_impl::VehiclePropertyGroup::MASK)) |
43            toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR);
44 }
45 
46 // These properties are used for the end-to-end testing of ClusterHomeService.
47 constexpr int32_t VENDOR_CLUSTER_SWITCH_UI =
48         toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_SWITCH_UI);
49 constexpr int32_t VENDOR_CLUSTER_DISPLAY_STATE =
50         toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_DISPLAY_STATE);
51 constexpr int32_t VENDOR_CLUSTER_REPORT_STATE =
52         toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_REPORT_STATE);
53 constexpr int32_t VENDOR_CLUSTER_REQUEST_DISPLAY =
54         toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_REQUEST_DISPLAY);
55 constexpr int32_t VENDOR_CLUSTER_NAVIGATION_STATE =
56         toVendor(testpropertyutils_impl::VehicleProperty::CLUSTER_NAVIGATION_STATE);
57 
58 // These properties are placeholder properties for developers to test new features without
59 // implementing a real property.
60 constexpr int32_t PLACEHOLDER_PROPERTY_INT =
61         0x2a11 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) |
62         toInt(testpropertyutils_impl::VehicleArea::GLOBAL) |
63         toInt(testpropertyutils_impl::VehiclePropertyType::INT32);
64 constexpr int32_t PLACEHOLDER_PROPERTY_FLOAT =
65         0x2a11 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) |
66         toInt(testpropertyutils_impl::VehicleArea::GLOBAL) |
67         toInt(testpropertyutils_impl::VehiclePropertyType::FLOAT);
68 constexpr int32_t PLACEHOLDER_PROPERTY_BOOLEAN =
69         0x2a11 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) |
70         toInt(testpropertyutils_impl::VehicleArea::GLOBAL) |
71         toInt(testpropertyutils_impl::VehiclePropertyType::BOOLEAN);
72 constexpr int32_t PLACEHOLDER_PROPERTY_STRING =
73         0x2a11 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) |
74         toInt(testpropertyutils_impl::VehicleArea::GLOBAL) |
75         toInt(testpropertyutils_impl::VehiclePropertyType::STRING);
76 
77 // This property is used for testing LargeParcelable marshalling/unmarhsalling end to end.
78 // It acts as an regular property that stores the property value when setting and return the value
79 // when getting, except that all the byteValues used in the setValue response would be filled in
80 // the reverse order.
81 // 0x21702a12
82 constexpr int32_t ECHO_REVERSE_BYTES = 0x2a12 |
83                                        toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) |
84                                        toInt(testpropertyutils_impl::VehicleArea::GLOBAL) |
85                                        toInt(testpropertyutils_impl::VehiclePropertyType::BYTES);
86 
87 // This property is used for testing vendor error codes end to end.
88 // 0x21402a13
89 constexpr int32_t VENDOR_PROPERTY_ID = 0x2a13 |
90                                        toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) |
91                                        toInt(testpropertyutils_impl::VehicleArea::GLOBAL) |
92                                        toInt(testpropertyutils_impl::VehiclePropertyType::INT32);
93 
94 // This property is used for test purpose. End to end tests use this property to test set and get
95 // method for MIXED type properties.
96 constexpr int32_t kMixedTypePropertyForTest =
97         0x1111 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) |
98         toInt(testpropertyutils_impl::VehicleArea::GLOBAL) |
99         toInt(testpropertyutils_impl::VehiclePropertyType::MIXED);
100 }  // namespace vehicle
101 }  // namespace automotive
102 }  // namespace hardware
103 }  // namespace android
104 
105 #endif  // android_hardware_automotive_vehicle_utils_test_include_TestPropertyUtils_H_
106