• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 ACCESSTOKEN_AUDIO_MANAGER_ADAPTER_H
17 #define ACCESSTOKEN_AUDIO_MANAGER_ADAPTER_H
18 
19 #include <mutex>
20 #include <string>
21 
22 #include <iremote_proxy.h>
23 #include "nocopyable.h"
24 
25 namespace OHOS {
26 namespace Security {
27 namespace AccessToken {
28 class AudioManagerAdapter final {
29 private:
30     AudioManagerAdapter();
31     virtual ~AudioManagerAdapter();
32     DISALLOW_COPY_AND_MOVE(AudioManagerAdapter);
33 
34 public:
35     static AudioManagerAdapter& GetInstance();
36 
37     bool GetPersistentMicMuteState();
38 
39 #ifdef AUDIO_FRAMEWORK_ENABLE
40 private:
41     void InitProxy();
42 
43     class AudioManagerDeathRecipient : public IRemoteObject::DeathRecipient {
44     public:
45         AudioManagerDeathRecipient() = default;
46         ~AudioManagerDeathRecipient() override = default;
47         void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
48     private:
49         DISALLOW_COPY_AND_MOVE(AudioManagerDeathRecipient);
50     };
51 
52     sptr<IRemoteObject> GetProxy();
53     void ReleaseProxy(const wptr<IRemoteObject>& remote);
54 
55     std::mutex proxyMutex_;
56     sptr<IRemoteObject> proxy_ = nullptr;
57     sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr;
58 #endif
59 };
60 } // namespace AccessToken
61 } // namespace Security
62 } // namespace OHOS
63 #endif // ACCESSTOKEN_AUDIO_MANAGER_ADAPTER_H
64