• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef I_AUDIO_POLICY_BASE_H
17 #define I_AUDIO_POLICY_BASE_H
18 
19 #include "audio_interrupt_callback.h"
20 #include "audio_policy_ipc_interface_code.h"
21 #include "ipc_types.h"
22 #include "iremote_broker.h"
23 #include "iremote_proxy.h"
24 #include "iremote_stub.h"
25 #include "audio_system_manager.h"
26 #include "audio_effect.h"
27 #include "microphone_descriptor.h"
28 
29 namespace OHOS {
30 namespace AudioStandard {
31 using InternalDeviceType = DeviceType;
32 using InternalAudioCapturerOptions = AudioCapturerOptions;
33 
34 class IAudioPolicy : public IRemoteBroker {
35 public:
36 
37     virtual int32_t GetMaxVolumeLevel(AudioVolumeType volumeType) = 0;
38 
39     virtual int32_t GetMinVolumeLevel(AudioVolumeType volumeType) = 0;
40 
41     virtual int32_t SetSystemVolumeLevelLegacy(AudioVolumeType volumeType, int32_t volumeLevel) = 0;
42 
43     virtual int32_t SetSystemVolumeLevel(AudioVolumeType volumeType, int32_t volumeLevel, int32_t volumeFlag = 0) = 0;
44 
45     virtual int32_t SetSystemVolumeLevelWithDevice(AudioVolumeType volumeType, int32_t volumeLevel,
46         DeviceType deviceType, int32_t volumeFlag = 0) = 0;
47 
48     virtual int32_t GetAppVolumeLevel(int32_t appUid) = 0;
49 
50     virtual int32_t GetSelfAppVolumeLevel() = 0;
51 
52     virtual int32_t SetAppVolumeLevel(int32_t appUid, int32_t volumeLevel, int32_t volumeFlag = 0) = 0;
53 
54     virtual bool IsAppVolumeMute(int32_t appUid, bool muted) = 0;
55 
56     virtual int32_t SetAppVolumeMuted(int32_t appUid, bool muted, int32_t volumeFlag = 0) = 0;
57 
58     virtual int32_t SetSelfAppVolumeLevel(int32_t volumeLevel, int32_t volumeFlag = 0) = 0;
59 
60     virtual AudioStreamType GetSystemActiveVolumeType(const int32_t clientUid) = 0;
61 
62     virtual int32_t GetSystemVolumeLevel(AudioVolumeType volumeType) = 0;
63 
64     virtual int32_t SetLowPowerVolume(int32_t streamId, float volume) = 0;
65 
66     virtual float GetLowPowerVolume(int32_t streamId) = 0;
67 
68     virtual float GetSingleStreamVolume(int32_t streamId) = 0;
69 
70     virtual int32_t SetStreamMuteLegacy(AudioVolumeType volumeType, bool mute,
71         const DeviceType &deviceType = DEVICE_TYPE_NONE) = 0;
72 
73     virtual int32_t SetStreamMute(AudioVolumeType volumeType, bool mute,
74         const DeviceType &deviceType = DEVICE_TYPE_NONE) = 0;
75 
76     virtual bool GetStreamMute(AudioVolumeType volumeType) = 0;
77 
78     virtual bool IsStreamActive(AudioVolumeType volumeType) = 0;
79 
80     virtual std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag) = 0;
81 
82     virtual std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetDevicesInner(DeviceFlag deviceFlag) = 0;
83 
84     virtual std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetOutputDevice(
85         sptr<AudioRendererFilter> audioRendererFilter) = 0;
86 
87     virtual std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetInputDevice(
88         sptr<AudioCapturerFilter> audioCapturerFilter) = 0;
89 
90     virtual int32_t SetDeviceActive(InternalDeviceType deviceType, bool active, const int32_t uid = INVALID_UID) = 0;
91 
92     virtual bool IsDeviceActive(InternalDeviceType deviceType) = 0;
93 
94     virtual DeviceType GetActiveOutputDevice() = 0;
95 
96     virtual DeviceType GetActiveInputDevice() = 0;
97 
98 #ifdef FEATURE_DTMF_TONE
99     virtual std::shared_ptr<ToneInfo> GetToneConfig(int32_t ltonetype, const std::string &countryCode) = 0;
100 
101     virtual std::vector<int32_t> GetSupportedTones(const std::string &countryCode) = 0;
102 #endif
103 
104     virtual int32_t SetRingerModeLegacy(AudioRingerMode ringMode) = 0;
105 
106     virtual int32_t SetRingerMode(AudioRingerMode ringMode) = 0;
107 
108     virtual AudioRingerMode GetRingerMode() = 0;
109 
110     virtual int32_t SetAudioScene(AudioScene scene) = 0;
111 
112     virtual int32_t SetMicrophoneMute(bool isMute) = 0;
113 
114     virtual int32_t SetMicrophoneMuteAudioConfig(bool isMute) = 0;
115 
116     virtual int32_t SetMicrophoneMutePersistent(const bool isMute, const PolicyType type) = 0;
117 
118     virtual bool GetPersistentMicMuteState() = 0;
119 
120     virtual bool IsMicrophoneMuteLegacy() = 0;
121 
122     virtual bool IsMicrophoneMute() = 0;
123 
124     virtual AudioScene GetAudioScene() = 0;
125 
126     virtual int32_t ActivateAudioSession(const AudioSessionStrategy &strategy) = 0;
127 
128     virtual int32_t DeactivateAudioSession() = 0;
129 
130     virtual bool IsAudioSessionActivated() = 0;
131 
132     virtual int32_t SetAudioInterruptCallback(const uint32_t sessionID, const sptr<IRemoteObject> &object,
133         uint32_t clientUid, const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
134 
135     virtual int32_t UnsetAudioInterruptCallback(const uint32_t sessionID,
136         const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
137 
138     virtual int32_t ActivateAudioInterrupt(AudioInterrupt &audioInterrupt,
139         const int32_t zoneID = 0 /* default value: 0 -- local device */,
140         const bool isUpdatedAudioStrategy = false /* default value: false -- is update audio strategy */) = 0;
141 
142     virtual int32_t DeactivateAudioInterrupt(const AudioInterrupt &audioInterrupt,
143         const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
144 
145     virtual int32_t SetAudioManagerInterruptCallback(const int32_t clientId, const sptr<IRemoteObject> &object) = 0;
146 
147     virtual int32_t UnsetAudioManagerInterruptCallback(const int32_t clientId) = 0;
148 
149     virtual int32_t SetQueryClientTypeCallback(const sptr<IRemoteObject> &object) = 0;
150 
151     virtual int32_t SetAudioClientInfoMgrCallback(const sptr<IRemoteObject> &object) = 0;
152 
153     virtual int32_t RequestAudioFocus(const int32_t clientId, const AudioInterrupt &audioInterrupt) = 0;
154 
155     virtual int32_t AbandonAudioFocus(const int32_t clientId, const AudioInterrupt &audioInterrupt) = 0;
156 
157     virtual AudioStreamType GetStreamInFocus(const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
158 
159     virtual AudioStreamType GetStreamInFocusByUid(
160         const int32_t uid, const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
161 
162     virtual int32_t GetSessionInfoInFocus(AudioInterrupt &audioInterrupt,
163         const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
164 
165     virtual int32_t ReconfigureAudioChannel(const uint32_t &count, DeviceType deviceType) = 0;
166 
167     virtual int32_t GetPreferredOutputStreamType(AudioRendererInfo &rendererInfo) = 0;
168 
169     virtual int32_t GetPreferredInputStreamType(AudioCapturerInfo &capturerInfo) = 0;
170 
171     virtual int32_t RegisterTracker(AudioMode &mode,
172         AudioStreamChangeInfo &streamChangeInfo, const sptr<IRemoteObject> &object) = 0;
173 
174     virtual int32_t UpdateTracker(AudioMode &mode, AudioStreamChangeInfo &streamChangeInfo) = 0;
175 
176     virtual int32_t GetCurrentRendererChangeInfos(
177         std::vector<std::shared_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos) = 0;
178 
179     virtual int32_t GetCurrentCapturerChangeInfos(
180         std::vector<std::shared_ptr<AudioCapturerChangeInfo>> &audioCapturerChangeInfos) = 0;
181 
182     virtual int32_t UpdateStreamState(const int32_t clientUid, StreamSetState streamSetState,
183                                             StreamUsage streamUsage) = 0;
184 
185     virtual int32_t SelectOutputDevice(sptr<AudioRendererFilter> audioRendererFilter,
186         std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) = 0;
187 
188     virtual std::string GetSelectedDeviceInfo(int32_t uid, int32_t pid, AudioStreamType streamType) = 0;
189 
190     virtual int32_t SelectInputDevice(sptr<AudioCapturerFilter> audioCapturerFilter,
191         std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) = 0;
192 
193     virtual int32_t ExcludeOutputDevices(AudioDeviceUsage audioDevUsage,
194         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors) = 0;
195 
196     virtual int32_t UnexcludeOutputDevices(AudioDeviceUsage audioDevUsage,
197         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &audioDeviceDescriptors) = 0;
198 
199     virtual std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetExcludedDevices(
200         AudioDeviceUsage audioDevUsage) = 0;
201 
202     virtual int32_t GetVolumeGroupInfos(std::string networkId, std::vector<sptr<VolumeGroupInfo>> &infos) = 0;
203 
204     virtual int32_t GetNetworkIdByGroupId(int32_t groupId, std::string &networkId) = 0;
205 
206     virtual std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetPreferredOutputDeviceDescriptors(
207         AudioRendererInfo &rendererInfo, bool forceNoBTPermission) = 0;
208 
209     virtual std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetPreferredInputDeviceDescriptors(
210         AudioCapturerInfo &captureInfo) = 0;
211 
212     virtual int32_t SetClientCallbacksEnable(const CallbackChange &callbackchange, const bool &enable) = 0;
213 
214     virtual int32_t SetCallbackRendererInfo(const AudioRendererInfo &rendererInfo) = 0;
215 
216     virtual int32_t SetCallbackCapturerInfo(const AudioCapturerInfo &capturerInfo) = 0;
217 
218     virtual int32_t GetAudioFocusInfoList(std::list<std::pair<AudioInterrupt, AudioFocuState>> &focusInfoList,
219         const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
220 
221     virtual int32_t SetSystemSoundUri(const std::string &key, const std::string &uri) = 0;
222 
223     virtual std::string GetSystemSoundUri(const std::string &key) = 0;
224 
225     virtual float GetMinStreamVolume(void) = 0;
226 
227     virtual float GetMaxStreamVolume(void) = 0;
228 
229     virtual int32_t GetMaxRendererInstances() = 0;
230 
231     virtual bool IsVolumeUnadjustable(void) = 0;
232 
233     virtual int32_t AdjustVolumeByStep(VolumeAdjustType adjustType) = 0;
234 
235     virtual int32_t AdjustSystemVolumeByStep(AudioVolumeType volumeType, VolumeAdjustType adjustType) = 0;
236 
237     virtual float GetSystemVolumeInDb(AudioVolumeType volumeType, int32_t volumeLevel, DeviceType deviceType) = 0;
238 
239     virtual int32_t QueryEffectSceneMode(SupportedEffectConfig &supportedEffectConfig) = 0;
240 
241     virtual int32_t GetHardwareOutputSamplingRate(const std::shared_ptr<AudioDeviceDescriptor> &desc) = 0;
242 
243     virtual std::vector<sptr<MicrophoneDescriptor>> GetAudioCapturerMicrophoneDescriptors(int32_t sessionId) = 0;
244 
245     virtual std::vector<sptr<MicrophoneDescriptor>> GetAvailableMicrophones() = 0;
246 
247     virtual int32_t SetDeviceAbsVolumeSupported(const std::string &macAddress, const bool support) = 0;
248 
249     virtual bool IsAbsVolumeScene() = 0;
250 
251     virtual int32_t SetA2dpDeviceVolume(const std::string &macAddress, const int32_t volume, bool updateUi) = 0;
252 
253     virtual std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetAvailableDevices(AudioDeviceUsage usage) = 0;
254 
255     virtual int32_t SetAvailableDeviceChangeCallback(const int32_t clientId, const AudioDeviceUsage usage,
256         const sptr<IRemoteObject> &object) = 0;
257 
258     virtual int32_t UnsetAvailableDeviceChangeCallback(const int32_t clientId, AudioDeviceUsage usage) = 0;
259 
260     virtual int32_t ConfigDistributedRoutingRole(
261         const std::shared_ptr<AudioDeviceDescriptor> descriptor, CastType type) = 0;
262 
263     virtual int32_t SetDistributedRoutingRoleCallback(const sptr<IRemoteObject> &object) = 0;
264 
265     virtual int32_t UnsetDistributedRoutingRoleCallback() = 0;
266 
267     virtual bool IsSpatializationEnabled() = 0;
268 
269     virtual bool IsSpatializationEnabled(const std::string address) = 0;
270 
271     virtual bool IsSpatializationEnabledForCurrentDevice() = 0;
272 
273     virtual int32_t SetSpatializationEnabled(const bool enable) = 0;
274 
275     virtual int32_t SetSpatializationEnabled(const std::shared_ptr<AudioDeviceDescriptor> &selectedAudioDevice,
276         const bool enable) = 0;
277 
278     virtual bool IsHeadTrackingEnabled() = 0;
279 
280     virtual bool IsHeadTrackingEnabled(const std::string address) = 0;
281 
282     virtual int32_t SetHeadTrackingEnabled(const bool enable) = 0;
283 
284     virtual int32_t SetHeadTrackingEnabled(const std::shared_ptr<AudioDeviceDescriptor> &selectedAudioDevice,
285         const bool enable) = 0;
286 
287     virtual AudioSpatializationState GetSpatializationState(const StreamUsage streamUsage) = 0;
288 
289     virtual bool IsSpatializationSupported() = 0;
290 
291     virtual bool IsSpatializationSupportedForDevice(const std::string address) = 0;
292 
293     virtual bool IsHeadTrackingSupported() = 0;
294 
295     virtual bool IsHeadTrackingSupportedForDevice(const std::string address) = 0;
296 
297     virtual int32_t UpdateSpatialDeviceState(const AudioSpatialDeviceState audioSpatialDeviceState) = 0;
298 
299     virtual int32_t RegisterSpatializationStateEventListener(const uint32_t sessionID, const StreamUsage streamUsage,
300         const sptr<IRemoteObject> &object) = 0;
301 
302     virtual int32_t UnregisterSpatializationStateEventListener(const uint32_t sessionID) = 0;
303 
304     virtual int32_t RegisterPolicyCallbackClient(const sptr<IRemoteObject> &object,
305         const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
306 
307     virtual int32_t CreateAudioInterruptZone(const std::set<int32_t> &pids,
308         const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
309 
310     virtual int32_t AddAudioInterruptZonePids(const std::set<int32_t> &pids,
311         const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
312 
313     virtual int32_t RemoveAudioInterruptZonePids(const std::set<int32_t> &pids,
314         const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
315 
316     virtual int32_t ReleaseAudioInterruptZone(const int32_t zoneID = 0 /* default value: 0 -- local device */) = 0;
317 
318     virtual int32_t SetCallDeviceActive(InternalDeviceType deviceType, bool active, std::string address,
319         const int32_t uid = INVALID_UID) = 0;
320 
321     virtual std::shared_ptr<AudioDeviceDescriptor> GetActiveBluetoothDevice() = 0;
322 
323     virtual ConverterConfig GetConverterConfig() = 0;
324 
325     virtual void FetchOutputDeviceForTrack(AudioStreamChangeInfo &streamChangeInfo,
326         const AudioStreamDeviceChangeReasonExt reason) = 0;
327 
328     virtual void FetchInputDeviceForTrack(AudioStreamChangeInfo &streamChangeInfo) = 0;
329 
330     virtual bool IsHighResolutionExist(void) = 0;
331 
332     virtual int32_t SetHighResolutionExist(bool highResExist) = 0;
333 
334     virtual AudioSpatializationSceneType GetSpatializationSceneType() = 0;
335 
336     virtual int32_t SetSpatializationSceneType(const AudioSpatializationSceneType spatializationSceneType) = 0;
337 
338     virtual float GetMaxAmplitude(const int32_t deviceId) = 0;
339 
340     virtual int32_t DisableSafeMediaVolume() = 0;
341 
342     virtual bool IsHeadTrackingDataRequested(const std::string &macAddress) = 0;
343 
344     virtual int32_t SetAudioDeviceRefinerCallback(const sptr<IRemoteObject> &object) = 0;
345 
346     virtual int32_t UnsetAudioDeviceRefinerCallback() = 0;
347 
348     virtual int32_t TriggerFetchDevice(AudioStreamDeviceChangeReasonExt reason) = 0;
349 
350     virtual int32_t SetPreferredDevice(const PreferredType preferredType,
351         const std::shared_ptr<AudioDeviceDescriptor> &desc, const int32_t uid = INVALID_UID) = 0;
352 
353     virtual int32_t SetAudioDeviceAnahsCallback(const sptr<IRemoteObject> &object) = 0;
354 
355     virtual int32_t UnsetAudioDeviceAnahsCallback() = 0;
356 
357     virtual int32_t SetAudioConcurrencyCallback(const uint32_t sessionID, const sptr<IRemoteObject> &object) = 0;
358 
359     virtual int32_t UnsetAudioConcurrencyCallback(const uint32_t sessionID) = 0;
360 
361     virtual int32_t ActivateAudioConcurrency(const AudioPipeType &pipeType) = 0;
362 
363     virtual int32_t MoveToNewPipe(const uint32_t sessionId, const AudioPipeType pipeType) = 0;
364 
365     virtual int32_t InjectInterruption(const std::string networkId, InterruptEvent &event) = 0;
366 
367     virtual int32_t LoadSplitModule(const std::string &splitArgs, const std::string &networkId) = 0;
368 
369     virtual bool IsAllowedPlayback(const int32_t &uid, const int32_t &pid) = 0;
370 
371     virtual int32_t SetVoiceRingtoneMute(bool isMute) = 0;
372 
373     virtual void SaveRemoteInfo(const std::string &networkId, DeviceType deviceType) = 0;
374 
375     virtual int32_t SetDeviceConnectionStatus(const std::shared_ptr<AudioDeviceDescriptor> &desc,
376         const bool isConnected) = 0;
377 
378     virtual int32_t GetSupportedAudioEffectProperty(AudioEffectPropertyArrayV3 &propertyArray) = 0;
379 
380     virtual int32_t SetAudioEffectProperty(const AudioEffectPropertyArrayV3 &propertyArray) = 0;
381 
382     virtual int32_t GetAudioEffectProperty(AudioEffectPropertyArrayV3 &propertyArray) = 0;
383 
384     virtual int32_t GetSupportedAudioEffectProperty(AudioEffectPropertyArray &propertyArray) = 0;
385 
386     virtual int32_t GetSupportedAudioEnhanceProperty(AudioEnhancePropertyArray &propertyArray) = 0;
387 
388     virtual int32_t SetAudioEffectProperty(const AudioEffectPropertyArray &propertyArray) = 0;
389 
390     virtual int32_t GetAudioEffectProperty(AudioEffectPropertyArray &propertyArray) = 0;
391 
392     virtual int32_t SetAudioEnhanceProperty(const AudioEnhancePropertyArray &propertyArray) = 0;
393 
394     virtual int32_t GetAudioEnhanceProperty(AudioEnhancePropertyArray &propertyArray) = 0;
395 
396     virtual int32_t SetVirtualCall(const bool isVirtual) = 0;
397 
398     virtual int32_t SetQueryAllowedPlaybackCallback(const sptr<IRemoteObject> &object) = 0;
399 public:
400     DECLARE_INTERFACE_DESCRIPTOR(u"IAudioPolicy");
401 };
402 } // namespace AudioStandard
403 } // namespace OHOS
404 #endif // I_AUDIO_POLICY_BASE_H
405