• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_HDI_POWER_V1_1_RUNNINGLOCKIMPL_H
17 #define OHOS_HDI_POWER_V1_1_RUNNINGLOCKIMPL_H
18 
19 #include <cstdint>
20 #include <map>
21 #include <mutex>
22 
23 #include "running_lock_counter.h"
24 #include "running_lock_timer_handler.h"
25 #include "v1_1/power_types.h"
26 #include "v1_1/running_lock_types.h"
27 
28 namespace OHOS {
29 namespace HDI {
30 namespace Power {
31 namespace V1_1 {
32 class RunningLockImpl {
33 public:
34     static int32_t Hold(const RunningLockInfo &info, PowerHdfState state);
35     static int32_t Unhold(const RunningLockInfo &info);
36     static void Clean();
37     static uint32_t GetCount(RunningLockType type);
38     static std::string GetRunningLockTag(RunningLockType type);
39     static void SetDefaultTimeOutMs(int32_t timeOutMs);
40 
41 private:
42     static bool IsValidType(RunningLockType type, PowerHdfState state = PowerHdfState::AWAKE);
43     static RunningLockInfo FillRunningLockInfo(const RunningLockInfo &info);
44     static std::mutex mutex_;
45     static int32_t defaultTimeOutMs_;
46     static std::unique_ptr<RunningLockTimerHandler> timerHandler_;
47     static std::map<RunningLockType, std::shared_ptr<RunningLockCounter>> lockCounters_;
48 };
49 
50 } // namespace V1_1
51 } // namespace Power
52 } // namespace HDI
53 } // namespace OHOS
54 
55 #endif // OHOS_HDI_POWER_V1_1_RUNNINGLOCKIMPL_H
56