From 1f0c6044a576b0bb4586f5275c398c4ac3d97632 Mon Sep 17 00:00:00 2001 From: Mupceet Date: Thu, 10 Mar 2022 15:37:07 +0800 Subject: [PATCH] bugfix: can't get root when closed the app Signed-off-by: Mupceet --- .../include/accessible_ability_connection.h | 4 ++-- .../aams/src/accessibility_window_manager.cpp | 4 ---- .../aams/src/accessible_ability_connection.cpp | 18 +++++++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/services/aams/include/accessible_ability_connection.h b/services/aams/include/accessible_ability_connection.h index 051ca0b1..ee5e28b5 100644 --- a/services/aams/include/accessible_ability_connection.h +++ b/services/aams/include/accessible_ability_connection.h @@ -133,7 +133,7 @@ public: private: class AccessibleAbilityConnectionDeathRecipient final : public IRemoteObject::DeathRecipient { public: - AccessibleAbilityConnectionDeathRecipient(wptr& accountData, + AccessibleAbilityConnectionDeathRecipient(sptr accountData, AppExecFwk::ElementName& elementName) : recipientAccountData_(accountData), recipientElementName_(elementName) {}; ~AccessibleAbilityConnectionDeathRecipient() = default; @@ -141,7 +141,7 @@ private: void OnRemoteDied(const wptr& remote); - wptr& recipientAccountData_; + sptr recipientAccountData_; AppExecFwk::ElementName& recipientElementName_; }; diff --git a/services/aams/src/accessibility_window_manager.cpp b/services/aams/src/accessibility_window_manager.cpp index 24103eea..a9645c49 100644 --- a/services/aams/src/accessibility_window_manager.cpp +++ b/services/aams/src/accessibility_window_manager.cpp @@ -24,10 +24,6 @@ void AccessibilityWindowListener::OnWindowUpdate(const sptr& HILOG_DEBUG("windowId[%{public}d] type[%{public}d]", windowInfo->wid_, type); auto aams = DelayedSingleton::GetInstance(); auto accountData = aams->GetCurrentAccountData(); - if (accountData->GetAccessibilityWindowConnection(windowInfo->wid_) == nullptr) { - HILOG_ERROR("GetAccessibilityWindowConnection failed by window id(%{public}d)!!", windowInfo->wid_); - return; - } auto& winMgr = AccessibilityWindowInfoManager::GetInstance(); switch (type) { diff --git a/services/aams/src/accessible_ability_connection.cpp b/services/aams/src/accessible_ability_connection.cpp index 327673a0..64a56964 100644 --- a/services/aams/src/accessible_ability_connection.cpp +++ b/services/aams/src/accessible_ability_connection.cpp @@ -327,8 +327,7 @@ void AccessibleAbilityConnection::OnAbilityConnectDone(const AppExecFwk::Element HILOG_DEBUG("AccessibleAbilityConnection::OnAbilityConnectDone get AccessibleAbilityClientProxy successfully"); if (!deathRecipient_) { - wptr data(accountData_); - deathRecipient_ = new AccessibleAbilityConnectionDeathRecipient(data, elementName_); + deathRecipient_ = new AccessibleAbilityConnectionDeathRecipient(accountData_, elementName_); } if (!proxy_->AsObject()->AddDeathRecipient(deathRecipient_)) { @@ -531,16 +530,21 @@ void AccessibleAbilityConnection::AccessibleAbilityConnectionDeathRecipient::OnR const wptr& remote) { HILOG_DEBUG("start"); - sptr accountData = recipientAccountData_.promote(); - if (!accountData) { + if (!recipientAccountData_) { HILOG_ERROR("recipientAccountData_ is null."); return; } sptr connection = - accountData->GetAccessibleAbilityConnection(recipientElementName_.GetURI()); - accountData->RemoveConnectedAbility(connection); - accountData->RemoveEnabledAbility(recipientElementName_); + recipientAccountData_->GetAccessibleAbilityConnection(recipientElementName_.GetURI()); + recipientAccountData_->RemoveConnectedAbility(connection); + recipientAccountData_->RemoveEnabledAbility(recipientElementName_); + + // clear ui test data + sptr uiTestConnection = + recipientAccountData_->GetUITestConnectedAbilityConnection(); + recipientAccountData_->RemoveUITestConnectedAbility(uiTestConnection); + DelayedSingleton::GetInstance()->UpdateAbilities(); DelayedSingleton::GetInstance()->UpdateAccessibilityManagerService(); // temp deal: notify setting