• 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_POLICY_SERVER_H
17 #define ST_AUDIO_POLICY_SERVER_H
18 
19 #include <mutex>
20 #include <pthread.h>
21 
22 #include "singleton.h"
23 #include "system_ability_definition.h"
24 #include "ipc_skeleton.h"
25 #include "system_ability.h"
26 #include "iservice_registry.h"
27 
28 #include "accesstoken_kit.h"
29 #include "perm_state_change_callback_customize.h"
30 #include "power_state_callback_stub.h"
31 #include "power_state_listener.h"
32 #include "common_event_subscriber.h"
33 #include "common_event_support.h"
34 
35 #include "bundle_mgr_interface.h"
36 #include "bundle_mgr_proxy.h"
37 
38 #include "audio_policy_service.h"
39 #include "audio_policy_utils.h"
40 #include "audio_stream_removed_callback.h"
41 #include "audio_interrupt_callback.h"
42 #include "audio_policy_stub.h"
43 #include "audio_server_death_recipient.h"
44 #include "audio_collaborative_service.h"
45 #include "audio_spatialization_service.h"
46 #include "audio_policy_server_handler.h"
47 #include "audio_interrupt_service.h"
48 #include "audio_device_manager.h"
49 #include "audio_policy_dump.h"
50 #include "app_state_listener.h"
51 #include "audio_core_service.h"
52 #include "audio_converter_parser.h"
53 
54 #ifdef USB_ENABLE
55 #include "audio_usb_manager.h"
56 #endif
57 
58 namespace OHOS {
59 namespace AudioStandard {
60 
61 class AudioPolicyService;
62 class AudioInterruptService;
63 class AudioPolicyServerHandler;
64 class AudioSessionService;
65 class BluetoothEventSubscriber;
66 
67 class AudioPolicyServer : public SystemAbility,
68                           public AudioPolicyStub,
69                           public AudioStreamRemovedCallback {
70     DECLARE_SYSTEM_ABILITY(AudioPolicyServer);
71 
72 public:
73     DISALLOW_COPY_AND_MOVE(AudioPolicyServer);
74 
75     enum DeathRecipientId {
76         TRACKER_CLIENT = 0,
77         LISTENER_CLIENT
78     };
79 
80     explicit AudioPolicyServer(int32_t systemAbilityId, bool runOnCreate = true);
81 
~AudioPolicyServer()82     virtual ~AudioPolicyServer()
83     {
84         AUDIO_WARNING_LOG("dtor should not happen");
85     };
86 
87     void OnDump() override;
88     void OnStart() override;
89     void OnStop() override;
90 
91     int32_t GetMaxVolumeLevel(int32_t volumeType, int32_t &volumeLevel, int32_t deviceType = -1) override;
92 
93     int32_t GetMinVolumeLevel(int32_t volumeType, int32_t &volumeLevel, int32_t deviceType = -1) override;
94 
95     int32_t SetSystemVolumeLevelLegacy(int32_t streamTypeIn, int32_t volumeLevel) override;
96 
97     int32_t SetSystemVolumeLevel(int32_t volumeType, int32_t volumeLevel, int32_t volumeFlag, int32_t uid) override;
98 
99     int32_t SetSystemVolumeLevelWithDevice(int32_t volumeType, int32_t volumeLevel, int32_t deviceType,
100         int32_t volumeFlag = 0) override;
101 
102     int32_t SetAppVolumeLevel(int32_t appUid, int32_t volumeLevel, int32_t volumeFlag) override;
103 
104     int32_t IsAppVolumeMute(int32_t appUid, bool owned, bool &isMute) override;
105 
106     int32_t SetAppVolumeMuted(int32_t appUid, bool muted, int32_t volumeFlag) override;
107 
108     int32_t SetAppRingMuted(int32_t appUid, bool muted) override;
109 
110     int32_t SetAdjustVolumeForZone(int32_t zoneId) override;
111 
112     int32_t SetSelfAppVolumeLevel(int32_t volumeLevel, int32_t volumeFlag) override;
113 
114     int32_t GetSystemActiveVolumeType(int32_t clientUid, int32_t &streamType) override;
115 
116     int32_t GetSystemVolumeLevel(int32_t streamType, int32_t uid, int32_t &volumeLevel) override;
117 
118     int32_t GetAppVolumeLevel(int32_t appUid, int32_t &volumeLevel) override;
119 
120     int32_t GetSelfAppVolumeLevel(int32_t &volumeLevel) override;
121 
122     int32_t SetLowPowerVolume(int32_t streamId, float volume) override;
123 
124     int32_t GetFastStreamInfo(AudioStreamInfo &streamInfo) override;
125 
126     int32_t GetLowPowerVolume(int32_t streamId, float &outVolume) override;
127 
128     int32_t GetSingleStreamVolume(int32_t streamId, float &outVolume) override;
129 
130     int32_t SetStreamMuteLegacy(int32_t streamType, bool mute,
131         int32_t deviceType) override;
132 
133     int32_t SetStreamMute(int32_t streamType, bool mute,
134         int32_t deviceType) override;
135 
136     int32_t GetStreamMute(int32_t streamType, bool &mute) override;
137 
138     int32_t IsStreamActive(int32_t streamType, bool &active) override;
139 
140     int32_t IsStreamActiveByStreamUsage(int32_t streamUsage, bool &active) override;
141 
142     int32_t IsFastPlaybackSupported(const AudioStreamInfo &streamInfo, int32_t usage, bool &support) override;
143     int32_t IsFastRecordingSupported(const AudioStreamInfo &streamInfo, int32_t source, bool &support) override;
144 
145     int32_t IsVolumeUnadjustable(bool &unadjustable) override;
146 
147     int32_t AdjustVolumeByStep(int32_t adjustType) override;
148 
149     int32_t AdjustSystemVolumeByStep(int32_t volumeType, int32_t adjustType) override;
150 
151     int32_t GetSystemVolumeInDb(int32_t volumeType, int32_t volumeLevel,
152         int32_t deviceType, float &volume) override;
153 
154     bool IsArmUsbDevice(const AudioDeviceDescriptor &desc);
155 
156     void MapExternalToInternalDeviceType(AudioDeviceDescriptor &desc);
157 
158     int32_t SelectOutputDevice(const sptr<AudioRendererFilter> &audioRendererFilter,
159         const std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors) override;
160 
161     int32_t GetSelectedDeviceInfo(int32_t uid, int32_t pid, int32_t streamType, std::string &info) override;
162 
163     int32_t SelectInputDevice(const sptr<AudioCapturerFilter> &audioCapturerFilter,
164         const std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors) override;
165 
166     int32_t ExcludeOutputDevices(int32_t audioDevUsage,
167         const std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors) override;
168 
169     int32_t UnexcludeOutputDevices(int32_t audioDevUsage,
170         const std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors) override;
171 
172     int32_t GetExcludedDevices(int32_t audioDevUsage,
173         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors) override;
174 
175     int32_t GetDevices(int32_t deviceFlag, std::vector<std::shared_ptr<AudioDeviceDescriptor>> &deviceDescs) override;
176 
177     int32_t GetDevicesInner(int32_t deviceFlag,
178         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &deviceDescs) override;
179 
180     int32_t SetDeviceActive(int32_t deviceType, bool active, int32_t uid) override;
181 
182     int32_t IsDeviceActive(int32_t deviceType, bool &active) override;
183 
184     int32_t GetActiveOutputDevice(int32_t &deviceType) override;
185 
186     int32_t GetDmDeviceType(uint16_t &deviceType) override;
187 
188     int32_t GetActiveInputDevice(int32_t &deviceType) override;
189 
190     int32_t SetRingerModeLegacy(int32_t ringMode) override;
191 
192     int32_t SetRingerMode(int32_t ringMode) override;
193 
194 #ifdef FEATURE_DTMF_TONE
195     int32_t GetSupportedTones(const std::string &countryCode, std::vector<int32_t> &throw_with_nested) override;
196 
197     int32_t GetToneConfig(int32_t ltonetype, const std::string &countryCode,
198         std::shared_ptr<ToneInfo> &config) override;
199 #endif
200 
201     int32_t GetRingerMode(int32_t &ringMode) override;
202 
203     int32_t SetAudioScene(int32_t audioScene) override;
204 
205     int32_t SetMicrophoneMuteCommon(bool isMute, bool isLegacy);
206 
207     int32_t SetMicrophoneMute(bool isMute) override;
208 
209     int32_t SetMicrophoneMuteAudioConfig(bool isMute) override;
210 
211     int32_t SetMicrophoneMutePersistent(bool isMute, int32_t type) override;
212 
213     int32_t GetPersistentMicMuteState(bool &mute) override;
214 
215     int32_t IsMicrophoneMuteLegacy(bool &mute) override;
216 
217     int32_t IsMicrophoneMute(bool &mute) override;
218 
219     int32_t GetAudioScene(int32_t &scene) override;
220 
221     int32_t ActivateAudioSession(int32_t strategy) override;
222 
223     int32_t DeactivateAudioSession() override;
224 
225     int32_t IsAudioSessionActivated(bool &active) override;
226 
227     int32_t SetAudioSessionScene(int32_t audioSessionScene) override;
228 
229     int32_t GetDefaultOutputDevice(int32_t &deviceType) override;
230 
231     int32_t SetDefaultOutputDevice(int32_t deviceType) override;
232 
233     int32_t SetAudioInterruptCallback(uint32_t sessionID,
234         const sptr<IRemoteObject> &object, uint32_t clientUid, int32_t zoneId) override;
235 
236     int32_t UnsetAudioInterruptCallback(uint32_t sessionID, int32_t zoneId) override;
237 
238     int32_t ActivateAudioInterrupt(const AudioInterrupt &audioInterrupt, int32_t zoneId,
239         bool isUpdatedAudioStrategy) override;
240 
241     int32_t SetAppConcurrencyMode(const int32_t appUid, const int32_t mode = 0) override;
242 
243     int32_t SetAppSlientOnDisplay(const int32_t displayId = -1) override;
244 
245     int32_t DeactivateAudioInterrupt(const AudioInterrupt &audioInterrupt, int32_t zoneId) override;
246 
247     int32_t SetAudioRouteCallback(uint32_t sessionId, const sptr<IRemoteObject> &object, uint32_t clientUid) override;
248 
249     int32_t UnsetAudioRouteCallback(uint32_t sessionId) override;
250 
251     int32_t ActivatePreemptMode(void) override;
252 
253     int32_t DeactivatePreemptMode(void) override;
254 
255     int32_t SetAudioManagerInterruptCallback(int32_t clientId, const sptr<IRemoteObject> &object) override;
256 
257     int32_t UnsetAudioManagerInterruptCallback(int32_t clientId) override;
258 
259     int32_t SetQueryClientTypeCallback(const sptr<IRemoteObject> &object) override;
260 
261     int32_t SetQueryDeviceVolumeBehaviorCallback(const sptr<IRemoteObject> &object) override;
262 
263     int32_t SetAudioClientInfoMgrCallback(const sptr<IRemoteObject> &object) override;
264 
265     int32_t SetAudioVKBInfoMgrCallback(const sptr<IRemoteObject> &object) override;
266 
267     int32_t CheckVKBInfo(const std::string &bundleName, bool &isValid) override;
268 
269     int32_t SetQueryBundleNameListCallback(const sptr<IRemoteObject> &object) override;
270 
271     int32_t RequestAudioFocus(int32_t clientId, const AudioInterrupt &audioInterrupt) override;
272 
273     int32_t AbandonAudioFocus(int32_t clientId, const AudioInterrupt &audioInterrupt) override;
274 
275     int32_t GetStreamInFocus(int32_t zoneId, int32_t &streamType) override;
276 
277     int32_t GetStreamInFocusByUid(int32_t uid, int32_t zoneId, int32_t &streamType) override;
278 
279     int32_t GetSessionInfoInFocus(AudioInterrupt &audioInterrupt, int32_t zoneId) override;
280 
281     void OnAudioStreamRemoved(const uint64_t sessionID) override;
282 
283     int32_t Dump(int32_t fd, const std::vector<std::u16string> &args) override;
284 
285     int32_t GetPreferredOutputStreamType(const AudioRendererInfo &rendererInfo, int32_t &streamType) override;
286 
287     int32_t GetPreferredInputStreamType(const AudioCapturerInfo &capturerInfo, int32_t &streamType) override;
288 
289     int32_t CreateRendererClient(const std::shared_ptr<AudioStreamDescriptor> &streamDesc,
290         uint32_t &flag, uint32_t &sessionId, std::string &networkId) override;
291 
292     int32_t CreateCapturerClient(
293         const std::shared_ptr<AudioStreamDescriptor> &streamDesc, uint32_t &flag, uint32_t &sessionId) override;
294 
295     int32_t RegisterTracker(int32_t mode, const AudioStreamChangeInfo &streamChangeInfo,
296         const sptr<IRemoteObject> &object) override;
297 
298     int32_t UpdateTracker(int32_t mode, const AudioStreamChangeInfo &streamChangeInfo) override;
299 
300     int32_t GetCurrentRendererChangeInfos(
301         std::vector<std::shared_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos) override;
302 
303     int32_t GetCurrentCapturerChangeInfos(
304         std::vector<std::shared_ptr<AudioCapturerChangeInfo>> &audioCapturerChangeInfos) override;
305 
306     void RegisterClientDeathRecipient(const sptr<IRemoteObject> &object, DeathRecipientId id);
307 
308     void RegisteredTrackerClientDied(int pid, int uid);
309 
310     void RegisteredStreamListenerClientDied(int pid, int uid);
311 
312     int32_t ResumeStreamState();
313 
314     int32_t UpdateStreamState(int32_t clientUid, int32_t streamSetState,
315         int32_t streamUsage) override;
316 
317     int32_t GetVolumeGroupInfos(const std::string &networkId, std::vector<sptr<VolumeGroupInfo>> &infos) override;
318 
319     int32_t GetSupportedAudioEffectProperty(AudioEffectPropertyArrayV3 &propertyArray) override;
320     int32_t SetAudioEffectProperty(const AudioEffectPropertyArrayV3 &propertyArray) override;
321     int32_t GetAudioEffectProperty(AudioEffectPropertyArrayV3 &propertyArray) override;
322 
323     int32_t GetSupportedAudioEffectProperty(AudioEffectPropertyArray &propertyArray) override;
324     int32_t GetSupportedAudioEnhanceProperty(AudioEnhancePropertyArray &propertyArray) override;
325     int32_t SetAudioEffectProperty(const AudioEffectPropertyArray &propertyArray) override;
326     int32_t GetAudioEffectProperty(AudioEffectPropertyArray &propertyArray) override;
327     int32_t SetAudioEnhanceProperty(const AudioEnhancePropertyArray &propertyArray) override;
328     int32_t GetAudioEnhanceProperty(AudioEnhancePropertyArray &propertyArray) override;
329 
330     int32_t IsAcousticEchoCancelerSupported(int32_t sourceType, bool &ret) override;
331     int32_t IsAudioLoopbackSupported(int32_t mode, bool &ret) override;
332     int32_t SetKaraokeParameters(const std::string &parameters, bool &ret) override;
333 
334     int32_t GetNetworkIdByGroupId(int32_t groupId, std::string &networkId) override;
335 
336     int32_t GetPreferredOutputDeviceDescriptors(const AudioRendererInfo &rendererInfo, bool forceNoBTPermission,
337         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &deviceDescs) override;
338 
339     int32_t GetPreferredInputDeviceDescriptors(const AudioCapturerInfo &captureInfo,
340         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &deviceDescs) override;
341 
342     int32_t GetOutputDevice(const sptr<AudioRendererFilter> &audioRendererFilter,
343         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &deviceDescs) override;
344 
345     int32_t GetInputDevice(const sptr<AudioCapturerFilter> &audioCapturerFilter,
346         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &deviceDescs) override;
347 
348     int32_t SetClientCallbacksEnable(int32_t callbackchange, bool enable) override;
349 
350     int32_t SetCallbackRendererInfo(const AudioRendererInfo &rendererInfo) override;
351 
352     int32_t SetCallbackCapturerInfo(const AudioCapturerInfo &capturerInfo) override;
353 
354     int32_t GetAudioFocusInfoList(std::vector<std::map<AudioInterrupt, int32_t>> &focusInfoList,
355         int32_t zoneId) override;
356 
357     int32_t SetSystemSoundUri(const std::string &key, const std::string &uri) override;
358 
359     int32_t GetSystemSoundUri(const std::string &key, std::string &uri) override;
360 
361     int32_t GetMinStreamVolume(float &volume) override;
362 
363     int32_t GetMaxStreamVolume(float &volume) override;
364 
365     int32_t GetMaxRendererInstances(int32_t &ret) override;
366 
367     void GetStreamVolumeInfoMap(StreamVolumeInfoMap &streamVolumeInfos);
368 
369     int32_t QueryEffectSceneMode(SupportedEffectConfig &supportedEffectConfig) override;
370 
371     int32_t GetHardwareOutputSamplingRate(const std::shared_ptr<AudioDeviceDescriptor> &desc,
372         int32_t &ret) override;
373 
374     int32_t GetAudioCapturerMicrophoneDescriptors(int32_t sessionId,
375         std::vector<sptr<MicrophoneDescriptor>> &micDescs) override;
376 
377     int32_t GetAvailableMicrophones(std::vector<sptr<MicrophoneDescriptor>> &retMicList) override;
378 
379     int32_t SetDeviceAbsVolumeSupported(const std::string &macAddress, const bool support) override;
380 
381     int32_t IsAbsVolumeScene(bool &ret) override;
382 
383     int32_t SetA2dpDeviceVolume(const std::string &macAddress, int32_t volume, bool updateUi) override;
384 
385     int32_t SetNearlinkDeviceVolume(const std::string &macAddress, int32_t volumeType,
386         int32_t volume, bool updateUi) override;
387 
388     int32_t GetAvailableDevices(int32_t usage,
389         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &descs) override;
390 
391     int32_t SetAvailableDeviceChangeCallback(int32_t /*clientId*/, int32_t usage,
392         const sptr<IRemoteObject> &object) override;
393 
394     int32_t UnsetAvailableDeviceChangeCallback(int32_t clientId, int32_t usage) override;
395 
396     int32_t IsSpatializationEnabled(bool &ret) override;
397 
398     int32_t IsSpatializationEnabled(const std::string &address, bool &ret) override;
399 
400     int32_t IsSpatializationEnabledForCurrentDevice(bool &ret) override;
401 
402     int32_t SetSpatializationEnabled(const bool enable) override;
403 
404     int32_t SetSpatializationEnabled(const std::shared_ptr<AudioDeviceDescriptor> &selectedAudioDevice,
405         const bool enable) override;
406 
407     int32_t IsHeadTrackingEnabled(bool &ret) override;
408 
409     int32_t IsHeadTrackingEnabled(const std::string &address, bool &ret) override;
410 
411     int32_t SetHeadTrackingEnabled(const bool enable) override;
412 
413     int32_t SetHeadTrackingEnabled(
414         const std::shared_ptr<AudioDeviceDescriptor> &selectedAudioDevice, const bool enable) override;
415 
416     int32_t GetSpatializationState(int32_t streamUsage, AudioSpatializationState &state) override;
417 
418     int32_t IsSpatializationSupported(bool &ret) override;
419 
420     int32_t IsSpatializationSupportedForDevice(const std::string &address, bool &ret) override;
421 
422     int32_t IsHeadTrackingSupported(bool &ret) override;
423 
424     int32_t IsHeadTrackingSupportedForDevice(const std::string &address, bool &ret) override;
425 
426     int32_t UpdateSpatialDeviceState(const AudioSpatialDeviceState &audioSpatialDeviceState) override;
427 
428     int32_t RegisterSpatializationStateEventListener(uint32_t sessionID, int32_t streamUsage,
429         const sptr<IRemoteObject> &object) override;
430 
431     int32_t ConfigDistributedRoutingRole(
432         const std::shared_ptr<AudioDeviceDescriptor> &descriptor, int32_t type) override;
433 
434     int32_t SetDistributedRoutingRoleCallback(const sptr<IRemoteObject> &object) override;
435 
436     int32_t UnsetDistributedRoutingRoleCallback() override;
437 
438     int32_t UnregisterSpatializationStateEventListener(uint32_t sessionID) override;
439 
440     int32_t RegisterPolicyCallbackClient(const sptr<IRemoteObject> &object, int32_t zoneId) override;
441 
442     int32_t CreateAudioInterruptZone(const std::set<int32_t> &pids, int32_t zoneId) override;
443 
444     int32_t AddAudioInterruptZonePids(const std::set<int32_t> &pids, int32_t zoneId) override;
445 
446     int32_t RemoveAudioInterruptZonePids(const std::set<int32_t> &pids, int32_t zoneId) override;
447 
448     int32_t ReleaseAudioInterruptZone(int32_t zoneId) override;
449 
450     int32_t RegisterAudioZoneClient(const sptr<IRemoteObject> &object) override;
451 
452     int32_t CreateAudioZone(const std::string &name, const AudioZoneContext &context, int32_t &zoneId,
453         int32_t pid) override;
454 
455     int32_t ReleaseAudioZone(int32_t zoneId) override;
456 
457     int32_t GetAllAudioZone(std::vector<std::shared_ptr<AudioZoneDescriptor>> &descs) override;
458 
459     int32_t GetAudioZone(int32_t zoneId, std::shared_ptr<AudioZoneDescriptor> &desc) override;
460 
461     int32_t GetAudioZoneByName(const std::string &name, int32_t &zoneId) override;
462 
463     int32_t BindDeviceToAudioZone(int32_t zoneId,
464         const std::vector<std::shared_ptr<AudioDeviceDescriptor>> &devices) override;
465 
466     int32_t UnBindDeviceToAudioZone(int32_t zoneId,
467         const std::vector<std::shared_ptr<AudioDeviceDescriptor>> &devices) override;
468 
469     int32_t EnableAudioZoneReport (bool enable) override;
470 
471     int32_t EnableAudioZoneChangeReport(int32_t zoneId, bool enable) override;
472 
473     int32_t AddUidToAudioZone(int32_t zoneId, int32_t uid) override;
474 
475     int32_t RemoveUidFromAudioZone(int32_t zoneId, int32_t uid) override;
476 
477     int32_t EnableSystemVolumeProxy(int32_t zoneId, bool enable) override;
478 
479     int32_t AddStreamToAudioZone(int32_t zoneId, const AudioZoneStream &stream) override;
480 
481     int32_t AddStreamsToAudioZone(int32_t zoneId, const std::vector<AudioZoneStream> &streams) override;
482 
483     int32_t RemoveStreamFromAudioZone(int32_t zoneId, const AudioZoneStream &stream) override;
484 
485     int32_t RemoveStreamsFromAudioZone(int32_t zoneId, const std::vector<AudioZoneStream> &streams) override;
486 
487     int32_t SetZoneDeviceVisible(bool visible) override;
488 
489     int32_t GetAudioInterruptForZone(int32_t zoneId,
490         std::vector<std::map<AudioInterrupt, int32_t>> &retList) override;
491 
492     int32_t GetAudioInterruptForZone(int32_t zoneId, const std::string &deviceTag,
493         std::vector<std::map<AudioInterrupt, int32_t>> &retList) override;
494 
495     int32_t EnableAudioZoneInterruptReport(int32_t zoneId, const std::string &deviceTag, bool enable) override;
496 
497     int32_t InjectInterruptToAudioZone(int32_t zoneId,
498         const std::vector<std::map<AudioInterrupt, int32_t>> &interrupts) override;
499 
500     int32_t InjectInterruptToAudioZone(int32_t zoneId, const std::string &deviceTag,
501         const std::vector<std::map<AudioInterrupt, int32_t>> &interrupts) override;
502 
503     int32_t SetCallDeviceActive(int32_t deviceType, bool active, const std::string &address,
504         int32_t uid) override;
505 
506     int32_t GetActiveBluetoothDevice(std::shared_ptr<AudioDeviceDescriptor> &descs) override;
507 
508     int32_t GetConverterConfig(ConverterConfig &cfg) override;
509 
510     int32_t FetchOutputDeviceForTrack(const AudioStreamChangeInfo &streamChangeInfo,
511         const AudioStreamDeviceChangeReasonExt &reason) override;
512 
513     int32_t FetchInputDeviceForTrack(const AudioStreamChangeInfo &streamChangeInfo) override;
514 
515     int32_t GetSpatializationSceneType(int32_t &type) override;
516 
517     int32_t SetSpatializationSceneType(int32_t spatializationSceneType) override;
518 
519     int32_t GetMaxAmplitude(int32_t deviceId, float &ret) override;
520 
521     int32_t DisableSafeMediaVolume() override;
522 
523     int32_t IsHeadTrackingDataRequested(const std::string &macAddress, bool &ret) override;
524 
525     int32_t SetAudioDeviceRefinerCallback(const sptr<IRemoteObject> &object) override;
526 
527     int32_t UnsetAudioDeviceRefinerCallback() override;
528 
529     int32_t TriggerFetchDevice(
530         const AudioStreamDeviceChangeReasonExt &reason) override;
531 
532     int32_t SetPreferredDevice(int32_t preferredType,
533         const std::shared_ptr<AudioDeviceDescriptor> &desc, int32_t uid) override;
534 
535     int32_t SetDeviceVolumeBehavior(const std::string &networkId, int32_t deviceType,
536         const VolumeBehavior &volumeBehavior) override;
537 
538     int32_t SetAudioDeviceAnahsCallback(const sptr<IRemoteObject> &object) override;
539 
540     int32_t UnsetAudioDeviceAnahsCallback() override;
541 
542     int32_t MoveToNewPipe(uint32_t sessionId, int32_t pipeType) override;
543 
544     int32_t InjectInterruption(const std::string &networkId, const InterruptEvent &event) override;
545 
546     int32_t SetInputDevice(int32_t deviceType, uint32_t sessionID, int32_t sourceType, bool isRunning) override;
547 
548     int32_t LoadSplitModule(const std::string &splitArgs, const std::string &networkId) override;
549 
550     int32_t IsAllowedPlayback(int32_t uid, int32_t pid, bool &isAllowed) override;
551 
552     int32_t SetVoiceRingtoneMute(bool isMute) override;
553 
554     int32_t NotifySessionStateChange(int32_t uid, int32_t pid, bool hasSession) override;
555 
556     int32_t NotifyFreezeStateChange(const std::set<int32_t> &pidList, bool isFreeze) override;
557 
558     int32_t ResetAllProxy() override;
559 
560     int32_t NotifyProcessBackgroundState(int32_t uid, int32_t pid) override;
561 
562     int32_t SetVirtualCall(bool isVirtual) override;
563 
564     int32_t SetDeviceConnectionStatus(const std::shared_ptr<AudioDeviceDescriptor> &desc, bool isConnected) override;
565 
566     int32_t SetQueryAllowedPlaybackCallback(const sptr<IRemoteObject> &object) override;
567 
568     int32_t SetBackgroundMuteCallback(const sptr<IRemoteObject> &object) override;
569 
570     int32_t GetDirectPlaybackSupport(const AudioStreamInfo &streamInfo, int32_t streamUsage, int32_t &retMod) override;
571 
572     int32_t GetMaxVolumeLevelByUsage(int32_t streamUsage, int32_t &retMaxVolumeLevel) override;
573 
574     int32_t GetMinVolumeLevelByUsage(int32_t streamUsage, int32_t &retMinVolumeLevel) override;
575 
576     int32_t GetVolumeLevelByUsage(int32_t streamUsage, int32_t &retVolumeLevel) override;
577 
578     int32_t GetStreamMuteByUsage(int32_t streamUsage, bool &isMute) override;
579 
580     int32_t GetVolumeInDbByStream(int32_t streamUsage, int32_t volumeLevel,
581         int32_t deviceType, float &ret) override;
582 
583     int32_t GetSupportedAudioVolumeTypes(std::vector<int32_t> &ret) override;
584 
585     int32_t GetAudioVolumeTypeByStreamUsage(int32_t streamUsage, int32_t &volumeType) override;
586 
587     int32_t GetStreamUsagesByVolumeType(int32_t audioVolumeType, std::vector<int32_t> &ret) override;
588 
589     int32_t SetCallbackStreamUsageInfo(const std::set<int32_t> &streamUsages) override;
590 
591     int32_t ForceStopAudioStream(int32_t audioType) override;
592 
593     int32_t IsCapturerFocusAvailable(const AudioCapturerInfo &capturerInfo, bool &ret) override;
594 
595     int32_t ForceVolumeKeyControlType(int32_t volumeType, int32_t duration, int32_t &ret) override;
596 
597     void ProcessRemoteInterrupt(std::set<int32_t> sessionIds, InterruptEventInternal interruptEvent);
598     std::set<int32_t> GetStreamIdsForAudioSessionByStreamUsage(
599         const int32_t zoneId, const std::set<StreamUsage> &streamUsageSet);
600 
601     void SendVolumeKeyEventCbWithUpdateUiOrNot(AudioStreamType streamType, const bool& isUpdateUi = false,
602         int32_t zoneId = 0);
603     void SendMuteKeyEventCbWithUpdateUiOrNot(AudioStreamType streamType, const bool& isUpdateUi = false,
604         int32_t zoneId = 0);
605     void UpdateMuteStateAccordingToVolLevel(AudioStreamType streamType, int32_t volumeLevel,
606         bool mute, const bool& isUpdateUi = false, int32_t zoneId = 0);
607 
608     void ProcUpdateRingerMode();
609     uint32_t TranslateErrorCode(int32_t result);
610 
611     int32_t SetCollaborativePlaybackEnabledForDevice(
612         const std::shared_ptr<AudioDeviceDescriptor> &selectedAudioDevice, bool enabled) override;
613 
614     int32_t IsCollaborativePlaybackEnabledForDevice(
615         const std::shared_ptr<AudioDeviceDescriptor> &selectedAudioDevice, bool &enabled) override;
616 
617     int32_t IsCollaborativePlaybackSupported(bool &ret) override;
618 
619     class RemoteParameterCallback : public AudioParameterCallback {
620     public:
621         RemoteParameterCallback(sptr<AudioPolicyServer> server);
622         // AudioParameterCallback
623         void OnAudioParameterChange(const std::string networkId, const AudioParamKey key, const std::string &condition,
624             const std::string &value) override;
625     private:
626         sptr<AudioPolicyServer> server_;
627         void VolumeOnChange(const std::string networkId, const std::string &condition);
628         void InterruptOnChange(const std::string networkId, const std::string &condition);
629         void StateOnChange(const std::string networkId, const std::string &condition, const std::string &value);
630     };
631 
632     std::shared_ptr<RemoteParameterCallback> remoteParameterCallback_;
633 
634     class PerStateChangeCbCustomizeCallback : public Security::AccessToken::PermStateChangeCallbackCustomize {
635     public:
PerStateChangeCbCustomizeCallback(const Security::AccessToken::PermStateChangeScope & scopeInfo,sptr<AudioPolicyServer> server)636         explicit PerStateChangeCbCustomizeCallback(const Security::AccessToken::PermStateChangeScope &scopeInfo,
637             sptr<AudioPolicyServer> server) : PermStateChangeCallbackCustomize(scopeInfo),
638             ready_(false), server_(server) {}
~PerStateChangeCbCustomizeCallback()639         ~PerStateChangeCbCustomizeCallback() {}
640 
641         void PermStateChangeCallback(Security::AccessToken::PermStateChangeInfo &result);
642         void UpdateMicPrivacyByCapturerState(bool targetMuteState, uint32_t targetTokenId, int32_t appUid);
643 
644         bool ready_;
645     private:
646         sptr<AudioPolicyServer> server_;
647     };
648 
649     int32_t IsHighResolutionExist(bool &ret) override;
650 
651     int32_t SetHighResolutionExist(bool highResExist) override;
652 
653     void NotifyAccountsChanged(const int &id);
654     void SendVolumeKeyEventToRssWhenAccountsChanged();
655 
656     // for hidump
657     void AudioDevicesDump(std::string &dumpString);
658     void AudioModeDump(std::string &dumpString);
659     void AudioInterruptZoneDump(std::string &dumpString);
660     void AudioPolicyParserDump(std::string &dumpString);
661     void AudioVolumeDump(std::string &dumpString);
662     void AudioStreamDump(std::string &dumpString);
663     void OffloadStatusDump(std::string &dumpString);
664     void XmlParsedDataMapDump(std::string &dumpString);
665     void EffectManagerInfoDump(std::string &dumpString);
666     void MicrophoneMuteInfoDump(std::string &dumpString);
667     void AudioSessionInfoDump(std::string &dumpString);
668     void AudioPipeManagerDump(std::string &dumpString);
669     void SelectDeviceDump(std::string &dumpString);
670 
671     // for hibernate callback
672     void CheckHibernateState(bool hibernate);
673     // for S4 reboot update safevolume
674     void UpdateSafeVolumeByS4();
675 
676     void CheckConnectedDevice();
677     void SetDeviceConnectedFlagFalseAfterDuration();
678 
679     int32_t UpdateDeviceInfo(const std::shared_ptr<AudioDeviceDescriptor> &deviceDesc, int32_t command) override;
680     int32_t SetSleAudioOperationCallback(const sptr<IRemoteObject> &object) override;
681     int32_t CallRingtoneLibrary();
682     int32_t SetSystemVolumeDegree(int32_t streamType, int32_t volumeDegree, int32_t volumeFlag, int32_t uid) override;
683     int32_t GetSystemVolumeDegree(int32_t streamType, int32_t uid, int32_t &volumeDegree) override;
684     int32_t GetMinVolumeDegree(int32_t volumeType, int32_t &volumeDegree) override;
685 protected:
686     void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
687     void RegisterParamCallback();
688 
689     void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
690     int32_t GetApiTargetVersion();
691 
692 private:
693     int32_t SetSystemVolumeDegreeInner(AudioStreamType streamType, int32_t volumeDegree,
694         bool isUpdateUi, int32_t uid);
695 
696     friend class AudioInterruptService;
697 
698     static constexpr int32_t MAX_VOLUME_LEVEL = 15;
699     static constexpr int32_t MIN_VOLUME_LEVEL = 0;
700     static constexpr int32_t VOLUME_CHANGE_FACTOR = 1;
701     static constexpr int32_t VOLUME_KEY_DURATION = 0;
702     static constexpr int32_t VOLUME_MUTE_KEY_DURATION = 0;
703     static constexpr int32_t MEDIA_SERVICE_UID = 1013;
704     static constexpr int32_t EDM_SERVICE_UID = 3057;
705     static constexpr char DAUDIO_DEV_TYPE_SPK = '1';
706     static constexpr char DAUDIO_DEV_TYPE_MIC = '2';
707     static constexpr int32_t AUDIO_UID = 1041;
708     static constexpr uint32_t MICPHONE_CALLER = 0;
709     static constexpr int32_t ROOT_UID = 0;
710     static constexpr int32_t PREEMPT_UID = 7015;
711 
712     static const std::list<uid_t> RECORD_ALLOW_BACKGROUND_LIST;
713     static const std::list<uid_t> RECORD_PASS_APPINFO_LIST;
714     static constexpr const char* MICROPHONE_CONTROL_PERMISSION = "ohos.permission.MICROPHONE_CONTROL";
715 
716     class AudioPolicyServerPowerStateCallback : public PowerMgr::PowerStateCallbackStub {
717     public:
718         AudioPolicyServerPowerStateCallback(AudioPolicyServer *policyServer);
719         void OnAsyncPowerStateChanged(PowerMgr::PowerState state) override;
720 
721     private:
722         AudioPolicyServer *policyServer_;
723     };
724 
725     int32_t VerifyVoiceCallPermission(uint64_t fullTokenId, Security::AccessToken::AccessTokenID tokenId);
726 
727     // offload session
728     void CheckSubscribePowerStateChange();
729     bool CheckAudioSessionStrategy(const AudioSessionStrategy &sessionStrategy);
730 
731     // for audio volume and mute status
732     int32_t SetRingerModeInternal(AudioRingerMode inputRingerMode, bool hasUpdatedVolume = false);
733     int32_t SetSystemVolumeLevelInternal(AudioStreamType streamType, int32_t volumeLevel,
734         bool isUpdateUi, int32_t zoneId = 0);
735     int32_t SetAppVolumeLevelInternal(int32_t appUid, int32_t volumeLevel, bool isUpdateUi);
736     int32_t SetAppVolumeMutedInternal(int32_t appUid, bool muted, bool isUpdateUi);
737     int32_t SetAppRingMutedInternal(int32_t appUid, bool muted);
738     int32_t SetSystemVolumeLevelWithDeviceInternal(AudioStreamType streamType, int32_t volumeLevel,
739         bool isUpdateUi, DeviceType deviceType);
740     int32_t SetSingleStreamVolume(AudioStreamType streamType, int32_t volumeLevel, bool isUpdateUi,
741         bool mute, int32_t zoneId = 0);
742     int32_t SetAppSingleStreamVolume(int32_t streamType, int32_t volumeLevel, bool isUpdateUi);
743     int32_t SetSingleStreamVolumeWithDevice(AudioStreamType streamType, int32_t volumeLevel, bool isUpdateUi,
744         DeviceType deviceType);
745     AudioStreamType GetSystemActiveVolumeTypeInternal(const int32_t clientUid);
746     int32_t GetSystemVolumeLevelInternal(AudioStreamType streamType, int32_t zoneId = 0);
747     int32_t GetAppVolumeLevelInternal(int32_t appUid, int32_t &volumeLevel);
748     int32_t GetSystemVolumeLevelNoMuteState(AudioStreamType streamType);
749     float GetSystemVolumeDb(AudioStreamType streamType);
750     int32_t SetStreamMuteInternal(AudioStreamType streamType, bool mute, bool isUpdateUi,
751         const DeviceType &deviceType = DEVICE_TYPE_NONE, int32_t zoneId = 0);
752     void UpdateSystemMuteStateAccordingMusicState(AudioStreamType streamType, bool mute, bool isUpdateUi);
753     void ProcUpdateRingerModeForMute(bool updateRingerMode, bool mute);
754     int32_t SetSingleStreamMute(AudioStreamType streamType, bool mute, bool isUpdateUi,
755         const DeviceType &deviceType = DEVICE_TYPE_NONE, int32_t zoneId = 0);
756     bool GetStreamMuteInternal(AudioStreamType streamType, int32_t zoneId = 0);
757     bool IsVolumeTypeValid(AudioStreamType streamType);
758     bool IsVolumeLevelValid(AudioStreamType streamType, int32_t volumeLevel);
759     bool IsRingerModeValid(AudioRingerMode ringMode);
760     bool CheckCanMuteVolumeTypeByStep(AudioVolumeType volumeType, int32_t volumeLevel);
761 
762     // Permission and privacy
763     bool VerifyPermission(const std::string &permission, uint32_t tokenId = 0, bool isRecording = false);
764     bool VerifyBluetoothPermission();
765     int32_t OffloadStopPlaying(const AudioInterrupt &audioInterrupt);
766     int32_t SetAudioSceneInternal(AudioScene audioScene, const int32_t uid = INVALID_UID,
767         const int32_t pid = INVALID_PID);
768     bool VerifySessionId(uint32_t sessionId, uint32_t clientUid);
769 
770     // externel function call
771 #ifdef FEATURE_MULTIMODALINPUT_INPUT
772     bool MaxOrMinVolumeOption(const int32_t &volLevel, const int32_t keyType, const AudioStreamType &streamInFocus);
773     int32_t RegisterVolumeKeyEvents(const int32_t keyType);
774     int32_t RegisterVolumeKeyMuteEvents();
775     void SubscribeVolumeKeyEvents();
776     bool IsContinueAddVol();
777     void TriggerMuteCheck();
778     int32_t ProcessVolumeKeyEvents(const int32_t keyType);
779 #endif
780     void AddAudioServiceOnStart();
781     void SubscribeOsAccountChangeEvents();
782     void SubscribePowerStateChangeEvents();
783     void SubscribeCommonEvent(const std::string event);
784     void OnReceiveEvent(const EventFwk::CommonEventData &eventData);
785     void HandleKvDataShareEvent();
786     void InitMicrophoneMute();
787     void InitKVStore();
788     void NotifySettingsDataReady();
789     void ConnectServiceAdapter();
790     void LoadEffectLibrary();
791     void RegisterBluetoothListener();
792     void SubscribeAccessibilityConfigObserver();
793     void RegisterDataObserver();
794     void RegisterPowerStateListener();
795     void UnRegisterPowerStateListener();
796     void RegisterSyncHibernateListener();
797     void UnRegisterSyncHibernateListener();
798     void RegisterAppStateListener();
799     void AddRemoteDevstatusCallback();
800     void OnDistributedRoutingRoleChange(const std::shared_ptr<AudioDeviceDescriptor> descriptor, const CastType type);
801     void SubscribeSafeVolumeEvent();
802     void SubscribeCommonEventExecute();
803     void SubscribeBackgroundTask();
804     void SendMonitrtEvent(const int32_t keyType, int32_t resultOfVolumeKey);
805     void RegisterDefaultVolumeTypeListener();
806     int32_t SetVolumeInternalByKeyEvent(AudioStreamType streamInFocus, int32_t zoneId, const int32_t keyType);
807 
808     void InitPolicyDumpMap();
809     void PolicyDataDump(std::string &dumpString);
810     void ArgInfoDump(std::string &dumpString, std::queue<std::u16string> &argQue);
811     void InfoDumpHelp(std::string &dumpString);
812 
813     int32_t SetRingerModeInner(AudioRingerMode ringMode);
814     void AddSystemAbilityListeners();
815     void OnAddSystemAbilityExtract(int32_t systemAbilityId, const std::string &deviceId);
816 
817     // for updating default device selection state when game audio stream is muted
818     void UpdateDefaultOutputDeviceWhenStarting(const uint32_t sessionID);
819     void UpdateDefaultOutputDeviceWhenStopping(const uint32_t sessionID);
820     void ChangeVolumeOnVoiceAssistant(AudioStreamType &streamInFocus);
821     AudioStreamType GetCurrentStreamInFocus();
822 
823     AudioEffectService &audioEffectService_;
824     AudioAffinityManager &audioAffinityManager_;
825     AudioCapturerSession &audioCapturerSession_;
826     AudioStateManager &audioStateManager_;
827     AudioToneManager &audioToneManager_;
828     AudioMicrophoneDescriptor &audioMicrophoneDescriptor_;
829     AudioDeviceStatus &audioDeviceStatus_;
830     AudioPolicyConfigManager &audioConfigManager_;
831     AudioSceneManager &audioSceneManager_;
832     AudioConnectedDevice &audioConnectedDevice_;
833     AudioDeviceLock &audioDeviceLock_;
834     AudioStreamCollector &streamCollector_;
835     AudioOffloadStream &audioOffloadStream_;
836     AudioBackgroundManager &audioBackgroundManager_;
837     AudioVolumeManager &audioVolumeManager_;
838     AudioDeviceCommon &audioDeviceCommon_;
839     IAudioPolicyInterface &audioPolicyManager_;
840     AudioPolicyConfigManager &audioPolicyConfigManager_;
841     AudioPolicyService &audioPolicyService_;
842     AudioPolicyUtils &audioPolicyUtils_;
843     AudioDeviceManager &audioDeviceManager_;
844     AudioSpatializationService &audioSpatializationService_;
845     AudioCollaborativeService &audioCollaborativeService_;
846     AudioRouterCenter &audioRouterCenter_;
847     AudioPolicyDump &audioPolicyDump_;
848 #ifdef USB_ENABLE
849     AudioUsbManager &usbManager_;
850 #endif
851     AudioActiveDevice &audioActiveDevice_;
852 
853     std::shared_ptr<AudioInterruptService> interruptService_;
854     std::shared_ptr<AudioCoreService> coreService_;
855     std::shared_ptr<AudioCoreService::EventEntry> eventEntry_;
856 
857     int32_t volumeStep_;
858     std::atomic<bool> isFirstAudioServiceStart_ = false;
859     std::atomic<bool> isInitMuteState_ = false;
860     std::atomic<bool> isInitSettingsData_ = false;
861     std::atomic<bool> isScreenOffOrLock_ = false;
862     std::atomic<bool> isInitRingtoneReady_ = false;
863 #ifdef FEATURE_MULTIMODALINPUT_INPUT
864     std::mutex volUpHistoryMutex_;
865     std::deque<int64_t> volUpHistory_;
866     std::atomic<bool> hasSubscribedVolumeKeyEvents_ = false;
867 #endif
868     std::vector<pid_t> clientDiedListenerState_;
869     sptr<PowerStateListener> powerStateListener_;
870     sptr<SyncHibernateListener> syncHibernateListener_;
871     bool powerStateCallbackRegister_;
872     AppExecFwk::AppMgrClient appManager_;
873     sptr<AppStateListener> appStateListener_;
874 
875     std::mutex systemVolumeMutex_;
876     std::mutex micStateChangeMutex_;
877     std::mutex clientDiedListenerStateMutex_;
878     std::mutex subscribeVolumeKey_;
879 
880     std::shared_ptr<AudioPolicyServerHandler> audioPolicyServerHandler_;
881     bool volumeApplyToAll_ = false;
882     bool screenOffAdjustVolumeEnable_ = false;
883     bool supportVibrator_ = false;
884 
885     bool isHighResolutionExist_ = false;
886     std::mutex descLock_;
887 
888     using DumpFunc = void(AudioPolicyServer::*)(std::string &dumpString);
889     std::map<std::u16string, DumpFunc> dumpFuncMap;
890     pid_t lastMicMuteSettingPid_ = 0;
891     std::shared_ptr<AudioOsAccountInfo> accountObserver_ = nullptr;
892 
893     int32_t sessionIdByRemote_ = -1;
894     sptr<IStandardAudioPolicyManagerListener> queryBundleNameListCallback_ = nullptr;
895     bool isAlreadyRegisterCommonEventListener_ = false;
896 };
897 
898 class AudioOsAccountInfo : public AccountSA::OsAccountSubscriber {
899 public:
AudioOsAccountInfo(const AccountSA::OsAccountSubscribeInfo & subscribeInfo,AudioPolicyServer * audioPolicyServer)900     explicit AudioOsAccountInfo(const AccountSA::OsAccountSubscribeInfo &subscribeInfo,
901         AudioPolicyServer *audioPolicyServer) : AccountSA::OsAccountSubscriber(subscribeInfo),
902         audioPolicyServer_(audioPolicyServer) {}
903 
~AudioOsAccountInfo()904     ~AudioOsAccountInfo()
905     {
906         AUDIO_WARNING_LOG("Destructor AudioOsAccountInfo");
907     }
908 
OnAccountsChanged(const int & id)909     void OnAccountsChanged(const int &id) override
910     {
911         AUDIO_INFO_LOG("OnAccountsChanged received, id: %{public}d", id);
912     }
913 
OnAccountsSwitch(const int & newId,const int & oldId)914     void OnAccountsSwitch(const int &newId, const int &oldId) override
915     {
916         CHECK_AND_RETURN_LOG(oldId >= LOCAL_USER_ID, "invalid id");
917         AUDIO_INFO_LOG("OnAccountsSwitch received, newid: %{public}d, oldid: %{public}d", newId, oldId);
918         if (audioPolicyServer_ != nullptr) {
919             audioPolicyServer_->NotifyAccountsChanged(newId);
920         }
921     }
922 private:
923     static constexpr int32_t LOCAL_USER_ID = 100;
924     AudioPolicyServer *audioPolicyServer_;
925 };
926 
927 class AudioCommonEventSubscriber : public EventFwk::CommonEventSubscriber {
928 public:
AudioCommonEventSubscriber(const EventFwk::CommonEventSubscribeInfo & subscribeInfo,std::function<void (const EventFwk::CommonEventData &)> receiver)929     explicit AudioCommonEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo,
930         std::function<void(const EventFwk::CommonEventData&)> receiver)
931         : EventFwk::CommonEventSubscriber(subscribeInfo), eventReceiver_(receiver) {}
~AudioCommonEventSubscriber()932     ~AudioCommonEventSubscriber() {}
933     void OnReceiveEvent(const EventFwk::CommonEventData &eventData) override;
934 private:
935     AudioCommonEventSubscriber() = default;
936     std::function<void(const EventFwk::CommonEventData&)> eventReceiver_;
937 };
938 } // namespace AudioStandard
939 } // namespace OHOS
940 #endif // ST_AUDIO_POLICY_SERVER_H
941