!39063 修复首次点击UEC内部输入框概率不避让软键盘

Merge pull request !39063 from cuijiawei/master
This commit is contained in:
openharmony_ci 2024-07-29 08:09:01 +00:00 committed by Gitee
commit dc96f828b8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
11 changed files with 92 additions and 36 deletions

View File

@ -366,7 +366,7 @@ bool SecuritySessionWrapperImpl::NotifyBackPressedSync()
CHECK_NULL_RETURN(session_, false);
bool isConsumed = false;
session_->TransferBackPressedEventForConsumed(isConsumed);
PLATFORM_LOGI("BackPressed, persistentid = %{public}d and %{public}s consumed.",
PLATFORM_LOGI("BackPress, persistentid = %{public}d and %{public}s consumed.",
GetSessionId(), isConsumed ? "is" : "is not");
return isConsumed;
}

View File

@ -273,11 +273,6 @@ void SecurityUIExtensionPattern::OnDisconnect(bool isAbnormal)
host->MarkDirtyNode(PROPERTY_UPDATE_MEASURE);
}
void SecurityUIExtensionPattern::OnAreaChangedInner()
{
DispatchDisplayArea();
}
void SecurityUIExtensionPattern::FireBindModalCallback()
{}
@ -347,7 +342,18 @@ void SecurityUIExtensionPattern::OnAttachToFrameNode()
CHECK_NULL_VOID(pipeline);
auto host = GetHost();
CHECK_NULL_VOID(host);
auto eventHub = host->GetEventHub<EventHub>();
CHECK_NULL_VOID(eventHub);
OnAreaChangedFunc onAreaChangedFunc = [weak = WeakClaim(this)](
const RectF& oldRect,
const OffsetF& oldOrigin,
const RectF& rect,
const OffsetF& origin) {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
pattern->DispatchDisplayArea();
};
eventHub->AddInnerOnAreaChangedCallback(host->GetId(), std::move(onAreaChangedFunc));
pipeline->AddOnAreaChangeNode(host->GetId());
callbackId_ = pipeline->RegisterSurfacePositionChangedCallback(
[weak = WeakClaim(this)](int32_t, int32_t) {
@ -356,6 +362,7 @@ void SecurityUIExtensionPattern::OnAttachToFrameNode()
pattern->DispatchDisplayArea(true);
}
});
PLATFORM_LOGI("OnAttachToFrameNode");
}
void SecurityUIExtensionPattern::OnDetachFromFrameNode(FrameNode* frameNode)
@ -473,21 +480,24 @@ void SecurityUIExtensionPattern::FireOnTerminatedCallback(
return;
}
state_ = AbilityState::DESTRUCTION;
if (sessionWrapper_ && sessionWrapper_->IsSessionValid()) {
PLATFORM_LOGI("DestroySession.");
sessionWrapper_->DestroySession();
}
ContainerScope scope(instanceId_);
auto host = GetHost();
CHECK_NULL_VOID(host);
auto eventHub = host->GetEventHub<UIExtensionHub>();
CHECK_NULL_VOID(eventHub);
eventHub->FireOnTerminatedCallback(code, wantWrap);
state_ = AbilityState::DESTRUCTION;
if (sessionWrapper_ && sessionWrapper_->IsSessionValid()) {
sessionWrapper_->DestroySession();
}
}
void SecurityUIExtensionPattern::FireOnErrorCallback(
int32_t code, const std::string& name, const std::string& message)
{
state_ = AbilityState::NONE;
PlatformPattern::FireOnErrorCallback(code, name, message);
if (sessionWrapper_ && sessionWrapper_->IsSessionValid()) {
sessionWrapper_->DestroySession();
@ -584,7 +594,7 @@ void SecurityUIExtensionPattern::OnMountToParentDone()
return;
}
PLATFORM_LOGI("OnMountToParentDone");
PLATFORM_LOGI("OnMountToParentDone.");
auto wantWrap = GetWantWrap();
CHECK_NULL_VOID(wantWrap);
UpdateWant(wantWrap);

View File

@ -63,7 +63,6 @@ public:
int32_t GetNodeId();
int32_t GetInstanceId();
void OnAreaChangedInner() override;
void OnSyncGeometryNode(const DirtySwapConfig& config) override;
void OnWindowShow() override;
void OnWindowHide() override;

View File

@ -312,6 +312,7 @@ void SessionWrapperImpl::UpdateSessionConfig()
void SessionWrapperImpl::DestroySession()
{
CHECK_NULL_VOID(session_);
UIEXT_LOGI("DestroySession, persistentid = %{public}d.", session_->GetPersistentId());
session_->UnregisterLifecycleListener(lifecycleListener_);
session_ = nullptr;
}
@ -442,6 +443,7 @@ void SessionWrapperImpl::NotifyForeground()
auto pipeline = PipelineBase::GetCurrentContext();
CHECK_NULL_VOID(pipeline);
auto hostWindowId = pipeline->GetFocusWindowId();
UIEXT_LOGI("NotifyForeground, persistentid = %{public}d.", session_->GetPersistentId());
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionActivation(
session_, hostWindowId, std::move(foregroundCallback_));
}
@ -449,12 +451,14 @@ void SessionWrapperImpl::NotifyForeground()
void SessionWrapperImpl::NotifyBackground()
{
CHECK_NULL_VOID(session_);
UIEXT_LOGI("NotifyBackground, persistentid = %{public}d.", session_->GetPersistentId());
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionBackground(
session_, std::move(backgroundCallback_));
}
void SessionWrapperImpl::NotifyDestroy()
{
CHECK_NULL_VOID(session_);
UIEXT_LOGI("NotifyDestroy, persistentid = %{public}d.", session_->GetPersistentId());
Rosen::ExtensionSessionManager::GetInstance().RequestExtensionSessionDestruction(
session_, std::move(destructionCallback_));
}
@ -465,10 +469,16 @@ void SessionWrapperImpl::NotifyConfigurationUpdate() {}
/************************************************ Begin: The interface for responsing provider ************************/
void SessionWrapperImpl::OnConnect()
{
int32_t callSessionId = GetSessionId();
taskExecutor_->PostTask(
[weak = hostPattern_, wrapperWeak = WeakClaim(this)]() {
[weak = hostPattern_, wrapperWeak = WeakClaim(this), callSessionId]() {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
if (callSessionId != pattern->GetSessionId()) {
TAG_LOGW(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "OnConnect: The callSessionId(%{public}d)"
" is inconsistent with the curSession(%{public}d)",
callSessionId, pattern->GetSessionId());
}
pattern->OnConnect();
auto wrapper = wrapperWeak.Upgrade();
CHECK_NULL_VOID(wrapper && wrapper->session_);
@ -492,7 +502,7 @@ void SessionWrapperImpl::OnDisconnect(bool isAbnormal)
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
if (callSessionId != pattern->GetSessionId()) {
LOGW("[AceUiExtensionComponent]OnDisconnect: The callSessionId(%{public}d)"
TAG_LOGW(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "OnDisconnect: The callSessionId(%{public}d)"
" is inconsistent with the curSession(%{public}d)",
callSessionId, pattern->GetSessionId());
return;
@ -514,10 +524,16 @@ void SessionWrapperImpl::OnDisconnect(bool isAbnormal)
void SessionWrapperImpl::OnExtensionTimeout(int32_t /* errorCode */)
{
int32_t callSessionId = GetSessionId();
taskExecutor_->PostTask(
[weak = hostPattern_]() {
[weak = hostPattern_, callSessionId]() {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
if (callSessionId != pattern->GetSessionId()) {
TAG_LOGW(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "OnExtensionTimeout: The callSessionId(%{public}d)"
" is inconsistent with the curSession(%{public}d)",
callSessionId, pattern->GetSessionId());
}
pattern->FireOnErrorCallback(
ERROR_CODE_UIEXTENSION_LIFECYCLE_TIMEOUT, LIFECYCLE_TIMEOUT_NAME, LIFECYCLE_TIMEOUT_MESSAGE);
},
@ -526,10 +542,16 @@ void SessionWrapperImpl::OnExtensionTimeout(int32_t /* errorCode */)
void SessionWrapperImpl::OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info, int64_t offset)
{
int32_t callSessionId = GetSessionId();
taskExecutor_->PostTask(
[weak = hostPattern_, info, offset]() {
[weak = hostPattern_, info, offset, callSessionId]() {
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
if (callSessionId != pattern->GetSessionId()) {
TAG_LOGW(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "OnAccessibilityEvent: The callSessionId(%{public}d)"
" is inconsistent with the curSession(%{public}d)",
callSessionId, pattern->GetSessionId());
}
pattern->OnAccessibilityEvent(info, offset);
},
TaskExecutor::TaskType::UI, "ArkUIUIExtensionAccessibilityEvent");
@ -632,8 +654,11 @@ bool SessionWrapperImpl::NotifyOccupiedAreaChangeInfo(sptr<Rosen::OccupiedAreaCh
auto pipeline = PipelineBase::GetCurrentContext();
CHECK_NULL_RETURN(pipeline, false);
auto curWindow = pipeline->GetCurrentWindowRect();
UIEXT_LOGD("keyboardHeight = %{public}d, CurWindow = %{public}s, displayArea_ = %{public}s.",
keyboardHeight, curWindow.ToString().c_str(), displayArea_.ToString().c_str());
if (curWindow.Bottom() >= displayArea_.Bottom()) {
keyboardHeight = keyboardHeight - (curWindow.Bottom() - displayArea_.Bottom());
int32_t spaceWindow = std::max(curWindow.Bottom() - displayArea_.Bottom(), 0.0);
keyboardHeight = static_cast<int32_t>(std::max(keyboardHeight - spaceWindow, 0));
} else {
keyboardHeight = keyboardHeight + (displayArea_.Bottom() - curWindow.Bottom());
}

View File

@ -172,8 +172,8 @@ bool UIExtensionManager::NotifyOccupiedAreaChangeInfo(const sptr<Rosen::Occupied
return ret;
}
void UIExtensionManager::NotifySizeChangeReason(WindowSizeChangeReason type,
const std::shared_ptr<Rosen::RSTransaction>& rsTransaction)
void UIExtensionManager::NotifySizeChangeReason(
WindowSizeChangeReason type, const std::shared_ptr<Rosen::RSTransaction>& rsTransaction)
{
for (const auto& it : aliveUIExtensions_) {
auto uiExtension = it.second.Upgrade();

View File

@ -144,7 +144,7 @@ void UIExtensionModelNG::Create(const UIExtensionConfig& config)
void UIExtensionModelNG::CreateSecurityUIExtension(const UIExtensionConfig& config)
{
LOGI("CreateSecurityUIExtension");
LOGI("CreateSecurityUIExtension.");
auto* stack = ViewStackProcessor::GetInstance();
auto nodeId = stack->ClaimNodeId();
auto frameNode = FrameNode::GetOrCreateFrameNode(V2::UI_EXTENSION_COMPONENT_ETS_TAG, nodeId,

View File

@ -46,6 +46,8 @@ public:
const std::string& abcPath, const std::string& entryPoint, void* runtime) override;
void InitializeIsolatedComponent(const RefPtr<NG::FrameNode>& frameNode,
const RefPtr<OHOS::Ace::WantWrap>& wantWrap, void* runtime) override;
void SetPlatformOnError(std::function<void(
int32_t code, const std::string& name, const std::string& message)>&& onError) override;
void SetAdaptiveWidth(bool state) override;
void SetAdaptiveHeight(bool state) override;
@ -61,8 +63,6 @@ public:
void SetOnError(
std::function<void(int32_t code, const std::string& name, const std::string& message)>&& onError,
NG::SessionType sessionType = NG::SessionType::UI_EXTENSION_ABILITY) override;
void SetPlatformOnError(std::function<void(
int32_t code, const std::string& name, const std::string& message)>&& onError) override;
private:
void CreateSecurityUIExtension(const UIExtensionConfig& config);

View File

@ -137,7 +137,6 @@ private:
WeakPtr<UIExtensionPattern> weakPattern_;
};
}
UIExtensionPattern::UIExtensionPattern(
bool isTransferringCaller, bool isModal, bool isAsyncModalBinding, SessionType sessionType)
: isTransferringCaller_(isTransferringCaller), isModal_(isModal),
@ -149,7 +148,7 @@ UIExtensionPattern::UIExtensionPattern(
CHECK_NULL_VOID(uiExtensionManager);
uiExtensionId_ = uiExtensionManager->ApplyExtensionId();
sessionWrapper_ = SessionWrapperFactory::CreateSessionWrapper(
sessionType, WeakClaim(this), instanceId_, isTransferringCaller_);
sessionType, AceType::WeakClaim(this), instanceId_, isTransferringCaller_);
accessibilitySessionAdapter_ =
AceType::MakeRefPtr<AccessibilitySessionAdapterUIExtension>(sessionWrapper_);
UIEXT_LOGI("The %{public}smodal UIExtension is created.", isModal_ ? "" : "non");
@ -613,10 +612,16 @@ bool UIExtensionPattern::HandleKeyEvent(const KeyEvent& event)
void UIExtensionPattern::HandleFocusEvent()
{
auto pipeline = PipelineContext::GetCurrentContext();
if (pipeline->GetIsFocusActive()) {
DispatchFocusActiveEvent(true);
CHECK_NULL_VOID(pipeline);
if (canFocusSendToUIExtension_) {
if (pipeline->GetIsFocusActive()) {
DispatchFocusActiveEvent(true);
}
DispatchFocusState(true);
}
DispatchFocusState(true);
canFocusSendToUIExtension_ = true;
auto uiExtensionManager = pipeline->GetUIExtensionManager();
uiExtensionManager->RegisterUIExtensionInFocus(WeakClaim(this), sessionWrapper_);
}
@ -662,10 +667,20 @@ void UIExtensionPattern::HandleTouchEvent(const TouchEventInfo& info)
AceExtraInputData::InsertInterpolatePoints(info);
auto focusHub = host->GetFocusHub();
CHECK_NULL_VOID(focusHub);
if (pipeline->IsWindowFocused()) {
focusHub->RequestFocusImmediately();
bool ret = true;
if (pipeline->IsWindowFocused() && !focusHub->IsCurrentFocus()) {
canFocusSendToUIExtension_ = false;
ret = focusHub->RequestFocusImmediately();
if (!ret) {
canFocusSendToUIExtension_ = true;
UIEXT_LOGW("RequestFocusImmediately failed when HandleTouchEvent.");
}
}
DispatchPointerEvent(pointerEvent);
if (pipeline->IsWindowFocused() && ret &&
pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP) {
HandleFocusEvent();
}
}
void UIExtensionPattern::HandleMouseEvent(const MouseInfo& info)
@ -873,7 +888,7 @@ void UIExtensionPattern::SetOnResultCallback(const std::function<void(int32_t, c
void UIExtensionPattern::FireOnResultCallback(int32_t code, const AAFwk::Want& want)
{
UIEXT_LOGI("OnResult tThe state is changing from '%{public}s' to 'DESTRUCTION'.", ToString(state_));
UIEXT_LOGI("OnResult the state is changing from '%{public}s' to 'DESTRUCTION'.", ToString(state_));
if (onResultCallback_ && (state_ != AbilityState::DESTRUCTION)) {
ContainerScope scope(instanceId_);
onResultCallback_(code, want);

View File

@ -116,7 +116,7 @@ public:
void FireOnReceiveCallback(const AAFwk::WantParams& params);
void SetOnErrorCallback(
const std::function<void(int32_t code, const std::string& name, const std::string& message)>&& callback);
virtual void FireOnErrorCallback(int32_t code, const std::string& name, const std::string& message);
void FireOnErrorCallback(int32_t code, const std::string& name, const std::string& message);
void SetSyncCallbacks(const std::list<std::function<void(const RefPtr<UIExtensionProxy>&)>>&& callbackList);
void FireSyncCallbacks();
void SetAsyncCallbacks(const std::list<std::function<void(const RefPtr<UIExtensionProxy>&)>>&& callbackList);
@ -167,7 +167,6 @@ protected:
int32_t uiExtensionId_ = 0;
int32_t instanceId_ = Container::CurrentId();
std::function<void(int32_t code, const std::string& name, const std::string& message)> onErrorCallback_;
private:
enum class AbilityState {
@ -190,7 +189,6 @@ private:
void OnColorConfigurationUpdate() override;
void OnModifyDone() override;
bool CheckConstraint();
void LogoutModalUIExtension();
void InitKeyEvent(const RefPtr<FocusHub>& focusHub);
void InitTouchEvent(const RefPtr<GestureEventHub>& gestureHub);
@ -207,6 +205,7 @@ private:
void DispatchFocusActiveEvent(bool isFocusActive);
void DispatchFocusState(bool focusState);
void DispatchDisplayArea(bool isForce = false);
void LogoutModalUIExtension();
void RegisterVisibleAreaChange();
void MountPlaceholderNode();
@ -226,6 +225,7 @@ private:
std::function<void(int32_t, const AAFwk::Want&)> onResultCallback_;
std::function<void(int32_t, const RefPtr<WantWrap>&)> onTerminatedCallback_;
std::function<void(const AAFwk::WantParams&)> onReceiveCallback_;
std::function<void(int32_t code, const std::string& name, const std::string& message)> onErrorCallback_;
std::list<std::function<void(const RefPtr<UIExtensionProxy>&)>> onSyncOnCallbackList_;
std::list<std::function<void(const RefPtr<UIExtensionProxy>&)>> onAsyncOnCallbackList_;
std::function<void()> bindModalCallback_;
@ -243,6 +243,9 @@ private:
bool isAsyncModalBinding_ = false;
bool isShowPlaceholder_ = false;
bool densityDpi_ = false;
// Whether to send the focus to the UIExtension
// No multi-threading problem due to run js thread
bool canFocusSendToUIExtension_ = true;
int32_t callbackId_ = 0;
RectF displayArea_;
bool isKeyAsync_ = false;

View File

@ -28,8 +28,8 @@ int32_t ModalUIExtension::GetSessionId(const RefPtr<NG::FrameNode>& /* uiExtNode
return 0;
}
void ModalUIExtension::SetBindModalCallback(const RefPtr<NG::FrameNode>& uiExtNode,
std::function<void()>&& bindModalCallback)
void ModalUIExtension::SetBindModalCallback(
const RefPtr<NG::FrameNode>& uiExtNode, std::function<void()>&& bindModalCallback)
{
}
} // namespace OHOS::Ace

View File

@ -53,4 +53,8 @@ void UIExtensionModelNG::SetOnRemoteReady(std::function<void(const RefPtr<UIExte
void UIExtensionModelNG::SetOnError(
std::function<void(int32_t code, const std::string& name, const std::string& message)>&& onError)
{}
void UIExtensionModelNG::SetPlatformOnError(
std::function<void(int32_t code, const std::string& name, const std::string& message)>&& onError)
{}
} // namespace OHOS::Ace::NG