• 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 #include "mock_socperf_action.h"
17 
18 namespace OHOS {
19 namespace PowerMgr {
20 std::map<int32_t, int64_t> MockSocPerfAction::limitMap_ = {};
21 uint32_t MockSocPerfAction::boostCounter_ = 0;
22 constexpr int64_t INVALID_VALUE = -1;
23 
LimitRequest(int32_t tag,int64_t value)24 void MockSocPerfAction::LimitRequest(int32_t tag, int64_t value)
25 {
26     auto it = limitMap_.find(tag);
27     if (it == limitMap_.end()) {
28         limitMap_.emplace(tag, value);
29         return;
30     }
31     it->second = value;
32 }
33 
GetLimitValue(int32_t tag)34 int64_t MockSocPerfAction::GetLimitValue(int32_t tag)
35 {
36     auto it = limitMap_.find(tag);
37     if (it != limitMap_.end()) {
38         return it->second;
39     }
40     return INVALID_VALUE;
41 }
42 
ClearLimit()43 void MockSocPerfAction::ClearLimit()
44 {
45     limitMap_.clear();
46 }
47 
BoostRequest()48 void MockSocPerfAction::BoostRequest()
49 {
50     boostCounter_++;
51 }
52 
GetBoostRequestCounter()53 uint32_t MockSocPerfAction::GetBoostRequestCounter()
54 {
55     return boostCounter_;
56 }
57 
ClearBoost()58 void MockSocPerfAction::ClearBoost()
59 {
60     boostCounter_ = 0;
61 }
62 } // namespace Power
63 } // namespace OHOS
64