• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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_V2_0_impl_DefaultConfig_H_
18 #define android_hardware_automotive_vehicle_V2_0_impl_DefaultConfig_H_
19 
20 #include <android/hardware/automotive/vehicle/2.0/IVehicle.h>
21 #include <vhal_v2_0/VehicleUtils.h>
22 
23 namespace android {
24 namespace hardware {
25 namespace automotive {
26 namespace vehicle {
27 namespace V2_0 {
28 
29 namespace impl {
30 //
31 // Some handy constants to avoid conversions from enum to int.
32 constexpr int ABS_ACTIVE = (int)VehicleProperty::ABS_ACTIVE;
33 constexpr int OBD2_LIVE_FRAME = (int)VehicleProperty::OBD2_LIVE_FRAME;
34 constexpr int OBD2_FREEZE_FRAME = (int)VehicleProperty::OBD2_FREEZE_FRAME;
35 constexpr int OBD2_FREEZE_FRAME_INFO = (int)VehicleProperty::OBD2_FREEZE_FRAME_INFO;
36 constexpr int OBD2_FREEZE_FRAME_CLEAR = (int)VehicleProperty::OBD2_FREEZE_FRAME_CLEAR;
37 constexpr int TRACTION_CONTROL_ACTIVE = (int)VehicleProperty::TRACTION_CONTROL_ACTIVE;
38 constexpr int VEHICLE_MAP_SERVICE = (int)VehicleProperty::VEHICLE_MAP_SERVICE;
39 constexpr int WHEEL_TICK = (int)VehicleProperty::WHEEL_TICK;
40 constexpr int ALL_WHEELS =
41     (int)(Wheel::LEFT_FRONT | Wheel::RIGHT_FRONT | Wheel::LEFT_REAR | Wheel::RIGHT_REAR);
42 
43 /*
44  * This property is used for test purpose to generate fake events.
45  *
46  * It has the following format:
47  *
48  * int32Values[0] - command (1 - start fake data generation, 0 - stop)
49  * int32Values[1] - VehicleProperty to which command applies
50  *
51  * For start command, additional data should be provided:
52  *   int64Values[0] - periodic interval in nanoseconds
53  *   floatValues[0] - initial value
54  *   floatValues[1] - dispersion defines min and max range relative to initial value
55  *   floatValues[2] - increment, with every timer tick the value will be incremented by this amount
56  */
57 const int32_t kGenerateFakeDataControllingProperty = 0x0666
58         | VehiclePropertyGroup::VENDOR
59         | VehicleArea::GLOBAL
60         | VehiclePropertyType::COMPLEX;
61 
62 const int32_t kHvacPowerProperties[] = {
63     toInt(VehicleProperty::HVAC_FAN_SPEED),
64     toInt(VehicleProperty::HVAC_FAN_DIRECTION),
65 };
66 
67 struct ConfigDeclaration {
68     VehiclePropConfig config;
69 
70     /* This value will be used as an initial value for the property. If this field is specified for
71      * property that supports multiple areas then it will be used for all areas unless particular
72      * area is overridden in initialAreaValue field. */
73     VehiclePropValue::RawValue initialValue;
74     /* Use initialAreaValues if it is necessary to specify different values per each area. */
75     std::map<int32_t, VehiclePropValue::RawValue> initialAreaValues;
76 };
77 
78 const ConfigDeclaration kVehicleProperties[]{
79     {.config =
80          {
81              .prop = toInt(VehicleProperty::INFO_MAKE),
82              .access = VehiclePropertyAccess::READ,
83              .changeMode = VehiclePropertyChangeMode::STATIC,
84          },
85      .initialValue = {.stringValue = "Toy Vehicle"}},
86     {.config =
87          {
88              .prop = toInt(VehicleProperty::PERF_VEHICLE_SPEED),
89              .access = VehiclePropertyAccess::READ,
90              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
91              .minSampleRate = 1.0f,
92              .maxSampleRate = 1000.0f,
93          },
94      .initialValue = {.floatValues = {0.0f}}},
95 
96     {.config =
97          {
98              .prop = toInt(VehicleProperty::PERF_ODOMETER),
99              .access = VehiclePropertyAccess::READ,
100              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
101          },
102      .initialValue = {.floatValues = {0.0f}}},
103 
104     {
105         .config =
106             {
107                 .prop = toInt(VehicleProperty::ENGINE_RPM),
108                 .access = VehiclePropertyAccess::READ,
109                 .changeMode = VehiclePropertyChangeMode::CONTINUOUS,
110                 .minSampleRate = 1.0f,
111                 .maxSampleRate = 1000.0f,
112             },
113         .initialValue = {.floatValues = {0.0f}},
114     },
115 
116     {.config =
117          {
118              .prop = toInt(VehicleProperty::CURRENT_GEAR),
119              .access = VehiclePropertyAccess::READ,
120              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
121          },
122      .initialValue = {.int32Values = {toInt(VehicleGear::GEAR_PARK)}}},
123 
124     {.config =
125          {
126              .prop = toInt(VehicleProperty::PARKING_BRAKE_ON),
127              .access = VehiclePropertyAccess::READ,
128              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
129          },
130      .initialValue = {.int32Values = {1}}},
131 
132     {.config =
133          {
134              .prop = toInt(VehicleProperty::FUEL_LEVEL_LOW),
135              .access = VehiclePropertyAccess::READ,
136              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
137          },
138      .initialValue = {.int32Values = {0}}},
139 
140     {.config =
141          {
142              .prop = toInt(VehicleProperty::HVAC_POWER_ON),
143              .access = VehiclePropertyAccess::READ_WRITE,
144              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
145              .supportedAreas = toInt(VehicleAreaZone::ROW_1),
146              // TODO(bryaneyler): Ideally, this is generated dynamically from
147              // kHvacPowerProperties.
148              .configString = "0x12400500,0x12400501"  // HVAC_FAN_SPEED,HVAC_FAN_DIRECTION
149          },
150      .initialValue = {.int32Values = {1}}},
151 
152     {
153         .config = {.prop = toInt(VehicleProperty::HVAC_DEFROSTER),
154                    .access = VehiclePropertyAccess::READ_WRITE,
155                    .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
156                    .supportedAreas =
157                        VehicleAreaWindow::FRONT_WINDSHIELD | VehicleAreaWindow::REAR_WINDSHIELD},
158         .initialValue = {.int32Values = {0}}  // Will be used for all areas.
159     },
160 
161     {.config = {.prop = toInt(VehicleProperty::HVAC_RECIRC_ON),
162                 .access = VehiclePropertyAccess::READ_WRITE,
163                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
164                 .supportedAreas = toInt(VehicleAreaZone::ROW_1)},
165      .initialValue = {.int32Values = {1}}},
166 
167     {.config = {.prop = toInt(VehicleProperty::HVAC_AC_ON),
168                 .access = VehiclePropertyAccess::READ_WRITE,
169                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
170                 .supportedAreas = toInt(VehicleAreaZone::ROW_1)},
171      .initialValue = {.int32Values = {1}}},
172 
173     {.config = {.prop = toInt(VehicleProperty::HVAC_AUTO_ON),
174                 .access = VehiclePropertyAccess::READ_WRITE,
175                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
176                 .supportedAreas = toInt(VehicleAreaZone::ROW_1)},
177      .initialValue = {.int32Values = {1}}},
178 
179     {.config = {.prop = toInt(VehicleProperty::HVAC_FAN_SPEED),
180                 .access = VehiclePropertyAccess::READ_WRITE,
181                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
182                 .supportedAreas = toInt(VehicleAreaZone::ROW_1),
183                 .areaConfigs = {VehicleAreaConfig{.areaId = toInt(VehicleAreaZone::ROW_1),
184                                                   .minInt32Value = 1,
185                                                   .maxInt32Value = 7}}},
186      .initialValue = {.int32Values = {3}}},
187 
188     {.config =
189          {
190              .prop = toInt(VehicleProperty::HVAC_FAN_DIRECTION),
191              .access = VehiclePropertyAccess::READ_WRITE,
192              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
193              .supportedAreas = toInt(VehicleAreaZone::ROW_1),
194          },
195      .initialValue = {.int32Values = {toInt(VehicleHvacFanDirection::FACE)}}},
196 
197     {.config = {.prop = toInt(VehicleProperty::HVAC_TEMPERATURE_SET),
198                 .access = VehiclePropertyAccess::READ_WRITE,
199                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
200                 .supportedAreas = VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT,
201                 .areaConfigs = {VehicleAreaConfig{
202                                     .areaId = toInt(VehicleAreaZone::ROW_1_LEFT),
203                                     .minFloatValue = 16,
204                                     .maxFloatValue = 32,
205                                 },
206                                 VehicleAreaConfig{
207                                     .areaId = toInt(VehicleAreaZone::ROW_1_RIGHT),
208                                     .minFloatValue = 16,
209                                     .maxFloatValue = 32,
210                                 }}},
211      .initialAreaValues = {{toInt(VehicleAreaZone::ROW_1_LEFT), {.floatValues = {16}}},
212                            {toInt(VehicleAreaZone::ROW_1_RIGHT), {.floatValues = {20}}}}},
213 
214     {.config =
215          {
216              .prop = toInt(VehicleProperty::ENV_OUTSIDE_TEMPERATURE),
217              .access = VehiclePropertyAccess::READ,
218              // TODO(bryaneyler): Support ON_CHANGE as well.
219              .changeMode = VehiclePropertyChangeMode::CONTINUOUS,
220              .minSampleRate = 1.0f,
221              .maxSampleRate = 2.0f,
222          },
223      .initialValue = {.floatValues = {25.0f}}},
224 
225     {.config =
226          {
227              .prop = toInt(VehicleProperty::NIGHT_MODE),
228              .access = VehiclePropertyAccess::READ,
229              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
230          },
231      .initialValue = {.int32Values = {0}}},
232 
233     {.config =
234          {
235              .prop = toInt(VehicleProperty::DRIVING_STATUS),
236              .access = VehiclePropertyAccess::READ,
237              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
238          },
239      .initialValue = {.int32Values = {toInt(VehicleDrivingStatus::UNRESTRICTED)}}},
240 
241     {.config =
242          {
243              .prop = toInt(VehicleProperty::GEAR_SELECTION),
244              .access = VehiclePropertyAccess::READ,
245              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
246          },
247      .initialValue = {.int32Values = {toInt(VehicleGear::GEAR_PARK)}}},
248 
249     {
250         .config =
251             {
252                 .prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY),
253                 .access = VehiclePropertyAccess::READ,
254                 .changeMode = VehiclePropertyChangeMode::STATIC,
255             },
256         .initialValue = {.floatValues = {123000.0f}}  // In Milliliters
257     },
258 
259     {.config = {.prop = toInt(VehicleProperty::DISPLAY_BRIGHTNESS),
260                 .access = VehiclePropertyAccess::READ_WRITE,
261                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
262                 .areaConfigs = {VehicleAreaConfig{.minInt32Value = 0, .maxInt32Value = 10}}},
263      .initialValue = {.int32Values = {7}}},
264 
265     {.config =
266          {
267              .prop = toInt(VehicleProperty::IGNITION_STATE),
268              .access = VehiclePropertyAccess::READ,
269              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
270          },
271      .initialValue = {.int32Values = {toInt(VehicleIgnitionState::ON)}}},
272 
273     {.config =
274          {
275              .prop = toInt(VehicleProperty::ENGINE_OIL_TEMP),
276              .access = VehiclePropertyAccess::READ,
277              .changeMode = VehiclePropertyChangeMode::CONTINUOUS,
278              .minSampleRate = 0.1,  // 0.1 Hz, every 10 seconds
279              .maxSampleRate = 10,   // 10 Hz, every 100 ms
280          },
281      .initialValue = {.floatValues = {101.0f}}},
282 
283     {
284         .config =
285             {
286                 .prop = kGenerateFakeDataControllingProperty,
287                 .access = VehiclePropertyAccess::WRITE,
288                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
289             },
290     },
291 
292     {.config =
293          {
294              .prop = toInt(VehicleProperty::DOOR_LOCK),
295              .access = VehiclePropertyAccess::READ,
296              .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
297          },
298      .initialValue = {.int32Values = {1}}},
299 
300     {
301         .config =
302             {
303                 .prop = WHEEL_TICK,
304                 .access = VehiclePropertyAccess::READ,
305                 .changeMode = VehiclePropertyChangeMode::CONTINUOUS,
306                 .configArray = {ALL_WHEELS, 50000, 50000, 50000, 50000},
307                 .minSampleRate = 1.0f,
308                 .maxSampleRate = 100.0f,
309             },
310     },
311 
312     {
313         .config =
314             {
315                 .prop = ABS_ACTIVE,
316                 .access = VehiclePropertyAccess::READ,
317                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
318             },
319     },
320 
321     {
322         .config =
323             {
324                 .prop = TRACTION_CONTROL_ACTIVE,
325                 .access = VehiclePropertyAccess::READ,
326                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
327             },
328     },
329 
330     {
331         .config = {.prop = OBD2_LIVE_FRAME,
332                    .access = VehiclePropertyAccess::READ,
333                    .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
334                    .configArray = {0, 0}},
335     },
336 
337     {
338         .config = {.prop = OBD2_FREEZE_FRAME,
339                    .access = VehiclePropertyAccess::READ,
340                    .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
341                    .configArray = {0, 0}},
342     },
343 
344     {
345         .config = {.prop = OBD2_FREEZE_FRAME_INFO,
346                    .access = VehiclePropertyAccess::READ,
347                    .changeMode = VehiclePropertyChangeMode::ON_CHANGE},
348     },
349 
350     {
351         .config = {.prop = OBD2_FREEZE_FRAME_CLEAR,
352                    .access = VehiclePropertyAccess::WRITE,
353                    .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
354                    .configArray = {1}},
355     },
356 
357     {.config = {.prop = VEHICLE_MAP_SERVICE,
358                 .access = VehiclePropertyAccess::READ_WRITE,
359                 .changeMode = VehiclePropertyChangeMode::ON_CHANGE}},
360 };
361 
362 }  // impl
363 
364 }  // namespace V2_0
365 }  // namespace vehicle
366 }  // namespace automotive
367 }  // namespace hardware
368 }  // namespace android
369 
370 #endif // android_hardware_automotive_vehicle_V2_0_impl_DefaultConfig_H_
371