1 /*
2  * Copyright (c) 2023-2023 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_CAMERA_DPS_POWER_MANAGER_H
17 #define OHOS_CAMERA_DPS_POWER_MANAGER_H
18 
19 #include "singleton.h"
20 #ifdef CAMERA_USE_POWER
21 #include "power_mgr_client.h"
22 #include "running_lock.h"
23 #endif
24 
25 namespace OHOS {
26 namespace CameraStandard {
27 namespace DeferredProcessing {
28 class DPSProwerManager : public Singleton<DPSProwerManager> {
29     DECLARE_SINGLETON(DPSProwerManager)
30 
31 public:
32     void Initialize();
33     void SetAutoSuspend(bool isAutoSuspend, uint32_t time = 0);
34 
35 private:
36     void EnableAutoSuspend();
37     void DisableAutoSuspend(uint32_t time);
38 
39     std::mutex mutex_;
40     std::atomic<bool> initialized_ {false};
41     bool isSuspend_ {false};
42     std::shared_ptr<PowerMgr::RunningLock> wakeLock_ {nullptr};
43 };
44 } // namespace DeferredProcessing
45 } // namespace CameraStandard
46 } // namespace OHOS
47 #endif // OHOS_CAMERA_DPS_POWER_MANAGER_H