已合并
Skip TriggerSyncSleepCallback when WakeupAction=ACTION_NONE #2205
benjaminzhang000创建于 7 天前
Skip TriggerSyncSleepCallback when WakeupAction=ACTION_NONE #2205
已合并
共 3 个文件变更+45-27
| @@ -560,6 +560,12 @@ void WakeupController::ProcessWakeupReason() | |||
| 560 | POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] wakeupActionController is nullptr"); | 560 | POWER_HILOGE(FEATURE_WAKEUP, "[UL_POWER] wakeupActionController is nullptr"); |
| 561 | return; | 561 | return; |
| 562 | } | 562 | } |
| 563 | + std::string wakeupReason; | ||
| 564 | + wakeupActionController->GetWakeupReason(wakeupReason); | ||
| 565 | + if (wakeupActionController->GetWakeupAction(wakeupReason) == WakeupAction::ACTION_NONE) { | ||
| 566 | + POWER_HILOGI(FEATURE_WAKEUP, "[UL_POWER] WakeupAction is NONE, skip Wakeup and TriggerSyncSleepCallback."); | ||
| 567 | + return; | ||
| 568 | + } | ||
| 563 | SleepGuard sleepGuard(pms); | 569 | SleepGuard sleepGuard(pms); |
| 564 | Wakeup(); | 570 | Wakeup(); |
| 565 | auto suspendController = pms->GetSuspendController(); | 571 | auto suspendController = pms->GetSuspendController(); |
| @@ -567,7 +573,7 @@ void WakeupController::ProcessWakeupReason() | |||
| 567 | POWER_HILOGI(FEATURE_WAKEUP, "ControlListener TriggerSyncSleepCallback start."); | 573 | POWER_HILOGI(FEATURE_WAKEUP, "ControlListener TriggerSyncSleepCallback start."); |
| 568 | suspendController->TriggerSyncSleepCallback(true); | 574 | suspendController->TriggerSyncSleepCallback(true); |
| 569 | } | 575 | } |
| 570 | - wakeupActionController->ExecuteByGetReason(); | 576 | + wakeupActionController->ExecuteByGetReason(wakeupReason); |
| 571 | } | 577 | } |
| 572 | 578 | ||
| 573 | 579 | ||
| @@ -45,16 +45,35 @@ void WakeupActionController::Init() | |||
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | -bool WakeupActionController::IsWakeupReasonConfigMatched() | 48 | +void WakeupActionController::GetWakeupReason(std::string& reason) |
| 49 | { | 49 | { |
| 50 | - std::string reason; | ||
| 51 | SystemSuspendController::GetInstance().GetWakeupReason(reason); | 50 | SystemSuspendController::GetInstance().GetWakeupReason(reason); |
| 52 | if (reason.empty()) { | 51 | if (reason.empty()) { |
| 53 | POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason is empty"); | 52 | POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason is empty"); |
| 54 | - return false; | 53 | + return; |
| 55 | } | 54 | } |
| 56 | reason.erase(reason.end() - 1); | 55 | reason.erase(reason.end() - 1); |
| 57 | POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason %{public}s", reason.c_str()); | 56 | POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason %{public}s", reason.c_str()); |
| 57 | +} | ||
| 58 | + | ||
| 59 | +WakeupAction WakeupActionController::GetWakeupAction(const std::string& reason) const | ||
| 60 | +{ | ||
| 61 | + auto it = sourceMap_.find(reason); | ||
| 62 | + if (it == sourceMap_.end()) { | ||
| 63 | + return WakeupAction::ACTION_INVALID; | ||
| 64 | + } | ||
| 65 | + auto action = it->second->GetAction(); | ||
| 66 | + POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason %{public}s, action %{public}d", reason.c_str(), action); | ||
| 67 | + return static_cast<WakeupAction>(action); | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +bool WakeupActionController::IsWakeupReasonConfigMatched() | ||
| 71 | +{ | ||
| 72 | + std::string reason; | ||
| 73 | + GetWakeupReason(reason); | ||
| 74 | + if (reason.empty()) { | ||
| 75 | + return false; | ||
| 76 | + } | ||
| 58 | if (sourceMap_.find(reason) != sourceMap_.end()) { | 77 | if (sourceMap_.find(reason) != sourceMap_.end()) { |
| 59 | return true; | 78 | return true; |
| 60 | } | 79 | } |
| @@ -62,33 +81,24 @@ bool WakeupActionController::IsWakeupReasonConfigMatched() | |||
| 62 | return false; | 81 | return false; |
| 63 | } | 82 | } |
| 64 | 83 | ||
| 65 | -bool WakeupActionController::ExecuteByGetReason() | 84 | +bool WakeupActionController::ExecuteByGetReason(const std::string& reason) |
| 66 | { | 85 | { |
| 67 | - std::string reason; | 86 | + if (sourceMap_.find(reason) == sourceMap_.end()) { |
| 68 | - SystemSuspendController::GetInstance().GetWakeupReason(reason); | 87 | + POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason %{public}s doesn't exist", reason.c_str()); |
| 69 | - if (reason.empty()) { | ||
| 70 | - POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason is empty"); | ||
| 71 | return false; | 88 | return false; |
| 72 | } | 89 | } |
| 73 | - reason.erase(reason.end() - 1); | 90 | + pid_t pid = IPCSkeleton::GetCallingPid(); |
| 74 | - POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason %{public}s", reason.c_str()); | 91 | + auto uid = IPCSkeleton::GetCallingUid(); |
| 75 | - if (sourceMap_.find(reason) != sourceMap_.end()) { | 92 | + POWER_HILOGI(FEATURE_WAKEUP_ACTION, |
| 76 | - pid_t pid = IPCSkeleton::GetCallingPid(); | 93 | + "WakeupAction device, pid=%{public}d, uid=%{public}d, reason=%{public}s, scene=%{public}s, action=%{public}u", |
| 77 | - auto uid = IPCSkeleton::GetCallingUid(); | 94 | + pid, uid, reason.c_str(), sourceMap_[reason]->GetScene().c_str(), sourceMap_[reason]->GetAction()); |
| 78 | - POWER_HILOGI(FEATURE_WAKEUP_ACTION, | ||
| 79 | - "WakeupAction device, pid=%{public}d, uid=%{public}d, reason=%{public}s, scene=%{public}s, " | ||
| 80 | - "action=%{public}u", | ||
| 81 | - pid, uid, reason.c_str(), sourceMap_[reason]->GetScene().c_str(), sourceMap_[reason]->GetAction()); | ||
| 82 | 95 | ||
| 83 | - std::string str = reason + ":" + std::to_string(sourceMap_[reason]->GetAction()); | 96 | + std::string str = reason + ":" + std::to_string(sourceMap_[reason]->GetAction()); |
| 84 | - HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::POWER, "WAKEUP_STATISTIC", | 97 | + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::POWER, "WAKEUP_STATISTIC", |
| 85 | - HiviewDFX::HiSysEvent::EventType::STATISTIC, "WAKEUP_REASON", str.c_str()); | 98 | + HiviewDFX::HiSysEvent::EventType::STATISTIC, "WAKEUP_REASON", str.c_str()); |
| 86 | 99 | ||
| 87 | - HandleAction(reason); | 100 | + HandleAction(reason); |
| 88 | - return true; | 101 | + return true; |
| 89 | - } | ||
| 90 | - POWER_HILOGI(FEATURE_WAKEUP_ACTION, "WakeupAction reason %{public}s doesn't exist", reason.c_str()); | ||
| 91 | - return false; | ||
| 92 | } | 102 | } |
| 93 | 103 | ||
| 94 | void WakeupActionController::HandleAction(const std::string& reason) | 104 | void WakeupActionController::HandleAction(const std::string& reason) |
| @@ -35,7 +35,9 @@ public: | |||
| 35 | std::shared_ptr<ShutdownController>& shutdownController, std::shared_ptr<PowerStateMachine>& stateMachine); | 35 | std::shared_ptr<ShutdownController>& shutdownController, std::shared_ptr<PowerStateMachine>& stateMachine); |
| 36 | ~WakeupActionController(); | 36 | ~WakeupActionController(); |
| 37 | void Init(); | 37 | void Init(); |
| 38 | - bool ExecuteByGetReason(); | 38 | + void GetWakeupReason(std::string& reason); |
| 39 | + WakeupAction GetWakeupAction(const std::string& reason) const; | ||
| 40 | + bool ExecuteByGetReason(const std::string& reason); | ||
| 39 | bool IsWakeupReasonConfigMatched(); | 41 | bool IsWakeupReasonConfigMatched(); |
| 40 | 42 | ||
| 41 | private: | 43 | private: |