blob: 1c4be74280de50b29c8cef5ed782485cb9fbbcdc [file] [log] [blame]
Mikhail Naganov6b111f32017-04-27 18:52:37 -07001/*
2 * Copyright (C) 2017 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#define LOG_TAG "DevicesFactoryHalHybrid"
18//#define LOG_NDEBUG 0
19
20#include "DevicesFactoryHalHybrid.h"
21#include "DevicesFactoryHalLocal.h"
Mikhail Naganov6b111f32017-04-27 18:52:37 -070022#include "DevicesFactoryHalHidl.h"
Mikhail Naganov6b111f32017-04-27 18:52:37 -070023
24namespace android {
25
Mikhail Naganov6b111f32017-04-27 18:52:37 -070026DevicesFactoryHalHybrid::DevicesFactoryHalHybrid()
27 : mLocalFactory(new DevicesFactoryHalLocal()),
Dan Willemsen9e79c702017-10-25 22:57:10 -070028 mHidlFactory(new DevicesFactoryHalHidl()) {
Mikhail Naganov6b111f32017-04-27 18:52:37 -070029}
30
31DevicesFactoryHalHybrid::~DevicesFactoryHalHybrid() {
32}
33
34status_t DevicesFactoryHalHybrid::openDevice(const char *name, sp<DeviceHalInterface> *device) {
Jakub Pawlowski96358212018-04-13 10:42:42 -070035 if (mHidlFactory != 0 && strcmp(AUDIO_HARDWARE_MODULE_ID_A2DP, name) != 0 &&
36 strcmp(AUDIO_HARDWARE_MODULE_ID_HEARING_AID, name) != 0) {
Mikhail Naganov6b111f32017-04-27 18:52:37 -070037 return mHidlFactory->openDevice(name, device);
38 }
39 return mLocalFactory->openDevice(name, device);
40}
41
42} // namespace android