• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ST_AUDIO_SYSTEM_MANAGER_H
17 #define ST_AUDIO_SYSTEM_MANAGER_H
18 
19 #include "audio_system_manager_ext.h"
20 
21 namespace OHOS {
22 namespace AudioStandard {
23 /**
24  * @brief The AudioSystemManager class is an abstract definition of audio manager.
25  *        Provides a series of client/interfaces for audio management
26  */
27 
28 class AudioSystemManager {
29 public:
30     static AudioSystemManager *GetInstance();
31 
32     /**
33      * @brief Map volume to HDI.
34      *
35      * @param volume volume value.
36      * @return Returns current volume.
37      * @since 8
38      */
39     static float MapVolumeToHDI(int32_t volume);
40 
41     /**
42      * @brief Map volume from HDI.
43      *
44      * @param volume volume value.
45      * @return Returns current volume.
46      * @since 8
47      */
48     static int32_t MapVolumeFromHDI(float volume);
49 
50     /**
51      * @brief Get audio streamType.
52      *
53      * @param contentType Enumerates the audio content type.
54      * @param streamUsage Enumerates the stream usage.
55      * @return Returns Audio streamType.
56      * @since 8
57      */
58     static AudioStreamType GetStreamType(ContentType contentType, StreamUsage streamUsage);
59 
60     /**
61      * @brief Set the stream volume.
62      *
63      * @param volumeType Enumerates the audio volume type.
64      * @param volume The volume to be set for the current stream.
65      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
66      * defined in {@link audio_errors.h} otherwise.
67      * @since 8
68      */
69     int32_t SetVolume(AudioVolumeType volumeType, int32_t volume) const;
70 
71     /**
72      * @brief Set the stream volume.
73      *
74      * @param volumeType Enumerates the audio volume type.
75      * @param volume The volume to be set for the current stream.
76      * @param deviceType The volume to be set for the device.
77      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
78      * defined in {@link audio_errors.h} otherwise.
79      * @since 16
80      */
81     int32_t SetVolumeWithDevice(AudioVolumeType volumeType, int32_t volume, DeviceType deviceType) const;
82 
83    /**
84      * @brief Set the app volume.
85      *
86      * @param appUid app uid.
87      * @param volume The volume to be set for the current uid app.
88      * @param flag Is need update ui
89      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
90      * defined in {@link audio_errors.h} otherwise.
91      */
92     int32_t SetAppVolume(const int32_t appUid, const int32_t volume, const int32_t flag = 0);
93 
94     /**
95      * @brief Set self app volume.
96      *
97      * @param volume The volume to be set for the current app.
98      * @param flag Is need update ui
99      * @return self app volume level
100      */
101     int32_t SetSelfAppVolume(const int32_t volume, const int32_t flag = 0);
102 
103     /**
104      * @brief Get uid app volume.
105      *
106      * @param appUid App uid.
107      * @param volumeLevel App volume level.
108      * @return Get app volume result
109      */
110     int32_t GetAppVolume(int32_t appUid, int32_t &volumeLevel) const;
111 
112     /**
113      * @brief Get the uid app volume.
114      *
115      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
116      * defined in {@link audio_errors.h} otherwise.
117      */
118     int32_t GetSelfAppVolume(int32_t &volumeLevel) const;
119 
120     /**
121      * @brief Set self app volume change callback.
122      *
123      * @param callback callback when app volume change.
124      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
125      * defined in {@link audio_errors.h} otherwise.
126      */
127     int32_t SetSelfAppVolumeCallback(const std::shared_ptr<AudioManagerAppVolumeChangeCallback> &callback);
128 
129     /**
130      * @brief Unset self app volume change callback.
131      *
132      * @param callback Unset the callback.
133      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
134      * defined in {@link audio_errors.h} otherwise.
135      */
136     int32_t UnsetSelfAppVolumeCallback(const std::shared_ptr<AudioManagerAppVolumeChangeCallback> &callback = nullptr);
137 
138     /**
139      * @brief Set app volume change callback.
140      *
141      * @param appUid app uid.
142      * @param callback callback when app volume changed
143      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
144      * defined in {@link audio_errors.h} otherwise.
145      */
146     int32_t SetAppVolumeCallbackForUid(const int32_t appUid,
147         const std::shared_ptr<AudioManagerAppVolumeChangeCallback> &callback);
148 
149     /**
150      * @brief Unset app volume change callback.
151      *
152      * @param callback Unset the callback.
153      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
154      * defined in {@link audio_errors.h} otherwise.
155      */
156     int32_t UnsetAppVolumeCallbackForUid(
157         const std::shared_ptr<AudioManagerAppVolumeChangeCallback> &callback = nullptr);
158 
159     /**
160      * @brief Set the uid app volume muted.
161      * @param appUid app uid
162      * @param muted muted or unmuted.
163      * @param flag Is need update ui
164      * @return Returns {@link SUCCESS} if volume is successfully set; returns an error code
165      * defined in {@link audio_errors.h} otherwise.
166      */
167     int32_t SetAppVolumeMuted(const int32_t appUid, const bool muted, const int32_t flag = 0);
168 
169     /**
170      * @brief Set the mute state of the VoIP ringtone for the specified app.
171      * @param appUid The UID of the app.
172      * @param muted Set to true to mute the VoIP ringtone, false to unmute.
173      * @return Returns {@link SUCCESS} if the app ringtone is set successfully; returns an error code
174      * defined in {@link audio_errors.h} otherwise.
175      */
176     int32_t SetAppRingMuted(int32_t appUid, bool muted);
177 
178     int32_t SetAdjustVolumeForZone(int32_t zoneId);
179 
180     /**
181      * @brief Check the uid app volume is muted.
182      * @param appUid app uid
183      * @param owned If true is passed, the result will be indicated your owned muted statesettings to
184      * this app. Otherwise if false is passed, the result will be indicated the real muted state.
185      *  @param isMute App mute state has seted
186      * @return the app uid muted status
187      */
188     int32_t IsAppVolumeMute(const int32_t appUid, const bool owned, bool &isMute);
189 
190     /**
191      * @brief Unset active volume type change callback.
192      *
193      * @param callback Unset the callback.
194      * @return Returns {@link SUCCESS} if stream change callback is successfully unset; returns an error code
195      * defined in {@link audio_errors.h} otherwise.
196      */
197     int32_t UnsetActiveVolumeTypeCallback(
198         const std::shared_ptr<AudioManagerActiveVolumeTypeChangeCallback> &callback = nullptr);
199 
200     /**
201      * @brief Set active volume type change callback.
202      *
203      * @param callback callback when active volume type change.
204      * @return Returns {@link SUCCESS} if stream change callback is successfully set; returns an error code
205      * defined in {@link audio_errors.h} otherwise.
206      */
207     int32_t SetActiveVolumeTypeCallback(
208         const std::shared_ptr<AudioManagerActiveVolumeTypeChangeCallback> &callback);
209 
210     /**
211      * @brief Obtains the current stream volume.
212      *
213      * @param volumeType Enumerates the audio volume type.
214      * @return Returns current stream volume.
215      * @since 8
216      */
217     int32_t GetVolume(AudioVolumeType volumeType) const;
218 
219     /**
220      * @brief Set volume discount factor.
221      *
222      * @param streamId stream Unique identification.
223      * @param volume Adjustment percentage.
224      * @return Whether the operation is effective
225      * @since 9
226      */
227     int32_t SetLowPowerVolume(int32_t streamId, float volume) const;
228 
229     /**
230      * @brief get volume discount factor.
231      *
232      * @param streamId stream Unique identification.
233      * @return Returns current stream volume.
234      * @since 9
235      */
236     float GetLowPowerVolume(int32_t streamId) const;
237 
238     /**
239      * @brief get single stream volume.
240      *
241      * @param streamId stream Unique identification.
242      * @return Returns current stream volume.
243      * @since 9
244      */
245     float GetSingleStreamVolume(int32_t streamId) const;
246 
247     /**
248      * @brief get max stream volume.
249      *
250      * @param volumeType audio volume type.
251      * @return Returns current stream volume.
252      * @since 8
253      */
254     int32_t GetMaxVolume(AudioVolumeType volumeType);
255 
256     /**
257      * @brief get min stream volume.
258      *
259      * @param volumeType audio volume type.
260      * @return Returns current stream volume.
261      * @since 8
262      */
263     int32_t GetMinVolume(AudioVolumeType volumeType);
264 
265     /**
266      * @brief get device max stream volume.
267      *
268      * @param volumeType audio volume type.
269      * @param deviceType device type.
270      * @return Returns the maxinum stream volume.
271      */
272     int32_t GetDeviceMaxVolume(AudioVolumeType volumeType, DeviceType deviceType);
273 
274     /**
275      * @brief get device min stream volume.
276      *
277      * @param volumeType audio volume type.
278      * @param deviceType device type.
279      * @return Returns the mininum stream volume.
280      */
281     int32_t GetDeviceMinVolume(AudioVolumeType volumeType, DeviceType deviceType);
282 
283     /**
284      * @brief set stream mute.
285      *
286      * @param volumeType audio volume type.
287      * @param mute Specifies whether the stream is muted.
288      * @param deivceType Specifies which device to mute.
289      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
290      * in {@link audio_errors.h} otherwise.
291      * @since 8
292      */
293     int32_t SetMute(AudioVolumeType volumeType, bool mute, const DeviceType &deviceType = DEVICE_TYPE_NONE) const;
294 
295     /**
296      * @brief is stream mute.
297      *
298      * @param volumeType audio volume type.
299      * @return Returns <b>true</b> if the rendering is successfully started; returns <b>false</b> otherwise.
300      * @since 8
301      */
302     bool IsStreamMute(AudioVolumeType volumeType) const;
303 
304     /**
305      * @brief get volume db value that system calculate by volume type, volume level and device type.
306      *
307      * @param volumeType audio volume type.
308      * @param volumeLevel volume level.
309      * @param device device type.
310      * @return Returns volume db value that system calculate by volume type, volume level and device type.
311      * @since 20
312      */
313     float GetVolumeInUnitOfDb(AudioVolumeType volumeType, int32_t volumeLevel, DeviceType device);
314 
315     /**
316      * @brief Set global microphone mute state.
317      *
318      * @param mute Specifies whether the Microphone is muted.
319      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
320      * in {@link audio_errors.h} otherwise.
321      * @since 8
322      */
323     int32_t SetMicrophoneMute(bool isMute);
324 
325     /**
326      * @brief get global microphone mute state.
327      *
328      * @return Returns <b>true</b> if the rendering is successfully started; returns <b>false</b> otherwise.
329      * @since 9
330      */
331     bool IsMicrophoneMute();
332 
333     /**
334      * @brief Select output device.
335      *
336      * @param audioDeviceDescriptors Output device object.
337      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
338      * in {@link audio_errors.h} otherwise.
339      * @since 9
340      */
341     int32_t SelectOutputDevice(std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
342 
343     /**
344      * @brief Select input device.
345      *
346      * @param audioDeviceDescriptors Output device object.
347      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
348      * in {@link audio_errors.h} otherwise.
349      * @since 9
350      */
351     int32_t SelectInputDevice(std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
352 
353     /**
354      * @brief get selected device info.
355      *
356      * @param uid identifier.
357      * @param pid identifier.
358      * @param streamType audio stream type.
359      * @return Returns device info.
360      * @since 9
361      */
362     std::string GetSelectedDeviceInfo(int32_t uid, int32_t pid, AudioStreamType streamType) const;
363 
364     /**
365      * @brief Select the audio output device according to the filter conditions.
366      *
367      * @param audioRendererFilter filter conditions.
368      * @param audioDeviceDescriptors Output device object.
369      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
370      * in {@link audio_errors.h} otherwise.
371      * @since 9
372      */
373     int32_t SelectOutputDevice(sptr<AudioRendererFilter> audioRendererFilter,
374         std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
375 
376     /**
377      * @brief Select the audio input device according to the filter conditions.
378      *
379      * @param audioRendererFilter filter conditions.
380      * @param audioDeviceDescriptors Output device object.
381      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
382      * in {@link audio_errors.h} otherwise.
383      * @since 9
384      */
385     int32_t SelectInputDevice(sptr<AudioCapturerFilter> audioCapturerFilter,
386         std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
387 
388     /**
389      * @brief Exclude the audio output device according to the DeviceUsage.
390      *
391      * @param audioDevUsage AudioDeviceUsage.
392      * @param audioDeviceDescriptors Output device object.
393      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
394      * in {@link audio_errors.h} otherwise.
395      * @since 16
396      */
397     int32_t ExcludeOutputDevices(AudioDeviceUsage audioDevUsage,
398         std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
399 
400     /**
401      * @brief Unexclude the audio output device according to the DeviceUsage.
402      *
403      * @param audioDevUsage AudioDeviceUsage.
404      * @param audioDeviceDescriptors Output device object.
405      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
406      * in {@link audio_errors.h} otherwise.
407      * @since 16
408      */
409     int32_t UnexcludeOutputDevices(AudioDeviceUsage audioDevUsage,
410         std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
411 
412     /**
413      * @brief Unexclude the audio output device according to the DeviceUsage.
414      *
415      * @param audioDevUsage AudioDeviceUsage.
416      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
417      * in {@link audio_errors.h} otherwise.
418      * @since 16
419      */
420     int32_t UnexcludeOutputDevices(AudioDeviceUsage audioDevUsage) const;
421 
422     /**
423      * @brief Get the list of excluded audio output devices according to the DeviceUsage.
424      *
425      * @param audioDevUsage AudioDeviceUsage.
426      * @return Returns the device list is obtained.
427      * @since 16
428      */
429     std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetExcludedDevices(
430         AudioDeviceUsage audioDevUsage) const;
431 
432     /**
433      * @brief Get the list of audio devices.
434      *
435      * @param deviceFlag Flag of device type.
436      * @param GetAudioParameter Key of audio parameters to be obtained.
437      * @return Returns the device list is obtained.
438      * @since 9
439      */
440     std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag);
441 
442     /**
443      * @brief Get the list of audio devices (inner).
444      *
445      * @param deviceFlag Flag of device type.
446      * @return Returns the device list is obtained.
447      * @since 12
448      */
449     std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetDevicesInner(DeviceFlag deviceFlag);
450 
451     /**
452      * @brief Get the audio output device according to the filter conditions.
453      *
454      * @param AudioRendererFilter filter conditions.
455      * @return Returns the device list is obtained.
456      * @since 12
457      */
458     std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetOutputDevice(sptr<AudioRendererFilter> audioRendererFilter);
459 
460     /**
461      * @brief Get the audio input device according to the filter conditions.
462      *
463      * @param AudioCapturerFilter filter conditions.
464      * @return Returns the device list is obtained.
465      * @since 12
466      */
467     std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetInputDevice(sptr<AudioCapturerFilter> audioCapturerFilter);
468 
469     /**
470      * @brief Get audio parameter.
471      *
472      * @param key Key of audio parameters to be obtained.
473      * @return Returns the value of the obtained audio parameter
474      * @since 9
475      */
476     const std::string GetAudioParameter(const std::string key);
477 
478     /**
479      * @brief set audio parameter.
480      *
481      * @param key The key of the set audio parameter.
482      * @param value The value of the set audio parameter.
483      * @since 9
484      */
485     void SetAudioParameter(const std::string &key, const std::string &value);
486 
487     /**
488      * @brief set audio parameter.
489      *
490      * @parame key The key of the set audio parameter.
491      * @param value The value of the set audio parameter.
492      * @since 12
493      */
494     int32_t SetAsrAecMode(const AsrAecMode asrAecMode);
495     /**
496      * @brief set audio parameter.
497      *
498      * @parame key The key of the set audio parameter.
499      * @param value The value of the set audio parameter.
500      * @since 12
501      */
502     int32_t GetAsrAecMode(AsrAecMode &asrAecMode);
503     /**
504      * @brief set audio parameter.
505      *
506      * @parame key The key of the set audio parameter.
507      * @param value The value of the set audio parameter.
508      * @since 12
509      */
510     int32_t SetAsrNoiseSuppressionMode(const AsrNoiseSuppressionMode asrNoiseSuppressionMode);
511     /**
512      * @brief set audio parameter.
513      *
514      * @parame key The key of the set audio parameter.
515      * @param value The value of the set audio parameter.
516      * @since 12
517      */
518     int32_t GetAsrNoiseSuppressionMode(AsrNoiseSuppressionMode &asrNoiseSuppressionMode);
519     /**
520      * @brief set audio parameter.
521      *
522      * @parame key The key of the set audio parameter.
523      * @param value The value of the set audio parameter.
524      * @since 12
525      */
526     int32_t SetAsrWhisperDetectionMode(const AsrWhisperDetectionMode asrWhisperDetectionMode);
527     /**
528      * @brief set audio parameter.
529      *
530      * @parame key The key of the set audio parameter.
531      * @param value The value of the set audio parameter.
532      * @since 12
533      */
534     int32_t GetAsrWhisperDetectionMode(AsrWhisperDetectionMode &asrWhisperDetectionMode);
535     /**
536      * @brief set audio parameter.
537      *
538      * @parame key The key of the set audio parameter.
539      * @param value The value of the set audio parameter.
540      * @since 12
541      */
542     int32_t SetAsrVoiceControlMode(const AsrVoiceControlMode asrVoiceControlMode, bool on);
543     /**
544      * @brief set audio parameter.
545      *
546      * @parame key The key of the set audio parameter.
547      * @param value The value of the set audio parameter.
548      * @since 12
549      */
550     int32_t SetAsrVoiceMuteMode(const AsrVoiceMuteMode asrVoiceMuteMode, bool on);
551     /**
552      * @brief set audio parameter.
553      *
554      * @parame key The key of the set audio parameter.
555      * @param value The value of the set audio parameter.
556      * @since 12
557      */
558     int32_t IsWhispering();
559 
560     /**
561      * @brief Get audio parameter.
562      *
563      * @param mainKey Main key of audio parameters to be obtained.
564      * @param subKeys subKeys of audio parameters to be obtained.
565      * @param result value of sub key parameters.
566      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
567      * @since 11
568      */
569     int32_t GetExtraParameters(const std::string &mainKey,
570         const std::vector<std::string> &subKeys, std::vector<std::pair<std::string, std::string>> &result);
571 
572     /**
573      * @brief Set audio parameters.
574      *
575      * @param key The main key of the set audio parameter.
576      * @param kvpairs The pairs with sub keys and values of the set audio parameter.
577      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
578      * @since 11
579      */
580     int32_t SetExtraParameters(const std::string &key,
581         const std::vector<std::pair<std::string, std::string>> &kvpairs);
582 
583     /**
584      * @brief Get transaction Id.
585      *
586      * @param deviceType device type.
587      * @param deviceRole device role.
588      * @return Returns transaction Id.
589      * @since 9
590      */
591     uint64_t GetTransactionId(DeviceType deviceType, DeviceRole deviceRole);
592 
593     /**
594      * @brief Set device active.
595      *
596      * @param deviceType device type.
597      * @param flag Device activation status.
598      * @param clientPid pid of caller.
599      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
600      * in {@link audio_errors.h} otherwise.
601      * @since 9
602      */
603     int32_t SetDeviceActive(DeviceType deviceType, bool flag, const int32_t clientUid = -1) const;
604 
605     /**
606      * @brief get device active.
607      *
608      * @param deviceType device type.
609      * @return Returns <b>true</b> if the rendering is successfully started; returns <b>false</b> otherwise.
610      * @since 9
611      */
612     bool IsDeviceActive(DeviceType deviceType) const;
613 
614     /**
615      * @brief get active output device.
616      *
617      * @return Returns device type.
618      * @since 9
619      */
620     DeviceType GetActiveOutputDevice();
621 
622     /**
623      * @brief get active input device.
624      *
625      * @return Returns device type.
626      * @since 9
627      */
628     DeviceType GetActiveInputDevice();
629 
630     /**
631      * @brief Is stream active.
632      *
633      * @param volumeType audio volume type.
634      * @return Returns <b>true</b> if the rendering is successfully started; returns <b>false</b> otherwise.
635      * @since 9
636      */
637     bool IsStreamActive(AudioVolumeType volumeType) const;
638 
639     /**
640      * @brief Set ringer mode.
641      *
642      * @param ringMode audio ringer mode.
643      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
644      * in {@link audio_errors.h} otherwise.
645      * @since 8
646      */
647     int32_t SetRingerMode(AudioRingerMode ringMode);
648 
649     /**
650      * @brief Get ringer mode.
651      *
652      * @return Returns audio ringer mode.
653      * @since 8
654      */
655     AudioRingerMode GetRingerMode();
656 
657     /**
658      * @brief Set audio scene.
659      *
660      * @param scene audio scene.
661      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
662      * in {@link audio_errors.h} otherwise.
663      * @since 8
664      */
665     int32_t SetAudioScene(const AudioScene &scene);
666 
667     /**
668      * @brief Get audio scene.
669      *
670      * @return Returns audio scene.
671      * @since 8
672      */
673     AudioScene GetAudioScene() const;
674 
675     /**
676      * @brief Registers the deviceChange callback listener.
677      *
678      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
679      * defined in {@link audio_errors.h} otherwise.
680      * @since 8
681      */
682     int32_t SetDeviceChangeCallback(const DeviceFlag flag, const std::shared_ptr<AudioManagerDeviceChangeCallback>
683         &callback);
684 
685     /**
686      * @brief Unregisters the deviceChange callback listener
687      *
688      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
689      * defined in {@link audio_errors.h} otherwise.
690      * @since 8
691      */
692     int32_t UnsetDeviceChangeCallback(DeviceFlag flag = DeviceFlag::ALL_DEVICES_FLAG,
693         std::shared_ptr<AudioManagerDeviceChangeCallback> callback = nullptr);
694 
695     /**
696      * @brief Registers the ringerMode callback listener.
697      *
698      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
699      * defined in {@link audio_errors.h} otherwise.
700      * @since 8
701      */
702     int32_t SetRingerModeCallback(const int32_t clientId,
703                                   const std::shared_ptr<AudioRingerModeCallback> &callback);
704 
705     /**
706      * @brief Unregisters the VolumeKeyEvent callback listener
707      *
708      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
709      * defined in {@link audio_errors.h} otherwise.
710      * @since 8
711      */
712     int32_t UnsetRingerModeCallback(const int32_t clientId) const;
713 
714     /**
715      * @brief registers the volumeKeyEvent callback listener
716      *
717      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
718      * defined in {@link audio_errors.h} otherwise.
719      * @since 8
720      */
721     int32_t RegisterVolumeKeyEventCallback(const int32_t clientPid,
722         const std::shared_ptr<VolumeKeyEventCallback> &callback, API_VERSION api_v = API_9);
723 
724     /**
725      * @brief Unregisters the volumeKeyEvent callback listener
726      *
727      * @return Returns {@link SUCCESS} if callback unregistration is successful; returns an error code
728      * defined in {@link audio_errors.h} otherwise.
729      * @since 8
730      */
731     int32_t UnregisterVolumeKeyEventCallback(const int32_t clientPid,
732         const std::shared_ptr<VolumeKeyEventCallback> &callback = nullptr);
733 
734     /**
735      * @brief registers the volume degree callback listener
736      *
737      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
738      * defined in {@link audio_errors.h} otherwise.
739      */
740     int32_t RegisterVolumeDegreeCallback(const int32_t clientPid,
741         const std::shared_ptr<VolumeKeyEventCallback> &callback);
742 
743     /**
744      * @brief Unregisters the volumeKeyEvent callback listener
745      *
746      * @return Returns {@link SUCCESS} if callback unregistration is successful; returns an error code
747      * defined in {@link audio_errors.h} otherwise.
748      */
749     int32_t UnregisterVolumeDegreeCallback(const int32_t clientPid,
750         const std::shared_ptr<VolumeKeyEventCallback> &callback = nullptr);
751 
752     /**
753      * @brief registers the systemVolumeChange callback listener
754      *
755      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
756      * defined in {@link audio_errors.h} otherwise.
757      * @since 20
758      */
759     int32_t RegisterSystemVolumeChangeCallback(const int32_t clientPid,
760         const std::shared_ptr<SystemVolumeChangeCallback> &callback);
761 
762     /**
763      * @brief Unregisters the systemVolumeChange callback listener
764      *
765      * @return Returns {@link SUCCESS} if callback unregistration is successful; returns an error code
766      * defined in {@link audio_errors.h} otherwise.
767      * @since 20
768      */
769     int32_t UnregisterSystemVolumeChangeCallback(const int32_t clientPid,
770         const std::shared_ptr<SystemVolumeChangeCallback> &callback = nullptr);
771 
772     /**
773      * @brief registers the renderer data transfer callback listener
774      *
775      * @param param {@link DataTransferMonitorParam}
776      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
777      * defined in {@link audio_errors.h} otherwise.
778      * @since 20
779      */
780     int32_t RegisterRendererDataTransferCallback(const DataTransferMonitorParam &param,
781         const std::shared_ptr<AudioRendererDataTransferStateChangeCallback> &callback);
782 
783     /**
784      * @brief Unregisters the renderer data transfer callback listener
785      *
786      * @param param {@link DataTransferMonitorParam}
787      * @return Returns {@link SUCCESS} if callback unregistration is successful; returns an error code
788      * defined in {@link audio_errors.h} otherwise.
789      * @since 20
790      */
791     int32_t UnregisterRendererDataTransferCallback(
792         const std::shared_ptr<AudioRendererDataTransferStateChangeCallback> &callback);
793 
794     /**
795      * @brief Set mono audio state
796      *
797      * @param monoState mono state
798      * @since 8
799      */
800     void SetAudioMonoState(bool monoState);
801 
802     /**
803      * @brief Set audio balance value
804      *
805      * @param balanceValue balance value
806      * @since 8
807      */
808     void SetAudioBalanceValue(float balanceValue);
809 
810     /**
811      * @brief Set system sound uri
812      *
813      * @param key the key of uri
814      * @param uri the value of uri
815      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
816      * defined in {@link audio_errors.h} otherwise.
817      * @since 10
818      */
819     int32_t SetSystemSoundUri(const std::string &key, const std::string &uri);
820 
821     /**
822      * @brief Get system sound uri
823      *
824      * @param key the key of uri
825      * @return Returns the value of uri for the key
826      * @since 10
827      */
828     std::string GetSystemSoundUri(const std::string &key);
829 
830     // Below APIs are added to handle compilation error in call manager
831     // Once call manager adapt to new interrupt APIs, this will be removed
832 
833     /**
834      * @brief registers the audioManager callback listener
835      *
836      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
837      * defined in {@link audio_errors.h} otherwise.
838      * @since 8
839      */
840     int32_t SetAudioManagerCallback(const AudioVolumeType streamType,
841                                     const std::shared_ptr<AudioManagerCallback> &callback);
842 
843     /**
844      * @brief Unregisters the audioManager callback listener
845      *
846      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
847      * defined in {@link audio_errors.h} otherwise.
848      * @since 8
849      */
850     int32_t UnsetAudioManagerCallback(const AudioVolumeType streamType) const;
851 
852     /**
853      * @brief Activate audio Interrupt
854      *
855      * @param audioInterrupt audioInterrupt
856      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
857      * defined in {@link audio_errors.h} otherwise.
858      * @since 8
859      */
860     int32_t ActivateAudioInterrupt(AudioInterrupt &audioInterrupt);
861 
862     /**
863      * @brief Set App Concurrency Mode
864      *
865      * @param appUid app Uid
866      * @param mode concurrency Mode
867      * @return Returns {@link SUCCESS} if seting is successful; returns an error code
868      * defined in {@link audio_errors.h} otherwise.
869      * @since 20
870      */
871     int32_t SetAppConcurrencyMode(const int32_t appUid, const int32_t mode);
872 
873     /**
874      * @brief Set App Slient On Display
875      *
876      * @param displayId app slient On display id
877      * @return Returns {@link SUCCESS} if seting is successful; returns an error code
878      * defined in {@link audio_errors.h} otherwise.
879      * @since 20
880      */
881     int32_t SetAppSlientOnDisplay(const int32_t displayId);
882 
883     /**
884      * @brief Deactivactivate audio Interrupt
885      *
886      * @param audioInterrupt audioInterrupt
887      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
888      * defined in {@link audio_errors.h} otherwise.
889      * @since 8
890      */
891     int32_t DeactivateAudioInterrupt(const AudioInterrupt &audioInterrupt) const;
892 
893     /**
894      * @brief Activactivate preempt audio focus mode
895      *
896      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
897      * defined in {@link audio_errors.h} otherwise.
898      * @since 18
899      */
900     int32_t ActivatePreemptMode() const;
901 
902     /**
903      * @brief Deactivactivate preempt audio focus mode
904      *
905      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
906      * defined in {@link audio_errors.h} otherwise.
907      * @since 18
908      */
909     int32_t DeactivatePreemptMode() const;
910 
911     /**
912      * @brief registers the Interrupt callback listener
913      *
914      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
915      * defined in {@link audio_errors.h} otherwise.
916      * @since 8
917      */
918     int32_t SetAudioManagerInterruptCallback(const std::shared_ptr<AudioManagerCallback> &callback);
919 
920     /**
921      * @brief Unregisters the Interrupt callback listener
922      *
923      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
924      * defined in {@link audio_errors.h} otherwise.
925      * @since 8
926      */
927     int32_t UnsetAudioManagerInterruptCallback();
928 
929     /**
930      * @brief Request audio focus
931      *
932      * @param audioInterrupt audioInterrupt
933      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
934      * defined in {@link audio_errors.h} otherwise.
935      * @since 8
936      */
937     int32_t RequestAudioFocus(const AudioInterrupt &audioInterrupt);
938 
939     /**
940      * @brief Abandon audio focus
941      *
942      * @param audioInterrupt audioInterrupt
943      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
944      * defined in {@link audio_errors.h} otherwise.
945      * @since 8
946      */
947     int32_t AbandonAudioFocus(const AudioInterrupt &audioInterrupt);
948 
949     /**
950      * @brief Request independent interrupt
951      *
952      * @param focusType focus type
953      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
954      * in {@link audio_errors.h} otherwise.
955      * @since 8
956      */
957     bool RequestIndependentInterrupt(FocusType focusType);
958 
959     /**
960      * @brief Abandon independent interrupt
961      *
962      * @param focusType focus type
963      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
964      * in {@link audio_errors.h} otherwise.
965      * @since 8
966      */
967     bool AbandonIndependentInterrupt(FocusType focusType);
968 
969     /**
970      * @brief Update stream state
971      *
972      * @param clientUid client Uid
973      * @param streamSetState streamSetState
974      * @param streamUsage streamUsage
975      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
976      * defined in {@link audio_errors.h} otherwise.
977      * @since 8
978      */
979     int32_t UpdateStreamState(const int32_t clientUid, StreamSetState streamSetState,
980                                     StreamUsage streamUsage);
981 
982     /**
983      * @brief Get Pin Value From Type
984      *
985      * @param deviceType deviceType
986      * @param deviceRole deviceRole
987      * @return Returns Enumerate AudioPin
988      * @since 8
989      */
990     AudioPin GetPinValueFromType(DeviceType deviceType, DeviceRole deviceRole) const;
991 
992     /**
993      * @brief Get type Value From Pin
994      *
995      * @param pin AudioPin
996      * @return Returns Enumerate DeviceType
997      * @since 8
998      */
999     DeviceType GetTypeValueFromPin(AudioPin pin) const;
1000 
1001     /**
1002      * @brief Get volume groups
1003      *
1004      * @param networkId networkId
1005      * @param info VolumeGroupInfo
1006      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1007      * defined in {@link audio_errors.h} otherwise.
1008      * @since 8
1009      */
1010     int32_t GetVolumeGroups(std::string networkId, std::vector<sptr<VolumeGroupInfo>> &info);
1011 
1012     /**
1013      * @brief Get volume groups manager
1014      *
1015      * @param networkId networkId
1016      * @return Returns AudioGroupManager
1017      * @since 8
1018      */
1019     std::shared_ptr<AudioGroupManager> GetGroupManager(int32_t groupId);
1020 
1021     /**
1022      * @brief Get active output deviceDescriptors
1023      *
1024      * @return Returns AudioDeviceDescriptor
1025      * @since 8
1026      */
1027     std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetActiveOutputDeviceDescriptors();
1028 
1029     /**
1030      * @brief Get preferred input device deviceDescriptors
1031      *
1032      * @return Returns AudioDeviceDescriptor
1033      * @since 10
1034      */
1035     int32_t GetPreferredInputDeviceDescriptors();
1036 
1037     /**
1038      * @brief Get audio focus info
1039      *
1040      * @return Returns success or not
1041      * @since 10
1042      */
1043     int32_t GetAudioFocusInfoList(std::list<std::pair<AudioInterrupt, AudioFocuState>> &focusInfoList);
1044 
1045     /**
1046      * @brief Register callback to listen audio focus info change event
1047      *
1048      * @return Returns success or not
1049      * @since 10
1050      */
1051     int32_t RegisterFocusInfoChangeCallback(const std::shared_ptr<AudioFocusInfoChangeCallback> &callback);
1052 
1053     /**
1054      * @brief Unregister callback to listen audio focus info change event
1055      *
1056      * @return Returns success or not
1057      * @since 10
1058      */
1059     int32_t UnregisterFocusInfoChangeCallback(
1060         const std::shared_ptr<AudioFocusInfoChangeCallback> &callback = nullptr);
1061 
1062     int32_t SetAudioCapturerSourceCallback(const std::shared_ptr<AudioCapturerSourceCallback> &callback);
1063 
1064     int32_t SetWakeUpSourceCloseCallback(const std::shared_ptr<WakeUpSourceCloseCallback> &callback);
1065 
1066     /**
1067      * @brief Set whether or not absolute volume is supported for the specified Bluetooth device
1068      *
1069      * @return Returns success or not
1070      * @since 11
1071      */
1072     int32_t SetDeviceAbsVolumeSupported(const std::string &macAddress, const bool support);
1073 
1074     /**
1075      * @brief Set the absolute volume value for the specified Bluetooth device
1076      *
1077      * @return Returns success or not
1078      * @since 11
1079      */
1080     int32_t SetA2dpDeviceVolume(const std::string &macAddress, const int32_t volume, const bool updateUi);
1081 
1082     /**
1083      * @brief Set the absolute volume value for the specified Nearlink device
1084      *
1085      * @return Returns success or not
1086      */
1087     int32_t SetNearlinkDeviceVolume(const std::string &macAddress, AudioVolumeType volumeType,
1088         const int32_t volume, const bool updateUi);
1089 
1090     /**
1091      * @brief Registers the availbale deviceChange callback listener.
1092      *
1093      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1094      * defined in {@link audio_errors.h} otherwise.
1095      * @since 11
1096      */
1097     int32_t SetAvailableDeviceChangeCallback(const AudioDeviceUsage usage,
1098         const std::shared_ptr<AudioManagerAvailableDeviceChangeCallback>& callback);
1099     /**
1100      * @brief UnRegisters the availbale deviceChange callback listener.
1101      *
1102      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1103      * defined in {@link audio_errors.h} otherwise.
1104      * @since 11
1105      */
1106     int32_t UnsetAvailableDeviceChangeCallback(AudioDeviceUsage usage);
1107 
1108     /**
1109      * @brief Switch the output device accoring different cast type.
1110      *
1111      * @return Returns {@link SUCCESS} if device is successfully switched; returns an error code
1112      * defined in {@link audio_errors.h} otherwise.
1113      * @since 11
1114      */
1115     int32_t ConfigDistributedRoutingRole(std::shared_ptr<AudioDeviceDescriptor> desciptor, CastType type);
1116 
1117     /**
1118      * @brief Registers the descriptor Change callback listener.
1119      *
1120      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1121      * defined in {@link audio_errors.h} otherwise.
1122      * @since 11
1123      */
1124     int32_t SetDistributedRoutingRoleCallback(const std::shared_ptr<AudioDistributedRoutingRoleCallback> &callback);
1125 
1126     /**
1127      * @brief UnRegisters the descriptor Change callback callback listener.
1128      *
1129      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1130      * defined in {@link audio_errors.h} otherwise.
1131      * @since 11
1132      */
1133     int32_t UnsetDistributedRoutingRoleCallback(const std::shared_ptr<AudioDistributedRoutingRoleCallback> &callback);
1134 
1135     /**
1136      * @brief Set device address.
1137      *
1138      * @param deviceType device type.
1139      * @param flag Device activation status.
1140      * @param address Device address
1141      * @param clientPid pid of caller.
1142      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
1143      * in {@link audio_errors.h} otherwise.
1144      * @since 11
1145      */
1146     int32_t SetCallDeviceActive(DeviceType deviceType, bool flag, std::string address,
1147         const int32_t clientUid = -1) const;
1148 
1149     /**
1150      * @brief get the effect algorithmic latency value for a specified audio stream.
1151      *
1152      * @param sessionId the session ID value for the stream
1153      * @return Returns the effect algorithmic latency in ms.
1154      * @since 12
1155      */
1156     uint32_t GetEffectLatency(const std::string &sessionId);
1157 
1158     /**
1159      * @brief set useraction command
1160      *
1161      * @param actionCommand action command
1162      * @param paramInfo information
1163      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
1164      * in {@link audio_errors.h} otherwise.
1165      * @since 12
1166      */
1167     int32_t DisableSafeMediaVolume();
1168 
1169     static void AudioServerDied(pid_t pid, pid_t uid);
1170 
1171     int32_t SetMicrophoneBlockedCallback(const std::shared_ptr<AudioManagerMicrophoneBlockedCallback>& callback);
1172     int32_t UnsetMicrophoneBlockedCallback(std::shared_ptr<AudioManagerMicrophoneBlockedCallback> callback = nullptr);
1173 
1174     /**
1175      * @brief Registers the audioScene change callback listener.
1176      *
1177      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1178      * defined in {@link audio_errors.h} otherwise.
1179      * @since 16
1180      */
1181     int32_t SetAudioSceneChangeCallback(const std::shared_ptr<AudioManagerAudioSceneChangedCallback>& callback);
1182 
1183     /**
1184      * @brief Registers the audioScene change callback listener.
1185      *
1186      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1187      * defined in {@link audio_errors.h} otherwise.
1188      * @since 16
1189      */
1190     int32_t UnsetAudioSceneChangeCallback(std::shared_ptr<AudioManagerAudioSceneChangedCallback> callback = nullptr);
1191 
1192     std::string GetSelfBundleName(int32_t uid);
1193 
1194     int32_t SetQueryClientTypeCallback(const std::shared_ptr<AudioQueryClientTypeCallback> &callback);
1195     int32_t SetAudioClientInfoMgrCallback(const std::shared_ptr<AudioClientInfoMgrCallback> &callback);
1196     int32_t SetAudioVKBInfoMgrCallback(const std::shared_ptr<AudioVKBInfoMgrCallback> &callback);
1197     int32_t CheckVKBInfo(const std::string &bundleName, bool &isValid);
1198     int32_t SetQueryAllowedPlaybackCallback(const std::shared_ptr<AudioQueryAllowedPlaybackCallback> &callback);
1199     int32_t SetBackgroundMuteCallback(const std::shared_ptr<AudioBackgroundMuteCallback> &callback);
1200 
1201     int32_t SetQueryBundleNameListCallback(const std::shared_ptr<AudioQueryBundleNameListCallback> &callback);
1202 
1203     /**
1204      * @brief inject interruption event.
1205      *
1206      * @param networkId networkId.
1207      * @param event Indicates the InterruptEvent information needed by client.
1208      * For details, refer InterruptEvent struct in audio_interrupt_info.h
1209      * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
1210      * in {@link audio_errors.h} otherwise.
1211      * @since 12
1212      */
1213     int32_t InjectInterruption(const std::string networkId, InterruptEvent &event);
1214 
1215     /**
1216     * @brief Load the split module for audio stream separation.
1217     *
1218     * @param splitArgs Specifies the types of audio to be split into different streams.
1219     * @param networkId The network identifier of the output device.
1220     * @return Returns {@link SUCCESS} if the module is loaded successfully; otherwise, returns an error code defined
1221     * in {@link audio_errors.h}.
1222     * @since 12
1223     */
1224     int32_t LoadSplitModule(const std::string &splitArgs, const std::string &networkId);
1225 
1226     /**
1227     * @brief Set Custmoized Ring Back Tone mute state.
1228     *
1229     * @param isMute Specifies whether the Customized Ring Back Tone is muted.
1230     * @return Returns {@link SUCCESS} if the settings is successfully; otherwise, returns an error code defined
1231     * in {@link audio_errors.h}.
1232     */
1233     int32_t SetVoiceRingtoneMute(bool isMute);
1234 
1235     /**
1236      * @brief Set foreground list.
1237      *
1238      * @param list The foreground list.
1239      * @return Returns {@link SUCCESS} if the operation is successfully.
1240      * @return Returns {@link ERR_ILLEGAL_STATE} if the server is not available.
1241      * @return Returns {@link ERR_INVALID_PARAM} if the sessionId is not exist.
1242      */
1243     int32_t SetForegroundList(std::vector<std::string> list);
1244 
1245     /**
1246     * @brief Get standby state.
1247     *
1248     * @param sessionId Specifies which stream to be check.
1249     * @param isStandby true means the stream is in standby status.
1250     * @param enterStandbyTime Specifies when the stream enter standby status, in MONOTONIC time.
1251     * @return Returns {@link SUCCESS} if the operation is successfully.
1252     * @return Returns {@link ERR_ILLEGAL_STATE} if the server is not available.
1253     * @return Returns {@link ERR_INVALID_PARAM} if the sessionId is not exist.
1254     */
1255     int32_t GetStandbyStatus(uint32_t sessionId, bool &isStandby, int64_t &enterStandbyTime);
1256 
1257     /**
1258     * @brief Set App AVSession state change.
1259     *
1260     * @param uid Specifies uid of app.
1261     * @param pid Specifies pid of app.
1262     * @param hasSession Specifies whether app has AVSession.
1263     * @return Returns {@link SUCCESS} if the settings is successfully; otherwise, returns an error code defined
1264     * in {@link audio_errors.h}.
1265     */
1266     int32_t NotifySessionStateChange(const int32_t uid, const int32_t pid, const bool hasSession);
1267 
1268     /**
1269     * @brief Set App Freeze state change.
1270     *
1271     * @param pidList Specifies all pid list to change state.
1272     * @param isFreeze Specifies Freeze or Unfreeze state.
1273     * @return Returns {@link SUCCESS} if the settings is successfully; otherwise, returns an error code defined
1274     * in {@link audio_errors.h}.
1275     */
1276     int32_t NotifyFreezeStateChange(const std::set<int32_t> &pidList, const bool isFreeze);
1277 
1278     /**
1279     * @brief RSS reboot reset all proxy Freeze state change.
1280     *
1281     * @return Returns {@link SUCCESS} if the settings is successfully; otherwise, returns an error code defined
1282     * in {@link audio_errors.h}.
1283     */
1284     int32_t ResetAllProxy();
1285 
1286     /**
1287     * @brief Notify process background state.
1288     *
1289     * @param uid Specifies uid of app.
1290     * @param pid Specifies pid of app.
1291     * @return Returns {@link SUCCESS} if the settings is successfully; otherwise, returns an error code defined
1292     * in {@link audio_errors.h}.
1293     */
1294     int32_t NotifyProcessBackgroundState(const int32_t uid, const int32_t pid);
1295 
1296     /**
1297      * @brief Set render whitelist.
1298      *
1299      * @param list render whitelist.
1300      * @return Returns {@link SUCCESS} if the operation is successfully.
1301      * @return Returns {@link ERR_ILLEGAL_STATE} if the server is not available.
1302      * @return Returns {@link ERR_INVALID_PARAM} if the sessionId is not exist.
1303      */
1304     int32_t SetRenderWhitelist(std::vector<std::string> list);
1305 
1306 #ifdef HAS_FEATURE_INNERCAPTURER
1307     /**
1308     * @brief check capture limit
1309     *
1310     * @param AudioPlaybackCaptureConfig inner capture filter info
1311     * @param innerCapId unique identifier of inner capture
1312     * @return Returns {@link SUCCESS} if the operation is successfully.
1313     * @test
1314     */
1315     int32_t CheckCaptureLimit(const AudioPlaybackCaptureConfig &config, int32_t &innerCapId);
1316 
1317     /**
1318     * @brief release capture limit
1319     *
1320     * @param innerCapId unique identifier of inner capture
1321     * @return Returns {@link SUCCESS} if the operation is successfully.
1322     * @test
1323     */
1324     int32_t ReleaseCaptureLimit(int32_t innerCapId);
1325 #endif
1326 
1327     int32_t GenerateSessionId(uint32_t &sessionId);
1328     int32_t SetAudioInterruptCallback(const uint32_t sessionID, const std::shared_ptr<AudioInterruptCallback> &callback,
1329         uint32_t clientUid, const int32_t zoneID);
1330     int32_t UnsetAudioInterruptCallback(const int32_t zoneId, const uint32_t sessionId);
1331 
1332     int32_t SetVirtualCall(const bool isVirtual);
1333 
1334     int32_t OnVoiceWakeupState(bool state);
1335 
1336     uint16_t GetDmDeviceType() const;
1337     /**
1338      * @brief Get the maximum volume level for the specified stream usage.
1339      *
1340      * @param streamUsage Specifies the stream usage.
1341      * @return Returns the maximum volume level for the specified stream usage.
1342      * @since 20
1343      */
1344     int32_t GetMaxVolumeByUsage(StreamUsage streamUsage);
1345 
1346     /**
1347      * @brief Get the minimum volume level for the specified stream usage.
1348      *
1349      * @param streamUsage Specifies the stream usage.
1350      * @return Returns the minimum volume level for the specified stream usage.
1351      * @since 20
1352      */
1353     int32_t GetMinVolumeByUsage(StreamUsage streamUsage);
1354 
1355     /**
1356      * @brief Get the current volume level for the specified stream usage.
1357      *
1358      * @param streamUsage Specifies the stream usage.
1359      * @return Returns the current volume level for the specified stream usage.
1360      * @since 20
1361      */
1362     int32_t GetVolumeByUsage(StreamUsage streamUsage);
1363 
1364     /**
1365      * @brief Get the mute state of the specified stream usage.
1366      *
1367      * @param streamUsage Specifies the stream usage.
1368      * @param isMute Specifies the mute state.
1369      * @return Returns {@link SUCCESS} if the operation is successful; returns an error code defined
1370      * in {@link audio_errors.h} otherwise.
1371      * @since 20
1372      */
1373     int32_t IsStreamMuteByUsage(StreamUsage streamUsage, bool &isMute);
1374 
1375     /**
1376      * @brief Get the volume in unit of db by streamUsage.
1377      *
1378      * @param streamUsage Specifies the stream usage.
1379      * @param volumeLevel Specifies the volume level.
1380      * @param deviceType Specifies the device type.
1381      * @return Returns current volume in unit of db by streamUsage
1382      * @since 20
1383      */
1384     float GetVolumeInDbByStream(StreamUsage streamUsage, int32_t volumeLevel, DeviceType deviceType);
1385 
1386     /**
1387      * @brief Get supported audio volume types.
1388      *
1389      * @return Returns current supported audio volume types
1390      * @since 20
1391      */
1392     std::vector<AudioVolumeType>GetSupportedAudioVolumeTypes();
1393 
1394     /**
1395      * @brief Get the audioVolumeType that streamUsage belongs.
1396      *
1397      * @param streamUsage Specifies the stream usage.
1398      * @return Returns the audioVolumeType that streamUsage belongs
1399      * @since 20
1400      */
1401     AudioVolumeType GetAudioVolumeTypeByStreamUsage(StreamUsage streamUsage);
1402 
1403     /**
1404      * @brief Get the streamUsages contained in audioVolumeType
1405      *
1406      * @param audioVolumeType Specifies the audio volume type.
1407      * @return Returns the streamUsages contained in audioVolumeType
1408      * @since 20
1409      */
1410     std::vector<StreamUsage> GetStreamUsagesByVolumeType(AudioVolumeType audioVolumeType);
1411 
1412     /**
1413      * @brief registers the StreamVolumeChange callback listener
1414      *
1415      * @return Returns {@link SUCCESS} if callback registration is successful; returns an error code
1416      * defined in {@link audio_errors.h} otherwise.
1417      * @since 20
1418      */
1419     int32_t RegisterStreamVolumeChangeCallback(const int32_t clientPid, const std::set<StreamUsage> &streamUsages,
1420         const std::shared_ptr<StreamVolumeChangeCallback> &callback);
1421 
1422     /**
1423      * @brief Unregisters the StreamVolumeChange callback listener
1424      *
1425      * @return Returns {@link SUCCESS} if callback unregistration is successful; returns an error code
1426      * defined in {@link audio_errors.h} otherwise.
1427      * @since 20
1428      */
1429     int32_t UnregisterStreamVolumeChangeCallback(const int32_t clientPid,
1430         const std::shared_ptr<StreamVolumeChangeCallback> &callback = nullptr);
1431 
1432     /**
1433     * @brief create audio workgroup
1434     *
1435     * @return Returns id of workgroup. id < 0 if failed.
1436     * @test
1437     */
1438     int32_t CreateAudioWorkgroup();
1439 
1440     /**
1441     * @brief release audio workgroup.
1442     *
1443     * @param workgroupId audio workgroup id.
1444     * @return Returns {@link AUDIO_OK} if the operation is successfully.
1445     * @test
1446     */
1447     int32_t ReleaseAudioWorkgroup(int32_t workgroupId);
1448 
1449     /**
1450     * @brief add thread to audio workgroup.
1451     *
1452     * @param workgroupId workgroupId audio workgroup id.
1453     * @param tokenId the thread id of add workgroupId.
1454     * @return Returns {@link AUDIO_OK} if the operation is successfully.
1455     * @test
1456     */
1457     int32_t AddThreadToGroup(int32_t workgroupId, int32_t tokenId);
1458 
1459     /**
1460     * @brief remove thread to audio workgroup.y
1461     *
1462     * @param workgroupId workgroupId audio workgroup id.
1463     * @param tokenId the thread id of remove workgroupId.
1464     * @return Returns {@link AUDIO_OK} if the operation is successfully.
1465     * @test
1466     */
1467     int32_t RemoveThreadFromGroup(int32_t workgroupId, int32_t tokenId);
1468 
1469     /**
1470     * @brief the deadline workgroup starts to take effect.
1471     *
1472     * @param workgroupId workgroupId audio workgroup id.
1473     * @param startTime timestamp when the deadline task starts to be executed.
1474     * @param deadlineTime complete a periodic task within the time specified by deadlineTime.
1475     * @return Returns {@link AUDIO_OK} if the operation is successfully.
1476     * @test
1477     */
1478     int32_t StartGroup(int32_t workgroupId, uint64_t startTime, uint64_t deadlineTime,
1479         std::unordered_map<int32_t, bool> threads, bool &needUpdatePrio);
1480 
1481     /**
1482     * @brief stop the deadline workgroup.
1483     *
1484     * @param workgroupId workgroupId audio workgroup id.
1485     * @return Returns {@link AUDIO_OK} if the operation is successfully.
1486     * @test
1487     */
1488     int32_t StopGroup(int32_t workgroupId);
1489 
1490     /**
1491     * @brief set focus stream type when process volume key event.
1492     *
1493     * @param volumeType Audio stream type.
1494     * @param duration duration time to last or cancel force type.
1495     * @return Returns {@link AUDIO_OK} if the operation is successfully.
1496     * @test
1497     */
1498     int32_t ForceVolumeKeyControlType(AudioVolumeType volumeType, int32_t duration);
1499 
1500     class WorkgroupPrioRecorder {
1501     public:
1502         WorkgroupPrioRecorder(int32_t grpId);
1503         ~WorkgroupPrioRecorder() = default;
1504         void SetRestoreByPermission(bool isByPermission);
1505         bool GetRestoreByPermission();
1506         int32_t GetGrpId();
1507         void RecordThreadPrio(int32_t tokenId);
1508         int32_t RestoreGroupPrio(bool isByPermission);
1509         int32_t RestoreThreadPrio(int32_t tokenId);
1510     private:
1511         int32_t grpId_;
1512         std::unordered_map<int32_t, int32_t> threads_;
1513         bool restoreByPermission_;
1514         std::mutex workgroupThreadsMutex_;
1515     };
1516     std::shared_ptr<WorkgroupPrioRecorder> GetRecorderByGrpId(int32_t grpId);
1517     int32_t ExcuteAudioWorkgroupPrioImprove(int32_t workgroupId,
1518         const std::unordered_map<int32_t, bool> threads, bool &needUpdatePrio);
1519 
1520 private:
1521     class WakeUpCallbackImpl : public WakeUpSourceCallback {
1522     public:
WakeUpCallbackImpl(AudioSystemManager * audioSystemManager)1523         WakeUpCallbackImpl(AudioSystemManager *audioSystemManager)
1524             :audioSystemManager_(audioSystemManager)
1525         {
1526         }
OnCapturerState(bool isActive)1527         void OnCapturerState(bool isActive) override
1528         {
1529             auto callback = audioSystemManager_ -> audioCapturerSourceCallback_;
1530             if (callback != nullptr) {
1531                 callback -> OnCapturerState(isActive);
1532             }
1533         }
OnWakeupClose()1534         void OnWakeupClose() override
1535         {
1536             auto callback = audioSystemManager_ -> audioWakeUpSourceCloseCallback_;
1537             if (callback != nullptr) {
1538                 callback -> OnWakeupClose();
1539             }
1540         }
1541     private:
1542         AudioSystemManager *audioSystemManager_;
1543     };
1544 
1545     static constexpr int32_t MAX_VOLUME_LEVEL = 15;
1546     static constexpr int32_t MIN_VOLUME_LEVEL = 0;
1547     static constexpr int32_t CONST_FACTOR = 100;
1548     static const std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> streamTypeMap_;
1549 
1550     AudioSystemManager();
1551     virtual ~AudioSystemManager();
1552 
1553     static std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> CreateStreamMap();
1554     static void CreateStreamMap(std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> &streamMap);
1555     int32_t GetCallingPid() const;
1556     std::string GetSelfBundleName();
1557 
1558     int32_t RegisterWakeupSourceCallback();
1559     void OtherDeviceTypeCases(DeviceType deviceType) const;
1560     AudioPin GetPinValueForPeripherals(DeviceType deviceType, DeviceRole deviceRole, uint16_t dmDeviceType) const;
1561 
1562     int32_t cbClientId_ = -1;
1563     int32_t volumeChangeClientPid_ = -1;
1564     AudioRingerMode ringModeBackup_ = RINGER_MODE_NORMAL;
1565     std::shared_ptr<AudioManagerDeviceChangeCallback> deviceChangeCallback_ = nullptr;
1566     std::shared_ptr<AudioInterruptCallback> audioInterruptCallback_ = nullptr;
1567     std::shared_ptr<AudioRingerModeCallback> ringerModeCallback_ = nullptr;
1568     std::shared_ptr<AudioFocusInfoChangeCallback> audioFocusInfoCallback_ = nullptr;
1569     std::shared_ptr<AudioDistributedRoutingRoleCallback> audioDistributedRoutingRoleCallback_ = nullptr;
1570     std::vector<std::shared_ptr<AudioGroupManager>> groupManagerMap_;
1571     std::mutex ringerModeCallbackMutex_;
1572     std::mutex groupManagerMapMutex_;
1573 
1574     std::shared_ptr<AudioCapturerSourceCallback> audioCapturerSourceCallback_ = nullptr;
1575     std::shared_ptr<WakeUpSourceCloseCallback> audioWakeUpSourceCloseCallback_ = nullptr;
1576 
1577     std::shared_ptr<WakeUpCallbackImpl> remoteWakeUpCallback_;
1578 
1579     class AudioWorkgroupChangeCallbackImpl : public AudioWorkgroupChangeCallback {
1580     public:
AudioWorkgroupChangeCallbackImpl()1581         AudioWorkgroupChangeCallbackImpl() {};
~AudioWorkgroupChangeCallbackImpl()1582         ~AudioWorkgroupChangeCallbackImpl() {};
1583     private:
1584         void OnWorkgroupChange(const AudioWorkgroupChangeInfo &info) override;
1585     };
1586 
1587     std::mutex startGroupPermissionMapMutex_;
1588     std::unordered_map<uint32_t, std::unordered_map<uint32_t, bool>> startGroupPermissionMap_;
1589     void OnWorkgroupChange(const AudioWorkgroupChangeInfo &info);
1590     bool IsValidToStartGroup(int32_t workgroupId);
1591     bool hasSystemPermission_ = false;
1592     std::unordered_map<int32_t, std::shared_ptr<WorkgroupPrioRecorder>> workgroupPrioRecorderMap_;
1593     std::mutex workgroupPrioRecorderMutex_;
1594 };
1595 } // namespace AudioStandard
1596 } // namespace OHOS
1597 #endif // ST_AUDIO_SYSTEM_MANAGER_H