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_FRONT_ROW = (int)(VehicleAreaSeat::ROW_1_LEFT | VehicleAreaSeat::ROW_1_RIGHT); 54 constexpr int HVAC_REAR_ROW = (int)(VehicleAreaSeat::ROW_2_LEFT | VehicleAreaSeat::ROW_2_CENTER | 55 VehicleAreaSeat::ROW_2_RIGHT); 56 constexpr int HVAC_LEFT = (int)(VehicleAreaSeat::ROW_1_LEFT | VehicleAreaSeat::ROW_2_LEFT | 57 VehicleAreaSeat::ROW_2_CENTER); 58 constexpr int HVAC_RIGHT = (int)(VehicleAreaSeat::ROW_1_RIGHT | VehicleAreaSeat::ROW_2_RIGHT); 59 constexpr int HVAC_ALL = HVAC_LEFT | HVAC_RIGHT; 60 constexpr int VENDOR_EXTENSION_BOOLEAN_PROPERTY = 61 (int)(0x101 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::BOOLEAN | VehicleArea::DOOR); 62 constexpr int VENDOR_EXTENSION_FLOAT_PROPERTY = 63 (int)(0x102 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::FLOAT | VehicleArea::SEAT); 64 constexpr int VENDOR_EXTENSION_INT_PROPERTY = 65 (int)(0x103 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::INT32 | VehicleArea::WINDOW); 66 constexpr int VENDOR_EXTENSION_STRING_PROPERTY = 67 (int)(0x104 | VehiclePropertyGroup::VENDOR | VehiclePropertyType::STRING | VehicleArea::GLOBAL); 68 constexpr int FUEL_DOOR_REAR_LEFT = (int)PortLocationType::REAR_LEFT; 69 constexpr int CHARGE_PORT_FRONT_LEFT = (int)PortLocationType::FRONT_LEFT; 70 constexpr int CHARGE_PORT_REAR_LEFT = (int)PortLocationType::REAR_LEFT; 71 constexpr int LIGHT_STATE_ON = (int)VehicleLightState::ON; 72 constexpr int LIGHT_SWITCH_AUTO = (int)VehicleLightSwitch::AUTOMATIC; 73 constexpr int WHEEL_FRONT_LEFT = (int)VehicleAreaWheel::LEFT_FRONT; 74 constexpr int WHEEL_FRONT_RIGHT = (int)VehicleAreaWheel::RIGHT_FRONT; 75 constexpr int WHEEL_REAR_LEFT = (int)VehicleAreaWheel::LEFT_REAR; 76 constexpr int WHEEL_REAR_RIGHT = (int)VehicleAreaWheel::RIGHT_REAR; 77 78 /** 79 * This property is used for test purpose. End to end tests use this property to test set and get 80 * method for MIXED type properties. 81 */ 82 const int32_t kMixedTypePropertyForTest = 83 0x1111 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::MIXED; 84 85 #ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING 86 /** 87 * Converts the system property to the vendor property. 88 * WARNING: This is only for the end-to-end testing, Should NOT include in the 89 * user build */ toVendor(VehicleProperty prop)90inline constexpr int32_t toVendor(VehicleProperty prop) { 91 return (toInt(prop) & ~toInt(VehiclePropertyGroup::MASK)) | VehiclePropertyGroup::VENDOR; 92 } 93 94 /** 95 * These properties are used for the end-to-end testing of ClusterHomeService. 96 */ 97 constexpr int32_t VENDOR_CLUSTER_SWITCH_UI = toVendor(VehicleProperty::CLUSTER_SWITCH_UI); 98 constexpr int32_t VENDOR_CLUSTER_DISPLAY_STATE = toVendor(VehicleProperty::CLUSTER_DISPLAY_STATE); 99 constexpr int32_t VENDOR_CLUSTER_REPORT_STATE = toVendor(VehicleProperty::CLUSTER_REPORT_STATE); 100 constexpr int32_t VENDOR_CLUSTER_REQUEST_DISPLAY = 101 toVendor(VehicleProperty::CLUSTER_REQUEST_DISPLAY); 102 constexpr int32_t VENDOR_CLUSTER_NAVIGATION_STATE = 103 toVendor(VehicleProperty::CLUSTER_NAVIGATION_STATE); 104 #endif // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING 105 106 /** 107 * These properties are placeholder properties for developers to test new features without 108 * implementing a real property. 109 */ 110 constexpr int32_t PLACEHOLDER_PROPERTY_INT = 111 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::INT32; 112 constexpr int32_t PLACEHOLDER_PROPERTY_FLOAT = 113 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::FLOAT; 114 constexpr int32_t PLACEHOLDER_PROPERTY_BOOLEAN = 115 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::BOOLEAN; 116 constexpr int32_t PLACEHOLDER_PROPERTY_STRING = 117 0x2a11 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::STRING; 118 119 const int32_t kHvacPowerProperties[] = { 120 toInt(VehicleProperty::HVAC_FAN_SPEED), 121 toInt(VehicleProperty::HVAC_FAN_DIRECTION), 122 }; 123 124 } // namespace android::hardware::automotive::vehicle::V2_0::impl 125