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 "wakeup_action_sources.h" 17 18 #include <string> 19 #include "power_log.h" 20 21 namespace OHOS { 22 namespace PowerMgr { 23 mapSuspendDeviceType(const std::string & reason)24SuspendDeviceType WakeupActionSources::mapSuspendDeviceType(const std::string& reason) 25 { 26 if (reason == WakeupActionSources::LOW_CAPACITY_KEY) { 27 return SuspendDeviceType::SUSPEND_DEVICE_LOW_CAPACITY; 28 } 29 30 return SuspendDeviceType::SUSPEND_DEVICE_REASON_MIN; 31 } 32 PutSource(const std::string & key,std::shared_ptr<WakeupActionSource> & source)33void WakeupActionSources::PutSource(const std::string& key, std::shared_ptr<WakeupActionSource>& source) 34 { 35 std::lock_guard<std::mutex> lock(sourceMapMutex_); 36 sourceMap_.emplace(key, source); 37 } 38 GetSourceMap()39std::map<std::string, std::shared_ptr<WakeupActionSource>> WakeupActionSources::GetSourceMap() 40 { 41 std::lock_guard<std::mutex> lock(sourceMapMutex_); 42 return sourceMap_; 43 } 44 45 } // namespace PowerMgr 46 } // namespace OHOS