!365 添加焦点故障检测

Merge pull request !365 from maojiangping/master
This commit is contained in:
openharmony_ci
2022-02-23 00:45:45 +00:00
committed by Gitee
5 changed files with 65 additions and 0 deletions
+1
View File
@@ -1212,6 +1212,7 @@ void WindowImpl::SetDefaultOption()
property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
break;
}
case WindowType::SYSTEM_WINDOW_END: // SYSTEM_WINDOW_END is for boot animation, is unfocusable.
case WindowType::WINDOW_TYPE_POINTER: {
property_->SetFocusable(false);
break;
+1
View File
@@ -93,6 +93,7 @@ ohos_shared_library("libwms") {
"ces_standard:cesfwk_innerkits",
"graphic_standard:surface",
"hilog_native:libhilog",
"hisysevent_native:libhisysevent",
"ipc:ipc_core",
"multimodalinput_base:libmmi-client",
"safwk:system_ability_fwk",
+3
View File
@@ -62,6 +62,7 @@ public:
void NotifyDisplayDestroy(DisplayId displayId);
void NotifySystemBarTints();
WMError RaiseZOrderForAppWindow(sptr<WindowNode>& node);
void FocusFaultDetection() const;
float GetVirtualPixelRatio(DisplayId displayId) const;
private:
@@ -69,12 +70,14 @@ private:
WMError DestroyWindowInner(sptr<WindowNode>& node);
void UpdateFocusWindowWithWindowRemoved(const sptr<WindowNode>& node,
const sptr<WindowNodeContainer>& container) const;
std::string GenAllWindowsLogInfo() const;
bool CheckDisplayInfo(const sptr<AbstractDisplay>& display);
std::recursive_mutex& mutex_;
std::map<int32_t, sptr<WindowNodeContainer>> windowNodeContainerMap_;
std::map<uint32_t, sptr<WindowNode>> windowNodeMap_;
std::map<sptr<IRemoteObject>, uint32_t> windowIdMap_;
bool needCheckFocusWindow = false;
std::map<WindowManagerAgentType, std::vector<sptr<IWindowManagerAgent>>> windowManagerAgents_;
+4
View File
@@ -71,6 +71,7 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
if (res != WMError::WM_OK) {
return res;
}
windowRoot_->FocusFaultDetection();
FlushWindowInfo(property->GetWindowId());
if (node->GetWindowType() == WindowType::WINDOW_TYPE_STATUS_BAR ||
@@ -96,6 +97,7 @@ WMError WindowController::RemoveWindowNode(uint32_t windowId)
if (res != WMError::WM_OK) {
return res;
}
windowRoot_->FocusFaultDetection();
FlushWindowInfo(windowId);
return res;
}
@@ -111,6 +113,7 @@ WMError WindowController::DestroyWindow(uint32_t windowId, bool onlySelf)
if (res != WMError::WM_OK) {
return res;
}
windowRoot_->FocusFaultDetection();
FlushWindowInfoWithDisplayId(displayId);
return res;
}
@@ -385,6 +388,7 @@ WMError WindowController::ProcessWindowTouchedEvent(uint32_t windowId)
WLOGFI("ProcessWindowTouchedEvent end");
return WMError::WM_OK;
}
windowRoot_->FocusFaultDetection();
return WMError::WM_ERROR_INVALID_OPERATION;
}
+56
View File
@@ -16,6 +16,7 @@
#include "window_root.h"
#include <cinttypes>
#include <hisysevent.h>
#include "display_manager_service_inner.h"
#include "window_helper.h"
@@ -171,6 +172,7 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr<WindowNode>& node)
}
if (res == WMError::WM_OK && node->GetWindowProperty()->GetFocusable()) {
container->SetFocusWindow(node->GetWindowId());
needCheckFocusWindow = true;
}
return res;
}
@@ -467,6 +469,60 @@ WMError WindowRoot::SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mo
return ret;
}
std::string WindowRoot::GenAllWindowsLogInfo() const
{
std::ostringstream os;
WindowNodeOperationFunc func = [&os](sptr<WindowNode> node) {
if (node == nullptr) {
WLOGE("WindowNode is nullptr");
return false;
}
os<<"window_name:"<<node->GetWindowName()<<",id:"<<node->GetWindowId()<<
",focusable:"<<node->GetWindowProperty()->GetFocusable()<<";";
return false;
};
for (auto& elem : windowNodeContainerMap_) {
if (elem.second == nullptr) {
continue;
}
os<<"Display "<<elem.second->GetDisplayId()<<":";
elem.second->TraverseWindowTree(func, true);
}
return os.str();
}
void WindowRoot::FocusFaultDetection() const
{
if (!needCheckFocusWindow) {
return;
}
bool needReport = true;
uint32_t focusWinId = INVALID_WINDOW_ID;
for (auto& elem : windowNodeContainerMap_) {
if (elem.second == nullptr) {
continue;
}
focusWinId = elem.second->GetFocusWindow();
if (focusWinId != INVALID_WINDOW_ID) {
needReport = false;
sptr<WindowNode> windowNode = GetWindowNode(focusWinId);
if (windowNode == nullptr || !windowNode->currentVisibility_) {
needReport = true;
WLOGFE("The focus windowNode is nullptr or is invisible, focusWinId: %{public}u", focusWinId);
break;
}
}
}
if (needReport) {
std::string windowLog(GenAllWindowsLogInfo());
WLOGFE("The focus window is faulty, focusWinId:%{public}u, %{public}s", focusWinId, windowLog.c_str());
OHOS::HiviewDFX::HiSysEvent::Write(OHOS::HiviewDFX::HiSysEvent::Domain::GRAPHIC, "NO_FOCUS_WINDOW",
OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "PID", getpid(), "UID", getuid(),
"FOCUS_WINDOW", focusWinId, "FAULT_INFO", windowLog);
}
}
void WindowRoot::NotifyDisplayDestroy(DisplayId expandDisplayId)
{
WLOGFD("disconnect expand display, get default and expand display container");