From 945d68acc1e011b12113a178d69fbb33b0ef9d78 Mon Sep 17 00:00:00 2001 From: youshugen Date: Tue, 21 Jan 2025 11:22:14 +0800 Subject: [PATCH] fix: alarming improve Signed-off-by: youshugen --- displaymanager.yaml | 12 ++++++++ .../service/native/include/screen_action.h | 1 + .../service/native/src/screen_action.cpp | 28 ++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/displaymanager.yaml b/displaymanager.yaml index 89bd42b..eadff14 100644 --- a/displaymanager.yaml +++ b/displaymanager.yaml @@ -31,3 +31,15 @@ AMBIENT_LIGHT: __BASE: {type: STATISTIC, level: MINOR, tag: PowerStats, desc: ambient light information} TYPE: {type: INT32, desc: ambient light type} LEVEL: {type: INT32, desc: ambient light adjusts screen brightness} + +DMS_WAIT_LOCKSCREENON_TIMEOUT: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dms wait lockscreenon timeout information} + PACKAGE_NAME: {type: STRING, desc: call package name} + PROCESS_NAME: {type: STRING, desc: call process name} + MSG: {type: STRING, desc: dms wait lockscreenon timeout message} + +DMS_WAIT_LOCKSCREENOFF_TIMEOUT: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: dms wait lockscreenoff timeout information} + PACKAGE_NAME: {type: STRING, desc: call package name} + PROCESS_NAME: {type: STRING, desc: call process name} + MSG: {type: STRING, desc: dms wait lockscreenoff timeout message} \ No newline at end of file diff --git a/state_manager/service/native/include/screen_action.h b/state_manager/service/native/include/screen_action.h index eb21e06..448c5c1 100644 --- a/state_manager/service/native/include/screen_action.h +++ b/state_manager/service/native/include/screen_action.h @@ -38,6 +38,7 @@ public: uint32_t GetDisplayId(); DisplayState GetDisplayState(); + void WriteHiSysEvent(DisplayState state, int64_t beginTimeMs); bool SetDisplayState(DisplayState state, const std::function& callback); bool SetDisplayPower(DisplayState state, uint32_t reason); uint32_t GetBrightness(); diff --git a/state_manager/service/native/src/screen_action.cpp b/state_manager/service/native/src/screen_action.cpp index 38ad1de..937813e 100644 --- a/state_manager/service/native/src/screen_action.cpp +++ b/state_manager/service/native/src/screen_action.cpp @@ -14,7 +14,7 @@ */ #include "screen_action.h" - +#include #include #include @@ -85,8 +85,31 @@ bool ScreenAction::EnableSkipSetDisplayState(uint32_t reason) return false; } +void ScreenAction::WriteHiSysEvent(DisplayState state, int64_t beginTimeMs) +{ + constexpr int64_t DMS_WAIT_LOCKSCREENON_TIMEOUT = 300; + constexpr int64_t DMS_WAIT_LOCKSCREENOFF_TIMEOUT = 2000; + int64_t endTimeMs = GetTickCount(); + if ((endTimeMs - beginTimeMs > DMS_WAIT_LOCKSCREENON_TIMEOUT) && state == DisplayState::DISPLAY_ON) { + std::string msg = "Dms Wait Lockscreenon Time Consuming Over 300MS"; + DISPLAY_HILOGI(FEAT_STATE, "dms wait lockscreenon timeout=%{public}lld", (endTimeMs - beginTimeMs)); + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::DISPLAY, "DMS_WAIT_LOCKSCREENON_TIMEOUT", + HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "PACKAGE_NAME", "powermgr", "PROCESS_NAME", + "ScreenAction", "MSG", msg); + } else if ((endTimeMs - beginTimeMs > DMS_WAIT_LOCKSCREENOFF_TIMEOUT) && state == DisplayState::DISPLAY_OFF) { + std::string msg = "Dms Wait Lockscreenoff Time Consuming Over 2000MS"; + DISPLAY_HILOGI(FEAT_STATE, "dms wait lockscreenoff timeout=%{public}lld", (endTimeMs - beginTimeMs)); + HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::DISPLAY, "DMS_WAIT_LOCKSCREENOFF_TIMEOUT", + HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "PACKAGE_NAME", "powermgr", "PROCESS_NAME", + "ScreenAction", "MSG", msg); + } +} + bool ScreenAction::SetDisplayState(DisplayState state, const std::function& callback) { +#ifdef HAS_HIVIEWDFX_HISYSEVENT_PART + int64_t beginTimeMs = GetTickCount(); +#endif DISPLAY_HILOGI(FEAT_STATE, "[UL_POWER] SetDisplayState displayId=%{public}u, state=%{public}u", displayId_, static_cast(state)); Rosen::DisplayState rds = Rosen::DisplayState::UNKNOWN; @@ -120,6 +143,9 @@ bool ScreenAction::SetDisplayState(DisplayState state, const std::function