add system event for window, event include:

- WINDOW_LIFE_CYCLE_EXCEPTION
- WINDOW_BOOT_ANIMATION_DONE

Signed-off-by: xiahaiqin <xiahaiqin1@huawei.com>
Change-Id: I0268e77ce474262b1879d41af61957aa26ff5933
This commit is contained in:
xiahaiqin
2022-06-18 16:28:39 +08:00
parent 8653abb2be
commit 549e5ff561
7 changed files with 98 additions and 2 deletions
+10
View File
@@ -45,4 +45,14 @@ NO_FOCUS_WINDOW:
UID: {type: INT32, desc: session uid}
PACKAGE_NAME: {type: STRING, desc: package name}
PROCESS_NAME: {type: STRING, desc: process name}
MSG: {type: STRING, desc: windowmanager event message}
WINDOW_LIFE_CYCLE_EXCEPTION:
__BASE: {type: FAULT, level: CRITICAL, desc: The window life cycle is abnormal }
PID: {type: INT32, desc: session pid}
UID: {type: INT32, desc: session uid}
MSG: {type: STRING, desc: windowmanager event message}
WINDOW_BOOT_ANIMATION_DONE:
__BASE: {type: BEHAVIOR, level: CRITICAL, desc: Boot animation done }
MSG: {type: STRING, desc: windowmanager event message}
+7
View File
@@ -21,6 +21,13 @@
namespace OHOS {
namespace Rosen {
enum class LifeCycleEvent : uint32_t {
CREATE_EVENT,
SHOW_EVENT,
HIDE_EVENT,
DESTROY_EVENT,
};
enum class WindowState : uint32_t {
STATE_INITIAL,
STATE_CREATED,
+1 -1
View File
@@ -79,7 +79,7 @@ ohos_shared_library("libwm") {
"graphic_standard:surface",
"graphic_standard:window_animation",
"hilog_native:libhilog",
"hitrace_native:hitrace_meter",
"hisysevent_native:libhisysevent",
"input:libmmi-client",
"inputmethod_native:inputmethod_client",
"ipc:ipc_core",
+2
View File
@@ -273,6 +273,8 @@ private:
WMError Destroy(bool needNotifyServer);
WMError SetBackgroundColor(uint32_t color);
uint32_t GetBackgroundColor() const;
void RecordLifeCycleExceptionEvent(LifeCycleEvent event, WMError errCode) const;
std::string TransferLifeCycleEventToString(LifeCycleEvent type) const;
Rect GetSystemAlarmWindowDefaultSize(Rect defaultRect);
void HandleModeChangeHotZones(int32_t posX, int32_t posY);
WMError NotifyWindowTransition(TransitionReason reason);
+55
View File
@@ -18,6 +18,8 @@
#include <cmath>
#include <ability_manager_client.h>
#include <hisysevent.h>
#include <sstream>
#include "color_parser.h"
#include "display_manager.h"
@@ -709,6 +711,7 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<
}
WMError ret = SingletonContainer::Get<WindowAdapter>().CreateWindow(windowAgent, property_, surfaceNode_,
windowId, token);
RecordLifeCycleExceptionEvent(LifeCycleEvent::CREATE_EVENT, ret);
if (ret != WMError::WM_OK) {
WLOGFE("create window failed with errCode:%{public}d", static_cast<int32_t>(ret));
return ret;
@@ -803,6 +806,7 @@ WMError WindowImpl::Destroy(bool needNotifyServer)
}
}
ret = SingletonContainer::Get<WindowAdapter>().DestroyWindow(property_->GetWindowId());
RecordLifeCycleExceptionEvent(LifeCycleEvent::DESTROY_EVENT, ret);
if (ret != WMError::WM_OK) {
WLOGFE("destroy window failed with errCode:%{public}d", static_cast<int32_t>(ret));
return ret;
@@ -863,6 +867,7 @@ WMError WindowImpl::Show(uint32_t reason)
}
SetDefaultOption();
WMError ret = SingletonContainer::Get<WindowAdapter>().AddWindow(property_);
RecordLifeCycleExceptionEvent(LifeCycleEvent::SHOW_EVENT, ret);
if (ret == WMError::WM_OK || ret == WMError::WM_ERROR_DEATH_RECIPIENT) {
state_ = WindowState::STATE_SHOWN;
NotifyAfterForeground();
@@ -890,6 +895,7 @@ WMError WindowImpl::Hide(uint32_t reason)
return WMError::WM_OK;
}
WMError ret = SingletonContainer::Get<WindowAdapter>().RemoveWindow(property_->GetWindowId());
RecordLifeCycleExceptionEvent(LifeCycleEvent::HIDE_EVENT, ret);
if (ret != WMError::WM_OK) {
WLOGFE("hide errCode:%{public}d for winId:%{public}u", static_cast<int32_t>(ret), property_->GetWindowId());
return ret;
@@ -1077,6 +1083,55 @@ WMError WindowImpl::SetCallingWindow(uint32_t windowId)
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW);
}
void WindowImpl::RecordLifeCycleExceptionEvent(LifeCycleEvent event, WMError errCode) const
{
if (!(errCode == WMError::WM_ERROR_NULLPTR || errCode == WMError::WM_ERROR_INVALID_TYPE ||
errCode == WMError::WM_ERROR_INVALID_PARAM || errCode == WMError::WM_ERROR_SAMGR ||
errCode == WMError::WM_ERROR_IPC_FAILED)) {
WLOGFI("do not record, %{public}u", static_cast<uint32_t>(errCode));
return;
}
std::ostringstream oss;
oss << "life cycle is abnormal: " << "window_name: " << name_
<< ", id:" << GetWindowId() << ", event: " << TransferLifeCycleEventToString(event)
<< ", errCode: " << static_cast<int32_t>(errCode) << ";";
std::string info = oss.str();
WLOGFI("window life cycle exception: %{public}s", info.c_str());
int32_t ret = OHOS::HiviewDFX::HiSysEvent::Write(
OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER,
"WINDOW_LIFE_CYCLE_EXCEPTION",
OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
"PID", getpid(),
"UID", getuid(),
"MSG", info);
if (ret != 0) {
WLOGFE("Write HiSysEvent error, ret:%{public}d", ret);
}
}
std::string WindowImpl::TransferLifeCycleEventToString(LifeCycleEvent type) const
{
std::string event;
switch (type) {
case LifeCycleEvent::CREATE_EVENT:
event = "CREATE";
break;
case LifeCycleEvent::SHOW_EVENT:
event = "SHOW";
break;
case LifeCycleEvent::HIDE_EVENT:
event = "HIDE";
break;
case LifeCycleEvent::DESTROY_EVENT:
event = "DESTROY";
break;
default:
event = "UNDEFINE";
break;
}
return event;
}
void WindowImpl::SetPrivacyMode(bool isPrivacyMode)
{
property_->SetPrivacyMode(isPrivacyMode);
+1
View File
@@ -71,6 +71,7 @@ private:
void ProcessDisplayChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
void StopBootAnimationIfNeed(WindowType type) const;
void RecordBootAnimationEvent() const;
WMError SetWindowType(uint32_t windowId, WindowType type);
WMError SetWindowFlags(uint32_t windowId, uint32_t flags);
WMError SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& property);
+22 -1
View File
@@ -15,10 +15,13 @@
#include "window_controller.h"
#include <ability_manager_client.h>
#include <chrono>
#include <hisysevent.h>
#include <parameters.h>
#include <power_mgr_client.h>
#include <rs_window_animation_finished_callback.h>
#include <transaction/rs_transaction.h>
#include <sstream>
#include "minimize_app.h"
#include "remote_animation.h"
@@ -512,8 +515,26 @@ void WindowController::ProcessDisplayChange(DisplayId defaultDisplayId, sptr<Dis
void WindowController::StopBootAnimationIfNeed(WindowType type) const
{
if (WindowType::WINDOW_TYPE_DESKTOP == type) {
WLOGFD("stop boot animation");
WLOGFI("stop boot animation");
system::SetParameter("persist.window.boot.inited", "1");
RecordBootAnimationEvent();
}
}
void WindowController::RecordBootAnimationEvent() const
{
uint64_t time = std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::steady_clock::now()).
time_since_epoch().count();
WLOGFI("boot animation done duration(s): %{public}" PRIu64"", static_cast<uint64_t>(time));
std::ostringstream os;
os << "boot animation done duration(s): " << time <<";";
int32_t ret = OHOS::HiviewDFX::HiSysEvent::Write(
OHOS::HiviewDFX::HiSysEvent::Domain::WINDOW_MANAGER,
"WINDOW_BOOT_ANIMATION_DONE",
OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
"MSG", os.str());
if (ret != 0) {
WLOGFE("Write HiSysEvent error, ret:%{public}d", ret);
}
}