From 131a25c6b13906c2e6a29b1ff4ebd00858127696 Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Wed, 30 Aug 2023 18:22:53 +0800 Subject: [PATCH 1/2] opt: no need get binding object from ability runtime context for UIContentImpl ctor Signed-off-by: Caoruihong --- adapter/ohos/entrance/ui_content_impl.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index 3d79bbfe74e..bfd2455e8ca 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -271,11 +271,7 @@ private: UIContentImpl::UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime) : runtime_(runtime) { CHECK_NULL_VOID(context); - const auto& obj = context->GetBindingObject(); - auto ref = obj->Get(); - auto object = AbilityRuntime::ConvertNativeValueTo(ref->Get()); - auto weak = static_cast*>(object->GetNativePointer()); - context_ = *weak; + context_ = context->weak_from_this(); LOGI("Create UIContentImpl successfully."); } @@ -293,23 +289,14 @@ UIContentImpl::UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runti minCompatibleVersionCode_ = applicationInfo->minCompatibleVersionCode; isBundle_ = (hapModuleInfo->compileMode == AppExecFwk::CompileMode::JS_BUNDLE); SetConfiguration(context->GetConfiguration()); - const auto& obj = context->GetBindingObject(); - CHECK_NULL_VOID(obj); - auto ref = obj->Get(); - CHECK_NULL_VOID(ref); - auto object = AbilityRuntime::ConvertNativeValueTo(ref->Get()); - CHECK_NULL_VOID(object); - auto weak = static_cast*>(object->GetNativePointer()); - CHECK_NULL_VOID(weak); - context_ = *weak; + context_ = context->weak_from_this(); LOGI("Create form UIContentImpl successfully."); } UIContentImpl::UIContentImpl(OHOS::AppExecFwk::Ability* ability) { CHECK_NULL_VOID(ability); - auto weak = static_cast>(ability->GetAbilityContext()); - context_ = weak; + context_ = ability->GetAbilityContext(); LOGI("Create UIContentImpl successfully."); } -- Gitee From af434892ad7e9bc5e457f5b791fcaab4d6b35003 Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Wed, 13 Sep 2023 20:52:50 +0800 Subject: [PATCH 2/2] fix: fix form render resource adapter problem in card Signed-off-by: Caoruihong --- adapter/ohos/entrance/ace_container.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/ohos/entrance/ace_container.cpp b/adapter/ohos/entrance/ace_container.cpp index 99fb6d0dfa4..ee770b15f5d 100644 --- a/adapter/ohos/entrance/ace_container.cpp +++ b/adapter/ohos/entrance/ace_container.cpp @@ -1411,7 +1411,7 @@ std::shared_ptr AceContainer::GetAbilityContextBy { auto context = runtimeContext_.lock(); CHECK_NULL_RETURN(context, nullptr); - return context->CreateModuleContext(bundle, module); + return isFormRender_ ? nullptr : context->CreateModuleContext(bundle, module); } void AceContainer::UpdateConfiguration(const std::string& colorMode, const std::string& deviceAccess, -- Gitee