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 #ifndef android_hardware_automotive_vehicle_aidl_impl_fake_impl_obd2frame_include_FakeObd2Frame_H_
17 #define android_hardware_automotive_vehicle_aidl_impl_fake_impl_obd2frame_include_FakeObd2Frame_H_
18 
19 #include <Obd2SensorStore.h>
20 #include <VehicleHalTypes.h>
21 #include <VehiclePropertyStore.h>
22 
23 #include <android-base/result.h>
24 
25 namespace android {
26 namespace hardware {
27 namespace automotive {
28 namespace vehicle {
29 namespace fake {
30 namespace obd2frame {
31 
32 class FakeObd2Frame final {
33   public:
FakeObd2Frame(std::shared_ptr<VehiclePropertyStore> propStore)34     explicit FakeObd2Frame(std::shared_ptr<VehiclePropertyStore> propStore)
35         : mPropStore(propStore) {}
36 
37     void initObd2LiveFrame(
38             const aidl::android::hardware::automotive::vehicle::VehiclePropConfig& propConfig);
39     void initObd2FreezeFrame(
40             const aidl::android::hardware::automotive::vehicle::VehiclePropConfig& propConfig);
41     VhalResult<VehiclePropValuePool::RecyclableType> getObd2FreezeFrame(
42             const aidl::android::hardware::automotive::vehicle::VehiclePropValue&
43                     requestedPropValue) const;
44     VhalResult<VehiclePropValuePool::RecyclableType> getObd2DtcInfo() const;
45     VhalResult<void> clearObd2FreezeFrames(
46             const aidl::android::hardware::automotive::vehicle::VehiclePropValue& propValue);
47     static bool isDiagnosticProperty(
48             const aidl::android::hardware::automotive::vehicle::VehiclePropConfig& propConfig);
49 
50   private:
51     std::shared_ptr<VehiclePropertyStore> mPropStore;
52 
53     std::unique_ptr<Obd2SensorStore> fillDefaultObd2Frame(size_t numVendorIntegerSensors,
54                                                           size_t numVendorFloatSensors);
55 };
56 
57 }  // namespace obd2frame
58 }  // namespace fake
59 }  // namespace vehicle
60 }  // namespace automotive
61 }  // namespace hardware
62 }  // namespace android
63 
64 #endif  // android_hardware_automotive_vehicle_aidl_impl_fake_impl_obd2frame_include_FakeObd2Frame_H_
65