• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef android_hardware_automotive_vehicle_aidl_impl_fake_impl_userhal_include_UserHalHelper_H_
18 #define android_hardware_automotive_vehicle_aidl_impl_fake_impl_userhal_include_UserHalHelper_H_
19 
20 #include <UserHalTypes.h>
21 #include <VehicleHalTypes.h>
22 #include <VehicleObjectPool.h>
23 #include <android-base/result.h>
24 
25 #include <functional>
26 #include <memory>
27 
28 namespace android {
29 namespace hardware {
30 namespace automotive {
31 namespace vehicle {
32 namespace fake {
33 namespace user_hal_helper {
34 
35 // Verify whether the |value| can be casted to the type |T| and return the casted value on success.
36 // Otherwise, return the error.
37 template <typename T>
38 android::base::Result<T> verifyAndCast(int32_t value);
39 
40 // Below functions parse VehiclePropValues to the respective User HAL request structs. On success,
41 // these functions return the User HAL struct. Otherwise, they return the error.
42 android::base::Result<aidl::android::hardware::automotive::vehicle::InitialUserInfoRequest>
43 toInitialUserInfoRequest(
44         const aidl::android::hardware::automotive::vehicle::VehiclePropValue& propValue);
45 android::base::Result<aidl::android::hardware::automotive::vehicle::SwitchUserRequest>
46 toSwitchUserRequest(
47         const aidl::android::hardware::automotive::vehicle::VehiclePropValue& propValue);
48 android::base::Result<aidl::android::hardware::automotive::vehicle::CreateUserRequest>
49 toCreateUserRequest(
50         const aidl::android::hardware::automotive::vehicle::VehiclePropValue& propValue);
51 android::base::Result<aidl::android::hardware::automotive::vehicle::RemoveUserRequest>
52 toRemoveUserRequest(
53         const aidl::android::hardware::automotive::vehicle::VehiclePropValue& propValue);
54 android::base::Result<aidl::android::hardware::automotive::vehicle::UserIdentificationGetRequest>
55 toUserIdentificationGetRequest(
56         const aidl::android::hardware::automotive::vehicle::VehiclePropValue& propValue);
57 android::base::Result<aidl::android::hardware::automotive::vehicle::UserIdentificationSetRequest>
58 toUserIdentificationSetRequest(
59         const aidl::android::hardware::automotive::vehicle::VehiclePropValue& propValue);
60 
61 // Below functions convert the User HAL structs to VehiclePropValues. On success, these functions
62 // return the pointer to VehiclePropValue. Otherwise, they return the error.
63 android::base::Result<VehiclePropValuePool::RecyclableType> toVehiclePropValue(
64         VehiclePropValuePool& pool,
65         const aidl::android::hardware::automotive::vehicle::SwitchUserRequest& request);
66 VehiclePropValuePool::RecyclableType toVehiclePropValue(
67         VehiclePropValuePool& pool,
68         const aidl::android::hardware::automotive::vehicle::InitialUserInfoResponse& response);
69 VehiclePropValuePool::RecyclableType toVehiclePropValue(
70         VehiclePropValuePool& pool,
71         const aidl::android::hardware::automotive::vehicle::SwitchUserResponse& response);
72 VehiclePropValuePool::RecyclableType toVehiclePropValue(
73         VehiclePropValuePool& pool,
74         const aidl::android::hardware::automotive::vehicle::CreateUserResponse& response);
75 VehiclePropValuePool::RecyclableType toVehiclePropValue(
76         VehiclePropValuePool& pool,
77         const aidl::android::hardware::automotive::vehicle::UserIdentificationResponse& response);
78 
79 }  // namespace user_hal_helper
80 }  // namespace fake
81 }  // namespace vehicle
82 }  // namespace automotive
83 }  // namespace hardware
84 }  // namespace android
85 
86 #endif  // android_hardware_automotive_vehicle_aidl_impl_fake_impl_userhal_include_UserHalHelper_H_
87