• 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_CAMERA_MANAGER_ADAPTER_H
17 #define ACCESSTOKEN_CAMERA_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 CameraManagerAdapter final {
29 private:
30     CameraManagerAdapter();
31     virtual ~CameraManagerAdapter();
32     DISALLOW_COPY_AND_MOVE(CameraManagerAdapter);
33 
34 public:
35     static CameraManagerAdapter& GetInstance();
36     bool IsCameraMuted();
37 
38 #ifdef CAMERA_FRAMEWORK_ENABLE
39 private:
40     void InitProxy();
41 
42     class CameraManagerDeathRecipient : public IRemoteObject::DeathRecipient {
43     public:
44         CameraManagerDeathRecipient() = default;
45         ~CameraManagerDeathRecipient() override = default;
46         void OnRemoteDied(const wptr<IRemoteObject>& remote) override;
47     private:
48         DISALLOW_COPY_AND_MOVE(CameraManagerDeathRecipient);
49     };
50 
51     sptr<IRemoteObject> GetProxy();
52     void ReleaseProxy(const wptr<IRemoteObject>& remote);
53 
54     std::mutex proxyMutex_;
55     sptr<IRemoteObject> proxy_ = nullptr;
56     sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr;
57 #endif
58 };
59 } // namespace AccessToken
60 } // namespace Security
61 } // namespace OHOS
62 #endif // ACCESSTOKEN_CAMERA_MANAGER_ADAPTER_H
63