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 #pragma once 18 19 #include <android/hardware/automotive/vehicle/2.0/types.h> 20 #include <vhal_v2_0/VehicleUtils.h> 21 22 namespace android::hardware::automotive::vehicle::V2_0::impl { 23 24 // Some handy constants to avoid conversions from enum to int. 25 constexpr int ABS_ACTIVE = (int)VehicleProperty::ABS_ACTIVE; 26 constexpr int AP_POWER_STATE_REQ = (int)VehicleProperty::AP_POWER_STATE_REQ; 27 constexpr int AP_POWER_STATE_REPORT = (int)VehicleProperty::AP_POWER_STATE_REPORT; 28 constexpr int DOOR_1_LEFT = (int)VehicleAreaDoor::ROW_1_LEFT; 29 constexpr int DOOR_1_RIGHT = (int)VehicleAreaDoor::ROW_1_RIGHT; 30 constexpr int DOOR_2_LEFT = (int)VehicleAreaDoor::ROW_2_LEFT; 31 constexpr int DOOR_2_RIGHT = (int)VehicleAreaDoor::ROW_2_RIGHT; 32 constexpr int DOOR_REAR = (int)VehicleAreaDoor::REAR; 33 constexpr int WINDOW_1_LEFT = (int)VehicleAreaWindow::ROW_1_LEFT; 34 constexpr int WINDOW_1_RIGHT = (int)VehicleAreaWindow::ROW_1_RIGHT; 35 constexpr int WINDOW_2_LEFT = (int)VehicleAreaWindow::ROW_2_LEFT; 36 constexpr int WINDOW_2_RIGHT = (int)VehicleAreaWindow::ROW_2_RIGHT; 37 constexpr int WINDOW_ROOF_TOP_1 = (int)VehicleAreaWindow::ROOF_TOP_1; 38 constexpr int FAN_DIRECTION_FACE = (int)VehicleHvacFanDirection::FACE; 39 constexpr int FAN_DIRECTION_FLOOR = (int)VehicleHvacFanDirection::FLOOR; 40 constexpr int FAN_DIRECTION_DEFROST = (int)VehicleHvacFanDirection::DEFROST; 41 constexpr int OBD2_LIVE_FRAME = (int)VehicleProperty::OBD2_LIVE_FRAME; 42 constexpr int OBD2_FREEZE_FRAME = (int)VehicleProperty::OBD2_FREEZE_FRAME; 43 constexpr int OBD2_FREEZE_FRAME_INFO = (int)VehicleProperty::OBD2_FREEZE_FRAME_INFO; 44 constexpr int OBD2_FREEZE_FRAME_CLEAR = (int)VehicleProperty::OBD2_FREEZE_FRAME_CLEAR; 45 constexpr int TRACTION_CONTROL_ACTIVE = (int)VehicleProperty::TRACTION_CONTROL_ACTIVE; 46 constexpr int VEHICLE_MAP_SERVICE = (int)VehicleProperty::VEHICLE_MAP_SERVICE; 47 constexpr int WHEEL_TICK = (int)VehicleProperty::WHEEL_TICK; 48 constexpr int ALL_WHEELS = 49 (int)(VehicleAreaWheel::LEFT_FRONT | VehicleAreaWheel::RIGHT_FRONT | 50 VehicleAreaWheel::LEFT_REAR | VehicleAreaWheel::RIGHT_REAR); 51 constexpr int SEAT_1_LEFT = (int)(VehicleAreaSeat::ROW_1_LEFT); 52 constexpr int SEAT_1_RIGHT = (int)(VehicleAreaSeat::ROW_1_RIGHT); 53 constexpr int HVAC_LEFT = (int)(VehicleAreaSeat::ROW_1_LEFT | VehicleAreaSeat::ROW_2_LEFT | 54 VehicleAreaSeat::ROW_2_CENTER); 55 constexpr int HVAC_RIGHT = (int)(VehicleAreaSeat::ROW_1_RIGHT | VehicleAreaSeat::ROW_2_RIGHT); 56 constexpr int HVAC_ALL = HVAC_LEFT | HVAC_RIGHT; 57 constexpr int VENDOR_EXTENSION_BOOLEAN_PROPERTY = 58 (int)(0x101 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::BOOLEAN | VehicleArea::DOOR); 59 constexpr int VENDOR_EXTENSION_FLOAT_PROPERTY = 60 (int)(0x102 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::FLOAT | VehicleArea::SEAT); 61 constexpr int VENDOR_EXTENSION_INT_PROPERTY = 62 (int)(0x103 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::INT32 | VehicleArea::WINDOW); 63 constexpr int VENDOR_EXTENSION_STRING_PROPERTY = 64 (int)(0x104 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::STRING | VehicleArea::GLOBAL); 65 constexpr int FUEL_DOOR_REAR_LEFT = (int)PortLocationType::REAR_LEFT; 66 constexpr int CHARGE_PORT_FRONT_LEFT = (int)PortLocationType::FRONT_LEFT; 67 constexpr int CHARGE_PORT_REAR_LEFT = (int)PortLocationType::REAR_LEFT; 68 constexpr int LIGHT_STATE_ON = (int)VehicleLightState::ON; 69 constexpr int LIGHT_SWITCH_AUTO = (int)VehicleLightSwitch::AUTOMATIC; 70 constexpr int WHEEL_FRONT_LEFT = (int)VehicleAreaWheel::LEFT_FRONT; 71 constexpr int WHEEL_FRONT_RIGHT = (int)VehicleAreaWheel::RIGHT_FRONT; 72 constexpr int WHEEL_REAR_LEFT = (int)VehicleAreaWheel::LEFT_REAR; 73 constexpr int WHEEL_REAR_RIGHT = (int)VehicleAreaWheel::RIGHT_REAR; 74 75 /** 76 * This property is used for test purpose. End to end tests use this property to test set and get 77 * method for MIXED type properties. 78 */ 79 const int32_t kMixedTypePropertyForTest = 80 0x1111 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::MIXED; 81 82 #ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING 83 /** 84 * Converts the system property to the vendor property. 85 * WARNING: This is only for the end-to-end testing, Should NOT include in the 86 * user build */ toVendor(VehicleProperty prop)87inline constexpr int32_t toVendor(VehicleProperty prop) { 88 return (toInt(prop) & ~toInt(VehiclePropertyGroup::MASK)) | VehiclePropertyGroup::VENDOR; 89 } 90 91 /** 92 * These properties are used for the end-to-end testing of ClusterHomeService. 93 */ 94 constexpr int32_t VENDOR_CLUSTER_SWITCH_UI = toVendor(VehicleProperty::CLUSTER_SWITCH_UI); 95 constexpr int32_t VENDOR_CLUSTER_DISPLAY_STATE = toVendor(VehicleProperty::CLUSTER_DISPLAY_STATE); 96 constexpr int32_t VENDOR_CLUSTER_REPORT_STATE = toVendor(VehicleProperty::CLUSTER_REPORT_STATE); 97 constexpr int32_t VENDOR_CLUSTER_REQUEST_DISPLAY = 98 toVendor(VehicleProperty::CLUSTER_REQUEST_DISPLAY); 99 constexpr int32_t VENDOR_CLUSTER_NAVIGATION_STATE = 100 toVendor(VehicleProperty::CLUSTER_NAVIGATION_STATE); 101 #endif // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING 102 103 /** 104 * These properties are placeholder properties for developers to test new features without 105 * implementing a real property. 106 */ 107 constexpr int32_t PLACEHOLDER_PROPERTY_INT = 108 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::INT32; 109 constexpr int32_t PLACEHOLDER_PROPERTY_FLOAT = 110 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::FLOAT; 111 constexpr int32_t PLACEHOLDER_PROPERTY_BOOLEAN = 112 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::BOOLEAN; 113 constexpr int32_t PLACEHOLDER_PROPERTY_STRING = 114 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::STRING; 115 116 const int32_t kHvacPowerProperties[] = { 117 toInt(VehicleProperty::HVAC_FAN_SPEED), 118 toInt(VehicleProperty::HVAC_FAN_DIRECTION), 119 }; 120 121 } // namespace android::hardware::automotive::vehicle::V2_0::impl 122