• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #include "running_lock_inner.h"
17 
18 #include <datetime_ex.h>
19 
20 #include "power_log.h"
21 
22 namespace OHOS {
23 namespace PowerMgr {
RunningLockInner(const RunningLockParam & runningLockParam)24 RunningLockInner::RunningLockInner(const RunningLockParam& runningLockParam)
25 {
26     runningLockParam_ = runningLockParam;
27     lockTimeMs_ = GetTickCount();
28 }
29 
CreateRunningLockInner(const RunningLockParam & runningLockParam)30 std::shared_ptr<RunningLockInner> RunningLockInner::CreateRunningLockInner(const RunningLockParam& runningLockParam)
31 {
32     std::shared_ptr<RunningLockInner> runningLockInner = std::make_shared<RunningLockInner>(runningLockParam);
33     if (runningLockInner == nullptr) {
34         POWER_HILOGE(FEATURE_RUNNING_LOCK, "RunningLockInner is nullptr");
35         return nullptr;
36     }
37     POWER_HILOGI(FEATURE_RUNNING_LOCK, "name: %{public}s, type: %{public}d", runningLockParam.name.c_str(),
38         runningLockParam.type);
39     return runningLockInner;
40 }
41 
DumpInfo(const std::string & description)42 void RunningLockInner::DumpInfo(const std::string& description)
43 {
44     // this statement used to debug, can't find isDebugEnabled() interface. will be replaced later.
45     POWER_HILOGD(FEATURE_RUNNING_LOCK, "description: %{public}s, name: %{public}s, type: %{public}d,",
46         description.c_str(), runningLockParam_.name.c_str(), runningLockParam_.type);
47 }
48 } // namespace PowerMgr
49 } // namespace OHOS
50