blob: bee34cf0f6afefdd71e5fe8a943d70a4ea7e1a1c [file] [log] [blame]
Lakshman Annadoraib33e2ab2020-07-27 10:42:32 -07001/*
2 * Copyright (C) 2020 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_UserHalHelper_H_
18#define android_hardware_automotive_vehicle_V2_0_impl_UserHalHelper_H_
19
20#include <android-base/result.h>
21#include <android/hardware/automotive/vehicle/2.0/types.h>
22
23#include <functional>
24#include <memory>
25
26namespace android {
27namespace hardware {
28namespace automotive {
29namespace vehicle {
30namespace V2_0 {
31
32namespace user_hal_helper {
33
34// Below functions parse VehiclePropValues to the respective User HAL request structs. On success,
35// these functions return the User HAL struct. Otherwise, they return the error.
36android::base::Result<InitialUserInfoRequest> toInitialUserInfoRequest(
37 const VehiclePropValue& propValue);
38android::base::Result<SwitchUserRequest> toSwitchUserRequest(const VehiclePropValue& propValue);
39android::base::Result<CreateUserRequest> toCreateUserRequest(const VehiclePropValue& propValue);
40android::base::Result<RemoveUserRequest> toRemoveUserRequest(const VehiclePropValue& propValue);
41android::base::Result<UserIdentificationGetRequest> toUserIdentificationGetRequest(
42 const VehiclePropValue& propValue);
43android::base::Result<UserIdentificationSetRequest> toUserIdentificationSetRequest(
44 const VehiclePropValue& propValue);
45
46// Below functions convert the User HAL structs to VehiclePropValues. On success, these functions
47// return the pointer to VehiclePropValue. Otherwise, they return nullptr.
48std::unique_ptr<VehiclePropValue> toVehiclePropValue(const SwitchUserRequest& request);
49std::unique_ptr<VehiclePropValue> toVehiclePropValue(const InitialUserInfoResponse& response);
50std::unique_ptr<VehiclePropValue> toVehiclePropValue(const SwitchUserResponse& response);
51std::unique_ptr<VehiclePropValue> toVehiclePropValue(const CreateUserResponse& response);
52std::unique_ptr<VehiclePropValue> toVehiclePropValue(const UserIdentificationResponse& response);
53
54} // namespace user_hal_helper
55
56} // namespace V2_0
57} // namespace vehicle
58} // namespace automotive
59} // namespace hardware
60} // namespace android
61
62#endif // android_hardware_automotive_vehicle_V2_0_impl_UserHalHelper_H_