blob: da0d47690989f129cda7be06abdedbcbc0d25e10 [file] [log] [blame]
Keun-young Park450faba2016-02-10 18:15:12 -08001/*
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 CAR_VEHICLE_HAL_PROPERTY_UTIL_H_
18#define CAR_VEHICLE_HAL_PROPERTY_UTIL_H_
19
20#include <stdint.h>
21#include <sys/types.h>
22#include <inttypes.h>
23
24#include <hardware/hardware.h>
25#include <hardware/vehicle.h>
26
27#include <utils/String8.h>
28
29namespace android {
30
31class VechilePropertyUtil {
32public:
33 static void dumpProperty(String8& msg, const vehicle_prop_config_t& config) {
34 msg.appendFormat("property 0x%x, access:0x%x, change_mode:0x%x, value_type:0x%x",
35 config.prop, config.access, config.change_mode, config.value_type);
36 msg.appendFormat(",permission:0x%x, conflg_flag:0x%x, fsmin:%f, fsmax:%f",
37 config.permission_model, config.config_flags, config.min_sample_rate,
38 config.max_sample_rate);
39 switch (config.value_type) {
40 case VEHICLE_VALUE_TYPE_FLOAT:
41 case VEHICLE_VALUE_TYPE_FLOAT_VEC2:
42 case VEHICLE_VALUE_TYPE_FLOAT_VEC3:
43 case VEHICLE_VALUE_TYPE_FLOAT_VEC4:
44 case VEHICLE_VALUE_TYPE_ZONED_FLOAT:
45 case VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC2:
46 case VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC3: {
47 msg.appendFormat(",v min:%f, v max:%f\n", config.float_min_value,
48 config.float_max_value);
49 } break;
50 case VEHICLE_VALUE_TYPE_INT64: {
Keun-young Park558e9b12016-02-26 13:52:45 -080051 msg.appendFormat(",v min:%" PRId64 " max:%" PRId64 "\n", config.int64_min_value,
Keun-young Park450faba2016-02-10 18:15:12 -080052 config.int64_max_value);
53 } break;
54 case VEHICLE_VALUE_TYPE_INT32:
55 case VEHICLE_VALUE_TYPE_INT32_VEC2:
56 case VEHICLE_VALUE_TYPE_INT32_VEC3:
57 case VEHICLE_VALUE_TYPE_INT32_VEC4:
58 case VEHICLE_VALUE_TYPE_ZONED_INT32:
59 case VEHICLE_VALUE_TYPE_ZONED_INT32_VEC2:
60 case VEHICLE_VALUE_TYPE_ZONED_INT32_VEC3: {
61 msg.appendFormat(",v min:%d, v max:%d\n", config.int32_min_value,
62 config.int32_max_value);
63 } break;
64 default:
65 msg.appendFormat("\n");
66 }
67 }
68};
69
70
71};
72
73#endif /* CAR_VEHICLE_HAL_PROPERTY_UTIL_H_ */