• 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 class PowerExtIntfWrapper final : public NoCopyable {
28 public:
29     enum class ErrCode : uint32_t {
30         ERR_OK = 0,
31         ERR_NOT_FOUND = 1,
32         ERR_FAILURE = 2
33     };
34 
35     static PowerExtIntfWrapper& Instance();
~PowerExtIntfWrapper()36     virtual ~PowerExtIntfWrapper() noexcept
37     {
38         DeInit();
39     }
40 
Init()41     void Init()
42     {
43         intfLoader_.Init();
44     }
45 
DeInit()46     void DeInit()
47     {
48         intfLoader_.DeInit();
49     }
50 
51     ErrCode GetRebootCommand(const std::string& rebootReason, std::string& rebootCmd) const;
52     ErrCode SubscribeScreenLockCommonEvent() const;
53     ErrCode UnSubscribeScreenLockCommonEvent() const;
54     ErrCode BlockHibernateUntilScrLckReady() const;
55     void OnHibernateEnd(bool hibernateResult);
56 #ifdef POWER_MANAGER_ENABLE_WATCH_CUSTOMIZED_SCREEN_COMMON_EVENT_RULES
57     ErrCode SetScreenOnEventRules(StateChangeReason reason, const std::vector<StateChangeReason>& stateChangeReason,
58         const std::vector<WakeupDeviceType>& wakeupDeviceTypes);
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