无障碍监听窗口信息接口优化

Signed-off-by: getsit <zhengxinsheng@h-partners.com>
This commit is contained in:
getsit 2024-04-15 11:35:25 +08:00
parent 043cef876c
commit cc64c9b18d
5 changed files with 106 additions and 0 deletions

37
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,37 @@
{
"files.associations": {
"cstddef": "cpp",
"cstdlib": "cpp",
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cwchar": "cpp",
"map": "cpp",
"string": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"random": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"string_view": "cpp",
"typeinfo": "cpp"
}
}

View File

@ -182,5 +182,29 @@ int64_t AccessibilityWindowInfo::GetUiNodeId() const
return uiNodeId_;
}
void AccessibilityWindowInfo::SetBundleName(const std::string bundleName)
{
bundleName_ = bundleName;
HILOG_DEBUG("set bundleName_");
}
std::string AccessibilityWindowInfo::GetBundleName()
{
HILOG_DEBUG("get bundleName_");
return bundleName_;
}
void AccessibilityWindowInfo::SetTouchHotAreas(const std::vector<Rect>& touchHotAreas)
{
touchHotAreas_ = touchHotAreas;
HILOG_DEBUG("set touchHotAreas_");
}
std::vector<Rect> AccessibilityWindowInfo::GetTouchHotAreas()
{
HILOG_DEBUG("get touchHotAreas_");
return touchHotAreas_;
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -226,6 +226,12 @@ public:
*/
int64_t GetUiNodeId() const;
void SetBundleName(const std::string bundleName);
std::string GetBundleName();
void SetTouchHotAreas(const std::vector<Rect>& touchHotAreas);
std::vector<Rect> GetTouchHotAreas();
protected:
uint64_t displayId_ = 0;
uint32_t windowMode_ = 0;
@ -240,6 +246,8 @@ protected:
bool isDecorEnable_ = false;
int32_t innerWid_ = 0; // used for window id 1, scene board
int64_t uiNodeId_ = 0; // used for window id 1, scene board
std::string bundleName_ = "";
std::vector<Rect> touchHotAreas_ = {};
};
} // namespace Accessibility
} // namespace OHOS

View File

@ -109,6 +109,7 @@ private:
void WindowUpdateActive(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos);
void WindowUpdateFocused(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos);
void WindowUpdateProperty(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos);
void WindowUpdateAll(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos) ;
void ClearOldActiveWindow();
sptr<AccessibilityWindowListener> windowListener_ = nullptr;

View File

@ -137,6 +137,8 @@ void AccessibilityWindowManager::OnWindowUpdate(const std::vector<sptr<Rosen::Ac
break;
case Rosen::WindowUpdateType::WINDOW_UPDATE_PROPERTY: // 6
WindowUpdateProperty(infos);
case Rosen::WindowUpdateType::WINDOW_UPDATE_ALL:
WindowUpdateALL(infos);
break;
default:
break;
@ -260,6 +262,13 @@ void AccessibilityWindowManager::UpdateAccessibilityWindowInfo(AccessibilityWind
accWindowInfo.SetWindowId(windowInfo->innerWid_);
HILOG_DEBUG("scene board window id 1 convert inner window id[%{public}d]", windowInfo->innerWid_);
}
accWindowInfo.SetBundleName(windowInfo->bundleName_);
std::vector<Rect> temp = {};
for(auto &rect:windowInfo->touchHotAreas_)
{
temp.push_back(Rect(rect.posX_,rect.posY_,rect.posX_+rect.width_,rect.posY_+rect.height_));
}
accWindowInfo.SetTouchHotAreas(temp);
}
int32_t AccessibilityWindowManager::GetRealWindowId(const sptr<Rosen::AccessibilityWindowInfo> windowInfo)
@ -569,6 +578,33 @@ void AccessibilityWindowManager::WindowUpdateProperty(const std::vector<sptr<Ros
}
}
void AccessibilityWindowManager::WindowUpdateAll(const std::vector<sptr<Rosen::AccessibilityWindowInfo>>& infos)
{
DeInit();
for(auto &window : infos)
{
if(!window)
{
HILOG_ERROR("window is nullptr");
continue;
}
int32_t realWid = GetRealWindowId(window);
if (!a11yWindows_.count(realWid)) {
auto a11yWindowInfo = CreateAccessibilityWindowInfo(window);
a11yWindows_.emplace(realWid, a11yWindowInfo);
}
if (IsSceneBoard(window)) {
subWindows_.insert(realWid);
sceneBoardElementIdMap_.InsertPair(realWid, window->uiNodeId_);
}
if (a11yWindows_[realWid].IsFocused()) {
SetActiveWindow(realWid);
}
}
}
void AccessibilityWindowManager::ClearOldActiveWindow()
{
HILOG_DEBUG("active window id is %{public}d", activeWindowId_);