Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | |
Kevin Rocard | df9b420 | 2018-05-10 19:56:08 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_VERSION_UTILS_H |
| 18 | #define ANDROID_HARDWARE_VERSION_UTILS_H |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 19 | |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 20 | #include <android/hardware/audio/2.0/types.h> |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 21 | #include <android/hardware/audio/4.0/types.h> |
| 22 | #include <hidl/HidlSupport.h> |
| 23 | |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 24 | using ::android::hardware::audio::CPP_VERSION::ParameterValue; |
| 25 | using ::android::hardware::audio::CPP_VERSION::Result; |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 26 | using ::android::hardware::Return; |
| 27 | using ::android::hardware::hidl_vec; |
| 28 | using ::android::hardware::hidl_string; |
| 29 | |
| 30 | namespace android { |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 31 | namespace CPP_VERSION { |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 32 | namespace utils { |
| 33 | |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 34 | #if MAJOR_VERSION == 2 |
| 35 | template <class T, class Callback> |
| 36 | Return<void> getParameters(T& object, hidl_vec<ParameterValue> /*context*/, |
| 37 | hidl_vec<hidl_string> keys, Callback callback) { |
| 38 | return object->getParameters(keys, callback); |
| 39 | } |
| 40 | |
| 41 | template <class T> |
| 42 | Return<Result> setParameters(T& object, hidl_vec<ParameterValue> /*context*/, |
| 43 | hidl_vec<ParameterValue> keys) { |
| 44 | return object->setParameters(keys); |
| 45 | } |
| 46 | #elif MAJOR_VERSION == 4 |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 47 | template <class T, class Callback> |
| 48 | Return<void> getParameters(T& object, hidl_vec<ParameterValue> context, |
| 49 | hidl_vec<hidl_string> keys, Callback callback) { |
| 50 | return object->getParameters(context, keys, callback); |
| 51 | } |
| 52 | |
| 53 | template <class T> |
| 54 | Return<Result> setParameters(T& object, hidl_vec<ParameterValue> context, |
| 55 | hidl_vec<ParameterValue> keys) { |
| 56 | return object->setParameters(context, keys); |
| 57 | } |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 58 | #endif |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 59 | |
| 60 | } // namespace utils |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 61 | } // namespace CPP_VERSION |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 62 | } // namespace android |
| 63 | |
Kevin Rocard | df9b420 | 2018-05-10 19:56:08 -0700 | [diff] [blame] | 64 | #endif // ANDROID_HARDWARE_VERSION_UTILS_H |