1 /*
2 * Copyright (c) 2021-2024 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 "AudioManagerStub"
17 #endif
18
19 #include "audio_manager_base.h"
20 #include "audio_system_manager.h"
21 #include "audio_service_log.h"
22 #include "i_audio_process.h"
23 #include "audio_effect_server.h"
24 #include "audio_asr.h"
25 #include "audio_utils.h"
26
27 using namespace std;
28
29 namespace OHOS {
30 namespace AudioStandard {
31 namespace {
32 constexpr int32_t AUDIO_EXTRA_PARAMETERS_COUNT_UPPER_LIMIT = 40;
33 const char *g_audioServerCodeStrs[] = {
34 "GET_AUDIO_PARAMETER",
35 "SET_AUDIO_PARAMETER",
36 "GET_EXTRA_AUDIO_PARAMETERS",
37 "SET_EXTRA_AUDIO_PARAMETERS",
38 "SET_MICROPHONE_MUTE",
39 "SET_AUDIO_SCENE",
40 "UPDATE_ROUTE_REQ",
41 "UPDATE_ROUTES_REQ",
42 "UPDATE_DUAL_TONE_REQ",
43 "GET_TRANSACTION_ID",
44 "SET_PARAMETER_CALLBACK",
45 "GET_REMOTE_AUDIO_PARAMETER",
46 "SET_REMOTE_AUDIO_PARAMETER",
47 "NOTIFY_DEVICE_INFO",
48 "CHECK_REMOTE_DEVICE_STATE",
49 "SET_VOICE_VOLUME",
50 "SET_AUDIO_MONO_STATE",
51 "SET_AUDIO_BALANCE_VALUE",
52 "CREATE_AUDIOPROCESS",
53 "LOAD_AUDIO_EFFECT_LIBRARIES",
54 "REQUEST_THREAD_PRIORITY",
55 "CREATE_AUDIO_EFFECT_CHAIN_MANAGER",
56 "SET_OUTPUT_DEVICE_SINK",
57 "CREATE_PLAYBACK_CAPTURER_MANAGER",
58 "SET_SUPPORT_STREAM_USAGE",
59 "REGISET_POLICY_PROVIDER",
60 "SET_WAKEUP_CLOSE_CALLBACK",
61 "SET_CAPTURE_SILENT_STATE",
62 "UPDATE_SPATIALIZATION_STATE",
63 "UPDATE_SPATIAL_DEVICE_TYPE",
64 "OFFLOAD_SET_VOLUME",
65 "NOTIFY_STREAM_VOLUME_CHANGED",
66 "SET_SPATIALIZATION_SCENE_TYPE",
67 "GET_MAX_AMPLITUDE",
68 "RESET_AUDIO_ENDPOINT",
69 "RESET_ROUTE_FOR_DISCONNECT",
70 "GET_EFFECT_LATENCY",
71 "UPDATE_LATENCY_TIMESTAMP",
72 "SET_ASR_AEC_MODE",
73 "GET_ASR_AEC_MODE",
74 "SET_ASR_NOISE_SUPPRESSION_MODE",
75 "GET_ASR_NOISE_SUPPRESSION_MODE",
76 "SET_ASR_WHISPER_DETECTION_MODE",
77 "GET_ASR_WHISPER_DETECTION_MODE",
78 "SET_ASR_VOICE_CONTROL_MODE",
79 "SET_ASR_VOICE_MUTE_MODE",
80 "IS_WHISPERING",
81 "GET_EFFECT_OFFLOAD_ENABLED",
82 "SUSPEND_RENDERSINK",
83 "RESTORE_RENDERSINK",
84 "LOAD_HDI_EFFECT_MODEL",
85 "UPDATE_EFFECT_BT_OFFLOAD_SUPPORTED",
86 "SET_SINK_MUTE_FOR_SWITCH_DEVICE",
87 "SET_ROTATION_TO_EFFECT",
88 "UPDATE_SESSION_CONNECTION_STATE",
89 "SET_SINGLE_STREAM_MUTE",
90 "CREATE_IPC_OFFLINE_STREAM",
91 "GET_OFFLINE_AUDIO_EFFECT_CHAINS",
92 };
93 constexpr size_t codeNums = sizeof(g_audioServerCodeStrs) / sizeof(const char *);
94 static_assert(codeNums == (static_cast<size_t> (AudioServerInterfaceCode::AUDIO_SERVER_CODE_MAX) + 1),
95 "keep same with AudioServerInterfaceCode");
96 }
LoadEffectLibrariesReadData(vector<Library> & libList,vector<Effect> & effectList,MessageParcel & data,int32_t countLib,int32_t countEff)97 static void LoadEffectLibrariesReadData(vector<Library>& libList, vector<Effect>& effectList, MessageParcel &data,
98 int32_t countLib, int32_t countEff)
99 {
100 int32_t i;
101 for (i = 0; i < countLib; i++) {
102 string libName = data.ReadString();
103 string libPath = data.ReadString();
104 libList.push_back({libName, libPath});
105 }
106 for (i = 0; i < countEff; i++) {
107 string effectName = data.ReadString();
108 string libName = data.ReadString();
109 effectList.push_back({effectName, libName});
110 }
111 }
112
LoadEffectLibrariesWriteReply(const vector<Effect> & successEffectList,MessageParcel & reply)113 static void LoadEffectLibrariesWriteReply(const vector<Effect>& successEffectList, MessageParcel &reply)
114 {
115 reply.WriteInt32(successEffectList.size());
116 for (Effect effect: successEffectList) {
117 reply.WriteString(effect.name);
118 reply.WriteString(effect.libraryName);
119 }
120 }
121
HandleGetAudioParameter(MessageParcel & data,MessageParcel & reply)122 int AudioManagerStub::HandleGetAudioParameter(MessageParcel &data, MessageParcel &reply)
123 {
124 const std::string key = data.ReadString();
125 const std::string value = GetAudioParameter(key);
126 reply.WriteString(value);
127 return AUDIO_OK;
128 }
129
HandleSetAudioParameter(MessageParcel & data,MessageParcel & reply)130 int AudioManagerStub::HandleSetAudioParameter(MessageParcel &data, MessageParcel &reply)
131 {
132 const std::string key = data.ReadString();
133 const std::string value = data.ReadString();
134 SetAudioParameter(key, value);
135 return AUDIO_OK;
136 }
137
HandleSetAsrAecMode(MessageParcel & data,MessageParcel & reply)138 int AudioManagerStub::HandleSetAsrAecMode(MessageParcel &data, MessageParcel &reply)
139 {
140 AsrAecMode asrAecMode = (static_cast<AsrAecMode>(data.ReadInt32()));
141 int32_t result = SetAsrAecMode(asrAecMode);
142 reply.WriteInt32(result);
143 return AUDIO_OK;
144 }
145
HandleGetAsrAecMode(MessageParcel & data,MessageParcel & reply)146 int AudioManagerStub::HandleGetAsrAecMode(MessageParcel &data, MessageParcel &reply)
147 {
148 AsrAecMode asrAecMode = (static_cast<AsrAecMode>(data.ReadInt32()));
149 int32_t ret = GetAsrAecMode(asrAecMode);
150 CHECK_AND_RETURN_RET_LOG(ret == 0, AUDIO_ERR, "Get AsrAec Mode audio parameters failed");
151 reply.WriteInt32(int32_t(asrAecMode));
152 return AUDIO_OK;
153 }
154
HandleSetAsrNoiseSuppressionMode(MessageParcel & data,MessageParcel & reply)155 int AudioManagerStub::HandleSetAsrNoiseSuppressionMode(MessageParcel &data, MessageParcel &reply)
156 {
157 AsrNoiseSuppressionMode asrNoiseSuppressionMode = (static_cast<AsrNoiseSuppressionMode>(data.ReadInt32()));
158 int32_t result = SetAsrNoiseSuppressionMode(asrNoiseSuppressionMode);
159 reply.WriteInt32(result);
160 return AUDIO_OK;
161 }
162
HandleGetAsrNoiseSuppressionMode(MessageParcel & data,MessageParcel & reply)163 int AudioManagerStub::HandleGetAsrNoiseSuppressionMode(MessageParcel &data, MessageParcel &reply)
164 {
165 AsrNoiseSuppressionMode asrNoiseSuppressionMode = (static_cast<AsrNoiseSuppressionMode>(data.ReadInt32()));
166 int32_t ret = GetAsrNoiseSuppressionMode(asrNoiseSuppressionMode);
167 CHECK_AND_RETURN_RET_LOG(ret == 0, AUDIO_ERR, "Get AsrNoiseSuppression Mode audio parameters failed");
168 reply.WriteInt32(int32_t(asrNoiseSuppressionMode));
169 return AUDIO_OK;
170 }
171
HandleSetAsrWhisperDetectionMode(MessageParcel & data,MessageParcel & reply)172 int AudioManagerStub::HandleSetAsrWhisperDetectionMode(MessageParcel &data, MessageParcel &reply)
173 {
174 AsrWhisperDetectionMode asrWhisperDetectionMode = (static_cast<AsrWhisperDetectionMode>(data.ReadInt32()));
175 int32_t result = SetAsrWhisperDetectionMode(asrWhisperDetectionMode);
176 reply.WriteInt32(result);
177 return AUDIO_OK;
178 }
179
HandleGetAsrWhisperDetectionMode(MessageParcel & data,MessageParcel & reply)180 int AudioManagerStub::HandleGetAsrWhisperDetectionMode(MessageParcel &data, MessageParcel &reply)
181 {
182 AsrWhisperDetectionMode asrWhisperDetectionMode = (static_cast<AsrWhisperDetectionMode>(data.ReadInt32()));
183 int32_t ret = GetAsrWhisperDetectionMode(asrWhisperDetectionMode);
184 CHECK_AND_RETURN_RET_LOG(ret == 0, AUDIO_ERR, "Get AsrWhisperDetection Mode audio parameters failed");
185 reply.WriteInt32(int32_t(asrWhisperDetectionMode));
186 return AUDIO_OK;
187 }
188
HandleSetAsrVoiceControlMode(MessageParcel & data,MessageParcel & reply)189 int AudioManagerStub::HandleSetAsrVoiceControlMode(MessageParcel &data, MessageParcel &reply)
190 {
191 AsrVoiceControlMode asrVoiceControlMode = (static_cast<AsrVoiceControlMode>(data.ReadInt32()));
192 bool on = data.ReadBool();
193 int32_t result = SetAsrVoiceControlMode(asrVoiceControlMode, on);
194 reply.WriteInt32(result);
195 return AUDIO_OK;
196 }
197
HandleSetAsrVoiceMuteMode(MessageParcel & data,MessageParcel & reply)198 int AudioManagerStub::HandleSetAsrVoiceMuteMode(MessageParcel &data, MessageParcel &reply)
199 {
200 AsrVoiceMuteMode asrVoiceMuteMode = (static_cast<AsrVoiceMuteMode>(data.ReadInt32()));
201 bool on = data.ReadBool();
202 int32_t result = SetAsrVoiceMuteMode(asrVoiceMuteMode, on);
203 reply.WriteInt32(result);
204 return AUDIO_OK;
205 }
206
HandleIsWhispering(MessageParcel & data,MessageParcel & reply)207 int AudioManagerStub::HandleIsWhispering(MessageParcel &data, MessageParcel &reply)
208 {
209 const std::string key = data.ReadString();
210 const std::string value = data.ReadString();
211 int32_t result = IsWhispering();
212 return result;
213 }
214
HandleGetEffectOffloadEnabled(MessageParcel & data,MessageParcel & reply)215 int AudioManagerStub::HandleGetEffectOffloadEnabled(MessageParcel &data, MessageParcel &reply)
216 {
217 bool result = GetEffectOffloadEnabled();
218 return result;
219 }
220
HandleGetExtraAudioParameters(MessageParcel & data,MessageParcel & reply)221 int AudioManagerStub::HandleGetExtraAudioParameters(MessageParcel &data, MessageParcel &reply)
222 {
223 const std::string mainKey = data.ReadString();
224 int32_t num = data.ReadInt32();
225 CHECK_AND_RETURN_RET_LOG(num >= 0 && num <= AUDIO_EXTRA_PARAMETERS_COUNT_UPPER_LIMIT,
226 AUDIO_ERR, "Get extra audio parameters failed");
227 std::vector<std::string> subKeys = {};
228 for (int32_t i = 0; i < num; i++) {
229 std::string subKey = data.ReadString();
230 subKeys.push_back(subKey);
231 }
232
233 std::vector<std::pair<std::string, std::string>> values;
234 int32_t result = GetExtraParameters(mainKey, subKeys, values);
235 reply.WriteInt32(static_cast<int32_t>(values.size()));
236 for (auto it = values.begin(); it != values.end(); it++) {
237 reply.WriteString(static_cast<std::string>(it->first));
238 reply.WriteString(static_cast<std::string>(it->second));
239 }
240 reply.WriteInt32(result);
241 return AUDIO_OK;
242 }
243
HandleSetExtraAudioParameters(MessageParcel & data,MessageParcel & reply)244 int AudioManagerStub::HandleSetExtraAudioParameters(MessageParcel &data, MessageParcel &reply)
245 {
246 const std::string mainKey = data.ReadString();
247 std::vector<std::pair<std::string, std::string>> audioParametersSubKVPairs;
248 int32_t mapSize = data.ReadInt32();
249 CHECK_AND_RETURN_RET_LOG(mapSize >= 0 && mapSize <= AUDIO_EXTRA_PARAMETERS_COUNT_UPPER_LIMIT,
250 AUDIO_ERR, "Set extra audio parameters failed");
251 for (int32_t i = 0; i < mapSize; i++) {
252 std::string subKey = data.ReadString();
253 std::string value = data.ReadString();
254 audioParametersSubKVPairs.push_back(std::make_pair(subKey, value));
255 }
256 int32_t result = SetExtraParameters(mainKey, audioParametersSubKVPairs);
257 reply.WriteInt32(result);
258 return AUDIO_OK;
259 }
260
HandleSetMicrophoneMute(MessageParcel & data,MessageParcel & reply)261 int AudioManagerStub::HandleSetMicrophoneMute(MessageParcel &data, MessageParcel &reply)
262 {
263 bool isMute = data.ReadBool();
264 int32_t result = SetMicrophoneMute(isMute);
265 reply.WriteInt32(result);
266 return AUDIO_OK;
267 }
268
HandleSetAudioScene(MessageParcel & data,MessageParcel & reply)269 int AudioManagerStub::HandleSetAudioScene(MessageParcel &data, MessageParcel &reply)
270 {
271 AudioScene audioScene = (static_cast<AudioScene>(data.ReadInt32()));
272 std::vector<DeviceType> activeOutputDevices;
273 int32_t vecSize = data.ReadInt32();
274 CHECK_AND_RETURN_RET_LOG(vecSize > 0 && static_cast<size_t>(vecSize) <= AUDIO_CONCURRENT_ACTIVE_DEVICES_LIMIT,
275 AUDIO_ERR, "HandleSetAudioScene failed");
276 for (int32_t i = 0; i < vecSize; i++) {
277 DeviceType deviceType = (static_cast<DeviceType>(data.ReadInt32()));
278 activeOutputDevices.push_back(deviceType);
279 }
280 DeviceType activeInputDevice = (static_cast<DeviceType>(data.ReadInt32()));
281 BluetoothOffloadState a2dpOffloadFlag = static_cast<BluetoothOffloadState>(data.ReadInt32());
282 int32_t result = SetAudioScene(audioScene, activeOutputDevices, activeInputDevice, a2dpOffloadFlag);
283 reply.WriteInt32(result);
284 return AUDIO_OK;
285 }
286
HandleUpdateActiveDeviceRoute(MessageParcel & data,MessageParcel & reply)287 int AudioManagerStub::HandleUpdateActiveDeviceRoute(MessageParcel &data, MessageParcel &reply)
288 {
289 DeviceType type = static_cast<DeviceType>(data.ReadInt32());
290 DeviceFlag flag = static_cast<DeviceFlag>(data.ReadInt32());
291 BluetoothOffloadState a2dpOffloadFlag = static_cast<BluetoothOffloadState>(data.ReadInt32());
292 int32_t ret = UpdateActiveDeviceRoute(type, flag, a2dpOffloadFlag);
293 reply.WriteInt32(ret);
294 return AUDIO_OK;
295 }
296
HandleUpdateActiveDevicesRoute(MessageParcel & data,MessageParcel & reply)297 int AudioManagerStub::HandleUpdateActiveDevicesRoute(MessageParcel &data, MessageParcel &reply)
298 {
299 std::vector<std::pair<DeviceType, DeviceFlag>> activeDevices;
300 int32_t vecSize = data.ReadInt32();
301 CHECK_AND_RETURN_RET_LOG(vecSize > 0 && static_cast<size_t>(vecSize) <= AUDIO_CONCURRENT_ACTIVE_DEVICES_LIMIT,
302 AUDIO_ERR, "HandleUpdateActiveDevicesRoute failed");
303 for (int32_t i = 0; i < vecSize; i++) {
304 DeviceType deviceType = (static_cast<DeviceType>(data.ReadInt32()));
305 DeviceFlag deviceFlag = (static_cast<DeviceFlag>(data.ReadInt32()));
306 activeDevices.push_back(std::make_pair(deviceType, deviceFlag));
307 }
308 BluetoothOffloadState a2dpOffloadFlag = static_cast<BluetoothOffloadState>(data.ReadInt32());
309 int32_t ret = UpdateActiveDevicesRoute(activeDevices, a2dpOffloadFlag);
310 reply.WriteInt32(ret);
311 return AUDIO_OK;
312 }
313
HandleDualToneState(MessageParcel & data,MessageParcel & reply)314 int AudioManagerStub::HandleDualToneState(MessageParcel &data, MessageParcel &reply)
315 {
316 bool enable = data.ReadBool();
317 int32_t sessionId = data.ReadInt32();
318
319 int32_t ret = UpdateDualToneState(enable, sessionId);
320 reply.WriteInt32(ret);
321 return AUDIO_OK;
322 }
323
HandleGetTransactionId(MessageParcel & data,MessageParcel & reply)324 int AudioManagerStub::HandleGetTransactionId(MessageParcel &data, MessageParcel &reply)
325 {
326 DeviceType deviceType = (static_cast<DeviceType>(data.ReadInt32()));
327 DeviceRole deviceRole = (static_cast<DeviceRole>(data.ReadInt32()));
328 uint64_t transactionId = GetTransactionId(deviceType, deviceRole);
329 reply.WriteUint64(transactionId);
330 return AUDIO_OK;
331 }
332
HandleSetParameterCallback(MessageParcel & data,MessageParcel & reply)333 int AudioManagerStub::HandleSetParameterCallback(MessageParcel &data, MessageParcel &reply)
334 {
335 sptr<IRemoteObject> object = data.ReadRemoteObject();
336 CHECK_AND_RETURN_RET_LOG(object != nullptr, AUDIO_ERR, "SET_PARAMETER_CALLBACK obj is null");
337 int32_t result = SetParameterCallback(object);
338 reply.WriteInt32(result);
339 return AUDIO_OK;
340 }
341
HandleGetRemoteAudioParameter(MessageParcel & data,MessageParcel & reply)342 int AudioManagerStub::HandleGetRemoteAudioParameter(MessageParcel &data, MessageParcel &reply)
343 {
344 const std::string networkId = data.ReadString();
345 AudioParamKey key = static_cast<AudioParamKey>(data.ReadInt32());
346 const std::string condition = data.ReadString();
347 const std::string value = GetAudioParameter(networkId, key, condition);
348 reply.WriteString(value);
349 return AUDIO_OK;
350 }
351
HandleSetRemoteAudioParameter(MessageParcel & data,MessageParcel & reply)352 int AudioManagerStub::HandleSetRemoteAudioParameter(MessageParcel &data, MessageParcel &reply)
353 {
354 const std::string networkId = data.ReadString();
355 AudioParamKey key = static_cast<AudioParamKey>(data.ReadInt32());
356 const std::string condtion = data.ReadString();
357 const std::string value = data.ReadString();
358 SetAudioParameter(networkId, key, condtion, value);
359 return AUDIO_OK;
360 }
361
HandleNotifyDeviceInfo(MessageParcel & data,MessageParcel & reply)362 int AudioManagerStub::HandleNotifyDeviceInfo(MessageParcel &data, MessageParcel &reply)
363 {
364 const std::string networkId = data.ReadString();
365 const bool connected = data.ReadBool();
366 NotifyDeviceInfo(networkId, connected);
367 return AUDIO_OK;
368 }
369
HandleCheckRemoteDeviceState(MessageParcel & data,MessageParcel & reply)370 int AudioManagerStub::HandleCheckRemoteDeviceState(MessageParcel &data, MessageParcel &reply)
371 {
372 std::string networkId = data.ReadString();
373 DeviceRole deviceRole = static_cast<DeviceRole>(data.ReadInt32());
374 bool isStartDevice = data.ReadBool();
375 int32_t result = CheckRemoteDeviceState(networkId, deviceRole, isStartDevice);
376 reply.WriteInt32(result);
377 return AUDIO_OK;
378 }
379
HandleSetVoiceVolume(MessageParcel & data,MessageParcel & reply)380 int AudioManagerStub::HandleSetVoiceVolume(MessageParcel &data, MessageParcel &reply)
381 {
382 const float volume = data.ReadFloat();
383 int32_t result = SetVoiceVolume(volume);
384 reply.WriteInt32(result);
385 return AUDIO_OK;
386 }
387
HandleSetAudioMonoState(MessageParcel & data,MessageParcel & reply)388 int AudioManagerStub::HandleSetAudioMonoState(MessageParcel &data, MessageParcel &reply)
389 {
390 bool audioMonoState = data.ReadBool();
391 SetAudioMonoState(audioMonoState);
392 return AUDIO_OK;
393 }
394
HandleSetAudioBalanceValue(MessageParcel & data,MessageParcel & reply)395 int AudioManagerStub::HandleSetAudioBalanceValue(MessageParcel &data, MessageParcel &reply)
396 {
397 float audioBalanceValue = data.ReadFloat();
398 SetAudioBalanceValue(audioBalanceValue);
399 return AUDIO_OK;
400 }
401
HandleCreateAudioProcess(MessageParcel & data,MessageParcel & reply)402 int AudioManagerStub::HandleCreateAudioProcess(MessageParcel &data, MessageParcel &reply)
403 {
404 AudioProcessConfig config;
405 ProcessConfig::ReadConfigFromParcel(config, data);
406 int32_t errorCode = 0;
407 sptr<IRemoteObject> process = CreateAudioProcess(config, errorCode);
408 CHECK_AND_RETURN_RET_LOG(process != nullptr, AUDIO_ERR,
409 "CREATE_AUDIOPROCESS AudioManagerStub CreateAudioProcess failed");
410 reply.WriteRemoteObject(process);
411 reply.WriteInt32(errorCode);
412 return AUDIO_OK;
413 }
414
HandleLoadAudioEffectLibraries(MessageParcel & data,MessageParcel & reply)415 int AudioManagerStub::HandleLoadAudioEffectLibraries(MessageParcel &data, MessageParcel &reply)
416 {
417 vector<Library> libList = {};
418 vector<Effect> effectList = {};
419 int32_t countLib = data.ReadInt32();
420 int32_t countEff = data.ReadInt32();
421 CHECK_AND_RETURN_RET_LOG((countLib >= 0) && (countLib <= AUDIO_EFFECT_COUNT_UPPER_LIMIT) &&
422 (countEff >= 0) && (countEff <= AUDIO_EFFECT_COUNT_UPPER_LIMIT), AUDIO_ERR,
423 "LOAD_AUDIO_EFFECT_LIBRARIES read data failed");
424 LoadEffectLibrariesReadData(libList, effectList, data, countLib, countEff);
425 if (countLib > 0) {
426 // load lib and reply success list
427 vector<Effect> successEffectList = {};
428 bool loadSuccess = LoadAudioEffectLibraries(libList, effectList, successEffectList);
429 CHECK_AND_RETURN_RET_LOG(loadSuccess, AUDIO_ERR, "Load audio effect libraries failed, please check log");
430 LoadEffectLibrariesWriteReply(successEffectList, reply);
431 }
432 return AUDIO_OK;
433 }
434
HandleRequestThreadPriority(MessageParcel & data,MessageParcel & reply)435 int AudioManagerStub::HandleRequestThreadPriority(MessageParcel &data, MessageParcel &reply)
436 {
437 uint32_t tid = data.ReadUint32();
438 string bundleName = data.ReadString();
439 RequestThreadPriority(tid, bundleName);
440 return AUDIO_OK;
441 }
442
UnmarshellEffectChainMgrParam(EffectChainManagerParam & effectChainMgrParam,MessageParcel & data)443 static bool UnmarshellEffectChainMgrParam(EffectChainManagerParam &effectChainMgrParam, MessageParcel &data)
444 {
445 effectChainMgrParam.maxExtraNum = static_cast <uint32_t>(data.ReadInt32());
446 effectChainMgrParam.defaultSceneName = data.ReadString();
447
448 int32_t containSize = data.ReadInt32();
449 CHECK_AND_RETURN_RET_LOG(containSize >= 0 && containSize <= AUDIO_EFFECT_PRIOR_SCENE_UPPER_LIMIT,
450 false, "Create audio effect prioscene failed, please check log");
451 while (containSize--) {
452 effectChainMgrParam.priorSceneList.emplace_back(data.ReadString());
453 }
454
455 containSize = data.ReadInt32();
456 CHECK_AND_RETURN_RET_LOG(containSize >= 0 && containSize <= AUDIO_EFFECT_CHAIN_CONFIG_UPPER_LIMIT,
457 false, "Create audio effect chain name map failed, please check log");
458 while (containSize--) {
459 string key = data.ReadString();
460 string value = data.ReadString();
461 effectChainMgrParam.sceneTypeToChainNameMap[key] = value;
462 }
463
464 containSize = data.ReadInt32();
465 CHECK_AND_RETURN_RET_LOG(containSize >= 0 && containSize <= AUDIO_EFFECT_COUNT_PROPERTY_UPPER_LIMIT,
466 false, "Create audio effect default property failed, please check log");
467 while (containSize--) {
468 string key = data.ReadString();
469 string value = data.ReadString();
470 effectChainMgrParam.effectDefaultProperty[key] = value;
471 }
472 return true;
473 }
474
HandleCreateAudioEffectChainManager(MessageParcel & data,MessageParcel & reply)475 int AudioManagerStub::HandleCreateAudioEffectChainManager(MessageParcel &data, MessageParcel &reply)
476 {
477 int32_t i;
478 vector<EffectChain> effectChains = {};
479 vector<int32_t> countEffect = {};
480 int32_t countChains = data.ReadInt32();
481 CHECK_AND_RETURN_RET_LOG(countChains >= 0 && countChains <= AUDIO_EFFECT_CHAIN_COUNT_UPPER_LIMIT,
482 AUDIO_ERR, "Create audio effect chains failed, invalid countChains");
483 for (i = 0; i < countChains; i++) {
484 int32_t count = data.ReadInt32();
485 CHECK_AND_RETURN_RET_LOG(count >= 0 && count <= AUDIO_EFFECT_COUNT_PER_CHAIN_UPPER_LIMIT,
486 AUDIO_ERR, "Create audio effect chains failed, invalid count");
487 countEffect.emplace_back(count);
488 }
489
490 for (int32_t count: countEffect) {
491 EffectChain effectChain;
492 effectChain.name = data.ReadString();
493 for (i = 0; i < count; i++) {
494 effectChain.apply.emplace_back(data.ReadString());
495 }
496 effectChains.emplace_back(effectChain);
497 }
498
499 EffectChainManagerParam effectParam;
500 EffectChainManagerParam enhanceParam;
501 if (!UnmarshellEffectChainMgrParam(effectParam, data) || !UnmarshellEffectChainMgrParam(enhanceParam, data)) {
502 return AUDIO_ERR;
503 }
504
505 bool createSuccess = CreateEffectChainManager(effectChains, effectParam, enhanceParam);
506 CHECK_AND_RETURN_RET_LOG(createSuccess, AUDIO_ERR,
507 "Create audio effect chain manager failed, please check log");
508 return AUDIO_OK;
509 }
510
HandleSetOutputDeviceSink(MessageParcel & data,MessageParcel & reply)511 int AudioManagerStub::HandleSetOutputDeviceSink(MessageParcel &data, MessageParcel &reply)
512 {
513 int32_t deviceType = data.ReadInt32();
514 CHECK_AND_RETURN_RET_LOG(deviceType >= DEVICE_TYPE_NONE && deviceType <= DEVICE_TYPE_MAX, AUDIO_ERR,
515 "Set output device sink failed, please check log");
516 std::string sinkName = data.ReadString();
517 SetOutputDeviceSink(deviceType, sinkName);
518 return AUDIO_OK;
519 }
520
HandleCreatePlaybackCapturerManager(MessageParcel & data,MessageParcel & reply)521 int AudioManagerStub::HandleCreatePlaybackCapturerManager(MessageParcel &data, MessageParcel &reply)
522 {
523 bool ret = CreatePlaybackCapturerManager();
524 reply.WriteBool(ret);
525 return AUDIO_OK;
526 }
527
HandleSetSupportStreamUsage(MessageParcel & data,MessageParcel & reply)528 int AudioManagerStub::HandleSetSupportStreamUsage(MessageParcel &data, MessageParcel &reply)
529 {
530 vector<int32_t> usage;
531 size_t cnt = static_cast<size_t>(data.ReadInt32());
532 CHECK_AND_RETURN_RET_LOG(cnt <= AUDIO_SUPPORTED_STREAM_USAGES.size(), AUDIO_ERR,
533 "Set support stream usage failed, please check");
534 for (size_t i = 0; i < cnt; i++) {
535 int32_t tmp_usage = data.ReadInt32();
536 if (find(AUDIO_SUPPORTED_STREAM_USAGES.begin(), AUDIO_SUPPORTED_STREAM_USAGES.end(), tmp_usage) ==
537 AUDIO_SUPPORTED_STREAM_USAGES.end()) {
538 continue;
539 }
540 usage.emplace_back(tmp_usage);
541 }
542 int32_t ret = SetSupportStreamUsage(usage);
543 reply.WriteInt32(ret);
544 return AUDIO_OK;
545 }
546
HandleRegiestPolicyProvider(MessageParcel & data,MessageParcel & reply)547 int AudioManagerStub::HandleRegiestPolicyProvider(MessageParcel &data, MessageParcel &reply)
548 {
549 sptr<IRemoteObject> object = data.ReadRemoteObject();
550 CHECK_AND_RETURN_RET_LOG(object != nullptr, AUDIO_ERR, "obj is null");
551 int32_t result = RegiestPolicyProvider(object);
552 reply.WriteInt32(result);
553 return AUDIO_OK;
554 }
555
HandleSetWakeupSourceCallback(MessageParcel & data,MessageParcel & reply)556 int AudioManagerStub::HandleSetWakeupSourceCallback(MessageParcel &data, MessageParcel &reply)
557 {
558 sptr<IRemoteObject> object = data.ReadRemoteObject();
559 CHECK_AND_RETURN_RET_LOG(object != nullptr, AUDIO_ERR,
560 "SET_WAKEUP_CLOSE_CALLBACK obj is null");
561 int32_t result = SetWakeupSourceCallback(object);
562 reply.WriteInt32(result);
563 return AUDIO_OK;
564 }
565
HandleSetCaptureSilentState(MessageParcel & data,MessageParcel & reply)566 int AudioManagerStub::HandleSetCaptureSilentState(MessageParcel &data, MessageParcel &reply)
567 {
568 bool state = false;
569 int32_t flag = data.ReadInt32();
570 if (flag == 1) {
571 state = true;
572 }
573 int32_t ret = SetCaptureSilentState(state);
574 reply.WriteInt32(ret);
575 return AUDIO_OK;
576 }
577
HandleUpdateSpatializationState(MessageParcel & data,MessageParcel & reply)578 int AudioManagerStub::HandleUpdateSpatializationState(MessageParcel &data, MessageParcel &reply)
579 {
580 AudioSpatializationState spatializationState;
581 spatializationState.spatializationEnabled = data.ReadBool();
582 spatializationState.headTrackingEnabled = data.ReadBool();
583 int32_t ret = UpdateSpatializationState(spatializationState);
584 reply.WriteInt32(ret);
585 return AUDIO_OK;
586 }
587
HandleUpdateSpatialDeviceType(MessageParcel & data,MessageParcel & reply)588 int AudioManagerStub::HandleUpdateSpatialDeviceType(MessageParcel& data, MessageParcel& reply)
589 {
590 AudioSpatialDeviceType spatialDeviceType = static_cast<AudioSpatialDeviceType>(data.ReadInt32());
591 int32_t ret = UpdateSpatialDeviceType(spatialDeviceType);
592 reply.WriteInt32(ret);
593 return AUDIO_OK;
594 }
595
HandleOffloadSetVolume(MessageParcel & data,MessageParcel & reply)596 int AudioManagerStub::HandleOffloadSetVolume(MessageParcel &data, MessageParcel &reply)
597 {
598 const float volume = data.ReadFloat();
599 int32_t result = OffloadSetVolume(volume);
600 reply.WriteInt32(result);
601 return AUDIO_OK;
602 }
603
HandleNotifyStreamVolumeChanged(MessageParcel & data,MessageParcel & reply)604 int AudioManagerStub::HandleNotifyStreamVolumeChanged(MessageParcel &data, MessageParcel &reply)
605 {
606 AudioStreamType type = static_cast<AudioStreamType>(data.ReadInt32());
607 float volume = data.ReadFloat();
608 int32_t ret = NotifyStreamVolumeChanged(type, volume);
609 reply.WriteInt32(ret);
610
611 return AUDIO_OK;
612 }
613
HandleSetSpatializationSceneType(MessageParcel & data,MessageParcel & reply)614 int AudioManagerStub::HandleSetSpatializationSceneType(MessageParcel &data, MessageParcel &reply)
615 {
616 AudioSpatializationSceneType spatializationSceneType = static_cast<AudioSpatializationSceneType>(data.ReadInt32());
617 int32_t ret = SetSpatializationSceneType(spatializationSceneType);
618 reply.WriteInt32(ret);
619 return AUDIO_OK;
620 }
621
HandleResetRouteForDisconnect(MessageParcel & data,MessageParcel & reply)622 int AudioManagerStub::HandleResetRouteForDisconnect(MessageParcel &data, MessageParcel &reply)
623 {
624 DeviceType deviceType = static_cast<DeviceType>(data.ReadInt32());
625 int32_t ret = ResetRouteForDisconnect(deviceType);
626 reply.WriteInt32(ret);
627 return AUDIO_OK;
628 }
629
HandleGetEffectLatency(MessageParcel & data,MessageParcel & reply)630 int AudioManagerStub::HandleGetEffectLatency(MessageParcel &data, MessageParcel &reply)
631 {
632 string sessionId = data.ReadString();
633 uint32_t ret = GetEffectLatency(sessionId);
634 reply.WriteUint32(ret);
635 return AUDIO_OK;
636 }
637
HandleUpdateLatencyTimestamp(MessageParcel & data,MessageParcel & reply)638 int AudioManagerStub::HandleUpdateLatencyTimestamp(MessageParcel &data, MessageParcel &reply)
639 {
640 std::string timestamp = data.ReadString();
641 bool isRenderer = data.ReadBool();
642 UpdateLatencyTimestamp(timestamp, isRenderer);
643 return AUDIO_OK;
644 }
645
HandleGetMaxAmplitude(MessageParcel & data,MessageParcel & reply)646 int AudioManagerStub::HandleGetMaxAmplitude(MessageParcel &data, MessageParcel &reply)
647 {
648 bool isOutputDevice = data.ReadBool();
649 int32_t deviceType = data.ReadInt32();
650 float result = GetMaxAmplitude(isOutputDevice, deviceType);
651 reply.WriteFloat(result);
652 return AUDIO_OK;
653 }
654
HandleResetAudioEndpoint(MessageParcel & data,MessageParcel & reply)655 int AudioManagerStub::HandleResetAudioEndpoint(MessageParcel &data, MessageParcel &reply)
656 {
657 ResetAudioEndpoint();
658 return AUDIO_OK;
659 }
660
HandleSuspendRenderSink(MessageParcel & data,MessageParcel & reply)661 int AudioManagerStub::HandleSuspendRenderSink(MessageParcel &data, MessageParcel &reply)
662 {
663 std::string sinkName = data.ReadString();
664 int32_t ret = SuspendRenderSink(sinkName);
665 reply.WriteInt32(ret);
666 return AUDIO_OK;
667 }
668
HandleRestoreRenderSink(MessageParcel & data,MessageParcel & reply)669 int AudioManagerStub::HandleRestoreRenderSink(MessageParcel &data, MessageParcel &reply)
670 {
671 std::string sinkName = data.ReadString();
672 int32_t ret = RestoreRenderSink(sinkName);
673 reply.WriteInt32(ret);
674 return AUDIO_OK;
675 }
676
HandleLoadHdiEffectModel(MessageParcel & data,MessageParcel & reply)677 int AudioManagerStub::HandleLoadHdiEffectModel(MessageParcel &data, MessageParcel &reply)
678 {
679 LoadHdiEffectModel();
680 return AUDIO_OK;
681 }
682
HandleUpdateEffectBtOffloadSupported(MessageParcel & data,MessageParcel & reply)683 int AudioManagerStub::HandleUpdateEffectBtOffloadSupported(MessageParcel &data, MessageParcel &reply)
684 {
685 UpdateEffectBtOffloadSupported(data.ReadBool());
686 return AUDIO_OK;
687 }
688
HandleSetSinkMuteForSwitchDevice(MessageParcel & data,MessageParcel & reply)689 int AudioManagerStub::HandleSetSinkMuteForSwitchDevice(MessageParcel &data, MessageParcel &reply)
690 {
691 const std::string deviceClass = data.ReadString();
692 int32_t duration = data.ReadInt32();
693 int32_t mute = data.ReadBool();
694 int32_t result = SetSinkMuteForSwitchDevice(deviceClass, duration, mute);
695 reply.WriteInt32(result);
696 return AUDIO_OK;
697 }
698
HandleSetRotationToEffect(MessageParcel & data,MessageParcel & reply)699 int AudioManagerStub::HandleSetRotationToEffect(MessageParcel &data, MessageParcel &reply)
700 {
701 SetRotationToEffect(data.ReadUint32());
702 return AUDIO_OK;
703 }
704
HandleUpdateSessionConnectionState(MessageParcel & data,MessageParcel & reply)705 int AudioManagerStub::HandleUpdateSessionConnectionState(MessageParcel &data, MessageParcel &reply)
706 {
707 int32_t sessionID = data.ReadInt32();
708 int32_t state = data.ReadInt32();
709 UpdateSessionConnectionState(sessionID, state);
710 return AUDIO_OK;
711 }
712
HandleFifthPartCode(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)713 int AudioManagerStub::HandleFifthPartCode(uint32_t code, MessageParcel &data, MessageParcel &reply,
714 MessageOption &option)
715 {
716 switch (code) {
717 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_SINK_MUTE_FOR_SWITCH_DEVICE):
718 return HandleSetSinkMuteForSwitchDevice(data, reply);
719 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_ROTATION_TO_EFFECT):
720 return HandleSetRotationToEffect(data, reply);
721 case static_cast<uint32_t>(AudioServerInterfaceCode::UPDATE_SESSION_CONNECTION_STATE):
722 return HandleUpdateSessionConnectionState(data, reply);
723 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_SINGLE_STREAM_MUTE):
724 return HandleSetNonInterruptMute(data, reply);
725 default:
726 AUDIO_ERR_LOG("default case, need check AudioManagerStub");
727 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
728 }
729 }
730
HandleCreateIpcOfflineStream(MessageParcel & data,MessageParcel & reply)731 int AudioManagerStub::HandleCreateIpcOfflineStream(MessageParcel &data, MessageParcel &reply)
732 {
733 int32_t errorCode = 0;
734 sptr<IRemoteObject> process = CreateIpcOfflineStream(errorCode);
735 CHECK_AND_RETURN_RET_LOG(process != nullptr, AUDIO_ERR,
736 "CREATE_IPC_OFFLINE_STREAM AudioManagerStub CreateIpcOfflineStream failed");
737 reply.WriteRemoteObject(process);
738 reply.WriteInt32(errorCode);
739 return AUDIO_OK;
740 }
741
HandleGetOfflineAudioEffectChains(MessageParcel & data,MessageParcel & reply)742 int AudioManagerStub::HandleGetOfflineAudioEffectChains(MessageParcel &data, MessageParcel &reply)
743 {
744 vector<string> effectChains{};
745 int32_t errCode = GetOfflineAudioEffectChains(effectChains);
746 reply.WriteInt32(effectChains.size());
747 for (auto &chainName : effectChains) {
748 reply.WriteString(chainName);
749 }
750 reply.WriteInt32(errCode);
751 return AUDIO_OK;
752 }
753
HandleFourthPartCode(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)754 int AudioManagerStub::HandleFourthPartCode(uint32_t code, MessageParcel &data, MessageParcel &reply,
755 MessageOption &option)
756 {
757 switch (code) {
758 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_ASR_NOISE_SUPPRESSION_MODE):
759 return HandleGetAsrNoiseSuppressionMode(data, reply);
760 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_ASR_WHISPER_DETECTION_MODE):
761 return HandleSetAsrWhisperDetectionMode(data, reply);
762 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_ASR_WHISPER_DETECTION_MODE):
763 return HandleGetAsrWhisperDetectionMode(data, reply);
764 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_ASR_VOICE_CONTROL_MODE):
765 return HandleSetAsrVoiceControlMode(data, reply);
766 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_ASR_VOICE_MUTE_MODE):
767 return HandleSetAsrVoiceMuteMode(data, reply);
768 case static_cast<uint32_t>(AudioServerInterfaceCode::IS_WHISPERING):
769 return HandleIsWhispering(data, reply);
770 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_EFFECT_OFFLOAD_ENABLED):
771 return HandleGetEffectOffloadEnabled(data, reply);
772 case static_cast<uint32_t>(AudioServerInterfaceCode::SUSPEND_RENDERSINK):
773 return HandleSuspendRenderSink(data, reply);
774 case static_cast<uint32_t>(AudioServerInterfaceCode::RESTORE_RENDERSINK):
775 return HandleRestoreRenderSink(data, reply);
776 case static_cast<uint32_t>(AudioServerInterfaceCode::LOAD_HDI_EFFECT_MODEL):
777 return HandleLoadHdiEffectModel(data, reply);
778 case static_cast<uint32_t>(AudioServerInterfaceCode::UPDATE_EFFECT_BT_OFFLOAD_SUPPORTED):
779 return HandleUpdateEffectBtOffloadSupported(data, reply);
780 default:
781 return HandleFifthPartCode(code, data, reply, option);
782 }
783 }
784
HandleThirdPartCode(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)785 int AudioManagerStub::HandleThirdPartCode(uint32_t code, MessageParcel &data, MessageParcel &reply,
786 MessageOption &option)
787 {
788 switch (code) {
789 case static_cast<uint32_t>(AudioServerInterfaceCode::NOTIFY_STREAM_VOLUME_CHANGED):
790 return HandleNotifyStreamVolumeChanged(data, reply);
791 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_SPATIALIZATION_SCENE_TYPE):
792 return HandleSetSpatializationSceneType(data, reply);
793 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_MAX_AMPLITUDE):
794 return HandleGetMaxAmplitude(data, reply);
795 case static_cast<uint32_t>(AudioServerInterfaceCode::RESET_AUDIO_ENDPOINT):
796 return HandleResetAudioEndpoint(data, reply);
797 case static_cast<uint32_t>(AudioServerInterfaceCode::RESET_ROUTE_FOR_DISCONNECT):
798 return HandleResetRouteForDisconnect(data, reply);
799 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_EFFECT_LATENCY):
800 return HandleGetEffectLatency(data, reply);
801 case static_cast<uint32_t>(AudioServerInterfaceCode::UPDATE_LATENCY_TIMESTAMP):
802 return HandleUpdateLatencyTimestamp(data, reply);
803 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_ASR_AEC_MODE):
804 return HandleSetAsrAecMode(data, reply);
805 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_ASR_AEC_MODE):
806 return HandleGetAsrAecMode(data, reply);
807 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_ASR_NOISE_SUPPRESSION_MODE):
808 return HandleSetAsrNoiseSuppressionMode(data, reply);
809 case static_cast<uint32_t>(AudioServerInterfaceCode::CREATE_IPC_OFFLINE_STREAM):
810 return HandleCreateIpcOfflineStream(data, reply);
811 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_OFFLINE_AUDIO_EFFECT_CHAINS):
812 return HandleGetOfflineAudioEffectChains(data, reply);
813 default:
814 return HandleFourthPartCode(code, data, reply, option);
815 }
816 }
817
HandleSecondPartCode(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)818 int AudioManagerStub::HandleSecondPartCode(uint32_t code, MessageParcel &data, MessageParcel &reply,
819 MessageOption &option)
820 {
821 switch (code) {
822 case static_cast<uint32_t>(AudioServerInterfaceCode::CHECK_REMOTE_DEVICE_STATE):
823 return HandleCheckRemoteDeviceState(data, reply);
824 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_VOICE_VOLUME):
825 return HandleSetVoiceVolume(data, reply);
826 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_AUDIO_MONO_STATE):
827 return HandleSetAudioMonoState(data, reply);
828 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_AUDIO_BALANCE_VALUE):
829 return HandleSetAudioBalanceValue(data, reply);
830 case static_cast<uint32_t>(AudioServerInterfaceCode::CREATE_AUDIOPROCESS):
831 return HandleCreateAudioProcess(data, reply);
832 case static_cast<uint32_t>(AudioServerInterfaceCode::LOAD_AUDIO_EFFECT_LIBRARIES):
833 return HandleLoadAudioEffectLibraries(data, reply);
834 case static_cast<uint32_t>(AudioServerInterfaceCode::REQUEST_THREAD_PRIORITY):
835 return HandleRequestThreadPriority(data, reply);
836 case static_cast<uint32_t>(AudioServerInterfaceCode::CREATE_AUDIO_EFFECT_CHAIN_MANAGER):
837 return HandleCreateAudioEffectChainManager(data, reply);
838 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_OUTPUT_DEVICE_SINK):
839 return HandleSetOutputDeviceSink(data, reply);
840 case static_cast<uint32_t>(AudioServerInterfaceCode::CREATE_PLAYBACK_CAPTURER_MANAGER):
841 return HandleCreatePlaybackCapturerManager(data, reply);
842 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_SUPPORT_STREAM_USAGE):
843 return HandleSetSupportStreamUsage(data, reply);
844 case static_cast<uint32_t>(AudioServerInterfaceCode::REGISET_POLICY_PROVIDER):
845 return HandleRegiestPolicyProvider(data, reply);
846 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_WAKEUP_CLOSE_CALLBACK):
847 return HandleSetWakeupSourceCallback(data, reply);
848 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_CAPTURE_SILENT_STATE):
849 return HandleSetCaptureSilentState(data, reply);
850 case static_cast<uint32_t>(AudioServerInterfaceCode::UPDATE_SPATIALIZATION_STATE):
851 return HandleUpdateSpatializationState(data, reply);
852 case static_cast<uint32_t>(AudioServerInterfaceCode::UPDATE_SPATIAL_DEVICE_TYPE):
853 return HandleUpdateSpatialDeviceType(data, reply);
854 case static_cast<uint32_t>(AudioServerInterfaceCode::OFFLOAD_SET_VOLUME):
855 return HandleOffloadSetVolume(data, reply);
856 default:
857 return HandleThirdPartCode(code, data, reply, option);
858 }
859 }
860
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)861 int AudioManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
862 {
863 CHECK_AND_RETURN_RET_LOG(data.ReadInterfaceToken() == GetDescriptor(),
864 -1, "ReadInterfaceToken failed");
865 Trace trace(code >= codeNums ? "invalid audio server code!" : g_audioServerCodeStrs[code]);
866 if (code <= static_cast<uint32_t>(AudioServerInterfaceCode::AUDIO_SERVER_CODE_MAX)) {
867 switch (code) {
868 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_AUDIO_PARAMETER):
869 return HandleGetAudioParameter(data, reply);
870 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_AUDIO_PARAMETER):
871 return HandleSetAudioParameter(data, reply);
872 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_EXTRA_AUDIO_PARAMETERS):
873 return HandleGetExtraAudioParameters(data, reply);
874 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_EXTRA_AUDIO_PARAMETERS):
875 return HandleSetExtraAudioParameters(data, reply);
876 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_MICROPHONE_MUTE):
877 return HandleSetMicrophoneMute(data, reply);
878 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_AUDIO_SCENE):
879 return HandleSetAudioScene(data, reply);
880 case static_cast<uint32_t>(AudioServerInterfaceCode::UPDATE_ROUTE_REQ):
881 return HandleUpdateActiveDeviceRoute(data, reply);
882 case static_cast<uint32_t>(AudioServerInterfaceCode::UPDATE_ROUTES_REQ):
883 return HandleUpdateActiveDevicesRoute(data, reply);
884 case static_cast<uint32_t>(AudioServerInterfaceCode::UPDATE_DUAL_TONE_REQ):
885 return HandleDualToneState(data, reply);
886 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_TRANSACTION_ID):
887 return HandleGetTransactionId(data, reply);
888 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_PARAMETER_CALLBACK):
889 return HandleSetParameterCallback(data, reply);
890 case static_cast<uint32_t>(AudioServerInterfaceCode::GET_REMOTE_AUDIO_PARAMETER):
891 return HandleGetRemoteAudioParameter(data, reply);
892 case static_cast<uint32_t>(AudioServerInterfaceCode::SET_REMOTE_AUDIO_PARAMETER):
893 return HandleSetRemoteAudioParameter(data, reply);
894 case static_cast<uint32_t>(AudioServerInterfaceCode::NOTIFY_DEVICE_INFO):
895 return HandleNotifyDeviceInfo(data, reply);
896 default:
897 return HandleSecondPartCode(code, data, reply, option);
898 }
899 }
900 AUDIO_ERR_LOG("default case, need check AudioManagerStub");
901 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
902 }
903
HandleSetNonInterruptMute(MessageParcel & data,MessageParcel & reply)904 int AudioManagerStub::HandleSetNonInterruptMute(MessageParcel &data, MessageParcel &reply)
905 {
906 uint32_t sessionId = data.ReadUint32();
907 bool muteFlag = data.ReadBool();
908 SetNonInterruptMute(sessionId, muteFlag);
909 return AUDIO_OK;
910 }
911 } // namespace AudioStandard
912 } // namespace OHOS
913