1 /*
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 #pragma once
18 
19 #include <android/hardware/audio/common/6.0/types.h>
20 #include <android/hardware/automotive/audiocontrol/2.0/IAudioControl.h>
21 #include <android/hardware/automotive/audiocontrol/2.0/ICloseHandle.h>
22 #include <hidl/MQDescriptor.h>
23 #include <hidl/Status.h>
24 
25 #include "AudioControlServer.h"
26 
27 using android::hardware::audio::common::V6_0::AudioUsage;
28 
29 namespace android::hardware::automotive::audiocontrol::V2_0::implementation {
30 
31 class AudioControl : public IAudioControl {
32   public:
33     explicit AudioControl(const std::string& audio_control_server_addr);
34 
35     bool isHealthy();
36 
37     void ServerStart();
38 
39     void ServerJoin();
40 
41     // Methods from ::android::hardware::automotive::audiocontrol::V2_0::IAudioControl follow.
42     Return<sp<ICloseHandle>> registerFocusListener(const sp<IFocusListener>& listener);
43     Return<void> onAudioFocusChange(hidl_bitfield<AudioUsage> usage, int zoneId,
44                                     hidl_bitfield<AudioFocusChange> focusChange);
45     Return<void> setBalanceTowardRight(float value) override;
46     Return<void> setFadeTowardFront(float value) override;
47     Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
48 
49   private:
50     std::unique_ptr<AudioControlServer> mAudioControlServer;
51 };
52 
53 }  // namespace android::hardware::automotive::audiocontrol::V2_0::implementation
54