1 /*
2  * Copyright (C) 2022 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_CORE_CONVERSION_HELPER_HIDL_H
18 #define ANDROID_HARDWARE_CORE_CONVERSION_HELPER_HIDL_H
19 
20 #include "ConversionHelperHidl.h"
21 
22 #include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h)
23 #include <utils/String8.h>
24 #include <utils/String16.h>
25 #include <utils/Vector.h>
26 
27 using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::ParameterValue;
28 using CoreResult = ::android::hardware::audio::CORE_TYPES_CPP_VERSION::Result;
29 
30 using ::android::hardware::hidl_string;
31 using ::android::hardware::hidl_vec;
32 
33 namespace android {
34 
35 class CoreConversionHelperHidl : public ConversionHelperHidl<CoreResult> {
36   protected:
37     static status_t keysFromHal(const String8& keys, hidl_vec<hidl_string> *hidlKeys);
38     static status_t parametersFromHal(const String8& kvPairs, hidl_vec<ParameterValue> *hidlParams);
39     static void parametersToHal(const hidl_vec<ParameterValue>& parameters, String8 *values);
40     static void argsFromHal(const Vector<String16>& args, hidl_vec<hidl_string> *hidlArgs);
41 
42     CoreConversionHelperHidl(std::string_view className);
43 
44   private:
45     static status_t analyzeResult(const CoreResult& result);
46 };
47 
48 }  // namespace android
49 
50 #endif // ANDROID_HARDWARE_CORE_CONVERSION_HELPER_HIDL_H
51