1 /* 2 * Copyright (c) 2024-2024 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 POWERMGR_UTILS_INTF_WRPAAER_POWER_EXT_INTF_WRAPPER_H 17 #define POWERMGR_UTILS_INTF_WRPAAER_POWER_EXT_INTF_WRAPPER_H 18 19 #include <vector> 20 #include "interface_loader.h" 21 22 namespace OHOS { 23 namespace PowerMgr { 24 25 class PowerExtIntfWrapper final : public NoCopyable { 26 public: 27 enum class ErrCode : uint32_t { 28 ERR_OK = 0, 29 ERR_NOT_FOUND = 1, 30 ERR_FAILURE = 2 31 }; 32 33 static PowerExtIntfWrapper& Instance(); ~PowerExtIntfWrapper()34 virtual ~PowerExtIntfWrapper() noexcept 35 { 36 DeInit(); 37 } 38 Init()39 void Init() 40 { 41 intfLoader_.Init(); 42 } 43 DeInit()44 void DeInit() 45 { 46 intfLoader_.DeInit(); 47 } 48 49 ErrCode GetRebootCommand(const std::string& rebootReason, std::string& rebootCmd) const; 50 ErrCode SubscribeScreenLockCommonEvent() const; 51 ErrCode UnSubscribeScreenLockCommonEvent() const; 52 ErrCode BlockHibernateUntilScrLckReady() const; 53 54 private: PowerExtIntfWrapper(const std::string & libPath,const std::vector<std::string> & symbolArr)55 PowerExtIntfWrapper(const std::string& libPath, const std::vector<std::string>& symbolArr) 56 : intfLoader_(libPath, symbolArr) {} 57 58 InterfaceLoader intfLoader_; 59 }; 60 61 } // namespace PowerMgr 62 } // namespace OHOS 63 #endif // POWERMGR_UTILS_INTF_WRPAAER_POWER_EXT_INTF_WRAPPER_H