!7489 修复photoPicker uiextension多发问题

Merge pull request !7489 from MoonPie/wentao
This commit is contained in:
openharmony_ci 2024-07-18 05:23:32 +00:00 committed by Gitee
commit 5522de5b90
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 59 additions and 0 deletions

View File

@ -89,6 +89,7 @@ public:
WMError HideNonSecureWindows(bool shouldHide) override;
WMError SetWaterMarkFlag(bool isEnable) override;
Rect GetHostWindowRect(int32_t hostWindowId) override;
bool PreNotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
protected:
NotifyTransferComponentDataFunc notifyTransferComponentDataFunc_;

View File

@ -346,6 +346,10 @@ void WindowExtensionSessionImpl::NotifyFocusStateEvent(bool focusState)
NotifyWindowAfterUnfocused();
}
focusState_ = focusState;
if (focusState_ != std::nullopt) {
TLOGI(WmsLogTag::WMS_FOCUS, "persistentId:%{public}d focusState:%{public}d",
GetPersistentId(), static_cast<int32_t>(focusState_.value()));
}
}
void WindowExtensionSessionImpl::NotifyFocusActiveEvent(bool isFocusActive)
@ -969,5 +973,32 @@ void WindowExtensionSessionImpl::ConsumePointerEvent(const std::shared_ptr<MMI::
}
NotifyPointerEvent(pointerEvent);
}
bool WindowExtensionSessionImpl::PreNotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
if (keyEvent == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "keyEvent is nullptr");
return false;
}
RefreshNoInteractionTimeoutMonitor();
if (property_->GetUIExtensionUsage() == UIExtensionUsage::CONSTRAINED_EMBEDDED) {
if (focusState_ == std::nullopt) {
TLOGW(WmsLogTag::WMS_EVENT, "focusState is null");
keyEvent->MarkProcessed();
return true;
}
if (!focusState_.value()) {
keyEvent->MarkProcessed();
return true;
}
TLOGI(WmsLogTag::WMS_EVENT, "InputTracking:%{public}d wid:%{public}d",
keyEvent->GetId(), keyEvent->GetAgentWindowId());
}
std::shared_ptr<Ace::UIContent> uiContent = GetUIContentSharedPtr();
if (uiContent != nullptr) {
return uiContent->ProcessKeyEvent(keyEvent, true);
}
return false;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -1384,6 +1384,33 @@ HWTEST_F(WindowExtensionSessionImplTest, ConsumePointerEvent, Function | SmallTe
pointerEvent->UpdatePointerItem(0, item);
window_->ConsumePointerEvent(pointerEvent);
}
/**
* @tc.name: PreNotifyKeyEvent
* @tc.desc: PreNotifyKeyEvent Test
* @tc.type: FUNC
*/
HWTEST_F(WindowExtensionSessionImplTest, PreNotifyKeyEvent, Function | SmallTest | Level3)
{
std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
ASSERT_NE(nullptr, keyEvent);
ASSERT_NE(nullptr, window_->property_);
window_->property_->SetUIExtensionUsage(UIExtensionUsage::MODAL);
bool ret = window_->PreNotifyKeyEvent(keyEvent);
ASSERT_EQ(ret, false);
window_->property_->SetUIExtensionUsage(UIExtensionUsage::CONSTRAINED_EMBEDDED);
ret = window_->PreNotifyKeyEvent(keyEvent);
ASSERT_EQ(ret, true);
window_->focusState_ = false;
ret = window_->PreNotifyKeyEvent(keyEvent);
ASSERT_EQ(ret, true);
window_->focusState_ = true;
ret = window_->PreNotifyKeyEvent(keyEvent);
ASSERT_EQ(ret, false);
}
}
} // namespace Rosen
} // namespace OHOS