• 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 "wakeup_controller.h"
17 
18 #include <datetime_ex.h>
19 #ifdef POWER_MANAGER_ENABLE_EXTERNAL_SCREEN_MANAGEMENT
20 #include <display_manager_lite.h>
21 #endif
22 #include <dlfcn.h>
23 #ifdef HAS_HIVIEWDFX_HISYSEVENT_PART
24 #include <hisysevent.h>
25 #endif
26 #include <input_manager.h>
27 #include <ipc_skeleton.h>
28 #include <json/json.h>
29 #include <securec.h>
30 #include "permission.h"
31 #include "power_errors.h"
32 #include "power_log.h"
33 #include "power_mgr_service.h"
34 #include "power_state_callback_stub.h"
35 #include "power_utils.h"
36 #include "setting_helper.h"
37 #include "suspend_controller.h"
38 #include "system_suspend_controller.h"
39 #include "customized_screen_event_rules.h"
40 #include "singleton.h"
41 
42 
43 namespace OHOS {
44 namespace PowerMgr {
45 using namespace OHOS::MMI;
46 namespace {
47 sptr<SettingObserver> g_wakeupSourcesKeyObserver = nullptr;
48 #ifdef POWER_DOUBLECLICK_ENABLE
49 const int32_t ERR_FAILED = -1;
50 #endif
51 
52 constexpr int32_t WAKEUP_LOCK_TIMEOUT_MS = 5000;
53 constexpr int32_t COLLABORATION_REMOTE_DEVICE_ID = 0xAAAAAAFF;
54 constexpr int32_t OTHER_SYSTEM_DEVICE_ID = 0xAAAAAAFE;
55 }
56 std::mutex WakeupController::sourceUpdateMutex_;
57 
58 /** WakeupController Implement */
WakeupController(std::shared_ptr<PowerStateMachine> & stateMachine)59 WakeupController::WakeupController(std::shared_ptr<PowerStateMachine>& stateMachine)
60 {
61     stateMachine_ = stateMachine;
62 #ifdef HAS_MULTIMODALINPUT_INPUT_PART
63     std::shared_ptr<InputCallback> callback = std::make_shared<InputCallback>();
64     if (monitorId_ < 0) {
65         monitorId_ = InputManager::GetInstance()->AddMonitor(std::static_pointer_cast<IInputEventConsumer>(callback));
66     }
67 #endif
68     eventHandleMap_.emplace(WakeupDeviceType::WAKEUP_DEVICE_KEYBOARD, 0);
69     eventHandleMap_.emplace(WakeupDeviceType::WAKEUP_DEVICE_MOUSE, 0);
70     eventHandleMap_.emplace(WakeupDeviceType::WAKEUP_DEVICE_TOUCHPAD, 0);
71     eventHandleMap_.emplace(WakeupDeviceType::WAKEUP_DEVICE_PEN, 0);
72     eventHandleMap_.emplace(WakeupDeviceType::WAKEUP_DEVICE_TOUCH_SCREEN, 0);
73     eventHandleMap_.emplace(WakeupDeviceType::WAKEUP_DEVICE_SINGLE_CLICK, 0);
74 }
75 
~WakeupController()76 WakeupController::~WakeupController()
77 {
78 #ifdef HAS_MULTIMODALINPUT_INPUT_PART
79     InputManager* inputManager = InputManager::GetInstance();
80     if (monitorId_ >= 0) {
81         inputManager->RemoveMonitor(monitorId_);
82     }
83 #endif
84     UnregisterSettingsObserver();
85 }
86 
Init()87 void WakeupController::Init()
88 {
89     std::lock_guard lock(monitorMutex_);
90     std::shared_ptr<WakeupSources> sources = WakeupSourceParser::ParseSources();
91     sourceList_ = sources->GetSourceList();
92     if (sourceList_.empty()) {
93         POWER_HILOGE(FEATURE_WAKEUP, "InputManager is null");
94         return;
95     }
96 
97     for (auto source = sourceList_.begin(); source != sourceList_.end(); source++) {
98         POWER_HILOGI(FEATURE_WAKEUP, "registered type=%{public}u", (*source).GetReason());
99         SetOriginSettingValue((*source));
100         std::shared_ptr<WakeupMonitor> monitor = WakeupMonitor::CreateMonitor(*source);
101         if (monitor != nullptr && monitor->Init()) {
102             POWER_HILOGI(FEATURE_WAKEUP, "monitor init success, type=%{public}u", (*source).GetReason());
103             monitor->RegisterListener([this](WakeupDeviceType reason) { this->ControlListener(reason); });
104             monitorMap_.emplace(monitor->GetReason(), monitor);
105         }
106     }
107     RegisterSettingsObserver();
108 }
109 
Cancel()110 void WakeupController::Cancel()
111 {
112     for (auto monitor = monitorMap_.begin(); monitor != monitorMap_.end(); monitor++) {
113         monitor->second->Cancel();
114     }
115     monitorMap_.clear();
116 }
117 
RegisterSettingsObserver()118 void WakeupController::RegisterSettingsObserver()
119 {
120     if (g_wakeupSourcesKeyObserver) {
121         POWER_HILOGE(FEATURE_POWER_STATE, "wakeup sources key observer is already registered");
122         return;
123     }
124     SettingObserver::UpdateFunc updateFunc = [&](const std::string&) {
125         std::lock_guard lock(monitorMutex_);
126         POWER_HILOGI(COMP_SVC, "start setting string update");
127         std::string jsonStr = SettingHelper::GetSettingWakeupSources();
128         std::shared_ptr<WakeupSources> sources = WakeupSourceParser::ParseSources(jsonStr);
129         if (sources->GetParseErrorFlag()) {
130             POWER_HILOGI(FEATURE_WAKEUP, "Parse failed, call GetWakeupSourcesByConfig again");
131             sources = WakeupSourceParser::ParseSources(WakeupSourceParser::GetWakeupSourcesByConfig());
132         }
133         std::vector<WakeupSource> updateSourceList = sources->GetSourceList();
134         if (updateSourceList.size() == 0) {
135             return;
136         }
137         sourceList_ = updateSourceList;
138         POWER_HILOGI(COMP_SVC, "start updateListener");
139         Cancel();
140         uint32_t id = 0;
141         for (auto source = sourceList_.begin(); source != sourceList_.end(); source++, id++) {
142             std::shared_ptr<WakeupMonitor> monitor = WakeupMonitor::CreateMonitor(*source);
143             POWER_HILOGI(FEATURE_WAKEUP, "UpdateFunc CreateMonitor[%{public}u] reason=%{public}d",
144                 id, source->GetReason());
145             if (monitor != nullptr && monitor->Init()) {
146                 monitor->RegisterListener([this](WakeupDeviceType reason) { this->ControlListener(reason); });
147                 monitorMap_.emplace(monitor->GetReason(), monitor);
148             }
149         }
150     };
151     g_wakeupSourcesKeyObserver = SettingHelper::RegisterSettingWakeupSourcesObserver(updateFunc);
152     POWER_HILOGI(FEATURE_POWER_STATE, "register setting observer fin");
153 }
154 
UnregisterSettingsObserver()155 void WakeupController::UnregisterSettingsObserver()
156 {
157     if (g_wakeupSourcesKeyObserver) {
158         SettingHelper::UnregisterSettingObserver(g_wakeupSourcesKeyObserver);
159         g_wakeupSourcesKeyObserver = nullptr;
160     }
161 }
162 
SetOriginSettingValue(WakeupSource & source)163 void WakeupController::SetOriginSettingValue(WakeupSource& source)
164 {
165 #ifdef POWER_DOUBLECLICK_ENABLE
166     if (source.GetReason() == WakeupDeviceType::WAKEUP_DEVICE_DOUBLE_CLICK) {
167         if (SettingHelper::IsWakeupDoubleSettingValid() == false) {
168             POWER_HILOGI(COMP_SVC, "the origin doubleClick_enable is: %{public}d", source.IsEnable());
169             SettingHelper::SetSettingWakeupDouble(source.IsEnable());
170             SetWakeupDoubleClickSensor(source.IsEnable());
171             return;
172         }
173 
174         auto enable = SettingHelper::GetSettingWakeupDouble();
175         SetWakeupDoubleClickSensor(enable);
176     }
177 #endif
178 #ifdef POWER_PICKUP_ENABLE
179     if (source.GetReason() == WakeupDeviceType::WAKEUP_DEVICE_PICKUP) {
180         if (!SettingHelper::IsWakeupPickupSettingValid()) {
181             POWER_HILOGI(FEATURE_WAKEUP, "GetReason_WAKEUP_DEVICE_PICKUP,source enable=%{public}d", source.IsEnable());
182             SettingHelper::SetSettingWakeupPickup(source.IsEnable());
183             PickupConnectMotionConfig(source.IsEnable());
184             return;
185         }
186 
187         auto enable = SettingHelper::GetSettingWakeupPickup();
188         PickupConnectMotionConfig(enable);
189     }
190 #endif
191 }
192 #ifdef POWER_DOUBLECLICK_ENABLE
ChangeWakeupSourceConfig(bool updateEnable)193 void WakeupController::ChangeWakeupSourceConfig(bool updateEnable)
194 {
195     std::lock_guard lock(sourceUpdateMutex_);
196     std::string jsonStr = SettingHelper::GetSettingWakeupSources();
197     if (jsonStr.empty()) {
198         POWER_HILOGE(COMP_SVC, "there is no such configuration file available");
199         return;
200     }
201     POWER_HILOGI(COMP_SVC, "the origin ccmJson is: %{public}s", jsonStr.c_str());
202     Json::Value root;
203     Json::Reader reader;
204     if (!reader.parse(jsonStr.data(), jsonStr.data() + jsonStr.size(), root)) {
205         POWER_HILOGE(COMP_SVC, "json parse error");
206         return;
207     }
208     if (root["touchscreen"].isNull()) {
209         POWER_HILOGE(COMP_SVC, "this touchscreenNode is empty");
210         return;
211     }
212     if (root["touchscreen"]["enable"].isNull()) {
213         POWER_HILOGE(COMP_SVC, "the touchscreenNode is empty");
214         return;
215     }
216     if (!root["touchscreen"]["enable"].isBool()) {
217         POWER_HILOGE(COMP_SVC, "the origin touchscreenEnable value is invalid");
218         return;
219     }
220     bool originEnable = root["touchscreen"]["enable"].asBool();
221     if (originEnable == updateEnable) {
222         POWER_HILOGI(COMP_SVC, "no need change jsonConfig value");
223         return;
224     }
225 
226     root["touchscreen"]["enable"] = updateEnable;
227     POWER_HILOGI(COMP_SVC, "the new doubleJsonConfig is: %{public}s", root.toStyledString().c_str());
228     SettingHelper::SetSettingWakeupSources(root.toStyledString());
229 }
230 
231 static const char* POWER_MANAGER_EXT_PATH = "libpower_manager_ext.z.so";
232 static const char* SET_WAKEUP_DOUBLE_CLICK_SENSOR = "SetWakeupDoubleClickSensor";
233 typedef int32_t(*Func)(bool);
SetWakeupDoubleClickSensor(bool enable)234 int32_t WakeupController::SetWakeupDoubleClickSensor(bool enable)
235 {
236     POWER_HILOGI(COMP_SVC, "enter SetWakeupDoubleClickSensor");
237     void *handler = dlopen(POWER_MANAGER_EXT_PATH, RTLD_LAZY | RTLD_NODELETE);
238     if (handler == nullptr) {
239         POWER_HILOGE(COMP_SVC, "Dlopen failed, reason : %{public}s", dlerror());
240         return ERR_FAILED;
241     }
242 
243     Func PowerDoubleClickFlag = (Func)dlsym(handler, SET_WAKEUP_DOUBLE_CLICK_SENSOR);
244     if (PowerDoubleClickFlag == nullptr) {
245         POWER_HILOGE(COMP_SVC, "find function failed, reason : %{public}s", dlerror());
246         dlclose(handler);
247         return ERR_FAILED;
248     }
249     auto resCode = PowerDoubleClickFlag(enable);
250     dlclose(handler);
251     return resCode;
252 }
253 #endif
254 #ifdef POWER_PICKUP_ENABLE
255 static const char* SET_WAKEUP_MOTION_SUBSCRIBER_CONFIG = "PickupMotionSubscriber";
256 static const char* SET_WAKEUP_MOTION_UNSUBSCRIBER_CONFIG = "PickupMotionUnsubscriber";
257 typedef void(*FuncSubscriber)();
258 typedef void(*FuncUnsubscriber)();
259 
PickupConnectMotionConfig(bool databaseSwitchValue)260 void WakeupController::PickupConnectMotionConfig(bool databaseSwitchValue)
261 {
262     POWER_HILOGI(COMP_SVC, "open enter PickupConnectMotionConfig");
263     if (databaseSwitchValue) {
264         void *subscriberHandler = dlopen(POWER_MANAGER_EXT_PATH, RTLD_LAZY | RTLD_NODELETE);
265         if (subscriberHandler == nullptr) {
266             POWER_HILOGE(COMP_SVC, "Dlopen failed, reason : %{public}s", dlerror());
267             return;
268         }
269         FuncSubscriber powerPickupMotionSubscriberFlag = reinterpret_cast<FuncSubscriber>(dlsym(subscriberHandler,
270             SET_WAKEUP_MOTION_SUBSCRIBER_CONFIG));
271         if (powerPickupMotionSubscriberFlag == nullptr) {
272             POWER_HILOGE(COMP_SVC, "find Subscriber function failed, reason : %{public}s", dlerror());
273             dlclose(subscriberHandler);
274             return;
275         }
276         powerPickupMotionSubscriberFlag();
277         POWER_HILOGI(COMP_SVC, "powerservice enable powerPickupMotionSubscriberFlag isSettingEnable=%{public}d",
278             databaseSwitchValue);
279         dlclose(subscriberHandler);
280         POWER_HILOGI(COMP_SVC, "open to close PickupMotionSubscriberConfig");
281     } else {
282         void *unsubscriberHandler = dlopen(POWER_MANAGER_EXT_PATH, RTLD_LAZY | RTLD_NODELETE);
283         if (unsubscriberHandler == nullptr) {
284             POWER_HILOGE(COMP_SVC, "Dlopen failed, reason : %{public}s", dlerror());
285             return;
286         }
287         FuncUnsubscriber powerPickupMotionUnsubscriberFlag = reinterpret_cast<FuncUnsubscriber>(dlsym(
288             unsubscriberHandler, SET_WAKEUP_MOTION_UNSUBSCRIBER_CONFIG));
289         if (powerPickupMotionUnsubscriberFlag == nullptr) {
290             POWER_HILOGE(COMP_SVC, "find Unsubscriber function failed, reason : %{public}s", dlerror());
291             dlclose(unsubscriberHandler);
292             return;
293         }
294         powerPickupMotionUnsubscriberFlag();
295         POWER_HILOGI(COMP_SVC, "powerservice disable powerPickupMotionUnsubscriberFlag isSettingEnable=%{public}d",
296             databaseSwitchValue);
297         dlclose(unsubscriberHandler);
298         POWER_HILOGI(COMP_SVC, "open to close PickupMotionSubscriberConfig");
299     }
300 }
301 
ChangePickupWakeupSourceConfig(bool updataEnable)302 void WakeupController::ChangePickupWakeupSourceConfig(bool updataEnable)
303 {
304     std::lock_guard lock(sourceUpdateMutex_);
305     std::string jsonStr = SettingHelper::GetSettingWakeupSources();
306     if (jsonStr.empty()) {
307         POWER_HILOGE(COMP_SVC, "there is no such configuration file available");
308         return;
309     }
310     POWER_HILOGI(COMP_SVC, "%{public}s(%{public}d)", __func__, updataEnable);
311     Json::Value root;
312     Json::Reader reader;
313     reader.parse(jsonStr, root);
314     if (!reader.parse(jsonStr, root)) {
315         POWER_HILOGE(COMP_SVC, "Failed to parse json string");
316         return;
317     }
318     if (root["pickup"].isNull()) {
319         POWER_HILOGE(COMP_SVC, "this pickNode is empty");
320         return;
321     }
322     if (root["pickup"]["enable"].isNull()) {
323         POWER_HILOGE(COMP_SVC, "the pickupNode is empty");
324         return;
325     }
326     if (!root["pickup"]["enable"].isBool()) {
327         POWER_HILOGE(COMP_SVC, "the origin pickupEnable value is invalid");
328         return;
329     }
330     bool originEnable = root["pickup"]["enable"].asBool();
331     if (originEnable == updataEnable) {
332         POWER_HILOGI(COMP_SVC, "no need change jsonconfig_value");
333         return;
334     }
335     root["pickup"]["enable"] = updataEnable;
336     POWER_HILOGI(COMP_SVC, "the new pickupJsonConfig is: %{public}s", root.toStyledString().c_str());
337     SettingHelper::SetSettingWakeupSources(root.toStyledString());
338 }
339 #endif
340 
ChangeLidWakeupSourceConfig(bool updataEnable)341 void WakeupController::ChangeLidWakeupSourceConfig(bool updataEnable)
342 {
343     std::lock_guard lock(sourceUpdateMutex_);
344     std::string jsonStr = SettingHelper::GetSettingWakeupSources();
345     POWER_HILOGI(FEATURE_POWER_STATE, "%{public}s", jsonStr.c_str());
346     Json::Value root;
347     Json::Reader reader;
348     reader.parse(jsonStr, root);
349     if (!reader.parse(jsonStr, root)) {
350         POWER_HILOGE(FEATURE_POWER_STATE, "Failed to parse json string");
351         return;
352     }
353     bool originEnable = true;
354     if (root["lid"]["enable"].isBool()) {
355         originEnable = root["lid"]["enable"].asBool();
356     }
357 
358     if (originEnable == updataEnable) {
359         POWER_HILOGI(FEATURE_POWER_STATE, "no need change jsonConfig value");
360         return;
361     }
362     if (root["lid"]["enable"].isBool()) {
363         root["lid"]["enable"] = updataEnable;
364     }
365     SettingHelper::SetSettingWakeupSources(root.toStyledString());
366 }
367 
368 
ExecWakeupMonitorByReason(WakeupDeviceType reason)369 void WakeupController::ExecWakeupMonitorByReason(WakeupDeviceType reason)
370 {
371     FFRTUtils::SubmitTask([this, reason] {
372         std::lock_guard lock(monitorMutex_);
373         if (monitorMap_.find(reason) != monitorMap_.end()) {
374             auto monitor = monitorMap_[reason];
375             monitor->Notify();
376         }
377     });
378 }
379 
Wakeup()380 void WakeupController::Wakeup()
381 {
382     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
383     if (pms == nullptr) {
384         POWER_HILOGE(FEATURE_WAKEUP, "get powerMgrService instance error");
385         return;
386     }
387     auto suspendController = pms->GetSuspendController();
388     if (suspendController == nullptr) {
389         POWER_HILOGE(FEATURE_WAKEUP, "get suspendController instance error");
390         return;
391     }
392     suspendController->StopSleep();
393 }
394 
SleepGuard(const sptr<PowerMgrService> & pms)395 WakeupController::SleepGuard::SleepGuard(const sptr<PowerMgrService>& pms) : pms_(pms)
396 {
397     token_ = new (std::nothrow) RunningLockTokenStub();
398     if (token_ == nullptr) {
399         POWER_HILOGE(COMP_SVC, "create runninglock token failed");
400         return;
401     }
402     RunningLockInfo info = {"SleepGuard", OHOS::PowerMgr::RunningLockType::RUNNINGLOCK_BACKGROUND_TASK};
403     pms_->CreateRunningLock(token_, info);
404     pms_->Lock(token_, WAKEUP_LOCK_TIMEOUT_MS);
405 }
406 
~SleepGuard()407 WakeupController::SleepGuard::~SleepGuard()
408 {
409     if (token_ == nullptr) {
410         POWER_HILOGE(COMP_SVC, "dtor: token_ is nullptr, direct return ");
411         return;
412     }
413     pms_->ReleaseRunningLock(token_);
414 }
415 
416 #ifdef POWER_MANAGER_WAKEUP_ACTION
IsLowCapacityWakeup(WakeupDeviceType reason)417 bool WakeupController::IsLowCapacityWakeup(WakeupDeviceType reason)
418 {
419     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
420     if (pms == nullptr) {
421         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] pms is nullptr");
422         return false;
423     }
424     auto wakeupActionController = pms->GetWakeupActionController();
425     if (wakeupActionController == nullptr) {
426         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] wakeupActionController is nullptr.");
427         return false;
428     }
429     return (reason == WakeupDeviceType::WAKEUP_DEVICE_POWER_BUTTON) &&
430         (wakeupActionController->IsLowCapacityWakeup());
431 }
432 
ProcessLowCapacityWakeup()433 void WakeupController::ProcessLowCapacityWakeup()
434 {
435     POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] processing low capacity wake up begins.");
436     if (stateMachine_->GetState() != PowerState::SLEEP) {
437         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] the current power state is not sleep.");
438         return;
439     }
440     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
441     if (pms == nullptr) {
442         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] pms is nullptr");
443         return;
444     }
445     auto wakeupActionController = pms->GetWakeupActionController();
446     if (wakeupActionController == nullptr) {
447         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] wakeupActionController is nullptr");
448         return;
449     }
450     SleepGuard sleepGuard(pms);
451     Wakeup();
452     auto suspendController = pms->GetSuspendController();
453     if (suspendController != nullptr) {
454         POWER_HILOGI(FEATURE_WAKEUP, "ControlListener TriggerSyncSleepCallback start.");
455         suspendController->TriggerSyncSleepCallback(true);
456     }
457     wakeupActionController->ExecuteByGetReason();
458 }
459 #endif
460 
HandleWakeup(const sptr<PowerMgrService> & pms,WakeupDeviceType reason)461 void WakeupController::HandleWakeup(const sptr<PowerMgrService>& pms, WakeupDeviceType reason)
462 {
463 #ifdef POWER_MANAGER_ENABLE_EXTERNAL_SCREEN_MANAGEMENT
464     if (IsPowerOnInernalScreenOnlyScene(reason)) {
465         ProcessPowerOnInternalScreenOnly(pms, reason);
466         return;
467     }
468 #endif
469 
470     pid_t pid = IPCSkeleton::GetCallingPid();
471     auto uid = IPCSkeleton::GetCallingUid();
472     POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] Try to wakeup device, pid=%{public}d, uid=%{public}d", pid, uid);
473     if (stateMachine_->GetState() != PowerState::AWAKE || reason == WakeupDeviceType::WAKEUP_DEVICE_SWITCH ||
474         reason == WakeupDeviceType::WAKEUP_DEVICE_LID) {
475         SleepGuard sleepGuard(pms);
476         Wakeup();
477         SystemSuspendController::GetInstance().Wakeup();
478         POWER_HILOGI(FEATURE_WAKEUP, "wakeup Request: %{public}d", reason);
479         if (!stateMachine_->SetState(PowerState::AWAKE, stateMachine_->GetReasonByWakeType(reason), true)) {
480             POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] setstate wakeup error");
481         }
482         auto suspendController = pms->GetSuspendController();
483         if (suspendController != nullptr && stateMachine_->GetState() == PowerState::AWAKE) {
484             POWER_HILOGI(FEATURE_WAKEUP, "WakeupController::ControlListener TriggerSyncSleepCallback start.");
485             suspendController->TriggerSyncSleepCallback(true);
486         }
487 #ifdef POWER_MANAGER_ENABLE_EXTERNAL_SCREEN_MANAGEMENT
488         if (suspendController != nullptr && !stateMachine_->IsSwitchOpen() &&
489             stateMachine_->GetExternalScreenNumber() > 0) {
490             suspendController->PowerOffInternalScreen(SuspendDeviceType::SUSPEND_DEVICE_REASON_SWITCH);
491         }
492 #endif
493     } else {
494         POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] state=%{public}u no transitor", stateMachine_->GetState());
495     }
496 }
497 
ControlListener(WakeupDeviceType reason)498 void WakeupController::ControlListener(WakeupDeviceType reason)
499 {
500     std::lock_guard lock(mutex_);
501     if (!Permission::IsSystem()) {
502         return;
503     }
504 
505     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
506     if (pms == nullptr) {
507         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] get PowerMgrService instance error");
508         return;
509     }
510 
511     if (NeedToSkipCurrentWakeup(pms, reason)) {
512         return;
513     }
514 
515     HandleWakeup(pms, reason);
516 }
517 
518 #ifdef HAS_MULTIMODALINPUT_INPUT_PART
519 /* InputCallback achieve */
isRemoteEvent(std::shared_ptr<InputEvent> event) const520 bool InputCallback::isRemoteEvent(std::shared_ptr<InputEvent> event) const
521 {
522     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
523     bool isCollaborationEvent =
524         pms && pms->IsCollaborationState() && event->GetDeviceId() == COLLABORATION_REMOTE_DEVICE_ID;
525     bool isFromOtherSource = event->GetDeviceId() == OTHER_SYSTEM_DEVICE_ID;
526     return isCollaborationEvent || isFromOtherSource;
527 }
528 
isKeyboardKeycode(int32_t keyCode) const529 bool InputCallback::isKeyboardKeycode(int32_t keyCode) const
530 {
531     if ((keyCode >= KeyEvent::KEYCODE_0 && keyCode <= KeyEvent::KEYCODE_NUMPAD_RIGHT_PAREN
532         && keyCode != KeyEvent::KEYCODE_F1)
533         || (keyCode == KeyEvent::KEYCODE_BRIGHTNESS_DOWN) // F1 hotkey
534         || (keyCode == KeyEvent::KEYCODE_BRIGHTNESS_UP) // F2 hotkey
535         || (keyCode == KeyEvent::KEYCODE_FN) // F3 hotkey
536         || (keyCode == KeyEvent::KEYCODE_VOLUME_MUTE) // F4 hotkey
537         || (keyCode == KeyEvent::KEYCODE_SOUND) // sound
538         || (keyCode == KeyEvent::KEYCODE_MUTE) // F7 hotkey
539         || (keyCode == KeyEvent::KEYCODE_SWITCHVIDEOMODE) // F8 hotkey
540         || (keyCode == KeyEvent::KEYCODE_SEARCH) // F9 hotkey
541         || (keyCode == KeyEvent::KEYCODE_ASSISTANT)) { // assistant
542         return true;
543     }
544     return false;
545 }
546 
OnInputEvent(std::shared_ptr<KeyEvent> keyEvent) const547 void InputCallback::OnInputEvent(std::shared_ptr<KeyEvent> keyEvent) const
548 {
549     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
550     if (pms == nullptr) {
551         POWER_HILOGE(FEATURE_WAKEUP, "get powerMgrService instance error");
552         return;
553     }
554     // ignores remote event
555     if (isRemoteEvent(keyEvent)) {
556         return;
557     }
558     int64_t now = static_cast<int64_t>(time(nullptr));
559     pms->RefreshActivityInner(now, UserActivityType::USER_ACTIVITY_TYPE_BUTTON, false);
560 
561     PowerState state = pms->GetState();
562     if (state == PowerState::AWAKE || state == PowerState::FREEZE) {
563         return;
564     }
565     std::shared_ptr<WakeupController> wakeupController = pms->GetWakeupController();
566     if (wakeupController == nullptr) {
567         POWER_HILOGE(FEATURE_WAKEUP, "wakeupController is not init");
568         return;
569     }
570 
571     int32_t keyCode = keyEvent->GetKeyCode();
572     WakeupDeviceType wakeupType = WakeupDeviceType::WAKEUP_DEVICE_UNKNOWN;
573     if (keyCode == KeyEvent::KEYCODE_F1) {
574         wakeupType = WakeupDeviceType::WAKEUP_DEVICE_DOUBLE_CLICK;
575     } else if (keyCode == KeyEvent::KEYCODE_STYLUS_SCREEN) {
576         wakeupType = WakeupDeviceType::WAKEUP_DEVICE_PEN;
577     } else if (keyCode == KeyEvent::KEYCODE_WAKEUP) {
578         wakeupType = WakeupDeviceType::WAKEUP_DEVICE_TP_TOUCH;
579     }
580 
581     if (isKeyboardKeycode(keyCode)) {
582         wakeupType = WakeupDeviceType::WAKEUP_DEVICE_KEYBOARD;
583         if (wakeupController->CheckEventReciveTime(wakeupType) ||
584             keyEvent->GetKeyAction() == KeyEvent::KEY_ACTION_UP) {
585             return;
586         }
587     }
588 
589     POWER_HILOGD(FEATURE_WAKEUP, "[UL_POWER] KeyEvent wakeupType=%{public}u, keyCode=%{public}d", wakeupType, keyCode);
590     if (wakeupType != WakeupDeviceType::WAKEUP_DEVICE_UNKNOWN) {
591         wakeupController->ExecWakeupMonitorByReason(wakeupType);
592     }
593 }
594 
TouchEventAfterScreenOn(std::shared_ptr<PointerEvent> pointerEvent,PowerState state) const595 bool InputCallback::TouchEventAfterScreenOn(std::shared_ptr<PointerEvent> pointerEvent, PowerState state) const
596 {
597     if (state == PowerState::AWAKE || state == PowerState::FREEZE) {
598 #ifdef POWER_MANAGER_ENABLE_WATCH_CUSTOMIZED_SCREEN_COMMON_EVENT_RULES
599         int32_t sourceType1 = pointerEvent->GetSourceType();
600         if (sourceType1 == PointerEvent::POINTER_ACTION_DOWN) {
601             DelayedSingleton<CustomizedScreenEventRules>::GetInstance()->NotifyOperateEventAfterScreenOn();
602         }
603 #endif
604         return true;
605     }
606     return false;
607 }
608 
OnInputEvent(std::shared_ptr<PointerEvent> pointerEvent) const609 void InputCallback::OnInputEvent(std::shared_ptr<PointerEvent> pointerEvent) const
610 {
611     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
612     if (pms == nullptr) {
613         return;
614     }
615     if (!NonWindowEvent(pointerEvent)) {
616         return;
617     }
618     if (isRemoteEvent(pointerEvent)) {
619         return;
620     }
621     int64_t now = static_cast<int64_t>(time(nullptr));
622     pms->RefreshActivityInner(now, UserActivityType::USER_ACTIVITY_TYPE_TOUCH, false);
623 
624     PowerState state = pms->GetState();
625     if (TouchEventAfterScreenOn(pointerEvent, state)) {
626         return;
627     }
628     std::shared_ptr<WakeupController> wakeupController = pms->GetWakeupController();
629     WakeupDeviceType wakeupType = WakeupDeviceType::WAKEUP_DEVICE_UNKNOWN;
630     PointerEvent::PointerItem pointerItem;
631     if (!pointerEvent->GetPointerItem(pointerEvent->GetPointerId(), pointerItem)) {
632         POWER_HILOGI(FEATURE_WAKEUP, "GetPointerItem false");
633     }
634     int32_t deviceType = pointerItem.GetToolType();
635     int32_t sourceType = pointerEvent->GetSourceType();
636     if (deviceType == PointerEvent::TOOL_TYPE_PEN) {
637         wakeupType = WakeupDeviceType::WAKEUP_DEVICE_PEN;
638     } else {
639         switch (sourceType) {
640             case PointerEvent::SOURCE_TYPE_MOUSE:
641                 wakeupType = WakeupDeviceType::WAKEUP_DEVICE_MOUSE;
642                 break;
643             case PointerEvent::SOURCE_TYPE_TOUCHPAD:
644                 wakeupType = WakeupDeviceType::WAKEUP_DEVICE_TOUCHPAD;
645                 break;
646             case PointerEvent::SOURCE_TYPE_TOUCHSCREEN:
647                 wakeupType = WakeupDeviceType::WAKEUP_DEVICE_SINGLE_CLICK;
648                 break;
649             default:
650                 break;
651         }
652     }
653     if (wakeupController->CheckEventReciveTime(wakeupType)) {
654         return;
655     }
656 
657     if (wakeupType != WakeupDeviceType::WAKEUP_DEVICE_UNKNOWN) {
658         POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] PointerEvent wakeupType=%{public}u", wakeupType);
659         wakeupController->ExecWakeupMonitorByReason(wakeupType);
660     }
661 }
662 
NonWindowEvent(const std::shared_ptr<PointerEvent> & pointerEvent) const663 bool InputCallback::NonWindowEvent(const std::shared_ptr<PointerEvent>& pointerEvent) const
664 {
665     auto action = pointerEvent->GetPointerAction();
666     if (action == PointerEvent::POINTER_ACTION_ENTER_WINDOW ||
667         action == PointerEvent::POINTER_ACTION_LEAVE_WINDOW ||
668         action == PointerEvent::POINTER_ACTION_PULL_IN_WINDOW ||
669         action == PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW) {
670         return false;
671     }
672     return true;
673 }
674 
OnInputEvent(std::shared_ptr<AxisEvent> axisEvent) const675 void InputCallback::OnInputEvent(std::shared_ptr<AxisEvent> axisEvent) const
676 {
677     POWER_HILOGD(FEATURE_WAKEUP, "AxisEvent");
678     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
679     if (pms == nullptr) {
680         return;
681     }
682     int64_t now = static_cast<int64_t>(time(nullptr));
683     pms->RefreshActivityInner(now, UserActivityType::USER_ACTIVITY_TYPE_ACCESSIBILITY, false);
684 }
685 #endif
686 
CheckEventReciveTime(WakeupDeviceType wakeupType)687 bool WakeupController::CheckEventReciveTime(WakeupDeviceType wakeupType)
688 {
689     // The minimum refreshactivity interval is 100ms!!
690     std::lock_guard lock(eventHandleMutex_);
691     int64_t now = GetTickCount();
692     if (eventHandleMap_.find(wakeupType) != eventHandleMap_.end()) {
693         if ((eventHandleMap_[wakeupType] + MIN_TIME_MS_BETWEEN_MULTIMODEACTIVITIES) > now) {
694             return true;
695         }
696         eventHandleMap_[wakeupType] = now;
697         return false;
698     }
699     return false;
700 }
701 
702 #ifdef POWER_MANAGER_ENABLE_EXTERNAL_SCREEN_MANAGEMENT
PowerOnInternalScreen(WakeupDeviceType type)703 void WakeupController::PowerOnInternalScreen(WakeupDeviceType type)
704 {
705 #ifdef POWER_MANAGER_POWER_ENABLE_S4
706     if (stateMachine_->IsHibernating()) {
707         POWER_HILOGI(FEATURE_SUSPEND, "[UL_POWER] Do not power the internal screen while hibernating");
708         return;
709     }
710 #endif
711     if (!stateMachine_->IsSwitchOpen()) {
712         POWER_HILOGI(FEATURE_SUSPEND, "[UL_POWER] Do not power the internal screen while switch is close");
713         return;
714     }
715 
716     auto changeReason = stateMachine_->GetReasonByWakeType(type);
717     auto dmsReason = PowerUtils::GetDmsReasonByPowerReason(changeReason);
718     uint64_t screenId = Rosen::DisplayManagerLite::GetInstance().GetInternalScreenId();
719     bool ret = Rosen::DisplayManagerLite::GetInstance().SetScreenPowerById(
720         screenId, Rosen::ScreenPowerState::POWER_ON, dmsReason);
721     POWER_HILOGI(FEATURE_WAKEUP,
722         "[UL_POWER] Power on internal screen, reason = %{public}u, screenId = %{public}u, ret = %{public}d", dmsReason,
723         static_cast<uint32_t>(screenId), ret);
724 }
725 
PowerOnAllScreens(WakeupDeviceType type)726 void WakeupController::PowerOnAllScreens(WakeupDeviceType type)
727 {
728 #ifdef POWER_MANAGER_POWER_ENABLE_S4
729     if (stateMachine_->IsHibernating()) {
730         POWER_HILOGI(FEATURE_SUSPEND, "[UL_POWER] Do not power all the screen while hibernating");
731         return;
732     }
733 #endif
734 
735     auto changeReason = stateMachine_->GetReasonByWakeType(type);
736     auto dmsReason = PowerUtils::GetDmsReasonByPowerReason(changeReason);
737     bool ret =
738         Rosen::ScreenManagerLite::GetInstance().SetScreenPowerForAll(Rosen::ScreenPowerState::POWER_ON, dmsReason);
739     POWER_HILOGI(FEATURE_WAKEUP, "Power on all screens, reason = %{public}u, ret = %{public}d", dmsReason, ret);
740 }
741 
IsPowerOnInernalScreenOnlyScene(WakeupDeviceType reason) const742 bool WakeupController::IsPowerOnInernalScreenOnlyScene(WakeupDeviceType reason) const
743 {
744     // switch action 0 menas only doing poweroff when closing switch
745     if (reason == WakeupDeviceType::WAKEUP_DEVICE_SWITCH && stateMachine_->GetSwitchAction() == 0 &&
746         stateMachine_->GetExternalScreenNumber() > 0 && stateMachine_->IsScreenOn()) {
747         return true;
748     }
749     return false;
750 }
751 
ProcessPowerOnInternalScreenOnly(const sptr<PowerMgrService> & pms,WakeupDeviceType reason)752 void WakeupController::ProcessPowerOnInternalScreenOnly(const sptr<PowerMgrService>& pms, WakeupDeviceType reason)
753 {
754     POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] Power on internal screen only when external screen is on");
755     PowerOnInternalScreen(reason);
756     pms->RefreshActivity(GetTickCount(), UserActivityType::USER_ACTIVITY_TYPE_SWITCH, false);
757 }
758 #endif
759 
NeedToSkipCurrentWakeup(const sptr<PowerMgrService> & pms,WakeupDeviceType reason) const760 bool WakeupController::NeedToSkipCurrentWakeup(const sptr<PowerMgrService>& pms, WakeupDeviceType reason) const
761 {
762     bool skipWakeup = !stateMachine_->IsSwitchOpen();
763 #ifdef POWER_MANAGER_ENABLE_EXTERNAL_SCREEN_MANAGEMENT
764     skipWakeup = skipWakeup && (stateMachine_->GetExternalScreenNumber() <= 0);
765 #endif
766     if (skipWakeup) {
767         POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] Switch is closed, skip current wakeup reason: %{public}u", reason);
768         return true;
769     }
770 
771 #ifdef POWER_MANAGER_POWER_ENABLE_S4
772     skipWakeup = stateMachine_->IsHibernating();
773     if (skipWakeup) {
774         POWER_HILOGI(
775             FEATURE_WAKEUP, "[UL_POWER] Device is hibernating, skip current wakeup reason: %{public}u", reason);
776         return true;
777     }
778 #endif
779 
780     skipWakeup = (pms->IsScreenOn()) && (reason != WakeupDeviceType::WAKEUP_DEVICE_SWITCH) &&
781         (reason != WakeupDeviceType::WAKEUP_DEVICE_LID);
782     if (skipWakeup) {
783         POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] Screen is on, skip current wakeup reason: %{public}u", reason);
784 #ifdef POWER_MANAGER_ENABLE_WATCH_CUSTOMIZED_SCREEN_COMMON_EVENT_RULES
785         DelayedSingleton<CustomizedScreenEventRules>::GetInstance()->NotifyScreenOnEventAgain(reason);
786 #endif
787         return true;
788     }
789 
790     return false;
791 }
792 
793 /* WakeupMonitor Implement */
794 
CreateMonitor(WakeupSource & source)795 std::shared_ptr<WakeupMonitor> WakeupMonitor::CreateMonitor(WakeupSource& source)
796 {
797     WakeupDeviceType reason = source.GetReason();
798     std::shared_ptr<WakeupMonitor> monitor = nullptr;
799     switch (reason) {
800         case WakeupDeviceType::WAKEUP_DEVICE_POWER_BUTTON:
801             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<PowerkeyWakeupMonitor>(source));
802             break;
803         case WakeupDeviceType::WAKEUP_DEVICE_MOUSE:
804             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<MousekeyWakeupMonitor>(source));
805             break;
806         case WakeupDeviceType::WAKEUP_DEVICE_KEYBOARD:
807             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<KeyboardWakeupMonitor>(source));
808             break;
809         case WakeupDeviceType::WAKEUP_DEVICE_PEN:
810             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<PenWakeupMonitor>(source));
811             break;
812         case WakeupDeviceType::WAKEUP_DEVICE_TOUCHPAD:
813             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<TouchpadWakeupMonitor>(source));
814             break;
815         case WakeupDeviceType::WAKEUP_DEVICE_SINGLE_CLICK:
816             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<SingleClickWakeupMonitor>(source));
817             break;
818         case WakeupDeviceType::WAKEUP_DEVICE_DOUBLE_CLICK:
819             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<DoubleClickWakeupMonitor>(source));
820             break;
821         case WakeupDeviceType::WAKEUP_DEVICE_LID:
822             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<LidWakeupMonitor>(source));
823             break;
824         case WakeupDeviceType::WAKEUP_DEVICE_SWITCH:
825             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<SwitchWakeupMonitor>(source));
826             break;
827         case WakeupDeviceType::WAKEUP_DEVICE_PICKUP:
828             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<PickupWakeupMonitor>(source));
829             break;
830         case WakeupDeviceType::WAKEUP_DEVICE_TP_TOUCH:
831             monitor = std::static_pointer_cast<WakeupMonitor>(std::make_shared<TPTouchWakeupMonitor>(source));
832             break;
833         default:
834             POWER_HILOGE(FEATURE_WAKEUP, "CreateMonitor : Invalid reason=%{public}d", reason);
835             break;
836     }
837     return monitor;
838 }
839 
840 /** PowerkeyWakeupMonitor Implement */
Init()841 bool PowerkeyWakeupMonitor::Init()
842 {
843     if (powerkeyShortPressId_ >= 0) {
844         return true;
845     }
846     std::shared_ptr<OHOS::MMI::KeyOption> keyOption = std::make_shared<OHOS::MMI::KeyOption>();
847     std::set<int32_t> preKeys;
848     keyOption.reset();
849     keyOption = std::make_shared<OHOS::MMI::KeyOption>();
850     keyOption->SetPreKeys(preKeys);
851     keyOption->SetFinalKey(OHOS::MMI::KeyEvent::KEYCODE_POWER);
852     keyOption->SetFinalKeyDown(true);
853     keyOption->SetFinalKeyDownDuration(0);
854     std::weak_ptr<PowerkeyWakeupMonitor> weak = weak_from_this();
855     powerkeyShortPressId_ = InputManager::GetInstance()->SubscribeKeyEvent(
856         keyOption, [weak](std::shared_ptr<OHOS::MMI::KeyEvent> keyEvent) {
857             std::shared_ptr<PowerkeyWakeupMonitor> strong = weak.lock();
858             if (!strong) {
859                 POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] PowerkeyWakeupMonitor is invaild, return");
860                 return;
861             }
862 
863             strong->ReceivePowerkeyCallback(keyEvent);
864         });
865 
866     POWER_HILOGI(FEATURE_WAKEUP, "powerkey register powerkeyShortPressId_=%{public}d", powerkeyShortPressId_);
867     return powerkeyShortPressId_ >= 0 ? true : false;
868 }
869 
ReceivePowerkeyCallback(std::shared_ptr<OHOS::MMI::KeyEvent> keyEvent)870 void PowerkeyWakeupMonitor::ReceivePowerkeyCallback(std::shared_ptr<OHOS::MMI::KeyEvent> keyEvent)
871 {
872 #ifndef POWER_MANAGER_ALLOW_INTERRUPTING_POWERKEY_OFF
873     ffrt::wait({&PowerKeySuspendMonitor::powerkeyScreenOff_});
874 #endif
875     POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] Received powerkey down");
876 
877     auto pms = DelayedSpSingleton<PowerMgrService>::GetInstance();
878     if (pms == nullptr) {
879         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] PowerMgrService is nullptr");
880         return;
881     }
882     int64_t now = static_cast<int64_t>(time(nullptr));
883     pms->RefreshActivityInner(now, UserActivityType::USER_ACTIVITY_TYPE_BUTTON, false);
884 
885     std::shared_ptr<WakeupController> wakeupController = pms->GetWakeupController();
886     if (wakeupController == nullptr) {
887         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] wakeupController is nullptr");
888         return;
889     }
890 #ifdef POWER_MANAGER_WAKEUP_ACTION
891     if (wakeupController->IsLowCapacityWakeup(WakeupDeviceType::WAKEUP_DEVICE_POWER_BUTTON)) {
892         wakeupController->ProcessLowCapacityWakeup();
893         return;
894     }
895 #endif
896     std::shared_ptr<SuspendController> suspendController = pms->GetSuspendController();
897     if (suspendController == nullptr) {
898         POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] suspendController is nullptr");
899         return;
900     }
901     bool poweroffInterrupted = false;
902     if (PowerKeySuspendMonitor::powerkeyScreenOff_.load()) {
903         auto stateMachine = pms->GetPowerStateMachine();
904         if (!stateMachine) {
905             POWER_HILOGE(FEATURE_WAKEUP, "TryToCancelScreenOff, state machine is nullptr");
906         } else {
907             poweroffInterrupted = stateMachine->TryToCancelScreenOff();
908         }
909     }
910     // sync with the end of powerkey screen off task
911     ffrt::wait({&PowerKeySuspendMonitor::powerkeyScreenOff_});
912     suspendController->RecordPowerKeyDown(poweroffInterrupted);
913     Notify();
914 }
915 
Cancel()916 void PowerkeyWakeupMonitor::Cancel()
917 {
918     if (powerkeyShortPressId_ >= 0) {
919         POWER_HILOGI(FEATURE_WAKEUP, "UnsubscribeKeyEvent: PowerkeyWakeupMonitor");
920         InputManager::GetInstance()->UnsubscribeKeyEvent(powerkeyShortPressId_);
921     }
922 }
923 
924 /** Keyboard Implement */
925 
Init()926 bool KeyboardWakeupMonitor::Init()
927 {
928     return true;
929 }
930 
Cancel()931 void KeyboardWakeupMonitor::Cancel() {}
932 
933 /** Mouse Implement */
934 
Init()935 bool MousekeyWakeupMonitor::Init()
936 {
937     return true;
938 }
939 
Cancel()940 void MousekeyWakeupMonitor::Cancel() {}
941 
942 /** Mouse Implement */
943 
Init()944 bool TouchpadWakeupMonitor::Init()
945 {
946     return true;
947 }
948 
Cancel()949 void TouchpadWakeupMonitor::Cancel() {}
950 
951 /** Pen Implement */
952 
Init()953 bool PenWakeupMonitor::Init()
954 {
955     return true;
956 }
957 
Cancel()958 void PenWakeupMonitor::Cancel() {}
959 
960 /** SingleClickWakeupMonitor Implement */
961 
Init()962 bool SingleClickWakeupMonitor::Init()
963 {
964     return true;
965 }
966 
Cancel()967 void SingleClickWakeupMonitor::Cancel() {}
968 
969 /** DoubleClickWakeupMonitor Implement */
970 
Init()971 bool DoubleClickWakeupMonitor::Init()
972 {
973     return true;
974 }
975 
Cancel()976 void DoubleClickWakeupMonitor::Cancel() {}
977 
978 /** SwitchWakeupMonitor Implement */
979 
Init()980 bool SwitchWakeupMonitor::Init()
981 {
982     return true;
983 }
984 
Cancel()985 void SwitchWakeupMonitor::Cancel() {}
986 
987 /** LidWakeupMonitor Implement */
988 
Init()989 bool LidWakeupMonitor::Init()
990 {
991     return true;
992 }
993 
Cancel()994 void LidWakeupMonitor::Cancel() {}
995 
996 /** PickupWakeupMonitor Implement */
997 
Init()998 bool PickupWakeupMonitor::Init()
999 {
1000     return true;
1001 }
1002 
Cancel()1003 void PickupWakeupMonitor::Cancel() {}
1004 
1005 /** TPTouchWakeupMonitor Implement */
1006 
Init()1007 bool TPTouchWakeupMonitor::Init()
1008 {
1009     return true;
1010 }
1011 
Cancel()1012 void TPTouchWakeupMonitor::Cancel() {}
1013 } // namespace PowerMgr
1014 } // namespace OHOS
1015