1 /*
2  * Copyright (C) 2024 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 use android_hardware_automotive_audiocontrol::aidl::android::hardware::automotive::audiocontrol::{
17     AudioFocusChange::AudioFocusChange,
18     AudioGainConfigInfo::AudioGainConfigInfo,
19     DuckingInfo::DuckingInfo,
20     IAudioControl::IAudioControl,
21     IAudioGainCallback::IAudioGainCallback,
22     IFocusListener::IFocusListener,
23     IModuleChangeCallback::IModuleChangeCallback,
24     MutingInfo::MutingInfo,
25     Reasons::Reasons,
26     AudioDeviceConfiguration::AudioDeviceConfiguration,
27     AudioZone::AudioZone
28 };
29 use android_hardware_audio_common::aidl::android::hardware::audio::common::{
30     PlaybackTrackMetadata::PlaybackTrackMetadata,
31 };
32 use android_media_audio_common_types::aidl::android::media::audio::common::{
33     AudioPort::AudioPort,
34 };
35 use binder::{Interface, Result as BinderResult, StatusCode, Strong};
36 
37 /// This struct is defined to implement IAudioControl AIDL interface.
38 pub struct DefaultAudioControlHal;
39 
40 impl Interface for DefaultAudioControlHal {}
41 
42 impl IAudioControl for DefaultAudioControlHal {
onAudioFocusChange(&self, _usage : &str, _zone_id : i32, _focus_change : AudioFocusChange ) -> BinderResult<()>43     fn onAudioFocusChange(&self, _usage : &str, _zone_id : i32, _focus_change : AudioFocusChange
44         ) -> BinderResult<()> {
45         Err(StatusCode::UNKNOWN_ERROR.into())
46     }
47 
onDevicesToDuckChange(&self, _ducking_infos : &[DuckingInfo]) -> BinderResult<()>48     fn onDevicesToDuckChange(&self, _ducking_infos : &[DuckingInfo]) -> BinderResult<()> {
49         Err(StatusCode::UNKNOWN_ERROR.into())
50     }
51 
onDevicesToMuteChange(&self, _muting_infos : &[MutingInfo]) -> BinderResult<()>52     fn onDevicesToMuteChange(&self, _muting_infos : &[MutingInfo]) -> BinderResult<()> {
53         Err(StatusCode::UNKNOWN_ERROR.into())
54     }
55 
registerFocusListener(&self, _listener : &Strong<dyn IFocusListener>) -> BinderResult<()>56     fn registerFocusListener(&self, _listener : &Strong<dyn IFocusListener>) -> BinderResult<()> {
57         Err(StatusCode::UNKNOWN_ERROR.into())
58     }
59 
setBalanceTowardRight(&self, _value : f32) -> BinderResult<()>60     fn setBalanceTowardRight(&self, _value : f32) -> BinderResult<()> {
61         Err(StatusCode::UNKNOWN_ERROR.into())
62     }
63 
setFadeTowardFront(&self, _value : f32) -> BinderResult<()>64     fn setFadeTowardFront(&self, _value : f32) -> BinderResult<()> {
65         Err(StatusCode::UNKNOWN_ERROR.into())
66     }
67 
onAudioFocusChangeWithMetaData(&self, _playback_metadata : &PlaybackTrackMetadata, _zone_id : i32, _focus_change : AudioFocusChange) -> BinderResult<()>68     fn onAudioFocusChangeWithMetaData(&self, _playback_metadata : &PlaybackTrackMetadata,
69             _zone_id : i32, _focus_change : AudioFocusChange) -> BinderResult<()> {
70         Err(StatusCode::UNKNOWN_ERROR.into())
71     }
72 
setAudioDeviceGainsChanged(&self, _reasons : &[Reasons], _gains : &[AudioGainConfigInfo] ) -> BinderResult<()>73     fn setAudioDeviceGainsChanged(&self, _reasons : &[Reasons], _gains : &[AudioGainConfigInfo]
74         ) -> BinderResult<()> {
75         Err(StatusCode::UNKNOWN_ERROR.into())
76     }
77 
registerGainCallback(&self, _callback : &Strong<dyn IAudioGainCallback> ) -> BinderResult<()>78     fn registerGainCallback(&self, _callback : &Strong<dyn IAudioGainCallback>
79         ) -> BinderResult<()> {
80         Err(StatusCode::UNKNOWN_ERROR.into())
81     }
82 
setModuleChangeCallback(&self, _callback : &Strong<dyn IModuleChangeCallback> ) -> BinderResult<()>83     fn setModuleChangeCallback(&self, _callback : &Strong<dyn IModuleChangeCallback>
84         ) -> BinderResult<()> {
85         Err(StatusCode::UNKNOWN_ERROR.into())
86     }
87 
clearModuleChangeCallback(&self) -> BinderResult<()>88     fn clearModuleChangeCallback(&self) -> BinderResult<()> {
89         Err(StatusCode::UNKNOWN_ERROR.into())
90     }
91 
getAudioDeviceConfiguration(&self) -> std::result::Result<AudioDeviceConfiguration, binder::Status>92     fn getAudioDeviceConfiguration(&self) -> std::result::Result<AudioDeviceConfiguration, binder::Status> {
93         Err(binder::StatusCode::UNKNOWN_ERROR.into())
94     }
95 
getOutputMirroringDevices(&self) -> std::result::Result<std::vec::Vec<AudioPort>, binder::Status>96     fn getOutputMirroringDevices(&self) -> std::result::Result<std::vec::Vec<AudioPort>, binder::Status> {
97         Err(binder::StatusCode::UNKNOWN_ERROR.into())
98     }
99 
getCarAudioZones(&self) -> std::result::Result<std::vec::Vec<AudioZone>, binder::Status>100     fn getCarAudioZones(&self) -> std::result::Result<std::vec::Vec<AudioZone>, binder::Status> {
101         Err(binder::StatusCode::UNKNOWN_ERROR.into())
102     }
103 }
104