• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_WRAPPER_POWER_EXT_INTF_WRAPPER_H
17 #define POWERMGR_UTILS_INTF_WRAPPER_POWER_EXT_INTF_WRAPPER_H
18 
19 #include <vector>
20 #include "interface_loader.h"
21 #ifdef POWER_MANAGER_ENABLE_WATCH_CUSTOMIZED_SCREEN_COMMON_EVENT_RULES
22 #include "power_state_machine_info.h"
23 #endif
24 
25 namespace OHOS {
26 namespace PowerMgr {
27 
28 class PowerExtIntfWrapper final : public NoCopyable {
29 public:
30     enum class ErrCode : uint32_t {
31         ERR_OK = 0,
32         ERR_NOT_FOUND = 1,
33         ERR_FAILURE = 2
34     };
35 
36     static PowerExtIntfWrapper& Instance();
~PowerExtIntfWrapper()37     virtual ~PowerExtIntfWrapper() noexcept
38     {
39         DeInit();
40     }
41 
Init()42     void Init()
43     {
44         intfLoader_.Init();
45     }
46 
DeInit()47     void DeInit()
48     {
49         intfLoader_.DeInit();
50     }
51 
52     ErrCode GetRebootCommand(const std::string& rebootReason, std::string& rebootCmd) const;
53     ErrCode SubscribeScreenLockCommonEvent() const;
54     ErrCode UnSubscribeScreenLockCommonEvent() const;
55     ErrCode BlockHibernateUntilScrLckReady() const;
56     void OnHibernateEnd(bool hibernateResult);
57 #ifdef POWER_MANAGER_ENABLE_WATCH_CUSTOMIZED_SCREEN_COMMON_EVENT_RULES
58     void SetScreenOnEventRules(StateChangeReason reason);
59     void PublishCustomizedScreenEvent(PowerState state, std::vector<std::string> bundleNames);
60     bool NotifyScreenOnEventAgain(WakeupDeviceType reason, std::vector<std::string> bundleNames);
61     void NotifyOperateEventAfterScreenOn(std::vector<std::string> bundleNames);
62 #endif
63 
64 private:
PowerExtIntfWrapper(const std::string & libPath,const std::vector<std::string> & symbolArr)65     PowerExtIntfWrapper(const std::string& libPath, const std::vector<std::string>& symbolArr)
66         : intfLoader_(libPath, symbolArr) {}
67 
68     InterfaceLoader intfLoader_;
69 };
70 
71 } // namespace PowerMgr
72 } // namespace OHOS
73 #endif // POWERMGR_UTILS_INTF_WRAPPER_POWER_EXT_INTF_WRAPPER_H