1 /*
2 * Copyright (c) 2021-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #ifndef LOG_TAG
16 #define LOG_TAG "AudioServerProxy"
17 #endif
18
19 #include "audio_server_proxy.h"
20 #include <ability_manager_client.h>
21 #include "iservice_registry.h"
22 #include "parameter.h"
23 #include "parameters.h"
24 #include "audio_service_log.h"
25 #include "audio_manager_listener_stub.h"
26 #include "audio_inner_call.h"
27 #include "media_monitor_manager.h"
28
29 namespace OHOS {
30 namespace AudioStandard {
31
GetAudioServerProxy()32 const sptr<IStandardAudioService> AudioServerProxy::GetAudioServerProxy()
33 {
34 AUDIO_DEBUG_LOG("[Policy Service] Start get audio policy service proxy.");
35 std::lock_guard<std::mutex> lock(adProxyMutex_);
36 auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
37 CHECK_AND_RETURN_RET_LOG(samgr != nullptr, nullptr, "[Policy Service] Get samgr failed.");
38
39 sptr<IRemoteObject> object = samgr->GetSystemAbility(AUDIO_DISTRIBUTED_SERVICE_ID);
40 CHECK_AND_RETURN_RET_LOG(object != nullptr, nullptr,
41 "[Policy Service] audio service remote object is NULL.");
42
43 const sptr<IStandardAudioService> gsp = iface_cast<IStandardAudioService>(object);
44 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, nullptr,
45 "[Policy Service] init gsp is NULL.");
46 return gsp;
47 }
48
SetAudioSceneProxy(AudioScene audioScene,std::vector<DeviceType> activeOutputDevices,DeviceType deviceType,BluetoothOffloadState state)49 int32_t AudioServerProxy::SetAudioSceneProxy(AudioScene audioScene, std::vector<DeviceType> activeOutputDevices,
50 DeviceType deviceType, BluetoothOffloadState state)
51 {
52 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
53 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "Service proxy unavailable");
54 std::string identity = IPCSkeleton::ResetCallingIdentity();
55 int32_t result = gsp->SetAudioScene(audioScene, activeOutputDevices, deviceType, state);
56 IPCSkeleton::SetCallingIdentity(identity);
57 return result;
58 }
59
GetMaxAmplitudeProxy(bool flag,std::string portName,SourceType sourceType)60 float AudioServerProxy::GetMaxAmplitudeProxy(bool flag, std::string portName, SourceType sourceType)
61 {
62 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
63 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, 0, "Service proxy unavailable");
64
65 std::string identity = IPCSkeleton::ResetCallingIdentity();
66 float maxAmplitude = gsp->GetMaxAmplitude(flag, portName, sourceType);
67 IPCSkeleton::SetCallingIdentity(identity);
68 return maxAmplitude;
69 }
70
UpdateEffectBtOffloadSupportedProxy(const bool & isSupported)71 void AudioServerProxy::UpdateEffectBtOffloadSupportedProxy(const bool &isSupported)
72 {
73 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
74 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
75 std::string identity = IPCSkeleton::ResetCallingIdentity();
76 gsp->UpdateEffectBtOffloadSupported(isSupported);
77 IPCSkeleton::SetCallingIdentity(identity);
78 return;
79 }
80
SetOutputDeviceSinkProxy(DeviceType deviceType,std::string sinkName)81 void AudioServerProxy::SetOutputDeviceSinkProxy(DeviceType deviceType, std::string sinkName)
82 {
83 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
84 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
85 std::string identity = IPCSkeleton::ResetCallingIdentity();
86 gsp->SetOutputDeviceSink(deviceType, sinkName);
87 IPCSkeleton::SetCallingIdentity(identity);
88 }
89
GetEffectOffloadEnabledProxy()90 bool AudioServerProxy::GetEffectOffloadEnabledProxy()
91 {
92 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
93 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, false, "Service proxy unavailable");
94 std::string identity = IPCSkeleton::ResetCallingIdentity();
95 bool effectOffloadFlag = gsp->GetEffectOffloadEnabled();
96 IPCSkeleton::SetCallingIdentity(identity);
97 return effectOffloadFlag;
98 }
99
UpdateActiveDevicesRouteProxy(std::vector<std::pair<DeviceType,DeviceFlag>> & activeDevices,BluetoothOffloadState state,const std::string & deviceName)100 int32_t AudioServerProxy::UpdateActiveDevicesRouteProxy(std::vector<std::pair<DeviceType, DeviceFlag>> &activeDevices,
101 BluetoothOffloadState state, const std::string &deviceName)
102 {
103 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
104 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "Service proxy unavailable");
105 std::string identity = IPCSkeleton::ResetCallingIdentity();
106 int32_t ret = gsp->UpdateActiveDevicesRoute(activeDevices, state, deviceName);
107 IPCSkeleton::SetCallingIdentity(identity);
108 return ret;
109 }
110
UpdateDualToneStateProxy(const bool & enable,const int32_t & sessionId)111 int32_t AudioServerProxy::UpdateDualToneStateProxy(const bool &enable, const int32_t &sessionId)
112 {
113 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
114 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "Service proxy unavailable");
115 std::string identity = IPCSkeleton::ResetCallingIdentity();
116 int32_t ret = gsp->UpdateDualToneState(enable, sessionId);
117 IPCSkeleton::SetCallingIdentity(identity);
118 return ret;
119 }
120
UpdateSessionConnectionStateProxy(const int32_t & sessionID,const int32_t & state)121 void AudioServerProxy::UpdateSessionConnectionStateProxy(const int32_t &sessionID, const int32_t &state)
122 {
123 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
124 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
125
126 std::string identity = IPCSkeleton::ResetCallingIdentity();
127 gsp->UpdateSessionConnectionState(sessionID, state);
128 IPCSkeleton::SetCallingIdentity(identity);
129 }
130
CheckRemoteDeviceStateProxy(std::string networkId,DeviceRole deviceRole,bool isStartDevice)131 int32_t AudioServerProxy::CheckRemoteDeviceStateProxy(std::string networkId, DeviceRole deviceRole, bool isStartDevice)
132 {
133 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
134 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "Service proxy unavailable");
135 std::string identity = IPCSkeleton::ResetCallingIdentity();
136 int32_t res = gsp->CheckRemoteDeviceState(networkId, deviceRole, isStartDevice);
137 IPCSkeleton::SetCallingIdentity(identity);
138 return res;
139 }
140
SetAudioParameterProxy(const std::string & key,const std::string & value)141 void AudioServerProxy::SetAudioParameterProxy(const std::string &key, const std::string &value)
142 {
143 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
144 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
145 std::string identity = IPCSkeleton::ResetCallingIdentity();
146 gsp->SetAudioParameter(key, value);
147 IPCSkeleton::SetCallingIdentity(identity);
148 }
149
ResetAudioEndpointProxy()150 void AudioServerProxy::ResetAudioEndpointProxy()
151 {
152 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
153 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
154 std::string identity = IPCSkeleton::ResetCallingIdentity();
155 gsp->ResetAudioEndpoint();
156 IPCSkeleton::SetCallingIdentity(identity);
157 }
158
GetAllSinkInputsProxy(std::vector<SinkInput> & sinkInputs)159 void AudioServerProxy::GetAllSinkInputsProxy(std::vector<SinkInput> &sinkInputs)
160 {
161 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
162 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
163 std::string identity = IPCSkeleton::ResetCallingIdentity();
164 gsp->GetAllSinkInputs(sinkInputs);
165 IPCSkeleton::SetCallingIdentity(identity);
166 }
167
SetDefaultAdapterEnableProxy(bool isEnable)168 void AudioServerProxy::SetDefaultAdapterEnableProxy(bool isEnable)
169 {
170 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
171 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
172 std::string identity = IPCSkeleton::ResetCallingIdentity();
173 gsp->SetDefaultAdapterEnable(isEnable);
174 IPCSkeleton::SetCallingIdentity(identity);
175 }
176
NotifyStreamVolumeChangedProxy(AudioStreamType streamType,float volume)177 bool AudioServerProxy::NotifyStreamVolumeChangedProxy(AudioStreamType streamType, float volume)
178 {
179 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
180 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, false, "Service proxy unavailable");
181 std::string identity = IPCSkeleton::ResetCallingIdentity();
182 gsp->NotifyStreamVolumeChanged(streamType, volume);
183 IPCSkeleton::SetCallingIdentity(identity);
184 return true;
185 }
186
OffloadSetVolumeProxy(float volume)187 void AudioServerProxy::OffloadSetVolumeProxy(float volume)
188 {
189 const sptr <IStandardAudioService> gsp = GetAudioServerProxy();
190 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
191 std::string identity = IPCSkeleton::ResetCallingIdentity();
192 gsp->OffloadSetVolume(volume);
193 IPCSkeleton::SetCallingIdentity(identity);
194 }
195
SetVoiceVolumeProxy(float volume)196 void AudioServerProxy::SetVoiceVolumeProxy(float volume)
197 {
198 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
199 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
200 std::string identity = IPCSkeleton::ResetCallingIdentity();
201 gsp->SetVoiceVolume(volume);
202 IPCSkeleton::SetCallingIdentity(identity);
203 }
204
UnsetOffloadModeProxy(uint32_t sessionId)205 void AudioServerProxy::UnsetOffloadModeProxy(uint32_t sessionId)
206 {
207 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
208 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
209 std::string identity = IPCSkeleton::ResetCallingIdentity();
210 gsp->UnsetOffloadMode(sessionId);
211 IPCSkeleton::SetCallingIdentity(identity);
212 }
213
SetOffloadModeProxy(uint32_t sessionId,int32_t state,bool isAppBack)214 void AudioServerProxy::SetOffloadModeProxy(uint32_t sessionId, int32_t state, bool isAppBack)
215 {
216 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
217 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
218 std::string identity = IPCSkeleton::ResetCallingIdentity();
219 gsp->SetOffloadMode(sessionId, state, isAppBack);
220 IPCSkeleton::SetCallingIdentity(identity);
221 }
222
CheckHibernateStateProxy(bool hibernate)223 void AudioServerProxy::CheckHibernateStateProxy(bool hibernate)
224 {
225 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
226 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
227 std::string identity = IPCSkeleton::ResetCallingIdentity();
228 gsp->CheckHibernateState(hibernate);
229 IPCSkeleton::SetCallingIdentity(identity);
230 }
231
RestoreSessionProxy(const uint32_t & sessionID,RestoreInfo restoreInfo)232 void AudioServerProxy::RestoreSessionProxy(const uint32_t &sessionID, RestoreInfo restoreInfo)
233 {
234 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
235 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
236 std::string identity = IPCSkeleton::ResetCallingIdentity();
237 gsp->RestoreSession(sessionID, restoreInfo);
238 IPCSkeleton::SetCallingIdentity(identity);
239 }
240
GetAudioEnhancePropertyProxy(AudioEnhancePropertyArray & propertyArray,DeviceType deviceType)241 int32_t AudioServerProxy::GetAudioEnhancePropertyProxy(AudioEnhancePropertyArray &propertyArray,
242 DeviceType deviceType)
243 {
244 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
245 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_INVALID_HANDLE, "Service proxy unavailable");
246 std::string identity = IPCSkeleton::ResetCallingIdentity();
247 int32_t ret = gsp->GetAudioEnhanceProperty(propertyArray, deviceType);
248 IPCSkeleton::SetCallingIdentity(identity);
249 return ret;
250 }
251
SetAudioEnhancePropertyProxy(const AudioEnhancePropertyArray & propertyArray,DeviceType deviceType)252 int32_t AudioServerProxy::SetAudioEnhancePropertyProxy(const AudioEnhancePropertyArray &propertyArray,
253 DeviceType deviceType)
254 {
255 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
256 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_INVALID_HANDLE, "Service proxy unavailable");
257 std::string identity = IPCSkeleton::ResetCallingIdentity();
258 int32_t ret = gsp->SetAudioEnhanceProperty(propertyArray, deviceType);
259 IPCSkeleton::SetCallingIdentity(identity);
260 return ret;
261 }
262
SetMicrophoneMuteProxy(bool isMute)263 int32_t AudioServerProxy::SetMicrophoneMuteProxy(bool isMute)
264 {
265 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
266 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "Service proxy unavailable");
267 std::string identity = IPCSkeleton::ResetCallingIdentity();
268 int32_t ret = gsp->SetMicrophoneMute(isMute);
269 IPCSkeleton::SetCallingIdentity(identity);
270 return ret;
271 }
272
SetSinkMuteForSwitchDeviceProxy(const std::string & devceClass,int32_t durationUs,bool mute)273 void AudioServerProxy::SetSinkMuteForSwitchDeviceProxy(const std::string &devceClass, int32_t durationUs, bool mute)
274 {
275 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
276 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
277 std::string identity = IPCSkeleton::ResetCallingIdentity();
278 gsp->SetSinkMuteForSwitchDevice(devceClass, durationUs, mute);
279 IPCSkeleton::SetCallingIdentity(identity);
280 }
281
SuspendRenderSinkProxy(const std::string & sinkName)282 void AudioServerProxy::SuspendRenderSinkProxy(const std::string &sinkName)
283 {
284 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
285 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
286 std::string identity = IPCSkeleton::ResetCallingIdentity();
287 gsp->SuspendRenderSink(sinkName);
288 IPCSkeleton::SetCallingIdentity(identity);
289 }
290
RestoreRenderSinkProxy(const std::string & sinkName)291 void AudioServerProxy::RestoreRenderSinkProxy(const std::string &sinkName)
292 {
293 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
294 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
295 std::string identity = IPCSkeleton::ResetCallingIdentity();
296 gsp->RestoreRenderSink(sinkName);
297 IPCSkeleton::SetCallingIdentity(identity);
298 }
299
LoadHdiEffectModelProxy()300 void AudioServerProxy::LoadHdiEffectModelProxy()
301 {
302 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
303 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
304 std::string identity = IPCSkeleton::ResetCallingIdentity();
305 gsp->LoadHdiEffectModel();
306 IPCSkeleton::SetCallingIdentity(identity);
307 }
308
NotifyDeviceInfoProxy(std::string networkId,bool connected)309 void AudioServerProxy::NotifyDeviceInfoProxy(std::string networkId, bool connected)
310 {
311 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
312 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
313 std::string identity = IPCSkeleton::ResetCallingIdentity();
314 gsp->NotifyDeviceInfo(networkId, connected);
315 IPCSkeleton::SetCallingIdentity(identity);
316 }
317
GetAudioParameterProxy(const std::string & key)318 std::string AudioServerProxy::GetAudioParameterProxy(const std::string &key)
319 {
320 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
321 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, "", "Service proxy unavailable");
322 std::string identity = IPCSkeleton::ResetCallingIdentity();
323 std::string result = gsp->GetAudioParameter(key);
324 IPCSkeleton::SetCallingIdentity(identity);
325 return result;
326 }
327
GetAudioParameterProxy(const std::string & networkId,const AudioParamKey key,const std::string & condition)328 std::string AudioServerProxy::GetAudioParameterProxy(const std::string& networkId, const AudioParamKey key,
329 const std::string& condition)
330 {
331 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
332 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, "", "Service proxy unavailable");
333 std::string identity = IPCSkeleton::ResetCallingIdentity();
334 std::string result = gsp->GetAudioParameter(networkId, key, condition);
335 IPCSkeleton::SetCallingIdentity(identity);
336 return result;
337 }
338
ResetRouteForDisconnectProxy(DeviceType type)339 void AudioServerProxy::ResetRouteForDisconnectProxy(DeviceType type)
340 {
341 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
342 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
343 std::string identity = IPCSkeleton::ResetCallingIdentity();
344 gsp->ResetRouteForDisconnect(type);
345 IPCSkeleton::SetCallingIdentity(identity);
346 }
347
CreatePlaybackCapturerManagerProxy()348 bool AudioServerProxy::CreatePlaybackCapturerManagerProxy()
349 {
350 #ifdef HAS_FEATURE_INNERCAPTURER
351 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
352 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, false, "Service proxy unavailable");
353 std::string identity = IPCSkeleton::ResetCallingIdentity();
354 bool ret = gsp->CreatePlaybackCapturerManager();
355 IPCSkeleton::SetCallingIdentity(identity);
356 return ret;
357 #else
358 return false;
359 #endif
360 }
361
LoadAudioEffectLibrariesProxy(const std::vector<Library> libraries,const std::vector<Effect> effects,std::vector<Effect> & successEffectList)362 bool AudioServerProxy::LoadAudioEffectLibrariesProxy(const std::vector<Library> libraries,
363 const std::vector<Effect> effects, std::vector<Effect>& successEffectList)
364 {
365 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
366 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, false, "Service proxy unavailable");
367 std::string identity = IPCSkeleton::ResetCallingIdentity();
368 bool ret = gsp->LoadAudioEffectLibraries(libraries, effects, successEffectList);
369 IPCSkeleton::SetCallingIdentity(identity);
370 return ret;
371 }
372
CreateEffectChainManagerProxy(std::vector<EffectChain> & effectChains,const EffectChainManagerParam & effectParam,const EffectChainManagerParam & enhanceParam)373 bool AudioServerProxy::CreateEffectChainManagerProxy(std::vector<EffectChain> &effectChains,
374 const EffectChainManagerParam &effectParam, const EffectChainManagerParam &enhanceParam)
375 {
376 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
377 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, false, "Service proxy unavailable");
378 std::string identity = IPCSkeleton::ResetCallingIdentity();
379 bool ret = gsp->CreateEffectChainManager(effectChains, effectParam, enhanceParam);
380 IPCSkeleton::SetCallingIdentity(identity);
381 return ret;
382 }
383
RegiestPolicyProviderProxy(const sptr<IRemoteObject> & object)384 int32_t AudioServerProxy::RegiestPolicyProviderProxy(const sptr<IRemoteObject> &object)
385 {
386 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
387 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_INVALID_HANDLE, "Service proxy unavailable");
388 std::string identity = IPCSkeleton::ResetCallingIdentity();
389 int32_t ret = gsp->RegiestPolicyProvider(object);
390 IPCSkeleton::SetCallingIdentity(identity);
391 return ret;
392 }
393
SetParameterCallbackProxy(const sptr<IRemoteObject> & object)394 void AudioServerProxy::SetParameterCallbackProxy(const sptr<IRemoteObject>& object)
395 {
396 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
397 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
398 std::string identity = IPCSkeleton::ResetCallingIdentity();
399 gsp->SetParameterCallback(object);
400 IPCSkeleton::SetCallingIdentity(identity);
401 }
402
SetAudioEffectPropertyProxy(const AudioEffectPropertyArrayV3 & propertyArray,const DeviceType & deviceType)403 int32_t AudioServerProxy::SetAudioEffectPropertyProxy(const AudioEffectPropertyArrayV3 &propertyArray,
404 const DeviceType& deviceType)
405 {
406 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
407 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_INVALID_HANDLE, "Service proxy unavailable");
408 std::string identity = IPCSkeleton::ResetCallingIdentity();
409 int32_t ret = gsp->SetAudioEffectProperty(propertyArray, deviceType);
410 IPCSkeleton::SetCallingIdentity(identity);
411 return ret;
412 }
413
GetAudioEffectPropertyProxy(AudioEffectPropertyArrayV3 & propertyArray)414 int32_t AudioServerProxy::GetAudioEffectPropertyProxy(AudioEffectPropertyArrayV3 &propertyArray)
415 {
416 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
417 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_INVALID_HANDLE, "Service proxy unavailable");
418 std::string identity = IPCSkeleton::ResetCallingIdentity();
419 int32_t ret = gsp->GetAudioEffectProperty(propertyArray);
420 IPCSkeleton::SetCallingIdentity(identity);
421 return ret;
422 }
423
SetAudioEffectPropertyProxy(const AudioEffectPropertyArray & propertyArray)424 int32_t AudioServerProxy::SetAudioEffectPropertyProxy(const AudioEffectPropertyArray &propertyArray)
425 {
426 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
427 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_INVALID_HANDLE, "Service proxy unavailable");
428 std::string identity = IPCSkeleton::ResetCallingIdentity();
429 int32_t ret = gsp->SetAudioEffectProperty(propertyArray);
430 IPCSkeleton::SetCallingIdentity(identity);
431 return ret;
432 }
433
GetAudioEffectPropertyProxy(AudioEffectPropertyArray & propertyArray)434 int32_t AudioServerProxy::GetAudioEffectPropertyProxy(AudioEffectPropertyArray &propertyArray)
435 {
436 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
437 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_INVALID_HANDLE, "Service proxy unavailable");
438 std::string identity = IPCSkeleton::ResetCallingIdentity();
439 int32_t ret = gsp->GetAudioEffectProperty(propertyArray);
440 IPCSkeleton::SetCallingIdentity(identity);
441 return ret;
442 }
443
SetRotationToEffectProxy(const uint32_t rotate)444 void AudioServerProxy::SetRotationToEffectProxy(const uint32_t rotate)
445 {
446 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
447 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
448 std::string identity = IPCSkeleton::ResetCallingIdentity();
449 gsp->SetRotationToEffect(rotate);
450 IPCSkeleton::SetCallingIdentity(identity);
451 }
452
SetAudioMonoStateProxy(bool audioMono)453 void AudioServerProxy::SetAudioMonoStateProxy(bool audioMono)
454 {
455 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
456 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
457 std::string identity = IPCSkeleton::ResetCallingIdentity();
458 gsp->SetAudioMonoState(audioMono);
459 IPCSkeleton::SetCallingIdentity(identity);
460 }
461
SetAudioBalanceValueProxy(float audioBalance)462 void AudioServerProxy::SetAudioBalanceValueProxy(float audioBalance)
463 {
464 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
465 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
466 std::string identity = IPCSkeleton::ResetCallingIdentity();
467 gsp->SetAudioBalanceValue(audioBalance);
468 IPCSkeleton::SetCallingIdentity(identity);
469 }
470
NotifyAccountsChanged()471 void AudioServerProxy::NotifyAccountsChanged()
472 {
473 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
474 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
475 std::string identity = IPCSkeleton::ResetCallingIdentity();
476 gsp->NotifyAccountsChanged();
477 IPCSkeleton::SetCallingIdentity(identity);
478 }
479
NotifyAudioPolicyReady()480 void AudioServerProxy::NotifyAudioPolicyReady()
481 {
482 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
483 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
484 std::string identity = IPCSkeleton::ResetCallingIdentity();
485 gsp->NotifyAudioPolicyReady();
486 IPCSkeleton::SetCallingIdentity(identity);
487 }
488
489 #ifdef HAS_FEATURE_INNERCAPTURER
SetInnerCapLimitProxy(uint32_t innerCapLimit)490 int32_t AudioServerProxy::SetInnerCapLimitProxy(uint32_t innerCapLimit)
491 {
492 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
493 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "Service proxy unavailable");
494 std::string identity = IPCSkeleton::ResetCallingIdentity();
495 int32_t res = gsp->SetInnerCapLimit(innerCapLimit);
496 IPCSkeleton::SetCallingIdentity(identity);
497 return res;
498 }
499 #endif
500
LoadHdiAdapterProxy(uint32_t devMgrType,const std::string & adapterName)501 int32_t AudioServerProxy::LoadHdiAdapterProxy(uint32_t devMgrType, const std::string &adapterName)
502 {
503 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
504 CHECK_AND_RETURN_RET_LOG(gsp != nullptr, ERR_OPERATION_FAILED, "Service proxy unavailable");
505 std::string identity = IPCSkeleton::ResetCallingIdentity();
506 int32_t res = gsp->LoadHdiAdapter(devMgrType, adapterName);
507 IPCSkeleton::SetCallingIdentity(identity);
508 return res;
509 }
510
UnloadHdiAdapterProxy(uint32_t devMgrType,const std::string & adapterName,bool force)511 void AudioServerProxy::UnloadHdiAdapterProxy(uint32_t devMgrType, const std::string &adapterName, bool force)
512 {
513 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
514 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
515 std::string identity = IPCSkeleton::ResetCallingIdentity();
516 gsp->UnloadHdiAdapter(devMgrType, adapterName, force);
517 IPCSkeleton::SetCallingIdentity(identity);
518 }
519
SetDeviceConnectedFlag(bool flag)520 void AudioServerProxy::SetDeviceConnectedFlag(bool flag)
521 {
522 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
523 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
524 std::string identity = IPCSkeleton::ResetCallingIdentity();
525 gsp->SetDeviceConnectedFlag(flag);
526 IPCSkeleton::SetCallingIdentity(identity);
527 }
528
NotifySettingsDataReady()529 void AudioServerProxy::NotifySettingsDataReady()
530 {
531 const sptr<IStandardAudioService> gsp = GetAudioServerProxy();
532 CHECK_AND_RETURN_LOG(gsp != nullptr, "Service proxy unavailable");
533 std::string identity = IPCSkeleton::ResetCallingIdentity();
534 gsp->NotifySettingsDataReady();
535 IPCSkeleton::SetCallingIdentity(identity);
536 }
537 }
538 }
539