• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_AUDIO_MANAGER_PRIVACY_PROXY_H
17 #define OHOS_AUDIO_MANAGER_PRIVACY_PROXY_H
18 
19 #include <iremote_proxy.h>
20 
21 namespace OHOS {
22 namespace Security {
23 namespace AccessToken {
24 enum AudioPolicyCommand {
25     SET_MICROPHONE_MUTE = 13,
26     IS_MICROPHONE_MUTE = 15,
27     SET_MIC_STATE_CHANGE_CALLBACK = 56,
28 };
29 
30 struct MicStateChangeEvent {
31     bool mute;
32 };
33 
34 class IStandardAudioRoutingManagerListener : public IRemoteBroker {
35 public:
36     virtual ~IStandardAudioRoutingManagerListener() = default;
37     virtual void OnMicStateUpdated(const MicStateChangeEvent &micStateChangeEvent) = 0;
38 
39     enum AudioRingerModeUpdateListenerMsg {
40         ON_ERROR = 0,
41         ON_MIC_STATE_UPDATED,
42     };
43 
44     DECLARE_INTERFACE_DESCRIPTOR(u"IStandardAudioRoutingManagerListener");
45 };
46 
47 class IAudioPolicy : public IRemoteBroker {
48 public:
49     DECLARE_INTERFACE_DESCRIPTOR(u"IAudioPolicy");
50 
51     virtual bool IsMicrophoneMute() = 0;
52     virtual int32_t SetMicrophoneMute(bool isMute) = 0;
53     virtual int32_t SetMicStateChangeCallback(const int32_t clientId, const sptr<IRemoteObject> &object) = 0;
54 };
55 
56 class AudioManagerPrivacyProxy : public IRemoteProxy<IAudioPolicy> {
57 public:
AudioManagerPrivacyProxy(const sptr<IRemoteObject> & impl)58     explicit AudioManagerPrivacyProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAudioPolicy>(impl) {};
59 
60     virtual ~AudioManagerPrivacyProxy() = default;
61 
62     bool IsMicrophoneMute() override;
63     int32_t SetMicrophoneMute(bool isMute) override;
64     int32_t SetMicStateChangeCallback(const int32_t clientId, const sptr<IRemoteObject> &object) override;
65 private:
66     static inline BrokerDelegator<AudioManagerPrivacyProxy> delegator_;
67 };
68 }
69 }
70 }
71 #endif // OHOS_AUDIO_MANAGER_PRIVACY_PROXY_H
72