已关闭
子树注册场景,增加单个进程最大注册数量限制 #2716
taojuncun创建于 8月12日关闭于 2 天前
子树注册场景,增加单个进程最大注册数量限制 #2716
已关闭
taojuncun创建于 8月12日关闭于 2 天前
共 3 个文件变更+24-2
@@ -94,6 +94,7 @@ public:
94 94
95 void OutsideTouch();95 void OutsideTouch();
96 96 
97+ bool IsCardProxySizeExceedLimit();
97private:98private:
98 class InteractionOperationDeathRecipient final : public IRemoteObject::DeathRecipient {99 class InteractionOperationDeathRecipient final : public IRemoteObject::DeathRecipient {
99 public:100 public:
@@ -201,6 +201,16 @@ RetError ElementOperatorManager::RegisterElementOperatorByWindowId(int32_t windo
201RetError ElementOperatorManager::RegisterElementOperatorByParameter(const RegistrationPara &parameter,201RetError ElementOperatorManager::RegisterElementOperatorByParameter(const RegistrationPara &parameter,
202 const sptr<IAccessibilityElementOperator> &elementOperator, uint32_t tokenId, bool isApp)202 const sptr<IAccessibilityElementOperator> &elementOperator, uint32_t tokenId, bool isApp)
203{203{
204+ sptr<AccessibilityWindowConnection> parentConnection = GetAccessibilityWindowConnection(parameter.parentWindowId);
205+ if (parentConnection && parentConnection->IsCardProxySizeExceedLimit()) {
206+ HILOG_ERROR("parentConnection cardProxy size exceeds limit");
207+ return RET_ERR_TREE_TOO_BIG;
208+ }
209+ sptr<AccessibilityWindowConnection> oldConnection = GetAccessibilityWindowConnection(parameter.windowId);
210+ if (oldConnection && oldConnection->IsCardProxySizeExceedLimit()) {
211+ HILOG_ERROR("oldConnection cardProxy size exceeds limit");
212+ return RET_ERR_TREE_TOO_BIG;
213+ }
204 int32_t treeId = ApplyTreeId();214 int32_t treeId = ApplyTreeId();
205 if (treeId == 0) {215 if (treeId == 0) {
206 HILOG_ERROR("TreeId is used up.");216 HILOG_ERROR("TreeId is used up.");
@@ -210,7 +220,6 @@ RetError ElementOperatorManager::RegisterElementOperatorByParameter(const Regist
210 treeId,220 treeId,
211 parameter.elementId);221 parameter.elementId);
212 uint64_t displayId = parameter.displayId;222 uint64_t displayId = parameter.displayId;
213- sptr<AccessibilityWindowConnection> parentConnection = GetAccessibilityWindowConnection(parameter.parentWindowId);
214 if (isApp && parentConnection) {223 if (isApp && parentConnection) {
215 sptr<IAccessibilityElementOperator> parentAamsOper = nullptr;224 sptr<IAccessibilityElementOperator> parentAamsOper = nullptr;
216 if (parameter.parentTreeId == 0) {225 if (parameter.parentTreeId == 0) {
@@ -236,7 +245,6 @@ RetError ElementOperatorManager::RegisterElementOperatorByParameter(const Regist
236 245
237 elementOperator->SetBelongTreeId(treeId);246 elementOperator->SetBelongTreeId(treeId);
238 elementOperator->SetParentWindowId(parameter.parentWindowId);247 elementOperator->SetParentWindowId(parameter.parentWindowId);
239- sptr<AccessibilityWindowConnection> oldConnection = GetAccessibilityWindowConnection(parameter.windowId);
240 if (parameter.parentWindowId != parameter.windowId && isApp && oldConnection) {248 if (parameter.parentWindowId != parameter.windowId && isApp && oldConnection) {
241 if (oldConnection->GetCardProxy(treeId) != nullptr) {249 if (oldConnection->GetCardProxy(treeId) != nullptr) {
242 HILOG_WARN("no need to register again.");250 HILOG_WARN("no need to register again.");
@@ -23,6 +23,9 @@ using namespace std;
23 23 
24namespace OHOS {24namespace OHOS {
25namespace Accessibility {25namespace Accessibility {
26+namespace {
27+ constexpr int32_t MAX_CARD_PROXY_SIZE = 500;
28+}
26AccessibilityWindowConnection::AccessibilityWindowConnection(const int32_t windowId, const int32_t accountId)29AccessibilityWindowConnection::AccessibilityWindowConnection(const int32_t windowId, const int32_t accountId)
27{30{
28 windowId_ = windowId;31 windowId_ = windowId;
@@ -69,6 +72,16 @@ sptr<IAccessibilityElementOperator> AccessibilityWindowConnection::GetRawProxy(u
69 return nullptr;72 return nullptr;
70}73}
71 74 
75+bool AccessibilityWindowConnection::IsCardProxySizeExceedLimit()
76+{
77+ if (cardProxy_.Size() >= MAX_CARD_PROXY_SIZE) {
78+ HILOG_ERROR("cardProxy size[%{public}d] exceeds limit[%{public}d]",
79+ cardProxy_.Size(), MAX_CARD_PROXY_SIZE);
80+ return true;
81+ }
82+ return false;
83+}
84+ 
72RetError AccessibilityWindowConnection::SetCardProxy(const int32_t treeId,85RetError AccessibilityWindowConnection::SetCardProxy(const int32_t treeId,
73 sptr<IAccessibilityElementOperator> operation)86 sptr<IAccessibilityElementOperator> operation)
74{87{