• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 
16 #include "audio_policy_manager_stub.h"
17 
18 #include "audio_errors.h"
19 #include "audio_log.h"
20 #include "audio_policy_ipc_interface_code.h"
21 
22 namespace OHOS {
23 namespace AudioStandard {
24 using namespace std;
25 
ReadAudioInterruptParams(MessageParcel & data,AudioInterrupt & audioInterrupt)26 void AudioPolicyManagerStub::ReadAudioInterruptParams(MessageParcel &data, AudioInterrupt &audioInterrupt)
27 {
28     audioInterrupt.streamUsage = static_cast<StreamUsage>(data.ReadInt32());
29     audioInterrupt.contentType = static_cast<ContentType>(data.ReadInt32());
30     audioInterrupt.audioFocusType.streamType = static_cast<AudioStreamType>(data.ReadInt32());
31     audioInterrupt.audioFocusType.sourceType = static_cast<SourceType>(data.ReadInt32());
32     audioInterrupt.audioFocusType.isPlay = data.ReadBool();
33     audioInterrupt.sessionID = data.ReadUint32();
34     audioInterrupt.pid = data.ReadInt32();
35     audioInterrupt.mode = static_cast<InterruptMode>(data.ReadInt32());
36     audioInterrupt.parallelPlayFlag = data.ReadBool();
37 }
38 
ReadAudioManagerInterruptParams(MessageParcel & data,AudioInterrupt & audioInterrupt)39 void AudioPolicyManagerStub::ReadAudioManagerInterruptParams(MessageParcel &data, AudioInterrupt &audioInterrupt)
40 {
41     audioInterrupt.streamUsage = static_cast<StreamUsage>(data.ReadInt32());
42     audioInterrupt.contentType = static_cast<ContentType>(data.ReadInt32());
43     audioInterrupt.audioFocusType.streamType = static_cast<AudioStreamType>(data.ReadInt32());
44     audioInterrupt.audioFocusType.sourceType = static_cast<SourceType>(data.ReadInt32());
45     audioInterrupt.audioFocusType.isPlay = data.ReadBool();
46     audioInterrupt.pauseWhenDucked = data.ReadBool();
47     audioInterrupt.pid = data.ReadInt32();
48     audioInterrupt.mode = static_cast<InterruptMode>(data.ReadInt32());
49 }
50 
WriteAudioInteruptParams(MessageParcel & reply,const AudioInterrupt & audioInterrupt)51 void AudioPolicyManagerStub::WriteAudioInteruptParams(MessageParcel &reply, const AudioInterrupt &audioInterrupt)
52 {
53     reply.WriteInt32(static_cast<int32_t>(audioInterrupt.streamUsage));
54     reply.WriteInt32(static_cast<int32_t>(audioInterrupt.contentType));
55     reply.WriteInt32(static_cast<int32_t>(audioInterrupt.audioFocusType.streamType));
56     reply.WriteInt32(static_cast<int32_t>(audioInterrupt.audioFocusType.sourceType));
57     reply.WriteBool(audioInterrupt.audioFocusType.isPlay);
58     reply.WriteUint32(audioInterrupt.sessionID);
59     reply.WriteInt32(audioInterrupt.pid);
60     reply.WriteInt32(static_cast<int32_t>(audioInterrupt.mode));
61     reply.WriteBool(audioInterrupt.parallelPlayFlag);
62 }
63 
ReadStreamChangeInfo(MessageParcel & data,const AudioMode & mode,AudioStreamChangeInfo & streamChangeInfo)64 void AudioPolicyManagerStub::ReadStreamChangeInfo(MessageParcel &data, const AudioMode &mode,
65     AudioStreamChangeInfo &streamChangeInfo)
66 {
67     if (mode == AUDIO_MODE_PLAYBACK) {
68         streamChangeInfo.audioRendererChangeInfo.sessionId = data.ReadInt32();
69         streamChangeInfo.audioRendererChangeInfo.rendererState = static_cast<RendererState>(data.ReadInt32());
70         streamChangeInfo.audioRendererChangeInfo.clientUID = data.ReadInt32();
71         streamChangeInfo.audioRendererChangeInfo.rendererInfo.contentType = static_cast<ContentType>(data.ReadInt32());
72         streamChangeInfo.audioRendererChangeInfo.rendererInfo.streamUsage = static_cast<StreamUsage>(data.ReadInt32());
73         streamChangeInfo.audioRendererChangeInfo.rendererInfo.rendererFlags = data.ReadInt32();
74         return;
75     } else {
76         // mode == AUDIO_MODE_RECORDING
77         streamChangeInfo.audioCapturerChangeInfo.sessionId = data.ReadInt32();
78         streamChangeInfo.audioCapturerChangeInfo.capturerState = static_cast<CapturerState>(data.ReadInt32());
79         streamChangeInfo.audioCapturerChangeInfo.clientUID = data.ReadInt32();
80         streamChangeInfo.audioCapturerChangeInfo.capturerInfo.sourceType = static_cast<SourceType>(data.ReadInt32());
81         streamChangeInfo.audioCapturerChangeInfo.capturerInfo.capturerFlags = data.ReadInt32();
82     }
83 }
84 
GetMaxVolumeLevelInternal(MessageParcel & data,MessageParcel & reply)85 void AudioPolicyManagerStub::GetMaxVolumeLevelInternal(MessageParcel &data, MessageParcel &reply)
86 {
87     AudioVolumeType volumeType = static_cast<AudioVolumeType>(data.ReadInt32());
88     int32_t maxLevel = GetMaxVolumeLevel(volumeType);
89     reply.WriteInt32(maxLevel);
90 }
91 
GetMinVolumeLevelInternal(MessageParcel & data,MessageParcel & reply)92 void AudioPolicyManagerStub::GetMinVolumeLevelInternal(MessageParcel &data, MessageParcel &reply)
93 {
94     AudioVolumeType volumeType = static_cast<AudioVolumeType>(data.ReadInt32());
95     int32_t minLevel = GetMinVolumeLevel(volumeType);
96     reply.WriteInt32(minLevel);
97 }
98 
SetSystemVolumeLevelInternal(MessageParcel & data,MessageParcel & reply)99 void AudioPolicyManagerStub::SetSystemVolumeLevelInternal(MessageParcel &data, MessageParcel &reply)
100 {
101     AudioStreamType streamType = static_cast<AudioStreamType>(data.ReadInt32());
102     int32_t volumeLevel = data.ReadInt32();
103     API_VERSION api_v = static_cast<API_VERSION>(data.ReadInt32());
104     int result = SetSystemVolumeLevel(streamType, volumeLevel, api_v);
105     reply.WriteInt32(result);
106 }
107 
SetRingerModeInternal(MessageParcel & data,MessageParcel & reply)108 void AudioPolicyManagerStub::SetRingerModeInternal(MessageParcel &data, MessageParcel &reply)
109 {
110     AudioRingerMode rMode = static_cast<AudioRingerMode>(data.ReadInt32());
111     API_VERSION api_v = static_cast<API_VERSION>(data.ReadInt32());
112     int32_t result = SetRingerMode(rMode, api_v);
113     reply.WriteInt32(result);
114 }
115 
116 #ifdef FEATURE_DTMF_TONE
GetToneInfoInternal(MessageParcel & data,MessageParcel & reply)117 void AudioPolicyManagerStub::GetToneInfoInternal(MessageParcel &data, MessageParcel &reply)
118 {
119     std::shared_ptr<ToneInfo> ltoneInfo = GetToneConfig(data.ReadInt32());
120     if (ltoneInfo == nullptr) {
121         AUDIO_ERR_LOG("AudioPolicyManagerStub: GetToneInfoInternal obj is null");
122         return;
123     }
124     reply.WriteUint32(ltoneInfo->segmentCnt);
125     reply.WriteUint32(ltoneInfo->repeatCnt);
126     reply.WriteUint32(ltoneInfo->repeatSegment);
127     for (uint32_t i = 0; i < ltoneInfo->segmentCnt; i++) {
128         reply.WriteUint32(ltoneInfo->segments[i].duration);
129         reply.WriteUint16(ltoneInfo->segments[i].loopCnt);
130         reply.WriteUint16(ltoneInfo->segments[i].loopIndx);
131         for (uint32_t j = 0; j < TONEINFO_MAX_WAVES + 1; j++) {
132             reply.WriteUint16(ltoneInfo->segments[i].waveFreq[j]);
133         }
134     }
135 }
136 
GetSupportedTonesInternal(MessageParcel & data,MessageParcel & reply)137 void AudioPolicyManagerStub::GetSupportedTonesInternal(MessageParcel &data, MessageParcel &reply)
138 {
139     int32_t lToneListSize = 0;
140     std::vector<int32_t> lToneList = GetSupportedTones();
141     lToneListSize = static_cast<int32_t>(lToneList.size());
142     reply.WriteInt32(lToneListSize);
143     for (int i = 0; i < lToneListSize; i++) {
144         reply.WriteInt32(lToneList[i]);
145     }
146 }
147 #endif
148 
GetRingerModeInternal(MessageParcel & reply)149 void AudioPolicyManagerStub::GetRingerModeInternal(MessageParcel &reply)
150 {
151     AudioRingerMode rMode = GetRingerMode();
152     reply.WriteInt32(static_cast<int>(rMode));
153 }
154 
SetAudioSceneInternal(MessageParcel & data,MessageParcel & reply)155 void AudioPolicyManagerStub::SetAudioSceneInternal(MessageParcel &data, MessageParcel &reply)
156 {
157     AudioScene audioScene = static_cast<AudioScene>(data.ReadInt32());
158     int32_t result = SetAudioScene(audioScene);
159     reply.WriteInt32(result);
160 }
161 
SetMicrophoneMuteInternal(MessageParcel & data,MessageParcel & reply)162 void AudioPolicyManagerStub::SetMicrophoneMuteInternal(MessageParcel &data, MessageParcel &reply)
163 {
164     bool isMute = data.ReadBool();
165     int32_t result = SetMicrophoneMute(isMute);
166     reply.WriteInt32(result);
167 }
168 
SetMicrophoneMuteAudioConfigInternal(MessageParcel & data,MessageParcel & reply)169 void AudioPolicyManagerStub::SetMicrophoneMuteAudioConfigInternal(MessageParcel &data, MessageParcel &reply)
170 {
171     bool isMute = data.ReadBool();
172     int32_t result = SetMicrophoneMuteAudioConfig(isMute);
173     reply.WriteInt32(result);
174 }
175 
IsMicrophoneMuteInternal(MessageParcel & data,MessageParcel & reply)176 void AudioPolicyManagerStub::IsMicrophoneMuteInternal(MessageParcel &data, MessageParcel &reply)
177 {
178     API_VERSION api_v = static_cast<API_VERSION>(data.ReadInt32());
179     int32_t result = IsMicrophoneMute(api_v);
180     reply.WriteBool(result);
181 }
182 
GetAudioSceneInternal(MessageParcel & reply)183 void AudioPolicyManagerStub::GetAudioSceneInternal(MessageParcel &reply)
184 {
185     AudioScene audioScene = GetAudioScene();
186     reply.WriteInt32(static_cast<int>(audioScene));
187 }
188 
GetSystemVolumeLevelInternal(MessageParcel & data,MessageParcel & reply)189 void AudioPolicyManagerStub::GetSystemVolumeLevelInternal(MessageParcel &data, MessageParcel &reply)
190 {
191     AudioStreamType streamType = static_cast<AudioStreamType>(data.ReadInt32());
192     int32_t volumeLevel = GetSystemVolumeLevel(streamType);
193     reply.WriteInt32(volumeLevel);
194 }
195 
SetLowPowerVolumeInternal(MessageParcel & data,MessageParcel & reply)196 void AudioPolicyManagerStub::SetLowPowerVolumeInternal(MessageParcel &data, MessageParcel &reply)
197 {
198     int32_t streamId = data.ReadInt32();
199     float volume = data.ReadFloat();
200     int result = SetLowPowerVolume(streamId, volume);
201     if (result == SUCCESS)
202         reply.WriteInt32(AUDIO_OK);
203     else
204         reply.WriteInt32(AUDIO_ERR);
205 }
206 
GetLowPowerVolumeInternal(MessageParcel & data,MessageParcel & reply)207 void AudioPolicyManagerStub::GetLowPowerVolumeInternal(MessageParcel &data, MessageParcel &reply)
208 {
209     int32_t streamId = data.ReadInt32();
210     float volume = GetLowPowerVolume(streamId);
211     reply.WriteFloat(volume);
212 }
213 
GetSingleStreamVolumeInternal(MessageParcel & data,MessageParcel & reply)214 void AudioPolicyManagerStub::GetSingleStreamVolumeInternal(MessageParcel &data, MessageParcel &reply)
215 {
216     int32_t streamId = data.ReadInt32();
217     float volume = GetSingleStreamVolume(streamId);
218     reply.WriteFloat(volume);
219 }
220 
SetStreamMuteInternal(MessageParcel & data,MessageParcel & reply)221 void AudioPolicyManagerStub::SetStreamMuteInternal(MessageParcel &data, MessageParcel &reply)
222 {
223     AudioStreamType streamType = static_cast<AudioStreamType>(data.ReadInt32());
224     bool mute = data.ReadBool();
225     API_VERSION api_v = static_cast<API_VERSION>(data.ReadInt32());
226     int result = SetStreamMute(streamType, mute, api_v);
227     reply.WriteInt32(result);
228 }
229 
GetStreamMuteInternal(MessageParcel & data,MessageParcel & reply)230 void AudioPolicyManagerStub::GetStreamMuteInternal(MessageParcel &data, MessageParcel &reply)
231 {
232     AudioStreamType streamType = static_cast<AudioStreamType>(data.ReadInt32());
233     bool mute = GetStreamMute(streamType);
234     reply.WriteBool(mute);
235 }
236 
IsStreamActiveInternal(MessageParcel & data,MessageParcel & reply)237 void AudioPolicyManagerStub::IsStreamActiveInternal(MessageParcel &data, MessageParcel &reply)
238 {
239     AudioStreamType streamType = static_cast<AudioStreamType>(data.ReadInt32());
240     bool isActive = IsStreamActive(streamType);
241     reply.WriteBool(isActive);
242 }
243 
AdjustVolumeByStepInternal(MessageParcel & data,MessageParcel & reply)244 void AudioPolicyManagerStub::AdjustVolumeByStepInternal(MessageParcel &data, MessageParcel &reply)
245 {
246     VolumeAdjustType adjustType = static_cast<VolumeAdjustType>(data.ReadInt32());
247     int32_t result = AdjustVolumeByStep(adjustType);
248     reply.WriteInt32(result);
249 }
250 
GetSystemVolumeInDbInternal(MessageParcel & data,MessageParcel & reply)251 void AudioPolicyManagerStub::GetSystemVolumeInDbInternal(MessageParcel &data, MessageParcel &reply)
252 {
253     AudioVolumeType volumeType = static_cast<AudioVolumeType>(data.ReadInt32());
254     int32_t volumeLevel = data.ReadInt32();
255     DeviceType deviceType = static_cast<DeviceType>(data.ReadInt32());
256     float result = GetSystemVolumeInDb(volumeType, volumeLevel, deviceType);
257     reply.WriteFloat(result);
258 }
259 
IsVolumeUnadjustableInternal(MessageParcel & data,MessageParcel & reply)260 void AudioPolicyManagerStub::IsVolumeUnadjustableInternal(MessageParcel &data, MessageParcel &reply)
261 {
262     bool isVolumeUnadjustable = IsVolumeUnadjustable();
263     reply.WriteBool(isVolumeUnadjustable);
264 }
265 
AdjustSystemVolumeByStepInternal(MessageParcel & data,MessageParcel & reply)266 void AudioPolicyManagerStub::AdjustSystemVolumeByStepInternal(MessageParcel &data, MessageParcel &reply)
267 {
268     AudioVolumeType volumeType = static_cast<AudioVolumeType>(data.ReadInt32());
269     VolumeAdjustType adjustType = static_cast<VolumeAdjustType>(data.ReadInt32());
270     int32_t result = AdjustSystemVolumeByStep(volumeType, adjustType);
271     reply.WriteInt32(result);
272 }
273 
GetDevicesInternal(MessageParcel & data,MessageParcel & reply)274 void AudioPolicyManagerStub::GetDevicesInternal(MessageParcel &data, MessageParcel &reply)
275 {
276     AUDIO_DEBUG_LOG("GET_DEVICES AudioManagerStub");
277     int deviceFlag = data.ReadInt32();
278     DeviceFlag deviceFlagConfig = static_cast<DeviceFlag>(deviceFlag);
279     std::vector<sptr<AudioDeviceDescriptor>> devices = GetDevices(deviceFlagConfig);
280     int32_t size = static_cast<int32_t>(devices.size());
281     AUDIO_DEBUG_LOG("GET_DEVICES size= %{public}d", size);
282     reply.WriteInt32(size);
283     for (int i = 0; i < size; i++) {
284         devices[i]->Marshalling(reply);
285     }
286 }
287 
SetWakeUpAudioCapturerInternal(MessageParcel & data,MessageParcel & reply)288 void AudioPolicyManagerStub::SetWakeUpAudioCapturerInternal(MessageParcel &data, MessageParcel &reply)
289 {
290     AUDIO_DEBUG_LOG("SetWakeUpAudioCapturerInternal AudioManagerStub");
291     InternalAudioCapturerOptions capturerOptions;
292     capturerOptions.streamInfo.samplingRate = static_cast<AudioSamplingRate>(data.ReadInt32());
293     capturerOptions.streamInfo.encoding = static_cast<AudioEncodingType>(data.ReadInt32());
294     capturerOptions.streamInfo.format = static_cast<AudioSampleFormat>(data.ReadInt32());
295     capturerOptions.streamInfo.channels = static_cast<AudioChannel>(data.ReadInt32());
296     capturerOptions.capturerInfo.sourceType = static_cast<SourceType>(data.ReadInt32());
297     capturerOptions.capturerInfo.capturerFlags = data.ReadInt32();
298     int32_t result = SetWakeUpAudioCapturer(capturerOptions);
299     reply.WriteInt32(result);
300 }
301 
CloseWakeUpAudioCapturerInternal(MessageParcel & data,MessageParcel & reply)302 void AudioPolicyManagerStub::CloseWakeUpAudioCapturerInternal(MessageParcel &data, MessageParcel &reply)
303 {
304     AUDIO_DEBUG_LOG("CloseWakeUpAudioCapturerInternal AudioManagerStub");
305     int32_t result = CloseWakeUpAudioCapturer();
306     reply.WriteInt32(result);
307 }
308 
GetPreferredOutputDeviceDescriptorsInternal(MessageParcel & data,MessageParcel & reply)309 void AudioPolicyManagerStub::GetPreferredOutputDeviceDescriptorsInternal(MessageParcel &data, MessageParcel &reply)
310 {
311     AUDIO_DEBUG_LOG("GET_ACTIVE_OUTPUT_DEVICE_DESCRIPTORS AudioManagerStub");
312     AudioRendererInfo rendererInfo;
313     std::vector<sptr<AudioDeviceDescriptor>> devices = GetPreferredOutputDeviceDescriptors(rendererInfo);
314     int32_t size = static_cast<int32_t>(devices.size());
315     AUDIO_DEBUG_LOG("GET_ACTIVE_OUTPUT_DEVICE_DESCRIPTORS size= %{public}d", size);
316     reply.WriteInt32(size);
317     for (int i = 0; i < size; i++) {
318         devices[i]->Marshalling(reply);
319     }
320 }
321 
GetPreferredInputDeviceDescriptorsInternal(MessageParcel & data,MessageParcel & reply)322 void AudioPolicyManagerStub::GetPreferredInputDeviceDescriptorsInternal(MessageParcel &data, MessageParcel &reply)
323 {
324     AudioCapturerInfo captureInfo;
325     std::vector<sptr<AudioDeviceDescriptor>> devices = GetPreferredInputDeviceDescriptors(captureInfo);
326     size_t size = static_cast<int32_t>(devices.size());
327     AUDIO_DEBUG_LOG("GET_PREFERRED_INTPUT_DEVICE_DESCRIPTORS size= %{public}zu", size);
328     reply.WriteInt32(size);
329     for (size_t i = 0; i < size; i++) {
330         devices[i]->Marshalling(reply);
331     }
332 }
333 
SetDeviceActiveInternal(MessageParcel & data,MessageParcel & reply)334 void AudioPolicyManagerStub::SetDeviceActiveInternal(MessageParcel &data, MessageParcel &reply)
335 {
336     InternalDeviceType deviceType = static_cast<InternalDeviceType>(data.ReadInt32());
337     bool active = data.ReadBool();
338     int32_t result = SetDeviceActive(deviceType, active);
339     if (result == SUCCESS)
340         reply.WriteInt32(AUDIO_OK);
341     else
342         reply.WriteInt32(AUDIO_ERR);
343 }
344 
IsDeviceActiveInternal(MessageParcel & data,MessageParcel & reply)345 void AudioPolicyManagerStub::IsDeviceActiveInternal(MessageParcel &data, MessageParcel &reply)
346 {
347     InternalDeviceType deviceType = static_cast<InternalDeviceType>(data.ReadInt32());
348     bool result = IsDeviceActive(deviceType);
349     reply.WriteBool(result);
350 }
351 
GetActiveOutputDeviceInternal(MessageParcel & data,MessageParcel & reply)352 void AudioPolicyManagerStub::GetActiveOutputDeviceInternal(MessageParcel &data, MessageParcel &reply)
353 {
354     InternalDeviceType deviceType = GetActiveOutputDevice();
355     reply.WriteInt32(static_cast<int>(deviceType));
356 }
357 
GetActiveInputDeviceInternal(MessageParcel & data,MessageParcel & reply)358 void AudioPolicyManagerStub::GetActiveInputDeviceInternal(MessageParcel &data, MessageParcel &reply)
359 {
360     InternalDeviceType deviceType = GetActiveInputDevice();
361     reply.WriteInt32(static_cast<int>(deviceType));
362 }
363 
SetPreferredOutputDeviceChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)364 void AudioPolicyManagerStub::SetPreferredOutputDeviceChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
365 {
366     int32_t clientId = data.ReadInt32();
367     sptr<IRemoteObject> object = data.ReadRemoteObject();
368     if (object == nullptr) {
369         AUDIO_ERR_LOG("AudioPolicyManagerStub: object is null");
370         return;
371     }
372     int32_t result = SetPreferredOutputDeviceChangeCallback(clientId, object);
373     reply.WriteInt32(result);
374 }
375 
SetPreferredInputDeviceChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)376 void AudioPolicyManagerStub::SetPreferredInputDeviceChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
377 {
378     sptr<IRemoteObject> object = data.ReadRemoteObject();
379     if (object == nullptr) {
380         AUDIO_ERR_LOG("object is null");
381         return;
382     }
383     int32_t result = SetPreferredInputDeviceChangeCallback(object);
384     reply.WriteInt32(result);
385 }
386 
UnsetPreferredOutputDeviceChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)387 void AudioPolicyManagerStub::UnsetPreferredOutputDeviceChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
388 {
389     int32_t clientId = data.ReadInt32();
390     int32_t result = UnsetPreferredOutputDeviceChangeCallback(clientId);
391     reply.WriteInt32(result);
392 }
393 
UnsetPreferredInputDeviceChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)394 void AudioPolicyManagerStub::UnsetPreferredInputDeviceChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
395 {
396     int32_t result = UnsetPreferredInputDeviceChangeCallback();
397     reply.WriteInt32(result);
398 }
399 
WriteAudioFocusInfo(MessageParcel & reply,const std::pair<AudioInterrupt,AudioFocuState> & focusInfo)400 void AudioPolicyManagerStub::WriteAudioFocusInfo(MessageParcel &reply,
401     const std::pair<AudioInterrupt, AudioFocuState> &focusInfo)
402 {
403     reply.WriteInt32(focusInfo.first.streamUsage);
404     reply.WriteInt32(focusInfo.first.contentType);
405     reply.WriteInt32(focusInfo.first.audioFocusType.streamType);
406     reply.WriteInt32(focusInfo.first.audioFocusType.sourceType);
407     reply.WriteBool(focusInfo.first.audioFocusType.isPlay);
408     reply.WriteInt32(focusInfo.first.sessionID);
409     reply.WriteBool(focusInfo.first.pauseWhenDucked);
410     reply.WriteInt32(focusInfo.first.mode);
411 
412     reply.WriteInt32(focusInfo.second);
413 }
414 
GetAudioFocusInfoListInternal(MessageParcel & data,MessageParcel & reply)415 void AudioPolicyManagerStub::GetAudioFocusInfoListInternal(MessageParcel &data, MessageParcel &reply)
416 {
417     std::list<std::pair<AudioInterrupt, AudioFocuState>> focusInfoList;
418     int32_t result = GetAudioFocusInfoList(focusInfoList);
419     int32_t size = static_cast<int32_t>(focusInfoList.size());
420     reply.WriteInt32(result);
421     reply.WriteInt32(size);
422     if (result == SUCCESS) {
423         AUDIO_DEBUG_LOG("GetAudioFocusInfoList size= %{public}d", size);
424         for (std::pair<AudioInterrupt, AudioFocuState> focusInfo : focusInfoList) {
425             WriteAudioFocusInfo(reply, focusInfo);
426         }
427     }
428 }
429 
RegisterFocusInfoChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)430 void AudioPolicyManagerStub::RegisterFocusInfoChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
431 {
432     int32_t clientId = data.ReadInt32();
433     sptr<IRemoteObject> object = data.ReadRemoteObject();
434     if (object == nullptr) {
435         AUDIO_ERR_LOG("AudioFocusInfoCallback obj is null");
436         return;
437     }
438     int32_t result = RegisterFocusInfoChangeCallback(clientId, object);
439     reply.WriteInt32(result);
440 }
441 
UnregisterFocusInfoChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)442 void AudioPolicyManagerStub::UnregisterFocusInfoChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
443 {
444     int32_t clientId = data.ReadInt32();
445     int32_t result = UnregisterFocusInfoChangeCallback(clientId);
446     reply.WriteInt32(result);
447 }
448 
SetRingerModeCallbackInternal(MessageParcel & data,MessageParcel & reply)449 void AudioPolicyManagerStub::SetRingerModeCallbackInternal(MessageParcel &data, MessageParcel &reply)
450 {
451     int32_t clientId = data.ReadInt32();
452     sptr<IRemoteObject> object = data.ReadRemoteObject();
453     API_VERSION api_v = static_cast<API_VERSION>(data.ReadInt32());
454     if (object == nullptr) {
455         AUDIO_ERR_LOG("AudioPolicyManagerStub: SetRingerModeCallback obj is null");
456         return;
457     }
458     int32_t result = SetRingerModeCallback(clientId, object, api_v);
459     reply.WriteInt32(result);
460 }
461 
SetMicStateChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)462 void AudioPolicyManagerStub::SetMicStateChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
463 {
464     int32_t clientId = data.ReadInt32();
465     sptr<IRemoteObject> object = data.ReadRemoteObject();
466     if (object == nullptr) {
467         AUDIO_ERR_LOG("AudioPolicyManagerStub: AudioInterruptCallback obj is null");
468         return;
469     }
470     int32_t result = SetMicStateChangeCallback(clientId, object);
471     reply.WriteInt32(result);
472 }
473 
UnsetRingerModeCallbackInternal(MessageParcel & data,MessageParcel & reply)474 void AudioPolicyManagerStub::UnsetRingerModeCallbackInternal(MessageParcel &data, MessageParcel &reply)
475 {
476     int32_t clientId = data.ReadInt32();
477     int32_t result = UnsetRingerModeCallback(clientId);
478     reply.WriteInt32(result);
479 }
480 
SelectOutputDeviceInternal(MessageParcel & data,MessageParcel & reply)481 void AudioPolicyManagerStub::SelectOutputDeviceInternal(MessageParcel &data, MessageParcel &reply)
482 {
483     sptr<AudioRendererFilter> audioRendererFilter = AudioRendererFilter::Unmarshalling(data);
484     if (audioRendererFilter == nullptr) {
485         AUDIO_ERR_LOG("AudioRendererFilter unmarshall fail.");
486         return;
487     }
488 
489     int validSize = 20; // Use 20 as limit.
490     int size = data.ReadInt32();
491     if (size <= 0 || size > validSize) {
492         AUDIO_ERR_LOG("SelectOutputDevice get invalid device size.");
493         return;
494     }
495     std::vector<sptr<AudioDeviceDescriptor>> targetOutputDevice;
496     for (int i = 0; i < size; i++) {
497         sptr<AudioDeviceDescriptor> audioDeviceDescriptor = AudioDeviceDescriptor::Unmarshalling(data);
498         if (audioDeviceDescriptor == nullptr) {
499             AUDIO_ERR_LOG("Unmarshalling fail.");
500             return;
501         }
502         targetOutputDevice.push_back(audioDeviceDescriptor);
503     }
504 
505     int32_t ret = SelectOutputDevice(audioRendererFilter, targetOutputDevice);
506     reply.WriteInt32(ret);
507 }
508 
GetSelectedDeviceInfoInternal(MessageParcel & data,MessageParcel & reply)509 void AudioPolicyManagerStub::GetSelectedDeviceInfoInternal(MessageParcel &data, MessageParcel &reply)
510 {
511     int32_t uid = data.ReadInt32();
512     int32_t pid = data.ReadInt32();
513     AudioStreamType streamType =  static_cast<AudioStreamType>(data.ReadInt32());
514 
515     std::string deviceName = GetSelectedDeviceInfo(uid, pid, streamType);
516     reply.WriteString(deviceName);
517 }
518 
SelectInputDeviceInternal(MessageParcel & data,MessageParcel & reply)519 void AudioPolicyManagerStub::SelectInputDeviceInternal(MessageParcel &data, MessageParcel &reply)
520 {
521     sptr<AudioCapturerFilter> audioCapturerFilter = AudioCapturerFilter::Unmarshalling(data);
522     if (audioCapturerFilter == nullptr) {
523         AUDIO_ERR_LOG("AudioCapturerFilter unmarshall fail.");
524         return;
525     }
526 
527     int validSize = 10; // Use 10 as limit.
528     int size = data.ReadInt32();
529     if (size <= 0 || size > validSize) {
530         AUDIO_ERR_LOG("SelectInputDevice get invalid device size.");
531         return;
532     }
533     std::vector<sptr<AudioDeviceDescriptor>> targetInputDevice;
534     for (int i = 0; i < size; i++) {
535         sptr<AudioDeviceDescriptor> audioDeviceDescriptor = AudioDeviceDescriptor::Unmarshalling(data);
536         if (audioDeviceDescriptor == nullptr) {
537             AUDIO_ERR_LOG("Unmarshalling fail.");
538             return;
539         }
540         targetInputDevice.push_back(audioDeviceDescriptor);
541     }
542 
543     int32_t ret = SelectInputDevice(audioCapturerFilter, targetInputDevice);
544     reply.WriteInt32(ret);
545 }
546 
SetDeviceChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)547 void AudioPolicyManagerStub::SetDeviceChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
548 {
549     int32_t clientId = data.ReadInt32();
550     DeviceFlag flag = static_cast<DeviceFlag>(data.ReadInt32());
551     sptr<IRemoteObject> object = data.ReadRemoteObject();
552     if (object == nullptr) {
553         AUDIO_ERR_LOG("AudioPolicyManagerStub: AudioInterruptCallback obj is null");
554         return;
555     }
556     int32_t result = SetDeviceChangeCallback(clientId, flag, object);
557     reply.WriteInt32(result);
558 }
559 
UnsetDeviceChangeCallbackInternal(MessageParcel & data,MessageParcel & reply)560 void AudioPolicyManagerStub::UnsetDeviceChangeCallbackInternal(MessageParcel &data, MessageParcel &reply)
561 {
562     int32_t clientId = data.ReadInt32();
563     DeviceFlag flag = static_cast<DeviceFlag>(data.ReadInt32());
564     int32_t result = UnsetDeviceChangeCallback(clientId, flag);
565     reply.WriteInt32(result);
566 }
567 
SetInterruptCallbackInternal(MessageParcel & data,MessageParcel & reply)568 void AudioPolicyManagerStub::SetInterruptCallbackInternal(MessageParcel &data, MessageParcel &reply)
569 {
570     uint32_t sessionID = data.ReadUint32();
571     sptr<IRemoteObject> object = data.ReadRemoteObject();
572     if (object == nullptr) {
573         AUDIO_ERR_LOG("AudioPolicyManagerStub: AudioInterruptCallback obj is null");
574         return;
575     }
576     int32_t result = SetAudioInterruptCallback(sessionID, object);
577     reply.WriteInt32(result);
578 }
579 
UnsetInterruptCallbackInternal(MessageParcel & data,MessageParcel & reply)580 void AudioPolicyManagerStub::UnsetInterruptCallbackInternal(MessageParcel &data, MessageParcel &reply)
581 {
582     uint32_t sessionID = data.ReadUint32();
583     int32_t result = UnsetAudioInterruptCallback(sessionID);
584     reply.WriteInt32(result);
585 }
586 
ActivateInterruptInternal(MessageParcel & data,MessageParcel & reply)587 void AudioPolicyManagerStub::ActivateInterruptInternal(MessageParcel &data, MessageParcel &reply)
588 {
589     AudioInterrupt audioInterrupt = {};
590     ReadAudioInterruptParams(data, audioInterrupt);
591     int32_t result = ActivateAudioInterrupt(audioInterrupt);
592     reply.WriteInt32(result);
593 }
594 
DeactivateInterruptInternal(MessageParcel & data,MessageParcel & reply)595 void AudioPolicyManagerStub::DeactivateInterruptInternal(MessageParcel &data, MessageParcel &reply)
596 {
597     AudioInterrupt audioInterrupt = {};
598     ReadAudioInterruptParams(data, audioInterrupt);
599     int32_t result = DeactivateAudioInterrupt(audioInterrupt);
600     reply.WriteInt32(result);
601 }
602 
SetAudioManagerInterruptCbInternal(MessageParcel & data,MessageParcel & reply)603 void AudioPolicyManagerStub::SetAudioManagerInterruptCbInternal(MessageParcel &data, MessageParcel &reply)
604 {
605     int32_t clientId = data.ReadInt32();
606     sptr<IRemoteObject> object = data.ReadRemoteObject();
607     if (object == nullptr) {
608         AUDIO_ERR_LOG("AudioPolicyManagerStub: AudioInterruptCallback obj is null");
609         return;
610     }
611     int32_t result = SetAudioManagerInterruptCallback(clientId, object);
612     reply.WriteInt32(result);
613 }
614 
UnsetAudioManagerInterruptCbInternal(MessageParcel & data,MessageParcel & reply)615 void AudioPolicyManagerStub::UnsetAudioManagerInterruptCbInternal(MessageParcel &data, MessageParcel &reply)
616 {
617     int32_t clientId = data.ReadInt32();
618     int32_t result = UnsetAudioManagerInterruptCallback(clientId);
619     reply.WriteInt32(result);
620 }
621 
RequestAudioFocusInternal(MessageParcel & data,MessageParcel & reply)622 void AudioPolicyManagerStub::RequestAudioFocusInternal(MessageParcel &data, MessageParcel &reply)
623 {
624     AudioInterrupt audioInterrupt = {};
625     int32_t clientId = data.ReadInt32();
626     ReadAudioManagerInterruptParams(data, audioInterrupt);
627     int32_t result = RequestAudioFocus(clientId, audioInterrupt);
628     reply.WriteInt32(result);
629 }
630 
AbandonAudioFocusInternal(MessageParcel & data,MessageParcel & reply)631 void AudioPolicyManagerStub::AbandonAudioFocusInternal(MessageParcel &data, MessageParcel &reply)
632 {
633     AudioInterrupt audioInterrupt = {};
634     int32_t clientId = data.ReadInt32();
635     ReadAudioManagerInterruptParams(data, audioInterrupt);
636     int32_t result = AbandonAudioFocus(clientId, audioInterrupt);
637     reply.WriteInt32(result);
638 }
639 
GetStreamInFocusInternal(MessageParcel & reply)640 void AudioPolicyManagerStub::GetStreamInFocusInternal(MessageParcel &reply)
641 {
642     AudioStreamType streamInFocus = GetStreamInFocus();
643     reply.WriteInt32(static_cast<int32_t>(streamInFocus));
644 }
645 
GetSessionInfoInFocusInternal(MessageParcel & reply)646 void AudioPolicyManagerStub::GetSessionInfoInFocusInternal(MessageParcel &reply)
647 {
648     uint32_t invalidSessionID = static_cast<uint32_t>(-1);
649     AudioInterrupt audioInterrupt {STREAM_USAGE_UNKNOWN, CONTENT_TYPE_UNKNOWN,
650         {AudioStreamType::STREAM_DEFAULT, SourceType::SOURCE_TYPE_INVALID, true}, invalidSessionID};
651     int32_t ret = GetSessionInfoInFocus(audioInterrupt);
652     WriteAudioInteruptParams(reply, audioInterrupt);
653     reply.WriteInt32(ret);
654 }
655 
SetVolumeKeyEventCallbackInternal(MessageParcel & data,MessageParcel & reply)656 void AudioPolicyManagerStub::SetVolumeKeyEventCallbackInternal(MessageParcel &data, MessageParcel &reply)
657 {
658     int32_t clientPid =  data.ReadInt32();
659     sptr<IRemoteObject> remoteObject = data.ReadRemoteObject();
660     API_VERSION api_v = static_cast<API_VERSION>(data.ReadInt32());
661     if (remoteObject == nullptr) {
662         AUDIO_ERR_LOG("AudioPolicyManagerStub: AudioManagerCallback obj is null");
663         return;
664     }
665     int ret = SetVolumeKeyEventCallback(clientPid, remoteObject, api_v);
666     reply.WriteInt32(ret);
667 }
668 
UnsetVolumeKeyEventCallbackInternal(MessageParcel & data,MessageParcel & reply)669 void AudioPolicyManagerStub::UnsetVolumeKeyEventCallbackInternal(MessageParcel &data, MessageParcel &reply)
670 {
671     int32_t clientPid = data.ReadInt32();
672     int ret = UnsetVolumeKeyEventCallback(clientPid);
673     reply.WriteInt32(ret);
674 }
675 
CheckRecordingCreateInternal(MessageParcel & data,MessageParcel & reply)676 void AudioPolicyManagerStub::CheckRecordingCreateInternal(MessageParcel &data, MessageParcel &reply)
677 {
678     uint32_t appTokenId = data.ReadUint32();
679     uint64_t appFullTokenId = data.ReadUint64();
680     uint32_t appUid = data.ReadInt32();
681     bool ret = CheckRecordingCreate(appTokenId, appFullTokenId, appUid);
682     reply.WriteBool(ret);
683 }
684 
CheckRecordingStateChangeInternal(MessageParcel & data,MessageParcel & reply)685 void AudioPolicyManagerStub::CheckRecordingStateChangeInternal(MessageParcel &data, MessageParcel &reply)
686 {
687     uint32_t appTokenId = data.ReadUint32();
688     uint64_t appFullTokenId = data.ReadUint64();
689     int32_t appUid = data.ReadInt32();
690     AudioPermissionState state = static_cast<AudioPermissionState>(data.ReadInt32());
691     bool ret = CheckRecordingStateChange(appTokenId, appFullTokenId, appUid, state);
692     reply.WriteBool(ret);
693 }
694 
GetAudioLatencyFromXmlInternal(MessageParcel & data,MessageParcel & reply)695 void AudioPolicyManagerStub::GetAudioLatencyFromXmlInternal(MessageParcel &data, MessageParcel &reply)
696 {
697     int ret = GetAudioLatencyFromXml();
698     reply.WriteInt32(ret);
699 }
700 
GetSinkLatencyFromXmlInternal(MessageParcel & data,MessageParcel & reply)701 void AudioPolicyManagerStub::GetSinkLatencyFromXmlInternal(MessageParcel &data, MessageParcel &reply)
702 {
703     uint32_t ret = GetSinkLatencyFromXml();
704     reply.WriteUint32(ret);
705 }
706 
ReconfigureAudioChannelInternal(MessageParcel & data,MessageParcel & reply)707 void AudioPolicyManagerStub::ReconfigureAudioChannelInternal(MessageParcel &data, MessageParcel &reply)
708 {
709     uint32_t count = data.ReadUint32();
710     DeviceType deviceType = static_cast<DeviceType>(data.ReadInt32());
711     int32_t ret = ReconfigureAudioChannel(count, deviceType);
712     reply.WriteInt32(ret);
713 }
714 
RegisterAudioRendererEventListenerInternal(MessageParcel & data,MessageParcel & reply)715 void AudioPolicyManagerStub::RegisterAudioRendererEventListenerInternal(MessageParcel &data, MessageParcel &reply)
716 {
717     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:register event listener entered");
718     int32_t clientUid =  data.ReadInt32();
719     sptr<IRemoteObject> remoteObject = data.ReadRemoteObject();
720     if (remoteObject == nullptr) {
721         AUDIO_ERR_LOG("AudioPolicyManagerStub: AudioRendererStateCallback obj is null");
722         return;
723     }
724     int ret = RegisterAudioRendererEventListener(clientUid, remoteObject);
725     reply.WriteInt32(ret);
726     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:register event listener exit");
727 }
728 
UnregisterAudioRendererEventListenerInternal(MessageParcel & data,MessageParcel & reply)729 void AudioPolicyManagerStub::UnregisterAudioRendererEventListenerInternal(MessageParcel &data, MessageParcel &reply)
730 {
731     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:unregister event listener entered");
732     int32_t clientUid = data.ReadInt32();
733     int ret = UnregisterAudioRendererEventListener(clientUid);
734     reply.WriteInt32(ret);
735     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:unregister event listener exit");
736 }
737 
RegisterAudioCapturerEventListenerInternal(MessageParcel & data,MessageParcel & reply)738 void AudioPolicyManagerStub::RegisterAudioCapturerEventListenerInternal(MessageParcel &data, MessageParcel &reply)
739 {
740     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:cap register event listener entered");
741     int32_t clientUid =  data.ReadInt32();
742     sptr<IRemoteObject> remoteObject = data.ReadRemoteObject();
743     if (remoteObject == nullptr) {
744         AUDIO_ERR_LOG("AudioPolicyManagerStub: AudioCapturerStateCallback obj is null");
745         return;
746     }
747     int ret = RegisterAudioCapturerEventListener(clientUid, remoteObject);
748     reply.WriteInt32(ret);
749     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:cap register event listener exit");
750 }
751 
UnregisterAudioCapturerEventListenerInternal(MessageParcel & data,MessageParcel & reply)752 void AudioPolicyManagerStub::UnregisterAudioCapturerEventListenerInternal(MessageParcel &data, MessageParcel &reply)
753 {
754     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:cap unnregister event listener entered");
755     int32_t clientUid = data.ReadInt32();
756     int ret = UnregisterAudioCapturerEventListener(clientUid);
757     reply.WriteInt32(ret);
758     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:cap unregister event listener exit");
759 }
760 
RegisterTrackerInternal(MessageParcel & data,MessageParcel & reply)761 void AudioPolicyManagerStub::RegisterTrackerInternal(MessageParcel &data, MessageParcel &reply)
762 {
763     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:register tracker internal entered");
764 
765     AudioStreamChangeInfo streamChangeInfo = {};
766     AudioMode mode = static_cast<AudioMode> (data.ReadInt32());
767     ReadStreamChangeInfo(data, mode, streamChangeInfo);
768     sptr<IRemoteObject> remoteObject = data.ReadRemoteObject();
769     if (remoteObject == nullptr) {
770         AUDIO_ERR_LOG("AudioPolicyManagerStub: Client Tracker obj is null");
771         return;
772     }
773 
774     int ret = RegisterTracker(mode, streamChangeInfo, remoteObject);
775     reply.WriteInt32(ret);
776     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:register tracker internal ret = %{public}d", ret);
777 }
778 
UpdateTrackerInternal(MessageParcel & data,MessageParcel & reply)779 void AudioPolicyManagerStub::UpdateTrackerInternal(MessageParcel &data, MessageParcel &reply)
780 {
781     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:update tracker internal entered");
782 
783     AudioStreamChangeInfo streamChangeInfo = {};
784     AudioMode mode = static_cast<AudioMode> (data.ReadInt32());
785     ReadStreamChangeInfo(data, mode, streamChangeInfo);
786     int ret = UpdateTracker(mode, streamChangeInfo);
787     reply.WriteInt32(ret);
788     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:update tracker internal ret = %{public}d", ret);
789 }
790 
GetRendererChangeInfosInternal(MessageParcel & data,MessageParcel & reply)791 void AudioPolicyManagerStub::GetRendererChangeInfosInternal(MessageParcel &data, MessageParcel &reply)
792 {
793     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:Renderer change info internal entered");
794 
795     size_t size = 0;
796     vector<unique_ptr<AudioRendererChangeInfo>> audioRendererChangeInfos;
797     int ret = GetCurrentRendererChangeInfos(audioRendererChangeInfos);
798     if (ret != SUCCESS) {
799         AUDIO_ERR_LOG("AudioPolicyManagerStub:GetRendererChangeInfos Error!!");
800         reply.WriteInt32(size);
801         return;
802     }
803 
804     size = audioRendererChangeInfos.size();
805     reply.WriteInt32(size);
806     for (const unique_ptr<AudioRendererChangeInfo> &rendererChangeInfo: audioRendererChangeInfos) {
807         if (!rendererChangeInfo) {
808             AUDIO_ERR_LOG("AudioPolicyManagerStub:Renderer change info null, something wrong!!");
809             continue;
810         }
811         reply.WriteInt32(rendererChangeInfo->sessionId);
812         reply.WriteInt32(rendererChangeInfo->rendererState);
813         reply.WriteInt32(rendererChangeInfo->clientUID);
814         reply.WriteInt32(rendererChangeInfo->tokenId);
815 
816         reply.WriteInt32(rendererChangeInfo->rendererInfo.contentType);
817         reply.WriteInt32(rendererChangeInfo->rendererInfo.streamUsage);
818         reply.WriteInt32(rendererChangeInfo->rendererInfo.rendererFlags);
819 
820         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.deviceType);
821         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.deviceRole);
822         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.deviceId);
823         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.channelMasks);
824         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.audioStreamInfo.samplingRate);
825         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.audioStreamInfo.encoding);
826         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.audioStreamInfo.format);
827         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.audioStreamInfo.channels);
828         reply.WriteString(rendererChangeInfo->outputDeviceInfo.deviceName);
829         reply.WriteString(rendererChangeInfo->outputDeviceInfo.macAddress);
830         reply.WriteString(rendererChangeInfo->outputDeviceInfo.displayName);
831         reply.WriteString(rendererChangeInfo->outputDeviceInfo.networkId);
832         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.interruptGroupId);
833         reply.WriteInt32(rendererChangeInfo->outputDeviceInfo.volumeGroupId);
834         reply.WriteBool(rendererChangeInfo->outputDeviceInfo.isLowLatencyDevice);
835     }
836 
837     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:Renderer change info internal exit");
838 }
839 
GetCapturerChangeInfosInternal(MessageParcel & data,MessageParcel & reply)840 void AudioPolicyManagerStub::GetCapturerChangeInfosInternal(MessageParcel &data, MessageParcel &reply)
841 {
842     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:Capturer change info internal entered");
843     size_t size = 0;
844     vector<unique_ptr<AudioCapturerChangeInfo>> audioCapturerChangeInfos;
845     int32_t ret = GetCurrentCapturerChangeInfos(audioCapturerChangeInfos);
846     if (ret != SUCCESS) {
847         AUDIO_ERR_LOG("AudioPolicyManagerStub:GetCapturerChangeInfos Error!!");
848         reply.WriteInt32(size);
849         return;
850     }
851 
852     size = audioCapturerChangeInfos.size();
853     reply.WriteInt32(size);
854     for (const unique_ptr<AudioCapturerChangeInfo> &capturerChangeInfo: audioCapturerChangeInfos) {
855         if (!capturerChangeInfo) {
856             AUDIO_ERR_LOG("AudioPolicyManagerStub:Capturer change info null, something wrong!!");
857             continue;
858         }
859         reply.WriteInt32(capturerChangeInfo->sessionId);
860         reply.WriteInt32(capturerChangeInfo->capturerState);
861         reply.WriteInt32(capturerChangeInfo->clientUID);
862         reply.WriteInt32(capturerChangeInfo->capturerInfo.sourceType);
863         reply.WriteInt32(capturerChangeInfo->capturerInfo.capturerFlags);
864 
865         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.deviceType);
866         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.deviceRole);
867         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.deviceId);
868         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.channelMasks);
869         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.audioStreamInfo.samplingRate);
870         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.audioStreamInfo.encoding);
871         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.audioStreamInfo.format);
872         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.audioStreamInfo.channels);
873         reply.WriteString(capturerChangeInfo->inputDeviceInfo.deviceName);
874         reply.WriteString(capturerChangeInfo->inputDeviceInfo.macAddress);
875         reply.WriteString(capturerChangeInfo->inputDeviceInfo.displayName);
876         reply.WriteString(capturerChangeInfo->inputDeviceInfo.networkId);
877         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.interruptGroupId);
878         reply.WriteInt32(capturerChangeInfo->inputDeviceInfo.volumeGroupId);
879         reply.WriteBool(capturerChangeInfo->inputDeviceInfo.isLowLatencyDevice);
880     }
881     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:Capturer change info internal exit");
882 }
883 
UpdateStreamStateInternal(MessageParcel & data,MessageParcel & reply)884 void AudioPolicyManagerStub::UpdateStreamStateInternal(MessageParcel &data, MessageParcel &reply)
885 {
886     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:UpdateStreamStateInternal change info internal entered");
887     int32_t clientUid = data.ReadInt32();
888     StreamSetState streamSetState = static_cast<StreamSetState>(data.ReadInt32());
889     AudioStreamType streamType = static_cast<AudioStreamType>(data.ReadInt32());
890 
891     int32_t result = UpdateStreamState(clientUid, streamSetState, streamType);
892     reply.WriteInt32(result);
893     AUDIO_DEBUG_LOG("AudioPolicyManagerStub:UpdateStreamStateInternal change info internal exit");
894 }
895 
GetVolumeGroupInfoInternal(MessageParcel & data,MessageParcel & reply)896 void AudioPolicyManagerStub::GetVolumeGroupInfoInternal(MessageParcel& data, MessageParcel& reply)
897 {
898     AUDIO_DEBUG_LOG("GetVolumeGroupInfoInternal entered");
899     std::string networkId = data.ReadString();
900     std::vector<sptr<VolumeGroupInfo>> groupInfos;
901     int32_t ret = GetVolumeGroupInfos(networkId, groupInfos);
902     int32_t size = static_cast<int32_t>(groupInfos.size());
903     AUDIO_DEBUG_LOG("GET_DEVICES size= %{public}d", size);
904 
905     if (ret == SUCCESS && size > 0) {
906         reply.WriteInt32(size);
907         for (int i = 0; i < size; i++) {
908             groupInfos[i]->Marshalling(reply);
909         }
910     } else {
911         reply.WriteInt32(ret);
912     }
913 
914     AUDIO_DEBUG_LOG("GetVolumeGroups internal exit");
915 }
916 
GetNetworkIdByGroupIdInternal(MessageParcel & data,MessageParcel & reply)917 void AudioPolicyManagerStub::GetNetworkIdByGroupIdInternal(MessageParcel& data, MessageParcel& reply)
918 {
919     AUDIO_DEBUG_LOG("GetNetworkIdByGroupId entered");
920     int32_t groupId = data.ReadInt32();
921     std::string networkId;
922     int32_t ret = GetNetworkIdByGroupId(groupId, networkId);
923 
924     reply.WriteString(networkId);
925     reply.WriteInt32(ret);
926 }
927 
IsAudioRendererLowLatencySupportedInternal(MessageParcel & data,MessageParcel & reply)928 void AudioPolicyManagerStub::IsAudioRendererLowLatencySupportedInternal(MessageParcel &data, MessageParcel &reply)
929 {
930     AudioStreamInfo audioStreamInfo = {};
931     audioStreamInfo.samplingRate = static_cast<AudioSamplingRate>(data.ReadInt32());
932     audioStreamInfo.channels = static_cast<AudioChannel>(data.ReadInt32());
933     audioStreamInfo.format = static_cast<OHOS::AudioStandard::AudioSampleFormat>(data.ReadInt32());
934     audioStreamInfo.encoding = static_cast<AudioEncodingType>(data.ReadInt32());
935     bool isSupported = IsAudioRendererLowLatencySupported(audioStreamInfo);
936     reply.WriteBool(isSupported);
937 }
938 
SetSystemSoundUriInternal(MessageParcel & data,MessageParcel & reply)939 void AudioPolicyManagerStub::SetSystemSoundUriInternal(MessageParcel &data, MessageParcel &reply)
940 {
941     std::string key = data.ReadString();
942     std::string value = data.ReadString();
943     int32_t result =  SetSystemSoundUri(key, value);
944     reply.WriteInt32(result);
945 }
946 
GetSystemSoundUriInternal(MessageParcel & data,MessageParcel & reply)947 void AudioPolicyManagerStub::GetSystemSoundUriInternal(MessageParcel &data, MessageParcel &reply)
948 {
949     std::string key = data.ReadString();
950     std::string result = GetSystemSoundUri(key);
951     reply.WriteString(result);
952 }
953 
GetMinStreamVolumeInternal(MessageParcel & data,MessageParcel & reply)954 void AudioPolicyManagerStub::GetMinStreamVolumeInternal(MessageParcel &data, MessageParcel &reply)
955 {
956     float volume = GetMinStreamVolume();
957     reply.WriteFloat(volume);
958 }
959 
GetMaxStreamVolumeInternal(MessageParcel & data,MessageParcel & reply)960 void AudioPolicyManagerStub::GetMaxStreamVolumeInternal(MessageParcel &data, MessageParcel &reply)
961 {
962     float volume = GetMaxStreamVolume();
963     reply.WriteFloat(volume);
964 }
965 
GetMaxRendererInstancesInternal(MessageParcel & data,MessageParcel & reply)966 void AudioPolicyManagerStub::GetMaxRendererInstancesInternal(MessageParcel &data, MessageParcel &reply)
967 {
968     int32_t result =  GetMaxRendererInstances();
969     reply.WriteInt32(result);
970 }
971 
PreprocessMode(SupportedEffectConfig & supportedEffectConfig,MessageParcel & reply,int32_t i,int32_t j)972 static void PreprocessMode(SupportedEffectConfig &supportedEffectConfig, MessageParcel &reply, int32_t i, int32_t j)
973 {
974     reply.WriteString(supportedEffectConfig.preProcessNew.stream[i].streamEffectMode[j].mode);
975     int32_t countDev = supportedEffectConfig.preProcessNew.stream[i].streamEffectMode[j].devicePort.size();
976     reply.WriteInt32(countDev);
977     if (countDev > 0) {
978         for (int32_t k = 0; k < countDev; k++) {
979             reply.WriteString(supportedEffectConfig.preProcessNew.stream[i].streamEffectMode[j].devicePort[k].type);
980             reply.WriteString(supportedEffectConfig.preProcessNew.stream[i].streamEffectMode[j].devicePort[k].chain);
981         }
982     }
983 }
PreprocessProcess(SupportedEffectConfig & supportedEffectConfig,MessageParcel & reply,int32_t i)984 static void PreprocessProcess(SupportedEffectConfig &supportedEffectConfig, MessageParcel &reply, int32_t i)
985 {
986     reply.WriteString(supportedEffectConfig.preProcessNew.stream[i].scene);
987     int32_t countMode = supportedEffectConfig.preProcessNew.stream[i].streamEffectMode.size();
988     reply.WriteInt32(countMode);
989     if (countMode > 0) {
990         for (int32_t j = 0; j < countMode; j++) {
991             PreprocessMode(supportedEffectConfig, reply, i, j);
992         }
993     }
994 }
PostprocessMode(SupportedEffectConfig & supportedEffectConfig,MessageParcel & reply,int32_t i,int32_t j)995 static void PostprocessMode(SupportedEffectConfig &supportedEffectConfig, MessageParcel &reply, int32_t i, int32_t j)
996 {
997     reply.WriteString(supportedEffectConfig.postProcessNew.stream[i].streamEffectMode[j].mode);
998     int32_t countDev = supportedEffectConfig.postProcessNew.stream[i].streamEffectMode[j].devicePort.size();
999     reply.WriteInt32(countDev);
1000     if (countDev > 0) {
1001         for (int32_t k = 0; k < countDev; k++) {
1002             reply.WriteString(supportedEffectConfig.postProcessNew.stream[i].streamEffectMode[j].devicePort[k].type);
1003             reply.WriteString(supportedEffectConfig.postProcessNew.stream[i].streamEffectMode[j].devicePort[k].chain);
1004         }
1005     }
1006 }
PostprocessProcess(SupportedEffectConfig & supportedEffectConfig,MessageParcel & reply,int32_t i)1007 static void PostprocessProcess(SupportedEffectConfig &supportedEffectConfig, MessageParcel &reply, int32_t i)
1008 {
1009     // i th stream
1010     reply.WriteString(supportedEffectConfig.postProcessNew.stream[i].scene);
1011     int countMode = supportedEffectConfig.postProcessNew.stream[i].streamEffectMode.size();
1012     reply.WriteInt32(countMode);
1013     if (countMode > 0) {
1014         for (int32_t j = 0; j < countMode; j++) {
1015             PostprocessMode(supportedEffectConfig, reply, i, j);
1016         }
1017     }
1018 }
1019 
QueryEffectSceneModeInternal(MessageParcel & data,MessageParcel & reply)1020 void AudioPolicyManagerStub::QueryEffectSceneModeInternal(MessageParcel &data, MessageParcel &reply)
1021 {
1022     int32_t i;
1023     SupportedEffectConfig supportedEffectConfig;
1024     int32_t ret = QueryEffectSceneMode(supportedEffectConfig); // audio_policy_server.cpp
1025     if (ret == -1) {
1026         AUDIO_ERR_LOG("default mode is unavailable !");
1027         return;
1028     }
1029 
1030     int32_t countPre = supportedEffectConfig.preProcessNew.stream.size();
1031     int32_t countPost = supportedEffectConfig.postProcessNew.stream.size();
1032     reply.WriteInt32(countPre);
1033     reply.WriteInt32(countPost);
1034 
1035     if (countPre > 0) {
1036         for (i = 0; i < countPre; i++) {
1037             PreprocessProcess(supportedEffectConfig, reply, i);
1038         }
1039     }
1040     if (countPost > 0) {
1041         for (i = 0; i < countPost; i++) {
1042             PostprocessProcess(supportedEffectConfig, reply, i);
1043         }
1044     }
1045 }
1046 
SetPlaybackCapturerFilterInfosInternal(MessageParcel & data,MessageParcel & reply)1047 void AudioPolicyManagerStub::SetPlaybackCapturerFilterInfosInternal(MessageParcel &data, MessageParcel &reply)
1048 {
1049     uint32_t maxUsageNum = 30;
1050     AudioPlaybackCaptureConfig config;
1051     int32_t flag = data.ReadInt32();
1052     if (flag == 1) {
1053         config.silentCapture = true;
1054     }
1055     uint32_t ss = data.ReadUint32();
1056     if (ss >= maxUsageNum) {
1057         reply.WriteInt32(ERROR);
1058         return;
1059     }
1060     for (int32_t i = 0; i < ss; i++) {
1061         int32_t tmp_usage = data.ReadInt32();
1062         if (std::find(AUDIO_SUPPORTED_STREAM_USAGES.begin(), AUDIO_SUPPORTED_STREAM_USAGES.end(), tmp_usage) ==
1063             AUDIO_SUPPORTED_STREAM_USAGES.end()) {
1064             continue;
1065         }
1066         config.filterOptions.usages.push_back(static_cast<StreamUsage>(tmp_usage));
1067     }
1068     uint32_t appTokenId = data.ReadUint32();
1069 
1070     int32_t ret = SetPlaybackCapturerFilterInfos(config, appTokenId);
1071     reply.WriteInt32(ret);
1072 }
1073 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)1074 int AudioPolicyManagerStub::OnRemoteRequest(
1075     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
1076 {
1077     if (data.ReadInterfaceToken() != GetDescriptor()) {
1078         AUDIO_ERR_LOG("OnRemoteRequest: ReadInterfaceToken failed");
1079         return -1;
1080     }
1081     switch (code) {
1082         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_MAX_VOLUMELEVEL):
1083             GetMaxVolumeLevelInternal(data, reply);
1084             break;
1085 
1086         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_MIN_VOLUMELEVEL):
1087             GetMinVolumeLevelInternal(data, reply);
1088             break;
1089 
1090         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_SYSTEM_VOLUMELEVEL):
1091             SetSystemVolumeLevelInternal(data, reply);
1092             break;
1093 
1094         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_RINGER_MODE):
1095             SetRingerModeInternal(data, reply);
1096             break;
1097 
1098         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_RINGER_MODE):
1099             GetRingerModeInternal(reply);
1100             break;
1101 
1102         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_AUDIO_SCENE):
1103             SetAudioSceneInternal(data, reply);
1104             break;
1105 
1106         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_AUDIO_SCENE):
1107             GetAudioSceneInternal(reply);
1108             break;
1109 
1110         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_MICROPHONE_MUTE):
1111             SetMicrophoneMuteInternal(data, reply);
1112             break;
1113 
1114         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_MICROPHONE_MUTE_AUDIO_CONFIG):
1115             SetMicrophoneMuteAudioConfigInternal(data, reply);
1116             break;
1117 
1118         case static_cast<uint32_t>(AudioPolicyInterfaceCode::IS_MICROPHONE_MUTE):
1119             IsMicrophoneMuteInternal(data, reply);
1120             break;
1121 
1122         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_SYSTEM_VOLUMELEVEL):
1123             GetSystemVolumeLevelInternal(data, reply);
1124             break;
1125 
1126         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_STREAM_MUTE):
1127             SetStreamMuteInternal(data, reply);
1128             break;
1129 
1130         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_STREAM_MUTE):
1131             GetStreamMuteInternal(data, reply);
1132             break;
1133 
1134         case static_cast<uint32_t>(AudioPolicyInterfaceCode::IS_STREAM_ACTIVE):
1135             IsStreamActiveInternal(data, reply);
1136             break;
1137 
1138         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_DEVICE_ACTIVE):
1139             SetDeviceActiveInternal(data, reply);
1140             break;
1141 
1142         case static_cast<uint32_t>(AudioPolicyInterfaceCode::IS_DEVICE_ACTIVE):
1143             IsDeviceActiveInternal(data, reply);
1144             break;
1145 
1146         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_ACTIVE_OUTPUT_DEVICE):
1147             GetActiveOutputDeviceInternal(data, reply);
1148             break;
1149 
1150         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_ACTIVE_INPUT_DEVICE):
1151             GetActiveInputDeviceInternal(data, reply);
1152             break;
1153 
1154         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_RINGERMODE_CALLBACK):
1155             SetRingerModeCallbackInternal(data, reply);
1156             break;
1157 
1158         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNSET_RINGERMODE_CALLBACK):
1159             UnsetRingerModeCallbackInternal(data, reply);
1160             break;
1161 
1162         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_MIC_STATE_CHANGE_CALLBACK):
1163             SetMicStateChangeCallbackInternal(data, reply);
1164             break;
1165 
1166         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_DEVICE_CHANGE_CALLBACK):
1167             SetDeviceChangeCallbackInternal(data, reply);
1168             break;
1169 
1170         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNSET_DEVICE_CHANGE_CALLBACK):
1171             UnsetDeviceChangeCallbackInternal(data, reply);
1172             break;
1173 
1174         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_CALLBACK):
1175             SetInterruptCallbackInternal(data, reply);
1176             break;
1177 
1178         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNSET_CALLBACK):
1179             UnsetInterruptCallbackInternal(data, reply);
1180             break;
1181 
1182         case static_cast<uint32_t>(AudioPolicyInterfaceCode::ACTIVATE_INTERRUPT):
1183             ActivateInterruptInternal(data, reply);
1184             break;
1185 
1186         case static_cast<uint32_t>(AudioPolicyInterfaceCode::DEACTIVATE_INTERRUPT):
1187             DeactivateInterruptInternal(data, reply);
1188             break;
1189 
1190         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_INTERRUPT_CALLBACK):
1191             SetAudioManagerInterruptCbInternal(data, reply);
1192             break;
1193 
1194         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNSET_INTERRUPT_CALLBACK):
1195             UnsetAudioManagerInterruptCbInternal(data, reply);
1196             break;
1197 
1198         case static_cast<uint32_t>(AudioPolicyInterfaceCode::REQUEST_AUDIO_FOCUS):
1199             RequestAudioFocusInternal(data, reply);
1200             break;
1201 
1202         case static_cast<uint32_t>(AudioPolicyInterfaceCode::ABANDON_AUDIO_FOCUS):
1203             AbandonAudioFocusInternal(data, reply);
1204             break;
1205 
1206         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_VOLUME_KEY_EVENT_CALLBACK):
1207             SetVolumeKeyEventCallbackInternal(data, reply);
1208             break;
1209 
1210         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNSET_VOLUME_KEY_EVENT_CALLBACK):
1211             UnsetVolumeKeyEventCallbackInternal(data, reply);
1212             break;
1213 
1214         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_STREAM_IN_FOCUS):
1215             GetStreamInFocusInternal(reply);
1216             break;
1217 
1218         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_SESSION_INFO_IN_FOCUS):
1219             GetSessionInfoInFocusInternal(reply);
1220             break;
1221 
1222         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_DEVICES):
1223             GetDevicesInternal(data, reply);
1224             break;
1225         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_WAKEUP_AUDIOCAPTURER):
1226             SetWakeUpAudioCapturerInternal(data, reply);
1227             break;
1228 
1229         case static_cast<uint32_t>(AudioPolicyInterfaceCode::CLOSE_WAKEUP_AUDIOCAPTURER):
1230             CloseWakeUpAudioCapturerInternal(data, reply);
1231             break;
1232 
1233         case static_cast<uint32_t>(AudioPolicyInterfaceCode::QUERY_MICROPHONE_PERMISSION):
1234             CheckRecordingCreateInternal(data, reply);
1235             break;
1236 
1237         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SELECT_OUTPUT_DEVICE):
1238             SelectOutputDeviceInternal(data, reply);
1239             break;
1240 
1241         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_SELECTED_DEVICE_INFO):
1242             GetSelectedDeviceInfoInternal(data, reply);
1243             break;
1244 
1245         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SELECT_INPUT_DEVICE):
1246             SelectInputDeviceInternal(data, reply);
1247             break;
1248 #ifdef FEATURE_DTMF_TONE
1249         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_TONEINFO):
1250             GetToneInfoInternal(data, reply);
1251             break;
1252         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_SUPPORTED_TONES):
1253             GetSupportedTonesInternal(data, reply);
1254             break;
1255 #endif
1256         case static_cast<uint32_t>(AudioPolicyInterfaceCode::RECONFIGURE_CHANNEL):
1257             ReconfigureAudioChannelInternal(data, reply);
1258             break;
1259 
1260         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_AUDIO_LATENCY):
1261             GetAudioLatencyFromXmlInternal(data, reply);
1262             break;
1263 
1264         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_SINK_LATENCY):
1265             GetSinkLatencyFromXmlInternal(data, reply);
1266             break;
1267 
1268         case static_cast<uint32_t>(AudioPolicyInterfaceCode::REGISTER_PLAYBACK_EVENT):
1269             RegisterAudioRendererEventListenerInternal(data, reply);
1270             break;
1271 
1272         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNREGISTER_PLAYBACK_EVENT):
1273             UnregisterAudioRendererEventListenerInternal(data, reply);
1274             break;
1275 
1276         case static_cast<uint32_t>(AudioPolicyInterfaceCode::REGISTER_RECORDING_EVENT):
1277             RegisterAudioCapturerEventListenerInternal(data, reply);
1278             break;
1279 
1280         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNREGISTER_RECORDING_EVENT):
1281             UnregisterAudioCapturerEventListenerInternal(data, reply);
1282             break;
1283 
1284         case static_cast<uint32_t>(AudioPolicyInterfaceCode::REGISTER_TRACKER):
1285             RegisterTrackerInternal(data, reply);
1286             break;
1287 
1288         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UPDATE_TRACKER):
1289             UpdateTrackerInternal(data, reply);
1290             break;
1291 
1292         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_RENDERER_CHANGE_INFOS):
1293             GetRendererChangeInfosInternal(data, reply);
1294             break;
1295 
1296         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_CAPTURER_CHANGE_INFOS):
1297             GetCapturerChangeInfosInternal(data, reply);
1298             break;
1299 
1300         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UPDATE_STREAM_STATE):
1301             UpdateStreamStateInternal(data, reply);
1302             break;
1303 
1304         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_LOW_POWER_STREM_VOLUME):
1305             SetLowPowerVolumeInternal(data, reply);
1306             break;
1307 
1308         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_LOW_POWRR_STREM_VOLUME):
1309             GetLowPowerVolumeInternal(data, reply);
1310             break;
1311 
1312         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_SINGLE_STREAM_VOLUME):
1313             GetSingleStreamVolumeInternal(data, reply);
1314             break;
1315 
1316         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_VOLUME_GROUP_INFO):
1317             GetVolumeGroupInfoInternal(data, reply);
1318             break;
1319 
1320         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_NETWORKID_BY_GROUP_ID):
1321             GetNetworkIdByGroupIdInternal(data, reply);
1322             break;
1323 
1324         case static_cast<uint32_t>(AudioPolicyInterfaceCode::IS_AUDIO_RENDER_LOW_LATENCY_SUPPORTED):
1325              IsAudioRendererLowLatencySupportedInternal(data, reply);
1326              break;
1327 
1328         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_USING_PEMISSION_FROM_PRIVACY):
1329              CheckRecordingStateChangeInternal(data, reply);
1330              break;
1331 
1332         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_ACTIVE_OUTPUT_DEVICE_DESCRIPTORS):
1333             GetPreferredOutputDeviceDescriptorsInternal(data, reply);
1334             break;
1335 
1336         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_PREFERRED_INTPUT_DEVICE_DESCRIPTORS):
1337             GetPreferredInputDeviceDescriptorsInternal(data, reply);
1338             break;
1339 
1340         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_ACTIVE_OUTPUT_DEVICE_CHANGE_CALLBACK):
1341             SetPreferredOutputDeviceChangeCallbackInternal(data, reply);
1342             break;
1343 
1344         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_ACTIVE_INPUT_DEVICE_CHANGE_CALLBACK):
1345             SetPreferredInputDeviceChangeCallbackInternal(data, reply);
1346             break;
1347 
1348         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNSET_ACTIVE_OUTPUT_DEVICE_CHANGE_CALLBACK):
1349             UnsetPreferredOutputDeviceChangeCallbackInternal(data, reply);
1350             break;
1351 
1352         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNSET_ACTIVE_INPUT_DEVICE_CHANGE_CALLBACK):
1353             UnsetPreferredInputDeviceChangeCallbackInternal(data, reply);
1354             break;
1355 
1356         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_AUDIO_FOCUS_INFO_LIST):
1357             GetAudioFocusInfoListInternal(data, reply);
1358             break;
1359 
1360         case static_cast<uint32_t>(AudioPolicyInterfaceCode::REGISTER_FOCUS_INFO_CHANGE_CALLBACK):
1361             RegisterFocusInfoChangeCallbackInternal(data, reply);
1362             break;
1363 
1364         case static_cast<uint32_t>(AudioPolicyInterfaceCode::UNREGISTER_FOCUS_INFO_CHANGE_CALLBACK):
1365             UnregisterFocusInfoChangeCallbackInternal(data, reply);
1366             break;
1367 
1368         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_SYSTEM_SOUND_URI):
1369             SetSystemSoundUriInternal(data, reply);
1370             break;
1371 
1372         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_SYSTEM_SOUND_URI):
1373             GetSystemSoundUriInternal(data, reply);
1374             break;
1375 
1376         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_MIN_VOLUME_STREAM):
1377             GetMinStreamVolumeInternal(data, reply);
1378             break;
1379 
1380         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_MAX_VOLUME_STREAM):
1381             GetMaxStreamVolumeInternal(data, reply);
1382             break;
1383 
1384         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_MAX_RENDERER_INSTANCES):
1385             GetMaxRendererInstancesInternal(data, reply);
1386             break;
1387 
1388         case static_cast<uint32_t>(AudioPolicyInterfaceCode::QUERY_EFFECT_SCENEMODE):
1389             QueryEffectSceneModeInternal(data, reply);
1390             break;
1391 
1392         case static_cast<uint32_t>(AudioPolicyInterfaceCode::IS_VOLUME_UNADJUSTABLE):
1393             IsVolumeUnadjustableInternal(data, reply);
1394             break;
1395 
1396         case static_cast<uint32_t>(AudioPolicyInterfaceCode::ADJUST_VOLUME_BY_STEP):
1397             AdjustVolumeByStepInternal(data, reply);
1398             break;
1399 
1400         case static_cast<uint32_t>(AudioPolicyInterfaceCode::ADJUST_SYSTEM_VOLUME_BY_STEP):
1401             AdjustSystemVolumeByStepInternal(data, reply);
1402             break;
1403 
1404         case static_cast<uint32_t>(AudioPolicyInterfaceCode::GET_SYSTEM_VOLUME_IN_DB):
1405             GetSystemVolumeInDbInternal(data, reply);
1406             break;
1407 
1408         case static_cast<uint32_t>(AudioPolicyInterfaceCode::SET_PLAYBACK_CAPTURER_FILTER_INFO):
1409             SetPlaybackCapturerFilterInfosInternal(data, reply);
1410             break;
1411 
1412         default:
1413             AUDIO_ERR_LOG("default case, need check AudioPolicyManagerStub");
1414             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
1415     }
1416     return AUDIO_OK;
1417 }
1418 } // namespace audio_policy
1419 } // namespace OHOS
1420