123b3eb3cSopenharmony_ci/* 223b3eb3cSopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License. 523b3eb3cSopenharmony_ci * You may obtain a copy of the License at 623b3eb3cSopenharmony_ci * 723b3eb3cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 823b3eb3cSopenharmony_ci * 923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and 1323b3eb3cSopenharmony_ci * limitations under the License. 1423b3eb3cSopenharmony_ci */ 1523b3eb3cSopenharmony_ci 1623b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/ui_content_impl.h" 1723b3eb3cSopenharmony_ci 1823b3eb3cSopenharmony_ci#include <atomic> 1923b3eb3cSopenharmony_ci#include <cinttypes> 2023b3eb3cSopenharmony_ci 2123b3eb3cSopenharmony_ci#include "ability_context.h" 2223b3eb3cSopenharmony_ci#include "ability_info.h" 2323b3eb3cSopenharmony_ci#include "bundlemgr/bundle_mgr_proxy.h" 2423b3eb3cSopenharmony_ci#include "configuration.h" 2523b3eb3cSopenharmony_ci#include "if_system_ability_manager.h" 2623b3eb3cSopenharmony_ci#include "ipc_skeleton.h" 2723b3eb3cSopenharmony_ci#include "iservice_registry.h" 2823b3eb3cSopenharmony_ci#include "js_runtime_utils.h" 2923b3eb3cSopenharmony_ci#include "locale_config.h" 3023b3eb3cSopenharmony_ci#include "native_reference.h" 3123b3eb3cSopenharmony_ci#include "ohos/init_data.h" 3223b3eb3cSopenharmony_ci#include "service_extension_context.h" 3323b3eb3cSopenharmony_ci#include "system_ability_definition.h" 3423b3eb3cSopenharmony_ci#include "wm_common.h" 3523b3eb3cSopenharmony_ci 3623b3eb3cSopenharmony_ci#include "base/log/log_wrapper.h" 3723b3eb3cSopenharmony_ci#include "base/memory/referenced.h" 3823b3eb3cSopenharmony_ci#include "base/utils/utils.h" 3923b3eb3cSopenharmony_ci#include "core/components/common/layout/constants.h" 4023b3eb3cSopenharmony_ci#include "core/components_ng/base/frame_node.h" 4123b3eb3cSopenharmony_ci#include "core/components_ng/render/animation_utils.h" 4223b3eb3cSopenharmony_ci 4323b3eb3cSopenharmony_ci#if !defined(ACE_UNITTEST) 4423b3eb3cSopenharmony_ci#include "core/components_ng/base/transparent_node_detector.h" 4523b3eb3cSopenharmony_ci#endif 4623b3eb3cSopenharmony_ci 4723b3eb3cSopenharmony_ci#include "core/components_ng/property/safe_area_insets.h" 4823b3eb3cSopenharmony_ci 4923b3eb3cSopenharmony_ci#ifdef ENABLE_ROSEN_BACKEND 5023b3eb3cSopenharmony_ci#include "render_service_client/core/transaction/rs_transaction.h" 5123b3eb3cSopenharmony_ci#include "render_service_client/core/ui/rs_ui_director.h" 5223b3eb3cSopenharmony_ci#endif 5323b3eb3cSopenharmony_ci 5423b3eb3cSopenharmony_ci#include "interfaces/inner_api/ui_session/ui_session_manager.h" 5523b3eb3cSopenharmony_ci 5623b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/ace_application_info.h" 5723b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/ace_container.h" 5823b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/ace_new_pipe_judgement.h" 5923b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/ace_view_ohos.h" 6023b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/capability_registry.h" 6123b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/cj_utils/cj_utils.h" 6223b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/dialog_container.h" 6323b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/dynamic_component/uv_task_wrapper_impl.h" 6423b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/file_asset_provider_impl.h" 6523b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/form_utils_impl.h" 6623b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/aps_monitor_impl.h" 6723b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/hap_asset_provider_impl.h" 6823b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/plugin_utils_impl.h" 6923b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/ui_event_impl.h" 7023b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/utils.h" 7123b3eb3cSopenharmony_ci#include "adapter/ohos/osal/navigation_route_ohos.h" 7223b3eb3cSopenharmony_ci#include "adapter/ohos/osal/page_url_checker_ohos.h" 7323b3eb3cSopenharmony_ci#include "adapter/ohos/osal/pixel_map_ohos.h" 7423b3eb3cSopenharmony_ci#include "adapter/ohos/osal/thp_extra_manager_impl.h" 7523b3eb3cSopenharmony_ci#include "adapter/ohos/osal/view_data_wrap_ohos.h" 7623b3eb3cSopenharmony_ci#include "base/geometry/rect.h" 7723b3eb3cSopenharmony_ci#include "base/i18n/localization.h" 7823b3eb3cSopenharmony_ci#include "base/log/ace_checker.h" 7923b3eb3cSopenharmony_ci#include "base/log/ace_performance_check.h" 8023b3eb3cSopenharmony_ci#include "base/log/ace_trace.h" 8123b3eb3cSopenharmony_ci#include "base/log/log.h" 8223b3eb3cSopenharmony_ci#include "base/perfmonitor/perf_monitor.h" 8323b3eb3cSopenharmony_ci#include "base/subwindow/subwindow_manager.h" 8423b3eb3cSopenharmony_ci#include "base/utils/system_properties.h" 8523b3eb3cSopenharmony_ci#include "bridge/card_frontend/form_frontend_declarative.h" 8623b3eb3cSopenharmony_ci#include "core/common/ace_engine.h" 8723b3eb3cSopenharmony_ci#include "core/common/asset_manager_impl.h" 8823b3eb3cSopenharmony_ci#include "core/common/container.h" 8923b3eb3cSopenharmony_ci#include "core/common/container_scope.h" 9023b3eb3cSopenharmony_ci#include "core/common/modal_ui_extension.h" 9123b3eb3cSopenharmony_ci#include "core/common/recorder/event_recorder.h" 9223b3eb3cSopenharmony_ci#include "core/common/resource/resource_manager.h" 9323b3eb3cSopenharmony_ci#include "core/common/xcollie/xcollieInterface.h" 9423b3eb3cSopenharmony_ci#include "core/components/theme/shadow_theme.h" 9523b3eb3cSopenharmony_ci#include "core/components_ng/base/inspector.h" 9623b3eb3cSopenharmony_ci#include "core/components_ng/base/view_abstract.h" 9723b3eb3cSopenharmony_ci#include "core/components_ng/pattern/text_field/text_field_manager.h" 9823b3eb3cSopenharmony_ci#include "core/image/image_file_cache.h" 9923b3eb3cSopenharmony_ci#include "core/pipeline_ng/pipeline_context.h" 10023b3eb3cSopenharmony_ci#ifdef FORM_SUPPORTED 10123b3eb3cSopenharmony_ci#include "core/common/form_manager.h" 10223b3eb3cSopenharmony_ci#endif 10323b3eb3cSopenharmony_ci#include "core/common/layout_inspector.h" 10423b3eb3cSopenharmony_ci#ifdef PLUGIN_COMPONENT_SUPPORTED 10523b3eb3cSopenharmony_ci#include "core/common/plugin_manager.h" 10623b3eb3cSopenharmony_ci#endif 10723b3eb3cSopenharmony_ci#ifdef NG_BUILD 10823b3eb3cSopenharmony_ci#include "frameworks/bridge/declarative_frontend/ng/declarative_frontend_ng.h" 10923b3eb3cSopenharmony_ci#endif 11023b3eb3cSopenharmony_ci 11123b3eb3cSopenharmony_ci#include "core/components_ng/render/adapter/rosen_render_context.h" 11223b3eb3cSopenharmony_ci#include "screen_session_manager_client.h" 11323b3eb3cSopenharmony_ci 11423b3eb3cSopenharmony_cinamespace OHOS::Ace { 11523b3eb3cSopenharmony_cinamespace { 11623b3eb3cSopenharmony_ci 11723b3eb3cSopenharmony_ciconst std::string ABS_BUNDLE_CODE_PATH = "/data/app/el1/bundle/public/"; 11823b3eb3cSopenharmony_ciconst std::string LOCAL_BUNDLE_CODE_PATH = "/data/storage/el1/bundle/"; 11923b3eb3cSopenharmony_ciconst std::string FILE_SEPARATOR = "/"; 12023b3eb3cSopenharmony_ciconst std::string START_PARAMS_KEY = "__startParams"; 12123b3eb3cSopenharmony_ciconst std::string ACTION_VIEWDATA = "ohos.want.action.viewData"; 12223b3eb3cSopenharmony_ciconstexpr char IS_PREFERRED_LANGUAGE[] = "1"; 12323b3eb3cSopenharmony_ci 12423b3eb3cSopenharmony_ci#define UICONTENT_IMPL_HELPER(name) _##name = std::make_shared<UIContentImplHelper>(this) 12523b3eb3cSopenharmony_ci#define UICONTENT_IMPL_PTR(name) _##name->uiContent_ 12623b3eb3cSopenharmony_ci#define UICONTENT_IMPL_HELPER_GUARD(name, ifInvalid...) \ 12723b3eb3cSopenharmony_ci std::lock_guard lg(*_##name->mutex_); \ 12823b3eb3cSopenharmony_ci if (!*_##name->isValid_) { \ 12923b3eb3cSopenharmony_ci ifInvalid; \ 13023b3eb3cSopenharmony_ci } 13123b3eb3cSopenharmony_ci 13223b3eb3cSopenharmony_cistruct UIContentImplHelper { 13323b3eb3cSopenharmony_ci explicit UIContentImplHelper(UIContentImpl* uiContent) : uiContent_(uiContent) 13423b3eb3cSopenharmony_ci { 13523b3eb3cSopenharmony_ci uiContent_->AddDestructCallback(this, [mutex = mutex_, isValid = isValid_] { 13623b3eb3cSopenharmony_ci std::lock_guard lg(*mutex); 13723b3eb3cSopenharmony_ci *isValid = false; 13823b3eb3cSopenharmony_ci }); 13923b3eb3cSopenharmony_ci } 14023b3eb3cSopenharmony_ci ~UIContentImplHelper() 14123b3eb3cSopenharmony_ci { 14223b3eb3cSopenharmony_ci std::lock_guard lg(*mutex_); 14323b3eb3cSopenharmony_ci if (*isValid_) { 14423b3eb3cSopenharmony_ci uiContent_->RemoveDestructCallback(this); 14523b3eb3cSopenharmony_ci } 14623b3eb3cSopenharmony_ci } 14723b3eb3cSopenharmony_ci UIContentImpl* uiContent_; 14823b3eb3cSopenharmony_ci std::shared_ptr<std::mutex> mutex_ = std::make_shared<std::mutex>(); 14923b3eb3cSopenharmony_ci std::shared_ptr<bool> isValid_ = std::make_shared<bool>(true); 15023b3eb3cSopenharmony_ci UIContentImplHelper(const UIContentImplHelper& rhs) = delete; 15123b3eb3cSopenharmony_ci UIContentImplHelper& operator=(const UIContentImplHelper& rhs) = delete; 15223b3eb3cSopenharmony_ci}; 15323b3eb3cSopenharmony_ci 15423b3eb3cSopenharmony_ciRosen::Rect ConvertToRSRect(NG::RectF& rect) 15523b3eb3cSopenharmony_ci{ 15623b3eb3cSopenharmony_ci Rosen::Rect rsRect; 15723b3eb3cSopenharmony_ci rsRect.posX_ = floor(rect.GetX()); 15823b3eb3cSopenharmony_ci rsRect.posY_ = floor(rect.GetY()); 15923b3eb3cSopenharmony_ci rsRect.width_ = ceil(rect.Width()); 16023b3eb3cSopenharmony_ci rsRect.height_ = ceil(rect.Height()); 16123b3eb3cSopenharmony_ci return rsRect; 16223b3eb3cSopenharmony_ci} 16323b3eb3cSopenharmony_ci 16423b3eb3cSopenharmony_cibool IsNeedAvoidWindowMode(OHOS::Rosen::Window* rsWindow) 16523b3eb3cSopenharmony_ci{ 16623b3eb3cSopenharmony_ci if (!SystemProperties::GetNeedAvoidWindow()) { 16723b3eb3cSopenharmony_ci return false; 16823b3eb3cSopenharmony_ci } 16923b3eb3cSopenharmony_ci 17023b3eb3cSopenharmony_ci auto mode = rsWindow->GetMode(); 17123b3eb3cSopenharmony_ci return mode == Rosen::WindowMode::WINDOW_MODE_FLOATING || mode == Rosen::WindowMode::WINDOW_MODE_SPLIT_PRIMARY || 17223b3eb3cSopenharmony_ci mode == Rosen::WindowMode::WINDOW_MODE_SPLIT_SECONDARY; 17323b3eb3cSopenharmony_ci} 17423b3eb3cSopenharmony_ci 17523b3eb3cSopenharmony_civoid AddResConfigInfo( 17623b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, ResourceConfiguration& aceResCfg) 17723b3eb3cSopenharmony_ci{ 17823b3eb3cSopenharmony_ci if (!context || !context->GetResourceManager()) { 17923b3eb3cSopenharmony_ci return; 18023b3eb3cSopenharmony_ci } 18123b3eb3cSopenharmony_ci auto resourceManager = context->GetResourceManager(); 18223b3eb3cSopenharmony_ci std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig()); 18323b3eb3cSopenharmony_ci resourceManager->GetResConfig(*resConfig); 18423b3eb3cSopenharmony_ci aceResCfg.SetMcc(resConfig->GetMcc()); 18523b3eb3cSopenharmony_ci aceResCfg.SetMnc(resConfig->GetMnc()); 18623b3eb3cSopenharmony_ci aceResCfg.SetAppHasDarkRes(resConfig->GetAppDarkRes()); 18723b3eb3cSopenharmony_ci auto preferredLocaleInfo = resConfig->GetPreferredLocaleInfo(); 18823b3eb3cSopenharmony_ci if (preferredLocaleInfo != nullptr) { 18923b3eb3cSopenharmony_ci std::string preferredLanguage = preferredLocaleInfo->getLanguage(); 19023b3eb3cSopenharmony_ci std::string script = preferredLocaleInfo->getScript(); 19123b3eb3cSopenharmony_ci std::string country = preferredLocaleInfo->getCountry(); 19223b3eb3cSopenharmony_ci if (!script.empty()) { 19323b3eb3cSopenharmony_ci preferredLanguage += "-" + script; 19423b3eb3cSopenharmony_ci } 19523b3eb3cSopenharmony_ci if (!country.empty()) { 19623b3eb3cSopenharmony_ci preferredLanguage += "-" + country; 19723b3eb3cSopenharmony_ci } 19823b3eb3cSopenharmony_ci aceResCfg.SetPreferredLanguage(preferredLanguage); 19923b3eb3cSopenharmony_ci } 20023b3eb3cSopenharmony_ci} 20123b3eb3cSopenharmony_ci 20223b3eb3cSopenharmony_civoid AddSetAppColorModeToResConfig( 20323b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::AbilityRuntime::Context>& context, ResourceConfiguration& aceResCfg) 20423b3eb3cSopenharmony_ci{ 20523b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 20623b3eb3cSopenharmony_ci auto config = context->GetConfiguration(); 20723b3eb3cSopenharmony_ci CHECK_NULL_VOID(config); 20823b3eb3cSopenharmony_ci auto colorModeIsSetByApp = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP); 20923b3eb3cSopenharmony_ci if (!colorModeIsSetByApp.empty()) { 21023b3eb3cSopenharmony_ci aceResCfg.SetColorModeIsSetByApp(true); 21123b3eb3cSopenharmony_ci } 21223b3eb3cSopenharmony_ci} 21323b3eb3cSopenharmony_ci} // namespace 21423b3eb3cSopenharmony_ci 21523b3eb3cSopenharmony_ciconst std::string SUBWINDOW_PREFIX = "ARK_APP_SUBWINDOW_"; 21623b3eb3cSopenharmony_ciconst std::string SUBWINDOW_TOAST_DIALOG_PREFIX = "ARK_APP_SUBWINDOW_TOAST_DIALOG_"; 21723b3eb3cSopenharmony_ciconst std::string SUBWINDOW_TOAST_PREFIX = "ARK_APP_SUBWINDOW_TOPMOST_TOAST"; 21823b3eb3cSopenharmony_ciconst int32_t REQUEST_CODE = -1; 21923b3eb3cSopenharmony_ciconstexpr uint32_t TIMEOUT_LIMIT = 5; 22023b3eb3cSopenharmony_ciconstexpr int32_t COUNT_LIMIT = 3; 22123b3eb3cSopenharmony_ci 22223b3eb3cSopenharmony_ciusing ContentFinishCallback = std::function<void()>; 22323b3eb3cSopenharmony_ciusing ContentStartAbilityCallback = std::function<void(const std::string& address)>; 22423b3eb3cSopenharmony_ciclass ContentEventCallback final : public Platform::PlatformEventCallback { 22523b3eb3cSopenharmony_cipublic: 22623b3eb3cSopenharmony_ci explicit ContentEventCallback(ContentFinishCallback onFinish) : onFinish_(onFinish) {} 22723b3eb3cSopenharmony_ci ContentEventCallback(ContentFinishCallback onFinish, ContentStartAbilityCallback onStartAbility) 22823b3eb3cSopenharmony_ci : onFinish_(onFinish), onStartAbility_(onStartAbility) 22923b3eb3cSopenharmony_ci {} 23023b3eb3cSopenharmony_ci ~ContentEventCallback() override = default; 23123b3eb3cSopenharmony_ci 23223b3eb3cSopenharmony_ci void OnFinish() const override 23323b3eb3cSopenharmony_ci { 23423b3eb3cSopenharmony_ci CHECK_NULL_VOID(onFinish_); 23523b3eb3cSopenharmony_ci onFinish_(); 23623b3eb3cSopenharmony_ci } 23723b3eb3cSopenharmony_ci 23823b3eb3cSopenharmony_ci void OnStartAbility(const std::string& address) override 23923b3eb3cSopenharmony_ci { 24023b3eb3cSopenharmony_ci CHECK_NULL_VOID(onStartAbility_); 24123b3eb3cSopenharmony_ci onStartAbility_(address); 24223b3eb3cSopenharmony_ci } 24323b3eb3cSopenharmony_ci 24423b3eb3cSopenharmony_ci void OnStatusBarBgColorChanged(uint32_t color) override 24523b3eb3cSopenharmony_ci { 24623b3eb3cSopenharmony_ci LOGI("StatusBarBgColorChanged: %{public}u", color); 24723b3eb3cSopenharmony_ci } 24823b3eb3cSopenharmony_ci 24923b3eb3cSopenharmony_ciprivate: 25023b3eb3cSopenharmony_ci ContentFinishCallback onFinish_; 25123b3eb3cSopenharmony_ci ContentStartAbilityCallback onStartAbility_; 25223b3eb3cSopenharmony_ci}; 25323b3eb3cSopenharmony_ci 25423b3eb3cSopenharmony_ciextern "C" ACE_FORCE_EXPORT void* OHOS_ACE_CreateUIContent(void* context, void* runtime) 25523b3eb3cSopenharmony_ci{ 25623b3eb3cSopenharmony_ci LOGI("CreateUIContent."); 25723b3eb3cSopenharmony_ci Recorder::Init(); 25823b3eb3cSopenharmony_ci return new UIContentImpl(reinterpret_cast<OHOS::AbilityRuntime::Context*>(context), runtime); 25923b3eb3cSopenharmony_ci} 26023b3eb3cSopenharmony_ci 26123b3eb3cSopenharmony_ciextern "C" ACE_FORCE_EXPORT void* OHOS_ACE_CreateFormContent(void* context, void* runtime, bool isCard) 26223b3eb3cSopenharmony_ci{ 26323b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_FORM, "CreateFormUIContent."); 26423b3eb3cSopenharmony_ci Recorder::Init(); 26523b3eb3cSopenharmony_ci return new UIContentImpl(reinterpret_cast<OHOS::AbilityRuntime::Context*>(context), runtime, isCard); 26623b3eb3cSopenharmony_ci} 26723b3eb3cSopenharmony_ci 26823b3eb3cSopenharmony_ciextern "C" ACE_FORCE_EXPORT void* OHOS_ACE_CreateSubWindowUIContent(void* ability) 26923b3eb3cSopenharmony_ci{ 27023b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_SUB_WINDOW, "Create SubWindowUIContent."); 27123b3eb3cSopenharmony_ci Recorder::Init(); 27223b3eb3cSopenharmony_ci return new UIContentImpl(reinterpret_cast<OHOS::AppExecFwk::Ability*>(ability)); 27323b3eb3cSopenharmony_ci} 27423b3eb3cSopenharmony_ci 27523b3eb3cSopenharmony_ciextern "C" ACE_FORCE_EXPORT void* OHOS_ACE_GetUIContent(int32_t instanceId) 27623b3eb3cSopenharmony_ci{ 27723b3eb3cSopenharmony_ci LOGI("GetUIContent: %{public}d", instanceId); 27823b3eb3cSopenharmony_ci auto uiWindow = Platform::AceContainer::GetUIWindow(instanceId); 27923b3eb3cSopenharmony_ci CHECK_NULL_RETURN(uiWindow, nullptr); 28023b3eb3cSopenharmony_ci return uiWindow->GetUIContent(); 28123b3eb3cSopenharmony_ci} 28223b3eb3cSopenharmony_ci 28323b3eb3cSopenharmony_ciextern "C" ACE_FORCE_EXPORT char* OHOS_ACE_GetCurrentUIStackInfo() 28423b3eb3cSopenharmony_ci{ 28523b3eb3cSopenharmony_ci auto container = Container::Current(); 28623b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, nullptr); 28723b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 28823b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipeline, nullptr); 28923b3eb3cSopenharmony_ci static auto tmp = pipeline->GetCurrentExtraInfo(); 29023b3eb3cSopenharmony_ci std::replace(tmp.begin(), tmp.end(), '\\', '/'); 29123b3eb3cSopenharmony_ci return tmp.data(); 29223b3eb3cSopenharmony_ci} 29323b3eb3cSopenharmony_ci 29423b3eb3cSopenharmony_civoid AddAlarmLogFunc() 29523b3eb3cSopenharmony_ci{ 29623b3eb3cSopenharmony_ci std::function<void(uint64_t, int, int)> logFunc = [](uint64_t nodeId, int count, int num) { 29723b3eb3cSopenharmony_ci auto rsNode = Rosen::RSNodeMap::Instance().GetNode<Rosen::RSNode>(nodeId); 29823b3eb3cSopenharmony_ci if (rsNode == nullptr) { 29923b3eb3cSopenharmony_ci LOGI("rsNodeId:%{public}" PRId64 "not found, sendCommands:%{public}d, totalNumber:%{public}d", 30023b3eb3cSopenharmony_ci nodeId, count, num); 30123b3eb3cSopenharmony_ci return; 30223b3eb3cSopenharmony_ci } 30323b3eb3cSopenharmony_ci auto frameNodeId = rsNode->GetFrameNodeId(); 30423b3eb3cSopenharmony_ci auto frameNodeTag = rsNode->GetFrameNodeTag(); 30523b3eb3cSopenharmony_ci auto frameNode = NG::FrameNode::GetFrameNode(frameNodeTag, frameNodeId); 30623b3eb3cSopenharmony_ci if (frameNode == nullptr) { 30723b3eb3cSopenharmony_ci LOGI("frameNodeId:%{public}d not found, rsNodeId:%{public}" PRId64 " sendCommands:%{public}d, " 30823b3eb3cSopenharmony_ci "totalRsNodeNumber:%{public}d.", 30923b3eb3cSopenharmony_ci frameNodeId, nodeId, count, num); 31023b3eb3cSopenharmony_ci return; 31123b3eb3cSopenharmony_ci } 31223b3eb3cSopenharmony_ci LOGI("frameNodeId:%{public}d found, rsNodeId:%{public}" PRId64 " sendCommands:%{public}d, " 31323b3eb3cSopenharmony_ci "FrameNodeTag:%{public}s, totalRsNodeNumber:%{public}d", 31423b3eb3cSopenharmony_ci frameNodeId, nodeId, count, frameNodeTag.c_str(), num); 31523b3eb3cSopenharmony_ci }; 31623b3eb3cSopenharmony_ci 31723b3eb3cSopenharmony_ci OHOS::Rosen::RSTransactionData::AddAlarmLog(logFunc); 31823b3eb3cSopenharmony_ci} 31923b3eb3cSopenharmony_ci 32023b3eb3cSopenharmony_cibool ParseAvoidAreasUpdate(const RefPtr<NG::PipelineContext>& context, 32123b3eb3cSopenharmony_ci const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas, 32223b3eb3cSopenharmony_ci const ViewportConfig& config) 32323b3eb3cSopenharmony_ci{ 32423b3eb3cSopenharmony_ci CHECK_NULL_RETURN(context, false); 32523b3eb3cSopenharmony_ci auto safeAreaManager = context->GetSafeAreaManager(); 32623b3eb3cSopenharmony_ci CHECK_NULL_RETURN(safeAreaManager, false); 32723b3eb3cSopenharmony_ci bool safeAreaUpdated = false; 32823b3eb3cSopenharmony_ci for (auto& avoidArea : avoidAreas) { 32923b3eb3cSopenharmony_ci if (avoidArea.first == OHOS::Rosen::AvoidAreaType::TYPE_SYSTEM) { 33023b3eb3cSopenharmony_ci safeAreaUpdated |= safeAreaManager->UpdateSystemSafeArea(ConvertAvoidArea(avoidArea.second)); 33123b3eb3cSopenharmony_ci } else if (avoidArea.first == OHOS::Rosen::AvoidAreaType::TYPE_NAVIGATION_INDICATOR) { 33223b3eb3cSopenharmony_ci safeAreaUpdated |= safeAreaManager->UpdateNavArea(ConvertAvoidArea(avoidArea.second)); 33323b3eb3cSopenharmony_ci } else if (avoidArea.first == OHOS::Rosen::AvoidAreaType::TYPE_CUTOUT && context->GetUseCutout()) { 33423b3eb3cSopenharmony_ci safeAreaUpdated |= safeAreaManager->UpdateCutoutSafeArea(ConvertAvoidArea(avoidArea.second), 33523b3eb3cSopenharmony_ci NG::OptionalSize<uint32_t>(config.Width(), config.Height())); 33623b3eb3cSopenharmony_ci } 33723b3eb3cSopenharmony_ci } 33823b3eb3cSopenharmony_ci if (safeAreaUpdated) { 33923b3eb3cSopenharmony_ci context->SyncSafeArea(SafeAreaSyncType::SYNC_TYPE_AVOID_AREA); 34023b3eb3cSopenharmony_ci return true; 34123b3eb3cSopenharmony_ci } 34223b3eb3cSopenharmony_ci return false; 34323b3eb3cSopenharmony_ci} 34423b3eb3cSopenharmony_ci 34523b3eb3cSopenharmony_civoid AvoidAreasUpdateOnUIExtension(const RefPtr<NG::PipelineContext>& context, 34623b3eb3cSopenharmony_ci const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas) 34723b3eb3cSopenharmony_ci{ 34823b3eb3cSopenharmony_ci if (avoidAreas.empty()) { 34923b3eb3cSopenharmony_ci return; 35023b3eb3cSopenharmony_ci } 35123b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 35223b3eb3cSopenharmony_ci // for ui extension component 35323b3eb3cSopenharmony_ci for (auto& avoidArea : avoidAreas) { 35423b3eb3cSopenharmony_ci context->UpdateOriginAvoidArea(avoidArea.second, static_cast<uint32_t>(avoidArea.first)); 35523b3eb3cSopenharmony_ci } 35623b3eb3cSopenharmony_ci} 35723b3eb3cSopenharmony_ci 35823b3eb3cSopenharmony_civoid UpdateSafeArea(const RefPtr<PipelineBase>& pipelineContext, 35923b3eb3cSopenharmony_ci const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas, 36023b3eb3cSopenharmony_ci const ViewportConfig& config, 36123b3eb3cSopenharmony_ci const RefPtr<Platform::AceContainer>& container) 36223b3eb3cSopenharmony_ci{ 36323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 36423b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 36523b3eb3cSopenharmony_ci auto context = AceType::DynamicCast<NG::PipelineContext>(pipelineContext); 36623b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 36723b3eb3cSopenharmony_ci auto safeAreaManager = context->GetSafeAreaManager(); 36823b3eb3cSopenharmony_ci CHECK_NULL_VOID(safeAreaManager); 36923b3eb3cSopenharmony_ci uint32_t keyboardHeight = safeAreaManager->GetKeyboardInset().Length(); 37023b3eb3cSopenharmony_ci safeAreaManager->UpdateKeyboardSafeArea(keyboardHeight, config.Height()); 37123b3eb3cSopenharmony_ci if (avoidAreas.find(OHOS::Rosen::AvoidAreaType::TYPE_CUTOUT) == avoidAreas.end()) { 37223b3eb3cSopenharmony_ci safeAreaManager->UpdateCutoutSafeArea(container->GetViewSafeAreaByType(Rosen::AvoidAreaType::TYPE_CUTOUT), 37323b3eb3cSopenharmony_ci NG::OptionalSize<uint32_t>(config.Width(), config.Height())); 37423b3eb3cSopenharmony_ci } 37523b3eb3cSopenharmony_ci ParseAvoidAreasUpdate(context, avoidAreas, config); 37623b3eb3cSopenharmony_ci AvoidAreasUpdateOnUIExtension(context, avoidAreas); 37723b3eb3cSopenharmony_ci} 37823b3eb3cSopenharmony_ci 37923b3eb3cSopenharmony_ciclass OccupiedAreaChangeListener : public OHOS::Rosen::IOccupiedAreaChangeListener { 38023b3eb3cSopenharmony_cipublic: 38123b3eb3cSopenharmony_ci explicit OccupiedAreaChangeListener(int32_t instanceId) : instanceId_(instanceId) {} 38223b3eb3cSopenharmony_ci ~OccupiedAreaChangeListener() = default; 38323b3eb3cSopenharmony_ci 38423b3eb3cSopenharmony_ci void OnSizeChange(const sptr<OHOS::Rosen::OccupiedAreaChangeInfo>& info, 38523b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction) 38623b3eb3cSopenharmony_ci { 38723b3eb3cSopenharmony_ci auto rect = info->rect_; 38823b3eb3cSopenharmony_ci double positionY = info->textFieldPositionY_; 38923b3eb3cSopenharmony_ci double height = info->textFieldHeight_; 39023b3eb3cSopenharmony_ci Rect keyboardRect = Rect(rect.posX_, rect.posY_, rect.width_, rect.height_); 39123b3eb3cSopenharmony_ci LOGI("OccupiedAreaChange rect:%{public}s type: %{public}d, positionY:%{public}f, height:%{public}f, " 39223b3eb3cSopenharmony_ci "instanceId_ %{public}d", 39323b3eb3cSopenharmony_ci keyboardRect.ToString().c_str(), info->type_, positionY, height, instanceId_); 39423b3eb3cSopenharmony_ci CHECK_NULL_VOID(info->type_ == OHOS::Rosen::OccupiedAreaType::TYPE_INPUT); 39523b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 39623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 39723b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 39823b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 39923b3eb3cSopenharmony_ci auto context = container->GetPipelineContext(); 40023b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 40123b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(context); 40223b3eb3cSopenharmony_ci if (pipeline) { 40323b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 40423b3eb3cSopenharmony_ci auto uiExtMgr = pipeline->GetUIExtensionManager(); 40523b3eb3cSopenharmony_ci if (uiExtMgr) { 40623b3eb3cSopenharmony_ci SetUIExtensionImeShow(keyboardRect); 40723b3eb3cSopenharmony_ci } 40823b3eb3cSopenharmony_ci if (uiExtMgr && uiExtMgr->NotifyOccupiedAreaChangeInfo(info)) { 40923b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_KEYBOARD, "uiExtension consumed"); 41023b3eb3cSopenharmony_ci taskExecutor->PostTask([id = instanceId_] { 41123b3eb3cSopenharmony_ci ContainerScope scope(id); 41223b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(id); 41323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 41423b3eb3cSopenharmony_ci auto context = container->GetPipelineContext(); 41523b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 41623b3eb3cSopenharmony_ci context->OnVirtualKeyboardAreaChange(Rect()); 41723b3eb3cSopenharmony_ci }, TaskExecutor::TaskType::UI, "ArkUIVirtualKeyboardAreaChange"); 41823b3eb3cSopenharmony_ci return; 41923b3eb3cSopenharmony_ci } 42023b3eb3cSopenharmony_ci } 42123b3eb3cSopenharmony_ci auto curWindow = context->GetCurrentWindowRect(); 42223b3eb3cSopenharmony_ci positionY -= curWindow.Top(); 42323b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 42423b3eb3cSopenharmony_ci if (LaterAvoid(keyboardRect, positionY, height)) { 42523b3eb3cSopenharmony_ci return; 42623b3eb3cSopenharmony_ci } 42723b3eb3cSopenharmony_ci taskExecutor->PostSyncTask([context, keyboardRect, rsTransaction, positionY, height] { 42823b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 42923b3eb3cSopenharmony_ci context->OnVirtualKeyboardAreaChange(keyboardRect, positionY, height, rsTransaction); 43023b3eb3cSopenharmony_ci }, TaskExecutor::TaskType::UI, "ArkUIVirtualKeyboardAreaChange"); 43123b3eb3cSopenharmony_ci } 43223b3eb3cSopenharmony_ci 43323b3eb3cSopenharmony_ciprivate: 43423b3eb3cSopenharmony_ci bool LaterAvoid(const Rect& keyboardRect, double positionY, double height) 43523b3eb3cSopenharmony_ci { 43623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 43723b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 43823b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 43923b3eb3cSopenharmony_ci CHECK_NULL_RETURN(taskExecutor, false); 44023b3eb3cSopenharmony_ci auto context = container->GetPipelineContext(); 44123b3eb3cSopenharmony_ci CHECK_NULL_RETURN(context, false); 44223b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(context); 44323b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipeline, false); 44423b3eb3cSopenharmony_ci bool isRotate = false; 44523b3eb3cSopenharmony_ci auto displayInfo = container->GetDisplayInfo(); 44623b3eb3cSopenharmony_ci uint32_t lastKeyboardHeight = pipeline->GetSafeAreaManager() ? 44723b3eb3cSopenharmony_ci pipeline->GetSafeAreaManager()->GetKeyboardInset().Length() : 0; 44823b3eb3cSopenharmony_ci if (displayInfo) { 44923b3eb3cSopenharmony_ci auto dmRotation = static_cast<int32_t>(displayInfo->GetRotation()); 45023b3eb3cSopenharmony_ci isRotate = lastRotation != -1 && lastRotation != dmRotation; 45123b3eb3cSopenharmony_ci lastRotation = dmRotation; 45223b3eb3cSopenharmony_ci } else { 45323b3eb3cSopenharmony_ci lastRotation = -1; 45423b3eb3cSopenharmony_ci } 45523b3eb3cSopenharmony_ci auto textFieldManager = AceType::DynamicCast<NG::TextFieldManagerNG>(pipeline->GetTextFieldManager()); 45623b3eb3cSopenharmony_ci CHECK_NULL_RETURN(textFieldManager, false); 45723b3eb3cSopenharmony_ci if (textFieldManager->GetLaterAvoid()) { 45823b3eb3cSopenharmony_ci auto laterRect = textFieldManager->GetLaterAvoidKeyboardRect(); 45923b3eb3cSopenharmony_ci if (NearEqual(laterRect.Height(), keyboardRect.Height())) { 46023b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_KEYBOARD, "will trigger avoid later, ignore this notify"); 46123b3eb3cSopenharmony_ci return true; 46223b3eb3cSopenharmony_ci } 46323b3eb3cSopenharmony_ci } 46423b3eb3cSopenharmony_ci // do not avoid immediately when device is in rotation, trigger it after context trigger root rect update 46523b3eb3cSopenharmony_ci if (isRotate && !NearZero(lastKeyboardHeight) && !NearZero(keyboardRect.Height())) { 46623b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_KEYBOARD, "rotation change to %{public}d," 46723b3eb3cSopenharmony_ci "later avoid %{public}s %{public}f %{public}f", 46823b3eb3cSopenharmony_ci lastRotation, keyboardRect.ToString().c_str(), positionY, height); 46923b3eb3cSopenharmony_ci textFieldManager->SetLaterAvoidArgs(keyboardRect, positionY, height); 47023b3eb3cSopenharmony_ci return true; 47123b3eb3cSopenharmony_ci } 47223b3eb3cSopenharmony_ci return false; 47323b3eb3cSopenharmony_ci } 47423b3eb3cSopenharmony_ci 47523b3eb3cSopenharmony_ci void SetUIExtensionImeShow(const Rect& keyboardRect) 47623b3eb3cSopenharmony_ci { 47723b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 47823b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 47923b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 48023b3eb3cSopenharmony_ci if (GreatNotEqual(keyboardRect.Height(), 0.0f)) { 48123b3eb3cSopenharmony_ci taskExecutor->PostTask( 48223b3eb3cSopenharmony_ci [id = instanceId_] { 48323b3eb3cSopenharmony_ci ContainerScope scope(id); 48423b3eb3cSopenharmony_ci auto pipeline = NG::PipelineContext::GetCurrentContext(); 48523b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 48623b3eb3cSopenharmony_ci pipeline->SetUIExtensionImeShow(true); 48723b3eb3cSopenharmony_ci }, TaskExecutor::TaskType::UI, "ArkUISetUIExtensionImeShow"); 48823b3eb3cSopenharmony_ci } else { 48923b3eb3cSopenharmony_ci taskExecutor->PostTask( 49023b3eb3cSopenharmony_ci [id = instanceId_] { 49123b3eb3cSopenharmony_ci ContainerScope scope(id); 49223b3eb3cSopenharmony_ci auto pipeline = NG::PipelineContext::GetCurrentContext(); 49323b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 49423b3eb3cSopenharmony_ci pipeline->SetUIExtensionImeShow(false); 49523b3eb3cSopenharmony_ci }, TaskExecutor::TaskType::UI, "ArkUISetUIExtensionImeHide"); 49623b3eb3cSopenharmony_ci } 49723b3eb3cSopenharmony_ci } 49823b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 49923b3eb3cSopenharmony_ci int32_t lastRotation = -1; 50023b3eb3cSopenharmony_ci}; 50123b3eb3cSopenharmony_ci 50223b3eb3cSopenharmony_ciclass AvoidAreaChangedListener : public OHOS::Rosen::IAvoidAreaChangedListener { 50323b3eb3cSopenharmony_cipublic: 50423b3eb3cSopenharmony_ci explicit AvoidAreaChangedListener(int32_t instanceId) : instanceId_(instanceId) {} 50523b3eb3cSopenharmony_ci ~AvoidAreaChangedListener() = default; 50623b3eb3cSopenharmony_ci 50723b3eb3cSopenharmony_ci void OnAvoidAreaChanged(const OHOS::Rosen::AvoidArea avoidArea, OHOS::Rosen::AvoidAreaType type) override 50823b3eb3cSopenharmony_ci { 50923b3eb3cSopenharmony_ci ACE_SCOPED_TRACE("OnAvoidAreaChanged: incoming avoidArea: %s, instanceId %d, type %d", 51023b3eb3cSopenharmony_ci avoidArea.ToString().c_str(), instanceId_, type); 51123b3eb3cSopenharmony_ci TAG_LOGI(ACE_LAYOUT, "Avoid area changed, type:%{public}d, value:%{public}s; instanceId %{public}d", type, 51223b3eb3cSopenharmony_ci avoidArea.ToString().c_str(), instanceId_); 51323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 51423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 51523b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 51623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 51723b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 51823b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 51923b3eb3cSopenharmony_ci if (type == Rosen::AvoidAreaType::TYPE_SYSTEM) { 52023b3eb3cSopenharmony_ci systemSafeArea_ = ConvertAvoidArea(avoidArea); 52123b3eb3cSopenharmony_ci } else if (type == Rosen::AvoidAreaType::TYPE_NAVIGATION_INDICATOR) { 52223b3eb3cSopenharmony_ci navigationBar_ = ConvertAvoidArea(avoidArea); 52323b3eb3cSopenharmony_ci } else if (type == Rosen::AvoidAreaType::TYPE_CUTOUT) { 52423b3eb3cSopenharmony_ci cutoutSafeArea_ = ConvertAvoidArea(avoidArea); 52523b3eb3cSopenharmony_ci } 52623b3eb3cSopenharmony_ci auto safeArea = systemSafeArea_; 52723b3eb3cSopenharmony_ci auto navSafeArea = navigationBar_; 52823b3eb3cSopenharmony_ci auto cutoutSafeArea = cutoutSafeArea_; 52923b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 53023b3eb3cSopenharmony_ci taskExecutor->PostTask( 53123b3eb3cSopenharmony_ci [pipeline, safeArea, navSafeArea, cutoutSafeArea, type, avoidArea] { 53223b3eb3cSopenharmony_ci if (type == Rosen::AvoidAreaType::TYPE_SYSTEM) { 53323b3eb3cSopenharmony_ci pipeline->UpdateSystemSafeArea(safeArea); 53423b3eb3cSopenharmony_ci } else if (type == Rosen::AvoidAreaType::TYPE_NAVIGATION_INDICATOR) { 53523b3eb3cSopenharmony_ci pipeline->UpdateNavSafeArea(navSafeArea); 53623b3eb3cSopenharmony_ci } else if (type == Rosen::AvoidAreaType::TYPE_CUTOUT && pipeline->GetUseCutout()) { 53723b3eb3cSopenharmony_ci pipeline->UpdateCutoutSafeArea(cutoutSafeArea); 53823b3eb3cSopenharmony_ci } 53923b3eb3cSopenharmony_ci // for ui extension component 54023b3eb3cSopenharmony_ci pipeline->UpdateOriginAvoidArea(avoidArea, static_cast<uint32_t>(type)); 54123b3eb3cSopenharmony_ci }, 54223b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUpdateOriginAvoidArea"); 54323b3eb3cSopenharmony_ci } 54423b3eb3cSopenharmony_ci 54523b3eb3cSopenharmony_ciprivate: 54623b3eb3cSopenharmony_ci NG::SafeAreaInsets systemSafeArea_; 54723b3eb3cSopenharmony_ci NG::SafeAreaInsets navigationBar_; 54823b3eb3cSopenharmony_ci NG::SafeAreaInsets cutoutSafeArea_; 54923b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 55023b3eb3cSopenharmony_ci}; 55123b3eb3cSopenharmony_ci 55223b3eb3cSopenharmony_ciclass PretendChangedListener : public OHOS::Rosen::IAvoidAreaChangedListener { 55323b3eb3cSopenharmony_cipublic: 55423b3eb3cSopenharmony_ci explicit PretendChangedListener(int32_t instanceId) {} 55523b3eb3cSopenharmony_ci ~PretendChangedListener() = default; 55623b3eb3cSopenharmony_ci 55723b3eb3cSopenharmony_ci void OnAvoidAreaChanged(const OHOS::Rosen::AvoidArea avoidArea, OHOS::Rosen::AvoidAreaType type) override {} 55823b3eb3cSopenharmony_ci}; 55923b3eb3cSopenharmony_ci 56023b3eb3cSopenharmony_ciclass AvailableAreaChangedListener : public OHOS::Rosen::DisplayManager::IAvailableAreaListener { 56123b3eb3cSopenharmony_cipublic: 56223b3eb3cSopenharmony_ci explicit AvailableAreaChangedListener(int32_t instanceId) : instanceId_(instanceId) {} 56323b3eb3cSopenharmony_ci ~AvailableAreaChangedListener() = default; 56423b3eb3cSopenharmony_ci 56523b3eb3cSopenharmony_ci void OnAvailableAreaChanged(const Rosen::DMRect availableArea) override 56623b3eb3cSopenharmony_ci { 56723b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 56823b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 56923b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 57023b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 57123b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 57223b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 57323b3eb3cSopenharmony_ci auto displayAvailableRect = ConvertDMRect2Rect(availableArea); 57423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 57523b3eb3cSopenharmony_ci taskExecutor->PostTask( 57623b3eb3cSopenharmony_ci [pipeline, displayAvailableRect] { 57723b3eb3cSopenharmony_ci pipeline->UpdateDisplayAvailableRect(displayAvailableRect); 57823b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_WINDOW, "UpdateDisplayAvailableRect : %{public}s", 57923b3eb3cSopenharmony_ci displayAvailableRect.ToString().c_str()); 58023b3eb3cSopenharmony_ci }, 58123b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUpdateDisplayAvailableRect"); 58223b3eb3cSopenharmony_ci } 58323b3eb3cSopenharmony_ci 58423b3eb3cSopenharmony_ciprivate: 58523b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 58623b3eb3cSopenharmony_ci}; 58723b3eb3cSopenharmony_ci 58823b3eb3cSopenharmony_ciclass DragWindowListener : public OHOS::Rosen::IWindowDragListener { 58923b3eb3cSopenharmony_cipublic: 59023b3eb3cSopenharmony_ci explicit DragWindowListener(int32_t instanceId) : instanceId_(instanceId) {} 59123b3eb3cSopenharmony_ci ~DragWindowListener() = default; 59223b3eb3cSopenharmony_ci void OnDrag(int32_t x, int32_t y, OHOS::Rosen::DragEvent event) 59323b3eb3cSopenharmony_ci { 59423b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 59523b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 59623b3eb3cSopenharmony_ci int32_t instanceId = instanceId_; 59723b3eb3cSopenharmony_ci if (container->IsSubContainer()) { 59823b3eb3cSopenharmony_ci instanceId = container->GetParentId(); 59923b3eb3cSopenharmony_ci } 60023b3eb3cSopenharmony_ci auto aceView = 60123b3eb3cSopenharmony_ci AceType::DynamicCast<Platform::AceViewOhos>(Platform::AceContainer::GetContainer(instanceId)->GetAceView()); 60223b3eb3cSopenharmony_ci CHECK_NULL_VOID(aceView); 60323b3eb3cSopenharmony_ci DragEventAction action; 60423b3eb3cSopenharmony_ci switch (event) { 60523b3eb3cSopenharmony_ci case OHOS::Rosen::DragEvent::DRAG_EVENT_END: 60623b3eb3cSopenharmony_ci action = DragEventAction::DRAG_EVENT_END; 60723b3eb3cSopenharmony_ci break; 60823b3eb3cSopenharmony_ci case OHOS::Rosen::DragEvent::DRAG_EVENT_OUT: 60923b3eb3cSopenharmony_ci action = DragEventAction::DRAG_EVENT_OUT; 61023b3eb3cSopenharmony_ci break; 61123b3eb3cSopenharmony_ci case OHOS::Rosen::DragEvent::DRAG_EVENT_MOVE: 61223b3eb3cSopenharmony_ci action = DragEventAction::DRAG_EVENT_MOVE; 61323b3eb3cSopenharmony_ci break; 61423b3eb3cSopenharmony_ci case OHOS::Rosen::DragEvent::DRAG_EVENT_IN: 61523b3eb3cSopenharmony_ci default: 61623b3eb3cSopenharmony_ci action = DragEventAction::DRAG_EVENT_START; 61723b3eb3cSopenharmony_ci break; 61823b3eb3cSopenharmony_ci } 61923b3eb3cSopenharmony_ci CHECK_NULL_VOID(static_cast<int>(action)); 62023b3eb3cSopenharmony_ci } 62123b3eb3cSopenharmony_ci 62223b3eb3cSopenharmony_ciprivate: 62323b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 62423b3eb3cSopenharmony_ci}; 62523b3eb3cSopenharmony_ci 62623b3eb3cSopenharmony_ciclass FoldScreenListener : public OHOS::Rosen::DisplayManager::IFoldStatusListener { 62723b3eb3cSopenharmony_cipublic: 62823b3eb3cSopenharmony_ci explicit FoldScreenListener(int32_t instanceId) : instanceId_(instanceId) {} 62923b3eb3cSopenharmony_ci ~FoldScreenListener() = default; 63023b3eb3cSopenharmony_ci void OnFoldStatusChanged(OHOS::Rosen::FoldStatus foldStatus) override 63123b3eb3cSopenharmony_ci { 63223b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 63323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 63423b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 63523b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 63623b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 63723b3eb3cSopenharmony_ci taskExecutor->PostTask( 63823b3eb3cSopenharmony_ci [container, foldStatus] { 63923b3eb3cSopenharmony_ci auto context = container->GetPipelineContext(); 64023b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 64123b3eb3cSopenharmony_ci auto aceFoldStatus = static_cast<FoldStatus>(static_cast<uint32_t>(foldStatus)); 64223b3eb3cSopenharmony_ci context->OnFoldStatusChanged(aceFoldStatus); 64323b3eb3cSopenharmony_ci }, 64423b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIFoldStatusChanged"); 64523b3eb3cSopenharmony_ci } 64623b3eb3cSopenharmony_ci 64723b3eb3cSopenharmony_ciprivate: 64823b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 64923b3eb3cSopenharmony_ci}; 65023b3eb3cSopenharmony_ci 65123b3eb3cSopenharmony_ciclass FoldDisplayModeListener : public OHOS::Rosen::DisplayManager::IDisplayModeListener { 65223b3eb3cSopenharmony_cipublic: 65323b3eb3cSopenharmony_ci explicit FoldDisplayModeListener(int32_t instanceId, bool isDialog = false) 65423b3eb3cSopenharmony_ci : instanceId_(instanceId), isDialog_(isDialog) 65523b3eb3cSopenharmony_ci {} 65623b3eb3cSopenharmony_ci ~FoldDisplayModeListener() = default; 65723b3eb3cSopenharmony_ci void OnDisplayModeChanged(OHOS::Rosen::FoldDisplayMode displayMode) override 65823b3eb3cSopenharmony_ci { 65923b3eb3cSopenharmony_ci if (!isDialog_) { 66023b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 66123b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 66223b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 66323b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 66423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 66523b3eb3cSopenharmony_ci taskExecutor->PostTask( 66623b3eb3cSopenharmony_ci [container, displayMode] { 66723b3eb3cSopenharmony_ci auto context = container->GetPipelineContext(); 66823b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 66923b3eb3cSopenharmony_ci auto aceDisplayMode = static_cast<FoldDisplayMode>(static_cast<uint32_t>(displayMode)); 67023b3eb3cSopenharmony_ci context->OnFoldDisplayModeChanged(aceDisplayMode); 67123b3eb3cSopenharmony_ci }, 67223b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIFoldDisplayModeChanged"); 67323b3eb3cSopenharmony_ci return; 67423b3eb3cSopenharmony_ci } 67523b3eb3cSopenharmony_ci auto container = Platform::DialogContainer::GetContainer(instanceId_); 67623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 67723b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 67823b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 67923b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 68023b3eb3cSopenharmony_ci taskExecutor->PostTask( 68123b3eb3cSopenharmony_ci [container, displayMode] { 68223b3eb3cSopenharmony_ci auto context = container->GetPipelineContext(); 68323b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 68423b3eb3cSopenharmony_ci auto aceDisplayMode = static_cast<FoldDisplayMode>(static_cast<uint32_t>(displayMode)); 68523b3eb3cSopenharmony_ci context->OnFoldDisplayModeChanged(aceDisplayMode); 68623b3eb3cSopenharmony_ci }, 68723b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIDialogFoldDisplayModeChanged"); 68823b3eb3cSopenharmony_ci } 68923b3eb3cSopenharmony_ci 69023b3eb3cSopenharmony_ciprivate: 69123b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 69223b3eb3cSopenharmony_ci bool isDialog_ = false; 69323b3eb3cSopenharmony_ci}; 69423b3eb3cSopenharmony_ci 69523b3eb3cSopenharmony_ciclass TouchOutsideListener : public OHOS::Rosen::ITouchOutsideListener { 69623b3eb3cSopenharmony_cipublic: 69723b3eb3cSopenharmony_ci explicit TouchOutsideListener(int32_t instanceId) : instanceId_(instanceId) {} 69823b3eb3cSopenharmony_ci ~TouchOutsideListener() = default; 69923b3eb3cSopenharmony_ci 70023b3eb3cSopenharmony_ci void OnTouchOutside() const 70123b3eb3cSopenharmony_ci { 70223b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_MENU, "window is touching outside. instance id is %{public}d", instanceId_); 70323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 70423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 70523b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 70623b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 70723b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 70823b3eb3cSopenharmony_ci taskExecutor->PostTask( 70923b3eb3cSopenharmony_ci [instanceId = instanceId_, targetId = targetId_] { 71023b3eb3cSopenharmony_ci SubwindowManager::GetInstance()->ClearMenu(); 71123b3eb3cSopenharmony_ci SubwindowManager::GetInstance()->ClearMenuNG(instanceId, targetId, true, true); 71223b3eb3cSopenharmony_ci SubwindowManager::GetInstance()->ClearPopupInSubwindow(instanceId); 71323b3eb3cSopenharmony_ci }, 71423b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUITouchOutsideSubwindowClear"); 71523b3eb3cSopenharmony_ci } 71623b3eb3cSopenharmony_ci 71723b3eb3cSopenharmony_ciprivate: 71823b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 71923b3eb3cSopenharmony_ci int32_t targetId_ = -1; 72023b3eb3cSopenharmony_ci}; 72123b3eb3cSopenharmony_ci 72223b3eb3cSopenharmony_ciUIContentImpl::UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime) : runtime_(runtime) 72323b3eb3cSopenharmony_ci{ 72423b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 72523b3eb3cSopenharmony_ci context_ = context->weak_from_this(); 72623b3eb3cSopenharmony_ci bundleName_ = context->GetBundleName(); 72723b3eb3cSopenharmony_ci auto hapModuleInfo = context->GetHapModuleInfo(); 72823b3eb3cSopenharmony_ci CHECK_NULL_VOID(hapModuleInfo); 72923b3eb3cSopenharmony_ci moduleName_ = hapModuleInfo->name; 73023b3eb3cSopenharmony_ci StoreConfiguration(context->GetConfiguration()); 73123b3eb3cSopenharmony_ci} 73223b3eb3cSopenharmony_ci 73323b3eb3cSopenharmony_ciUIContentImpl::UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime, bool isCard) 73423b3eb3cSopenharmony_ci : runtime_(runtime), isFormRender_(isCard) 73523b3eb3cSopenharmony_ci{ 73623b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 73723b3eb3cSopenharmony_ci bundleName_ = context->GetBundleName(); 73823b3eb3cSopenharmony_ci if (CJUtils::IsCJFrontendContext(context)) { 73923b3eb3cSopenharmony_ci LOGD("UIContentImpl cj"); 74023b3eb3cSopenharmony_ci context_ = context->weak_from_this(); 74123b3eb3cSopenharmony_ci } else { 74223b3eb3cSopenharmony_ci auto hapModuleInfo = context->GetHapModuleInfo(); 74323b3eb3cSopenharmony_ci CHECK_NULL_VOID(hapModuleInfo); 74423b3eb3cSopenharmony_ci moduleName_ = hapModuleInfo->name; 74523b3eb3cSopenharmony_ci hapPath_ = hapModuleInfo->hapPath; 74623b3eb3cSopenharmony_ci isBundle_ = (hapModuleInfo->compileMode == AppExecFwk::CompileMode::JS_BUNDLE); 74723b3eb3cSopenharmony_ci SetConfiguration(context->GetConfiguration()); 74823b3eb3cSopenharmony_ci context_ = context->weak_from_this(); 74923b3eb3cSopenharmony_ci } 75023b3eb3cSopenharmony_ci} 75123b3eb3cSopenharmony_ci 75223b3eb3cSopenharmony_ciUIContentImpl::UIContentImpl(OHOS::AppExecFwk::Ability* ability) 75323b3eb3cSopenharmony_ci{ 75423b3eb3cSopenharmony_ci CHECK_NULL_VOID(ability); 75523b3eb3cSopenharmony_ci context_ = ability->GetAbilityContext(); 75623b3eb3cSopenharmony_ci auto context = context_.lock(); 75723b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 75823b3eb3cSopenharmony_ci StoreConfiguration(context->GetConfiguration()); 75923b3eb3cSopenharmony_ci} 76023b3eb3cSopenharmony_ci 76123b3eb3cSopenharmony_civoid UIContentImpl::DestroyUIDirector() 76223b3eb3cSopenharmony_ci{ 76323b3eb3cSopenharmony_ci#ifndef NG_BUILD 76423b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 76523b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 76623b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<PipelineContext>(container->GetPipelineContext()); 76723b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 76823b3eb3cSopenharmony_ci#ifdef ENABLE_ROSEN_BACKEND 76923b3eb3cSopenharmony_ci auto rsUIDirector = pipelineContext->GetRSUIDirector(); 77023b3eb3cSopenharmony_ci CHECK_NULL_VOID(rsUIDirector); 77123b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: Destroying old rsUIDirectory", bundleName_.c_str(), moduleName_.c_str(), 77223b3eb3cSopenharmony_ci instanceId_); 77323b3eb3cSopenharmony_ci rsUIDirector->Destroy(); 77423b3eb3cSopenharmony_ci#endif 77523b3eb3cSopenharmony_ci#endif 77623b3eb3cSopenharmony_ci} 77723b3eb3cSopenharmony_ci 77823b3eb3cSopenharmony_civoid UIContentImpl::DestroyCallback() const 77923b3eb3cSopenharmony_ci{ 78023b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 78123b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 78223b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 78323b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 78423b3eb3cSopenharmony_ci pipelineContext->SetNextFrameLayoutCallback(nullptr); 78523b3eb3cSopenharmony_ci} 78623b3eb3cSopenharmony_ci 78723b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::InitializeInner( 78823b3eb3cSopenharmony_ci OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage, bool isNamedRouter) 78923b3eb3cSopenharmony_ci{ 79023b3eb3cSopenharmony_ci auto errorCode = UIContentErrorCode::NO_ERRORS; 79123b3eb3cSopenharmony_ci if (window && StringUtils::StartWith(window->GetWindowName(), SUBWINDOW_TOAST_DIALOG_PREFIX)) { 79223b3eb3cSopenharmony_ci return CommonInitialize(window, contentInfo, storage); 79323b3eb3cSopenharmony_ci } 79423b3eb3cSopenharmony_ci if (window) { 79523b3eb3cSopenharmony_ci errorCode = CommonInitialize(window, contentInfo, storage); 79623b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 79723b3eb3cSopenharmony_ci } 79823b3eb3cSopenharmony_ci 79923b3eb3cSopenharmony_ci // ArkTSCard need no window : 梳理所有需要window和不需要window的场景 80023b3eb3cSopenharmony_ci if (isFormRender_ && !window) { 80123b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: CommonInitializeForm url: %{public}s", bundleName_.c_str(), 80223b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_, contentInfo.c_str()); 80323b3eb3cSopenharmony_ci errorCode = CommonInitializeForm(window, contentInfo, storage); 80423b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 80523b3eb3cSopenharmony_ci } 80623b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: Initialize: %{public}s", bundleName_.c_str(), 80723b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_, startUrl_.c_str()); 80823b3eb3cSopenharmony_ci // run page. 80923b3eb3cSopenharmony_ci errorCode = Platform::AceContainer::RunPage(instanceId_, startUrl_, "", isNamedRouter); 81023b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 81123b3eb3cSopenharmony_ci auto distributedUI = std::make_shared<NG::DistributedUI>(); 81223b3eb3cSopenharmony_ci uiManager_ = std::make_unique<DistributedUIManager>(instanceId_, distributedUI); 81323b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetDistributedUI(distributedUI); 81423b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetUIExtensionSubWindow(isUIExtensionSubWindow_); 81523b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetUIExtensionAbilityProcess(isUIExtensionAbilityProcess_); 81623b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetUIExtensionAbilityHost(isUIExtensionAbilityHost_); 81723b3eb3cSopenharmony_ci#if !defined(ACE_UNITTEST) 81823b3eb3cSopenharmony_ci auto pipelineContext = NG::PipelineContext::GetCurrentContext(); 81923b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipelineContext, errorCode); 82023b3eb3cSopenharmony_ci auto rootNode = pipelineContext->GetRootElement(); 82123b3eb3cSopenharmony_ci NG::TransparentNodeDetector::GetInstance().PostCheckNodeTransparentTask(rootNode, startUrl_); 82223b3eb3cSopenharmony_ci#endif 82323b3eb3cSopenharmony_ci return errorCode; 82423b3eb3cSopenharmony_ci} 82523b3eb3cSopenharmony_ci 82623b3eb3cSopenharmony_civoid UIContentImpl::PreInitializeForm(OHOS::Rosen::Window* window, const std::string& url, napi_value storage) 82723b3eb3cSopenharmony_ci{ 82823b3eb3cSopenharmony_ci // ArkTSCard need no window 82923b3eb3cSopenharmony_ci if (isFormRender_ && !window) { 83023b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: InitializeForm: %{public}s", bundleName_.c_str(), 83123b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_, url.c_str()); 83223b3eb3cSopenharmony_ci CommonInitializeForm(window, url, storage); 83323b3eb3cSopenharmony_ci AddWatchSystemParameter(); 83423b3eb3cSopenharmony_ci } 83523b3eb3cSopenharmony_ci} 83623b3eb3cSopenharmony_ci 83723b3eb3cSopenharmony_civoid UIContentImpl::RunFormPage() 83823b3eb3cSopenharmony_ci{ 83923b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: Initialize startUrl: %{public}s", 84023b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, startUrl_.c_str()); 84123b3eb3cSopenharmony_ci // run page. 84223b3eb3cSopenharmony_ci Platform::AceContainer::RunPage(instanceId_, startUrl_, formData_, false); 84323b3eb3cSopenharmony_ci auto distributedUI = std::make_shared<NG::DistributedUI>(); 84423b3eb3cSopenharmony_ci uiManager_ = std::make_unique<DistributedUIManager>(instanceId_, distributedUI); 84523b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 84623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 84723b3eb3cSopenharmony_ci container->SetDistributedUI(distributedUI); 84823b3eb3cSopenharmony_ci} 84923b3eb3cSopenharmony_ci 85023b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::Initialize(OHOS::Rosen::Window* window, const std::string& url, napi_value storage) 85123b3eb3cSopenharmony_ci{ 85223b3eb3cSopenharmony_ci auto errorCode = InitializeInner(window, url, storage, false); 85323b3eb3cSopenharmony_ci AddWatchSystemParameter(); 85423b3eb3cSopenharmony_ci return errorCode; 85523b3eb3cSopenharmony_ci} 85623b3eb3cSopenharmony_ci 85723b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::Initialize( 85823b3eb3cSopenharmony_ci OHOS::Rosen::Window* window, const std::shared_ptr<std::vector<uint8_t>>& content, napi_value storage) 85923b3eb3cSopenharmony_ci{ 86023b3eb3cSopenharmony_ci auto errorCode = UIContentErrorCode::NO_ERRORS; 86123b3eb3cSopenharmony_ci errorCode = CommonInitialize(window, "", storage); 86223b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 86323b3eb3cSopenharmony_ci AddWatchSystemParameter(); 86423b3eb3cSopenharmony_ci if (content) { 86523b3eb3cSopenharmony_ci LOGI("Initialize by buffer, size:%{public}zu", content->size()); 86623b3eb3cSopenharmony_ci // run page. 86723b3eb3cSopenharmony_ci errorCode = Platform::AceContainer::RunPage(instanceId_, content, ""); 86823b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 86923b3eb3cSopenharmony_ci } else { 87023b3eb3cSopenharmony_ci LOGE("Initialize failed, buffer is null"); 87123b3eb3cSopenharmony_ci } 87223b3eb3cSopenharmony_ci auto distributedUI = std::make_shared<NG::DistributedUI>(); 87323b3eb3cSopenharmony_ci uiManager_ = std::make_unique<DistributedUIManager>(instanceId_, distributedUI); 87423b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetDistributedUI(distributedUI); 87523b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetUIExtensionSubWindow(isUIExtensionSubWindow_); 87623b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetUIExtensionAbilityProcess(isUIExtensionAbilityProcess_); 87723b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetUIExtensionAbilityHost(isUIExtensionAbilityHost_); 87823b3eb3cSopenharmony_ci return errorCode; 87923b3eb3cSopenharmony_ci} 88023b3eb3cSopenharmony_ci 88123b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::InitializeByName( 88223b3eb3cSopenharmony_ci OHOS::Rosen::Window* window, const std::string& name, napi_value storage) 88323b3eb3cSopenharmony_ci{ 88423b3eb3cSopenharmony_ci auto errorCode = InitializeInner(window, name, storage, true); 88523b3eb3cSopenharmony_ci AddWatchSystemParameter(); 88623b3eb3cSopenharmony_ci return errorCode; 88723b3eb3cSopenharmony_ci} 88823b3eb3cSopenharmony_ci 88923b3eb3cSopenharmony_civoid UIContentImpl::InitializeDynamic(int32_t hostInstanceId, const std::string& hapPath, const std::string& abcPath, 89023b3eb3cSopenharmony_ci const std::string& entryPoint, const std::vector<std::string>& registerComponents) 89123b3eb3cSopenharmony_ci{ 89223b3eb3cSopenharmony_ci isDynamicRender_ = true; 89323b3eb3cSopenharmony_ci hapPath_ = hapPath; 89423b3eb3cSopenharmony_ci hostInstanceId_ = hostInstanceId; 89523b3eb3cSopenharmony_ci registerComponents_ = registerComponents; 89623b3eb3cSopenharmony_ci auto env = reinterpret_cast<napi_env>(runtime_); 89723b3eb3cSopenharmony_ci CHECK_NULL_VOID(env); 89823b3eb3cSopenharmony_ci taskWrapper_ = std::make_shared<NG::UVTaskWrapperImpl>(env); 89923b3eb3cSopenharmony_ci 90023b3eb3cSopenharmony_ci CommonInitializeForm(nullptr, abcPath, nullptr); 90123b3eb3cSopenharmony_ci AddWatchSystemParameter(); 90223b3eb3cSopenharmony_ci 90323b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: InitializeDynamic, startUrl" 90423b3eb3cSopenharmony_ci ": %{public}s, entryPoint: %{public}s", 90523b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, startUrl_.c_str(), entryPoint.c_str()); 90623b3eb3cSopenharmony_ci Platform::AceContainer::RunDynamicPage(instanceId_, startUrl_, "", entryPoint); 90723b3eb3cSopenharmony_ci auto distributedUI = std::make_shared<NG::DistributedUI>(); 90823b3eb3cSopenharmony_ci uiManager_ = std::make_unique<DistributedUIManager>(instanceId_, distributedUI); 90923b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetDistributedUI(distributedUI); 91023b3eb3cSopenharmony_ci} 91123b3eb3cSopenharmony_ci 91223b3eb3cSopenharmony_civoid UIContentImpl::Initialize( 91323b3eb3cSopenharmony_ci OHOS::Rosen::Window* window, const std::string& url, napi_value storage, uint32_t focusWindowId) 91423b3eb3cSopenharmony_ci{ 91523b3eb3cSopenharmony_ci if (window == nullptr) { 91623b3eb3cSopenharmony_ci LOGE("UIExtensionAbility [%{public}s][%{public}s][%{public}d][%{public}s] initialize ui instance failed, the" 91723b3eb3cSopenharmony_ci "window is invalid", 91823b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, startUrl_.c_str()); 91923b3eb3cSopenharmony_ci return; 92023b3eb3cSopenharmony_ci } 92123b3eb3cSopenharmony_ci auto errorCode = CommonInitialize(window, url, storage, focusWindowId); 92223b3eb3cSopenharmony_ci if (errorCode != UIContentErrorCode::NO_ERRORS) { 92323b3eb3cSopenharmony_ci return; 92423b3eb3cSopenharmony_ci } 92523b3eb3cSopenharmony_ci AddWatchSystemParameter(); 92623b3eb3cSopenharmony_ci 92723b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_UIEXTENSIONCOMPONENT, "[%{public}s][%{public}s][%{public}d]: StartUIExtension: %{public}s", 92823b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, startUrl_.c_str()); 92923b3eb3cSopenharmony_ci // run page. 93023b3eb3cSopenharmony_ci Platform::AceContainer::RunPage(instanceId_, startUrl_, ""); 93123b3eb3cSopenharmony_ci auto distributedUI = std::make_shared<NG::DistributedUI>(); 93223b3eb3cSopenharmony_ci uiManager_ = std::make_unique<DistributedUIManager>(instanceId_, distributedUI); 93323b3eb3cSopenharmony_ci Platform::AceContainer::GetContainer(instanceId_)->SetDistributedUI(distributedUI); 93423b3eb3cSopenharmony_ci#if !defined(ACE_UNITTEST) 93523b3eb3cSopenharmony_ci auto pipelineContext = NG::PipelineContext::GetCurrentContext(); 93623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 93723b3eb3cSopenharmony_ci auto rootNode = pipelineContext->GetRootElement(); 93823b3eb3cSopenharmony_ci NG::TransparentNodeDetector::GetInstance().PostCheckNodeTransparentTask(rootNode, startUrl_); 93923b3eb3cSopenharmony_ci#endif 94023b3eb3cSopenharmony_ci} 94123b3eb3cSopenharmony_ci 94223b3eb3cSopenharmony_cinapi_value UIContentImpl::GetUINapiContext() 94323b3eb3cSopenharmony_ci{ 94423b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 94523b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 94623b3eb3cSopenharmony_ci napi_value result = nullptr; 94723b3eb3cSopenharmony_ci auto frontend = container->GetFrontend(); 94823b3eb3cSopenharmony_ci CHECK_NULL_RETURN(frontend, result); 94923b3eb3cSopenharmony_ci if (frontend->GetType() == FrontendType::DECLARATIVE_JS) { 95023b3eb3cSopenharmony_ci#ifdef NG_BUILD 95123b3eb3cSopenharmony_ci auto declarativeFrontend = AceType::DynamicCast<DeclarativeFrontendNG>(frontend); 95223b3eb3cSopenharmony_ci#else 95323b3eb3cSopenharmony_ci auto declarativeFrontend = AceType::DynamicCast<DeclarativeFrontend>(frontend); 95423b3eb3cSopenharmony_ci#endif 95523b3eb3cSopenharmony_ci CHECK_NULL_RETURN(declarativeFrontend, result); 95623b3eb3cSopenharmony_ci return declarativeFrontend->GetContextValue(); 95723b3eb3cSopenharmony_ci } 95823b3eb3cSopenharmony_ci 95923b3eb3cSopenharmony_ci return result; 96023b3eb3cSopenharmony_ci} 96123b3eb3cSopenharmony_ci 96223b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::Restore( 96323b3eb3cSopenharmony_ci OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage, ContentInfoType type) 96423b3eb3cSopenharmony_ci{ 96523b3eb3cSopenharmony_ci LOGI("Restore with contentInfo size: %{public}d, ContentInfotype: %{public}d", 96623b3eb3cSopenharmony_ci static_cast<int32_t>(contentInfo.size()), static_cast<int32_t>(type)); 96723b3eb3cSopenharmony_ci auto errorCode = UIContentErrorCode::NO_ERRORS; 96823b3eb3cSopenharmony_ci errorCode = CommonInitialize(window, contentInfo, storage); 96923b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 97023b3eb3cSopenharmony_ci RouterRecoverRecord record; 97123b3eb3cSopenharmony_ci std::tie(record, errorCode) = Platform::AceContainer::RestoreRouterStack(instanceId_, contentInfo, type); 97223b3eb3cSopenharmony_ci startUrl_ = record.url; 97323b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 97423b3eb3cSopenharmony_ci if (startUrl_.empty()) { 97523b3eb3cSopenharmony_ci LOGW("Restore start url is empty"); 97623b3eb3cSopenharmony_ci } 97723b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: Restore startUrl: %{public}s, isNamedRouter: %{public}s", 97823b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, startUrl_.c_str(), 97923b3eb3cSopenharmony_ci (record.isNamedRouter ? "yes" : "no")); 98023b3eb3cSopenharmony_ci return Platform::AceContainer::RunPage(instanceId_, startUrl_, record.params, record.isNamedRouter); 98123b3eb3cSopenharmony_ci} 98223b3eb3cSopenharmony_ci 98323b3eb3cSopenharmony_cistd::string UIContentImpl::GetContentInfo(ContentInfoType type) const 98423b3eb3cSopenharmony_ci{ 98523b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: GetContentInfoType: %{public}d", 98623b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, type); 98723b3eb3cSopenharmony_ci return Platform::AceContainer::GetContentInfo(instanceId_, type); 98823b3eb3cSopenharmony_ci} 98923b3eb3cSopenharmony_ci 99023b3eb3cSopenharmony_ci// ArkTSCard start 99123b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::CommonInitializeForm( 99223b3eb3cSopenharmony_ci OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage) 99323b3eb3cSopenharmony_ci{ 99423b3eb3cSopenharmony_ci ACE_FUNCTION_TRACE(); 99523b3eb3cSopenharmony_ci window_ = window; 99623b3eb3cSopenharmony_ci startUrl_ = contentInfo; 99723b3eb3cSopenharmony_ci auto errorCode = UIContentErrorCode::NO_ERRORS; 99823b3eb3cSopenharmony_ci 99923b3eb3cSopenharmony_ci if (window_) { 100023b3eb3cSopenharmony_ci if (StringUtils::StartWith(window->GetWindowName(), SUBWINDOW_TOAST_DIALOG_PREFIX)) { 100123b3eb3cSopenharmony_ci InitializeSubWindow(window_, true); 100223b3eb3cSopenharmony_ci return errorCode; 100323b3eb3cSopenharmony_ci } 100423b3eb3cSopenharmony_ci if (StringUtils::StartWith(window->GetWindowName(), SUBWINDOW_PREFIX)) { 100523b3eb3cSopenharmony_ci InitializeSubWindow(window_); 100623b3eb3cSopenharmony_ci return errorCode; 100723b3eb3cSopenharmony_ci } 100823b3eb3cSopenharmony_ci } 100923b3eb3cSopenharmony_ci 101023b3eb3cSopenharmony_ci auto context = context_.lock(); 101123b3eb3cSopenharmony_ci static std::once_flag onceFlag; 101223b3eb3cSopenharmony_ci if (!isFormRender_) { 101323b3eb3cSopenharmony_ci std::call_once(onceFlag, [&context]() { 101423b3eb3cSopenharmony_ci SetHwIcuDirectory(); 101523b3eb3cSopenharmony_ci Container::UpdateCurrent(INSTANCE_ID_PLATFORM); 101623b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetProcessName(context->GetBundleName()); 101723b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetPackageName(context->GetBundleName()); 101823b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetDataFileDirPath(context->GetFilesDir()); 101923b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetUid(IPCSkeleton::GetCallingUid()); 102023b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetPid(IPCSkeleton::GetCallingRealPid()); 102123b3eb3cSopenharmony_ci CapabilityRegistry::Register(); 102223b3eb3cSopenharmony_ci ImageFileCache::GetInstance().SetImageCacheFilePath(context->GetCacheDir()); 102323b3eb3cSopenharmony_ci ImageFileCache::GetInstance().SetCacheFileInfo(); 102423b3eb3cSopenharmony_ci }); 102523b3eb3cSopenharmony_ci } 102623b3eb3cSopenharmony_ci 102723b3eb3cSopenharmony_ci bool useNewPipe = true; 102823b3eb3cSopenharmony_ci int32_t deviceWidth = 0; 102923b3eb3cSopenharmony_ci int32_t deviceHeight = 0; 103023b3eb3cSopenharmony_ci float density = 1.0f; 103123b3eb3cSopenharmony_ci auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay(); 103223b3eb3cSopenharmony_ci if (defaultDisplay) { 103323b3eb3cSopenharmony_ci auto displayInfo = defaultDisplay->GetDisplayInfo(); 103423b3eb3cSopenharmony_ci if (displayInfo) { 103523b3eb3cSopenharmony_ci density = displayInfo->GetDensityInCurResolution(); 103623b3eb3cSopenharmony_ci } 103723b3eb3cSopenharmony_ci deviceWidth = defaultDisplay->GetWidth(); 103823b3eb3cSopenharmony_ci deviceHeight = defaultDisplay->GetHeight(); 103923b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_FORM, 104023b3eb3cSopenharmony_ci "[%{public}s][%{public}s][%{public}d]: CommonInitializeForm virtualPixelRatio: %{public}f, deviceWidth: " 104123b3eb3cSopenharmony_ci "%{public}d, deviceHeight: %{public}d", 104223b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, density, deviceWidth, deviceHeight); 104323b3eb3cSopenharmony_ci } 104423b3eb3cSopenharmony_ci 104523b3eb3cSopenharmony_ci SystemProperties::InitDeviceInfo(deviceWidth, deviceHeight, deviceHeight >= deviceWidth ? 0 : 1, density, false); 104623b3eb3cSopenharmony_ci std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig()); 104723b3eb3cSopenharmony_ci if (context) { 104823b3eb3cSopenharmony_ci auto resourceManager = context->GetResourceManager(); 104923b3eb3cSopenharmony_ci if (resourceManager != nullptr) { 105023b3eb3cSopenharmony_ci resourceManager->GetResConfig(*resConfig); 105123b3eb3cSopenharmony_ci auto localeInfo = resConfig->GetLocaleInfo(); 105223b3eb3cSopenharmony_ci Platform::AceApplicationInfoImpl::GetInstance().SetResourceManager(resourceManager); 105323b3eb3cSopenharmony_ci if (localeInfo != nullptr) { 105423b3eb3cSopenharmony_ci auto language = localeInfo->getLanguage(); 105523b3eb3cSopenharmony_ci auto region = localeInfo->getCountry(); 105623b3eb3cSopenharmony_ci auto script = localeInfo->getScript(); 105723b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetLocale((language == nullptr) ? "" : language, 105823b3eb3cSopenharmony_ci (region == nullptr) ? "" : region, (script == nullptr) ? "" : script, ""); 105923b3eb3cSopenharmony_ci } 106023b3eb3cSopenharmony_ci if (resConfig->GetColorMode() == OHOS::Global::Resource::ColorMode::DARK) { 106123b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::DARK); 106223b3eb3cSopenharmony_ci LOGI("Set dark mode"); 106323b3eb3cSopenharmony_ci } else { 106423b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::LIGHT); 106523b3eb3cSopenharmony_ci LOGI("Set light mode"); 106623b3eb3cSopenharmony_ci } 106723b3eb3cSopenharmony_ci SystemProperties::SetDeviceAccess( 106823b3eb3cSopenharmony_ci resConfig->GetInputDevice() == Global::Resource::InputDevice::INPUTDEVICE_POINTINGDEVICE); 106923b3eb3cSopenharmony_ci } 107023b3eb3cSopenharmony_ci } 107123b3eb3cSopenharmony_ci 107223b3eb3cSopenharmony_ci auto abilityContext = OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::AbilityContext>(context); 107323b3eb3cSopenharmony_ci std::shared_ptr<OHOS::AppExecFwk::AbilityInfo> info; 107423b3eb3cSopenharmony_ci if (abilityContext) { 107523b3eb3cSopenharmony_ci info = abilityContext->GetAbilityInfo(); 107623b3eb3cSopenharmony_ci } else { 107723b3eb3cSopenharmony_ci auto extensionContext = 107823b3eb3cSopenharmony_ci OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::ExtensionContext>(context); 107923b3eb3cSopenharmony_ci if (extensionContext) { 108023b3eb3cSopenharmony_ci info = extensionContext->GetAbilityInfo(); 108123b3eb3cSopenharmony_ci } 108223b3eb3cSopenharmony_ci } 108323b3eb3cSopenharmony_ci if (info) { 108423b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetAbilityName(info->name); 108523b3eb3cSopenharmony_ci } 108623b3eb3cSopenharmony_ci 108723b3eb3cSopenharmony_ci RefPtr<AssetManagerImpl> assetManagerImpl = Referenced::MakeRefPtr<AssetManagerImpl>(); 108823b3eb3cSopenharmony_ci bool isModelJson = info != nullptr ? info->isModuleJson : false; 108923b3eb3cSopenharmony_ci std::string moduleName = info != nullptr ? info->moduleName : ""; 109023b3eb3cSopenharmony_ci auto appInfo = context != nullptr ? context->GetApplicationInfo() : nullptr; 109123b3eb3cSopenharmony_ci auto hapModuleInfo = context != nullptr ? context->GetHapModuleInfo() : nullptr; 109223b3eb3cSopenharmony_ci auto bundleName = info != nullptr ? info->bundleName : ""; 109323b3eb3cSopenharmony_ci std::string moduleHapPath = info != nullptr ? info->hapPath : ""; 109423b3eb3cSopenharmony_ci std::string resPath; 109523b3eb3cSopenharmony_ci std::string pageProfile; 109623b3eb3cSopenharmony_ci if (isFormRender_) { 109723b3eb3cSopenharmony_ci std::vector<std::string> basePaths; 109823b3eb3cSopenharmony_ci basePaths.emplace_back("assets/js/" + moduleName_ + "/"); 109923b3eb3cSopenharmony_ci basePaths.emplace_back("assets/js/share/"); 110023b3eb3cSopenharmony_ci basePaths.emplace_back(""); 110123b3eb3cSopenharmony_ci basePaths.emplace_back("js/"); 110223b3eb3cSopenharmony_ci basePaths.emplace_back("ets/"); 110323b3eb3cSopenharmony_ci auto assetProvider = CreateAssetProviderImpl(hapPath_, basePaths, false); 110423b3eb3cSopenharmony_ci if (assetProvider) { 110523b3eb3cSopenharmony_ci assetManagerImpl->PushBack(std::move(assetProvider)); 110623b3eb3cSopenharmony_ci } 110723b3eb3cSopenharmony_ci } else { 110823b3eb3cSopenharmony_ci if (isModelJson) { 110923b3eb3cSopenharmony_ci std::string hapPath = info != nullptr ? info->hapPath : ""; 111023b3eb3cSopenharmony_ci // first use hap provider 111123b3eb3cSopenharmony_ci if (assetManagerImpl && !hapPath.empty()) { 111223b3eb3cSopenharmony_ci auto hapAssetProviderImpl = AceType::MakeRefPtr<HapAssetProviderImpl>(); 111323b3eb3cSopenharmony_ci if (hapAssetProviderImpl->Initialize(hapPath, { "", "ets/", "resources/base/profile/" })) { 111423b3eb3cSopenharmony_ci assetManagerImpl->PushBack(std::move(hapAssetProviderImpl)); 111523b3eb3cSopenharmony_ci } 111623b3eb3cSopenharmony_ci } 111723b3eb3cSopenharmony_ci 111823b3eb3cSopenharmony_ci if (appInfo) { 111923b3eb3cSopenharmony_ci std::vector<OHOS::AppExecFwk::ModuleInfo> moduleList = appInfo->moduleInfos; 112023b3eb3cSopenharmony_ci for (const auto& module : moduleList) { 112123b3eb3cSopenharmony_ci if (module.moduleName == moduleName) { 112223b3eb3cSopenharmony_ci std::regex pattern(ABS_BUNDLE_CODE_PATH + bundleName + FILE_SEPARATOR); 112323b3eb3cSopenharmony_ci auto moduleSourceDir = 112423b3eb3cSopenharmony_ci std::regex_replace(module.moduleSourceDir, pattern, LOCAL_BUNDLE_CODE_PATH); 112523b3eb3cSopenharmony_ci resPath = moduleSourceDir + "/"; 112623b3eb3cSopenharmony_ci break; 112723b3eb3cSopenharmony_ci } 112823b3eb3cSopenharmony_ci } 112923b3eb3cSopenharmony_ci } 113023b3eb3cSopenharmony_ci 113123b3eb3cSopenharmony_ci // second use file provider, will remove later 113223b3eb3cSopenharmony_ci auto assetBasePathStr = { std::string("ets/"), std::string("resources/base/profile/") }; 113323b3eb3cSopenharmony_ci if (assetManagerImpl && !resPath.empty()) { 113423b3eb3cSopenharmony_ci auto assetProvider = AceType::MakeRefPtr<FileAssetProviderImpl>(); 113523b3eb3cSopenharmony_ci if (assetProvider->Initialize(resPath, assetBasePathStr)) { 113623b3eb3cSopenharmony_ci assetManagerImpl->PushBack(std::move(assetProvider)); 113723b3eb3cSopenharmony_ci } 113823b3eb3cSopenharmony_ci } 113923b3eb3cSopenharmony_ci 114023b3eb3cSopenharmony_ci if (hapModuleInfo) { 114123b3eb3cSopenharmony_ci pageProfile = hapModuleInfo->pages; 114223b3eb3cSopenharmony_ci const std::string profilePrefix = "$profile:"; 114323b3eb3cSopenharmony_ci if (pageProfile.compare(0, profilePrefix.size(), profilePrefix) == 0) { 114423b3eb3cSopenharmony_ci pageProfile = pageProfile.substr(profilePrefix.length()).append(".json"); 114523b3eb3cSopenharmony_ci } 114623b3eb3cSopenharmony_ci } 114723b3eb3cSopenharmony_ci } else { 114823b3eb3cSopenharmony_ci auto packagePathStr = context->GetBundleCodeDir(); 114923b3eb3cSopenharmony_ci if (hapModuleInfo != nullptr) { 115023b3eb3cSopenharmony_ci packagePathStr += "/" + hapModuleInfo->package + "/"; 115123b3eb3cSopenharmony_ci } 115223b3eb3cSopenharmony_ci std::string srcPath = ""; 115323b3eb3cSopenharmony_ci if (info != nullptr && !info->srcPath.empty()) { 115423b3eb3cSopenharmony_ci srcPath = info->srcPath; 115523b3eb3cSopenharmony_ci } 115623b3eb3cSopenharmony_ci 115723b3eb3cSopenharmony_ci auto assetBasePathStr = { "assets/js/" + (srcPath.empty() ? "default" : srcPath) + "/", 115823b3eb3cSopenharmony_ci std::string("assets/js/share/") }; 115923b3eb3cSopenharmony_ci if (assetManagerImpl && !packagePathStr.empty()) { 116023b3eb3cSopenharmony_ci auto fileAssetProvider = AceType::MakeRefPtr<FileAssetProviderImpl>(); 116123b3eb3cSopenharmony_ci if (fileAssetProvider->Initialize(packagePathStr, assetBasePathStr)) { 116223b3eb3cSopenharmony_ci assetManagerImpl->PushBack(std::move(fileAssetProvider)); 116323b3eb3cSopenharmony_ci } 116423b3eb3cSopenharmony_ci } 116523b3eb3cSopenharmony_ci if (appInfo) { 116623b3eb3cSopenharmony_ci std::vector<OHOS::AppExecFwk::ModuleInfo> moduleList = appInfo->moduleInfos; 116723b3eb3cSopenharmony_ci for (const auto& module : moduleList) { 116823b3eb3cSopenharmony_ci if (module.moduleName == moduleName) { 116923b3eb3cSopenharmony_ci std::regex pattern(ABS_BUNDLE_CODE_PATH + bundleName + FILE_SEPARATOR); 117023b3eb3cSopenharmony_ci auto moduleSourceDir = 117123b3eb3cSopenharmony_ci std::regex_replace(module.moduleSourceDir, pattern, LOCAL_BUNDLE_CODE_PATH); 117223b3eb3cSopenharmony_ci resPath = moduleSourceDir + "/assets/" + module.moduleName + "/"; 117323b3eb3cSopenharmony_ci break; 117423b3eb3cSopenharmony_ci } 117523b3eb3cSopenharmony_ci } 117623b3eb3cSopenharmony_ci } 117723b3eb3cSopenharmony_ci } 117823b3eb3cSopenharmony_ci } 117923b3eb3cSopenharmony_ci 118023b3eb3cSopenharmony_ci std::string hapPath; // hap path in sandbox 118123b3eb3cSopenharmony_ci if (!moduleHapPath.empty()) { 118223b3eb3cSopenharmony_ci if (moduleHapPath.find(ABS_BUNDLE_CODE_PATH) == std::string::npos) { 118323b3eb3cSopenharmony_ci hapPath = moduleHapPath; 118423b3eb3cSopenharmony_ci } else { 118523b3eb3cSopenharmony_ci auto pos = moduleHapPath.find_last_of('/'); 118623b3eb3cSopenharmony_ci if (pos != std::string::npos) { 118723b3eb3cSopenharmony_ci hapPath = LOCAL_BUNDLE_CODE_PATH + moduleHapPath.substr(pos + 1); 118823b3eb3cSopenharmony_ci } 118923b3eb3cSopenharmony_ci } 119023b3eb3cSopenharmony_ci } 119123b3eb3cSopenharmony_ci 119223b3eb3cSopenharmony_ci#ifdef PLUGIN_COMPONENT_SUPPORTED 119323b3eb3cSopenharmony_ci auto pluginUtils = std::make_shared<PluginUtilsImpl>(); 119423b3eb3cSopenharmony_ci PluginManager::GetInstance().SetAceAbility(nullptr, pluginUtils); 119523b3eb3cSopenharmony_ci#endif 119623b3eb3cSopenharmony_ci // create container 119723b3eb3cSopenharmony_ci if (runtime_) { 119823b3eb3cSopenharmony_ci instanceId_ = Container::GenerateId<STAGE_CONTAINER>(); 119923b3eb3cSopenharmony_ci } else { 120023b3eb3cSopenharmony_ci instanceId_ = Container::GenerateId<FA_SUBWINDOW_CONTAINER>(); 120123b3eb3cSopenharmony_ci } 120223b3eb3cSopenharmony_ci#ifdef FORM_SUPPORTED 120323b3eb3cSopenharmony_ci auto formUtils = std::make_shared<FormUtilsImpl>(); 120423b3eb3cSopenharmony_ci FormManager::GetInstance().SetFormUtils(formUtils); 120523b3eb3cSopenharmony_ci#endif 120623b3eb3cSopenharmony_ci auto container = 120723b3eb3cSopenharmony_ci AceType::MakeRefPtr<Platform::AceContainer>(instanceId_, FrontendType::DECLARATIVE_JS, context_, info, 120823b3eb3cSopenharmony_ci std::make_unique<ContentEventCallback>( 120923b3eb3cSopenharmony_ci [window = window_] { 121023b3eb3cSopenharmony_ci CHECK_NULL_VOID(window); 121123b3eb3cSopenharmony_ci window->PerformBack(); 121223b3eb3cSopenharmony_ci }, 121323b3eb3cSopenharmony_ci [context = context_](const std::string& address) { 121423b3eb3cSopenharmony_ci auto sharedContext = context.lock(); 121523b3eb3cSopenharmony_ci CHECK_NULL_VOID(sharedContext); 121623b3eb3cSopenharmony_ci auto abilityContext = 121723b3eb3cSopenharmony_ci OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::AbilityContext>(sharedContext); 121823b3eb3cSopenharmony_ci CHECK_NULL_VOID(abilityContext); 121923b3eb3cSopenharmony_ci LOGI("Start ability: %{private}s", address.c_str()); 122023b3eb3cSopenharmony_ci AAFwk::Want want; 122123b3eb3cSopenharmony_ci want.AddEntity(Want::ENTITY_BROWSER); 122223b3eb3cSopenharmony_ci want.SetUri(address); 122323b3eb3cSopenharmony_ci want.SetAction(ACTION_VIEWDATA); 122423b3eb3cSopenharmony_ci abilityContext->StartAbility(want, REQUEST_CODE); 122523b3eb3cSopenharmony_ci }), 122623b3eb3cSopenharmony_ci taskWrapper_, false, false, useNewPipe); 122723b3eb3cSopenharmony_ci 122823b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, UIContentErrorCode::NULL_POINTER); 122923b3eb3cSopenharmony_ci container->SetIsFormRender(isFormRender_); 123023b3eb3cSopenharmony_ci container->SetIsDynamicRender(isDynamicRender_); 123123b3eb3cSopenharmony_ci container->SetRegisterComponents(registerComponents_); 123223b3eb3cSopenharmony_ci container->SetIsFRSCardContainer(isFormRender_); 123323b3eb3cSopenharmony_ci if (window_) { 123423b3eb3cSopenharmony_ci container->SetWindowName(window_->GetWindowName()); 123523b3eb3cSopenharmony_ci container->SetWindowId(window_->GetWindowId()); 123623b3eb3cSopenharmony_ci } 123723b3eb3cSopenharmony_ci 123823b3eb3cSopenharmony_ci if (context) { 123923b3eb3cSopenharmony_ci auto token = context->GetToken(); 124023b3eb3cSopenharmony_ci container->SetToken(token); 124123b3eb3cSopenharmony_ci } 124223b3eb3cSopenharmony_ci 124323b3eb3cSopenharmony_ci if (appInfo) { 124423b3eb3cSopenharmony_ci container->SetApiTargetVersion(appInfo->apiTargetVersion); 124523b3eb3cSopenharmony_ci } 124623b3eb3cSopenharmony_ci 124723b3eb3cSopenharmony_ci // Mark the relationship between windowId and containerId, it is 1:1 124823b3eb3cSopenharmony_ci if (window) { 124923b3eb3cSopenharmony_ci SubwindowManager::GetInstance()->AddContainerId(window->GetWindowId(), instanceId_); 125023b3eb3cSopenharmony_ci } 125123b3eb3cSopenharmony_ci AceEngine::Get().AddContainer(instanceId_, container); 125223b3eb3cSopenharmony_ci if (runtime_) { 125323b3eb3cSopenharmony_ci container->GetSettings().SetUsingSharedRuntime(true); 125423b3eb3cSopenharmony_ci container->SetSharedRuntime(runtime_); 125523b3eb3cSopenharmony_ci } else { 125623b3eb3cSopenharmony_ci container->GetSettings().SetUsingSharedRuntime(false); 125723b3eb3cSopenharmony_ci } 125823b3eb3cSopenharmony_ci container->SetPageProfile(pageProfile); 125923b3eb3cSopenharmony_ci container->Initialize(); 126023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 126123b3eb3cSopenharmony_ci auto front = container->GetFrontend(); 126223b3eb3cSopenharmony_ci if (front) { 126323b3eb3cSopenharmony_ci front->UpdateState(Frontend::State::ON_CREATE); 126423b3eb3cSopenharmony_ci front->SetJsMessageDispatcher(container); 126523b3eb3cSopenharmony_ci } 126623b3eb3cSopenharmony_ci auto aceResCfg = container->GetResourceConfiguration(); 126723b3eb3cSopenharmony_ci aceResCfg.SetOrientation(SystemProperties::GetDeviceOrientation()); 126823b3eb3cSopenharmony_ci aceResCfg.SetDensity(SystemProperties::GetResolution()); 126923b3eb3cSopenharmony_ci aceResCfg.SetDeviceType(SystemProperties::GetDeviceType()); 127023b3eb3cSopenharmony_ci aceResCfg.SetColorMode(SystemProperties::GetColorMode()); 127123b3eb3cSopenharmony_ci aceResCfg.SetDeviceAccess(SystemProperties::GetDeviceAccess()); 127223b3eb3cSopenharmony_ci AddResConfigInfo(context, aceResCfg); 127323b3eb3cSopenharmony_ci if (isDynamicRender_) { 127423b3eb3cSopenharmony_ci auto runtimeContext = Platform::AceContainer::GetRuntimeContext(hostInstanceId_); 127523b3eb3cSopenharmony_ci if (runtimeContext) { 127623b3eb3cSopenharmony_ci AddSetAppColorModeToResConfig(runtimeContext->shared_from_this(), aceResCfg); 127723b3eb3cSopenharmony_ci } 127823b3eb3cSopenharmony_ci } else { 127923b3eb3cSopenharmony_ci AddSetAppColorModeToResConfig(context, aceResCfg); 128023b3eb3cSopenharmony_ci } 128123b3eb3cSopenharmony_ci if (isDynamicRender_) { 128223b3eb3cSopenharmony_ci if (std::regex_match(hapPath_, std::regex(".*\\.hap"))) { 128323b3eb3cSopenharmony_ci hapPath = hapPath_; 128423b3eb3cSopenharmony_ci } else { 128523b3eb3cSopenharmony_ci resPath = hapPath_; 128623b3eb3cSopenharmony_ci } 128723b3eb3cSopenharmony_ci } else if (isFormRender_) { 128823b3eb3cSopenharmony_ci resPath = "/data/bundles/" + bundleName_ + "/" + moduleName_ + "/"; 128923b3eb3cSopenharmony_ci hapPath = hapPath_; 129023b3eb3cSopenharmony_ci } 129123b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_FORM, 129223b3eb3cSopenharmony_ci "[%{public}s][%{public}s][%{public}d]: CommonInitializeForm resPath = %{public}s hapPath = %{public}s", 129323b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, resPath.c_str(), hapPath.c_str()); 129423b3eb3cSopenharmony_ci container->SetResourceConfiguration(aceResCfg); 129523b3eb3cSopenharmony_ci container->SetPackagePathStr(resPath); 129623b3eb3cSopenharmony_ci container->SetHapPath(hapPath); 129723b3eb3cSopenharmony_ci container->SetAssetManager(assetManagerImpl); 129823b3eb3cSopenharmony_ci 129923b3eb3cSopenharmony_ci if (!isFormRender_) { 130023b3eb3cSopenharmony_ci container->SetBundlePath(context->GetBundleCodeDir()); 130123b3eb3cSopenharmony_ci container->SetFilesDataPath(context->GetFilesDir()); 130223b3eb3cSopenharmony_ci } 130323b3eb3cSopenharmony_ci 130423b3eb3cSopenharmony_ci if (window_) { 130523b3eb3cSopenharmony_ci if (window_->IsDecorEnable()) { 130623b3eb3cSopenharmony_ci container->SetWindowModal(WindowModal::CONTAINER_MODAL); 130723b3eb3cSopenharmony_ci } 130823b3eb3cSopenharmony_ci 130923b3eb3cSopenharmony_ci dragWindowListener_ = new DragWindowListener(instanceId_); 131023b3eb3cSopenharmony_ci window_->RegisterDragListener(dragWindowListener_); 131123b3eb3cSopenharmony_ci occupiedAreaChangeListener_ = new OccupiedAreaChangeListener(instanceId_); 131223b3eb3cSopenharmony_ci window_->RegisterOccupiedAreaChangeListener(occupiedAreaChangeListener_); 131323b3eb3cSopenharmony_ci } 131423b3eb3cSopenharmony_ci 131523b3eb3cSopenharmony_ci // create ace_view 131623b3eb3cSopenharmony_ci RefPtr<Platform::AceViewOhos> aceView = nullptr; 131723b3eb3cSopenharmony_ci if (isFormRender_ && !isDynamicRender_) { 131823b3eb3cSopenharmony_ci aceView = Platform::AceViewOhos::CreateView(instanceId_, true, container->GetSettings().usePlatformAsUIThread); 131923b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfaceCreated(aceView, window_); 132023b3eb3cSopenharmony_ci } else { 132123b3eb3cSopenharmony_ci aceView = Platform::AceViewOhos::CreateView(instanceId_, false, container->GetSettings().usePlatformAsUIThread); 132223b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfaceCreated(aceView, window_); 132323b3eb3cSopenharmony_ci } 132423b3eb3cSopenharmony_ci 132523b3eb3cSopenharmony_ci if (isFormRender_) { 132623b3eb3cSopenharmony_ci errorCode = Platform::AceContainer::SetViewNew(aceView, density, round(formWidth_), 132723b3eb3cSopenharmony_ci round(formHeight_), window_); 132823b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 132923b3eb3cSopenharmony_ci auto frontend = AceType::DynamicCast<FormFrontendDeclarative>(container->GetFrontend()); 133023b3eb3cSopenharmony_ci CHECK_NULL_RETURN(frontend, UIContentErrorCode::NULL_POINTER); 133123b3eb3cSopenharmony_ci frontend->SetBundleName(bundleName_); 133223b3eb3cSopenharmony_ci frontend->SetModuleName(moduleName_); 133323b3eb3cSopenharmony_ci // arkTSCard only support "esModule" compile mode 133423b3eb3cSopenharmony_ci frontend->SetIsBundle(false); 133523b3eb3cSopenharmony_ci container->SetBundleName(bundleName_); 133623b3eb3cSopenharmony_ci } else { 133723b3eb3cSopenharmony_ci errorCode = Platform::AceContainer::SetViewNew(aceView, density, 0, 0, window_); 133823b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 133923b3eb3cSopenharmony_ci } 134023b3eb3cSopenharmony_ci 134123b3eb3cSopenharmony_ci // after frontend initialize 134223b3eb3cSopenharmony_ci if (window_ && window_->IsFocused()) { 134323b3eb3cSopenharmony_ci Focus(); 134423b3eb3cSopenharmony_ci } 134523b3eb3cSopenharmony_ci 134623b3eb3cSopenharmony_ci if (isFormRender_ && !isFormRenderInit_) { 134723b3eb3cSopenharmony_ci container->UpdateFormSharedImage(formImageDataMap_); 134823b3eb3cSopenharmony_ci container->UpdateFormData(formData_); 134923b3eb3cSopenharmony_ci isFormRenderInit_ = true; 135023b3eb3cSopenharmony_ci } 135123b3eb3cSopenharmony_ci 135223b3eb3cSopenharmony_ci if (isFormRender_) { 135323b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfaceChanged(aceView, round(formWidth_), round(formHeight_), 135423b3eb3cSopenharmony_ci deviceHeight >= deviceWidth ? 0 : 1); 135523b3eb3cSopenharmony_ci container->CheckAndSetFontFamily(); 135623b3eb3cSopenharmony_ci SetFontScaleAndWeightScale(container, instanceId_); 135723b3eb3cSopenharmony_ci // Set sdk version in module json mode for form 135823b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 135923b3eb3cSopenharmony_ci if (pipeline && appInfo) { 136023b3eb3cSopenharmony_ci pipeline->SetMinPlatformVersion(appInfo->apiCompatibleVersion); 136123b3eb3cSopenharmony_ci } 136223b3eb3cSopenharmony_ci } else { 136323b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfaceChanged(aceView, 0, 0, deviceHeight >= deviceWidth ? 0 : 1); 136423b3eb3cSopenharmony_ci } 136523b3eb3cSopenharmony_ci // Set sdk version in module json mode 136623b3eb3cSopenharmony_ci if (isModelJson) { 136723b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 136823b3eb3cSopenharmony_ci if (pipeline && appInfo) { 136923b3eb3cSopenharmony_ci pipeline->SetMinPlatformVersion(appInfo->apiCompatibleVersion); 137023b3eb3cSopenharmony_ci } 137123b3eb3cSopenharmony_ci } 137223b3eb3cSopenharmony_ci if (runtime_ && !isFormRender_) { // ArkTSCard not support inherit local strorage from context 137323b3eb3cSopenharmony_ci auto nativeEngine = reinterpret_cast<NativeEngine*>(runtime_); 137423b3eb3cSopenharmony_ci if (!storage) { 137523b3eb3cSopenharmony_ci container->SetLocalStorage(nullptr, context); 137623b3eb3cSopenharmony_ci } else { 137723b3eb3cSopenharmony_ci auto env = reinterpret_cast<napi_env>(nativeEngine); 137823b3eb3cSopenharmony_ci napi_ref ref = nullptr; 137923b3eb3cSopenharmony_ci napi_create_reference(env, storage, 1, &ref); 138023b3eb3cSopenharmony_ci container->SetLocalStorage( 138123b3eb3cSopenharmony_ci reinterpret_cast<NativeReference*>(ref), context); 138223b3eb3cSopenharmony_ci } 138323b3eb3cSopenharmony_ci } 138423b3eb3cSopenharmony_ci if (context) { 138523b3eb3cSopenharmony_ci UpdateFontScale(context->GetConfiguration()); 138623b3eb3cSopenharmony_ci } 138723b3eb3cSopenharmony_ci return UIContentErrorCode::NO_ERRORS; 138823b3eb3cSopenharmony_ci} 138923b3eb3cSopenharmony_ci 139023b3eb3cSopenharmony_civoid UIContentImpl::UpdateFontScale(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) 139123b3eb3cSopenharmony_ci{ 139223b3eb3cSopenharmony_ci CHECK_NULL_VOID(config); 139323b3eb3cSopenharmony_ci auto maxAppFontScale = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::APP_FONT_MAX_SCALE); 139423b3eb3cSopenharmony_ci auto followSystem = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::APP_FONT_SIZE_SCALE); 139523b3eb3cSopenharmony_ci auto context = NG::PipelineContext::GetContextByContainerId(instanceId_); 139623b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 139723b3eb3cSopenharmony_ci auto isFollowSystem = followSystem == "followSystem"; 139823b3eb3cSopenharmony_ci if (!followSystem.empty()) { 139923b3eb3cSopenharmony_ci context->SetFollowSystem(isFollowSystem); 140023b3eb3cSopenharmony_ci } 140123b3eb3cSopenharmony_ci if (!maxAppFontScale.empty()) { 140223b3eb3cSopenharmony_ci context->SetMaxAppFontScale(StringUtils::StringToFloat(maxAppFontScale)); 140323b3eb3cSopenharmony_ci } 140423b3eb3cSopenharmony_ci if (!isFollowSystem) { 140523b3eb3cSopenharmony_ci context->SetFontScale(1.0f); 140623b3eb3cSopenharmony_ci } 140723b3eb3cSopenharmony_ci 140823b3eb3cSopenharmony_ci auto fontScale = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_FONT_SIZE_SCALE); 140923b3eb3cSopenharmony_ci if (!fontScale.empty()) { 141023b3eb3cSopenharmony_ci context->SetFontScale(StringUtils::StringToFloat(fontScale)); 141123b3eb3cSopenharmony_ci } 141223b3eb3cSopenharmony_ci} 141323b3eb3cSopenharmony_ci 141423b3eb3cSopenharmony_civoid UIContentImpl::SetConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) 141523b3eb3cSopenharmony_ci{ 141623b3eb3cSopenharmony_ci if (config == nullptr) { 141723b3eb3cSopenharmony_ci UErrorCode status = U_ZERO_ERROR; 141823b3eb3cSopenharmony_ci icu::Locale locale = icu::Locale::forLanguageTag(Global::I18n::LocaleConfig::GetSystemLanguage(), status); 141923b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetLocale(locale.getLanguage(), locale.getCountry(), locale.getScript(), ""); 142023b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::LIGHT); 142123b3eb3cSopenharmony_ci return; 142223b3eb3cSopenharmony_ci } 142323b3eb3cSopenharmony_ci 142423b3eb3cSopenharmony_ci auto deviceAccess = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE); 142523b3eb3cSopenharmony_ci auto languageTag = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); 142623b3eb3cSopenharmony_ci 142723b3eb3cSopenharmony_ci if (!deviceAccess.empty()) { 142823b3eb3cSopenharmony_ci // Event of accessing mouse or keyboard 142923b3eb3cSopenharmony_ci SystemProperties::SetDeviceAccess(deviceAccess == "true"); 143023b3eb3cSopenharmony_ci } 143123b3eb3cSopenharmony_ci 143223b3eb3cSopenharmony_ci if (!languageTag.empty()) { 143323b3eb3cSopenharmony_ci std::string language; 143423b3eb3cSopenharmony_ci std::string script; 143523b3eb3cSopenharmony_ci std::string region; 143623b3eb3cSopenharmony_ci Localization::ParseLocaleTag(languageTag, language, script, region, false); 143723b3eb3cSopenharmony_ci if (!language.empty() || !script.empty() || !region.empty()) { 143823b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetLocale(language, region, script, ""); 143923b3eb3cSopenharmony_ci } 144023b3eb3cSopenharmony_ci } 144123b3eb3cSopenharmony_ci StoreConfiguration(config); 144223b3eb3cSopenharmony_ci} 144323b3eb3cSopenharmony_ci 144423b3eb3cSopenharmony_civoid UIContentImpl::StoreConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) 144523b3eb3cSopenharmony_ci{ 144623b3eb3cSopenharmony_ci if (!config) { 144723b3eb3cSopenharmony_ci return; 144823b3eb3cSopenharmony_ci } 144923b3eb3cSopenharmony_ci TAG_LOGD(AceLogTag::ACE_WINDOW, "StoreConfiguration %{public}s", config->GetName().c_str()); 145023b3eb3cSopenharmony_ci auto colorMode = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); 145123b3eb3cSopenharmony_ci if (!colorMode.empty()) { 145223b3eb3cSopenharmony_ci if (colorMode == "dark") { 145323b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::DARK); 145423b3eb3cSopenharmony_ci } else { 145523b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::LIGHT); 145623b3eb3cSopenharmony_ci } 145723b3eb3cSopenharmony_ci } 145823b3eb3cSopenharmony_ci 145923b3eb3cSopenharmony_ci auto string2float = [](const std::string& str) { 146023b3eb3cSopenharmony_ci return std::stof(str); 146123b3eb3cSopenharmony_ci }; 146223b3eb3cSopenharmony_ci auto fontScale = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_FONT_SIZE_SCALE); 146323b3eb3cSopenharmony_ci if (!fontScale.empty()) { 146423b3eb3cSopenharmony_ci SystemProperties::SetFontScale(string2float(fontScale)); 146523b3eb3cSopenharmony_ci } 146623b3eb3cSopenharmony_ci auto fontWeightScale = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_FONT_WEIGHT_SCALE); 146723b3eb3cSopenharmony_ci if (!fontWeightScale.empty()) { 146823b3eb3cSopenharmony_ci SystemProperties::SetFontWeightScale(string2float(fontWeightScale)); 146923b3eb3cSopenharmony_ci } 147023b3eb3cSopenharmony_ci} 147123b3eb3cSopenharmony_ci 147223b3eb3cSopenharmony_cistd::shared_ptr<Rosen::RSSurfaceNode> UIContentImpl::GetFormRootNode() 147323b3eb3cSopenharmony_ci{ 147423b3eb3cSopenharmony_ci return Platform::AceContainer::GetFormSurfaceNode(instanceId_); 147523b3eb3cSopenharmony_ci} 147623b3eb3cSopenharmony_ci// ArkTSCard end 147723b3eb3cSopenharmony_ci 147823b3eb3cSopenharmony_civoid UIContentImpl::SetFontScaleAndWeightScale(const RefPtr<Platform::AceContainer>& container, int32_t instanceId) 147923b3eb3cSopenharmony_ci{ 148023b3eb3cSopenharmony_ci float fontScale = SystemProperties::GetFontScale(); 148123b3eb3cSopenharmony_ci if (isFormRender_ && !fontScaleFollowSystem_) { 148223b3eb3cSopenharmony_ci TAG_LOGW(AceLogTag::ACE_FORM, "setFontScale form default size"); 148323b3eb3cSopenharmony_ci fontScale = 1.0f; 148423b3eb3cSopenharmony_ci } 148523b3eb3cSopenharmony_ci float fontWeightScale = SystemProperties::GetFontWeightScale(); 148623b3eb3cSopenharmony_ci container->SetFontScale(instanceId, fontScale); 148723b3eb3cSopenharmony_ci container->SetFontWeightScale(instanceId, fontWeightScale); 148823b3eb3cSopenharmony_ci} 148923b3eb3cSopenharmony_ci 149023b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::CommonInitialize( 149123b3eb3cSopenharmony_ci OHOS::Rosen::Window* window, const std::string& contentInfo, napi_value storage, uint32_t focusWindowId) 149223b3eb3cSopenharmony_ci{ 149323b3eb3cSopenharmony_ci auto errorCode = UIContentErrorCode::NO_ERRORS; 149423b3eb3cSopenharmony_ci window_ = window; 149523b3eb3cSopenharmony_ci CHECK_NULL_RETURN(window_, UIContentErrorCode::NULL_WINDOW); 149623b3eb3cSopenharmony_ci auto windowName = window->GetWindowName(); 149723b3eb3cSopenharmony_ci ACE_SCOPED_TRACE_COMMERCIAL("UI Initialize:%s", windowName.c_str()); 149823b3eb3cSopenharmony_ci startUrl_ = contentInfo; 149923b3eb3cSopenharmony_ci if (StringUtils::StartWith(windowName, SUBWINDOW_TOAST_DIALOG_PREFIX)) { 150023b3eb3cSopenharmony_ci InitializeSubWindow(window_, true); 150123b3eb3cSopenharmony_ci return errorCode; 150223b3eb3cSopenharmony_ci } 150323b3eb3cSopenharmony_ci if (StringUtils::StartWith(windowName, SUBWINDOW_PREFIX)) { 150423b3eb3cSopenharmony_ci InitializeSubWindow(window_); 150523b3eb3cSopenharmony_ci return errorCode; 150623b3eb3cSopenharmony_ci } 150723b3eb3cSopenharmony_ci auto context = context_.lock(); 150823b3eb3cSopenharmony_ci CHECK_NULL_RETURN(context, UIContentErrorCode::NULL_POINTER); 150923b3eb3cSopenharmony_ci static std::once_flag onceFlag; 151023b3eb3cSopenharmony_ci std::call_once(onceFlag, [&context]() { 151123b3eb3cSopenharmony_ci SetHwIcuDirectory(); 151223b3eb3cSopenharmony_ci Container::UpdateCurrent(INSTANCE_ID_PLATFORM); 151323b3eb3cSopenharmony_ci auto abilityContext = OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::AbilityContext>(context); 151423b3eb3cSopenharmony_ci if (abilityContext) { 151523b3eb3cSopenharmony_ci int32_t missionId = -1; 151623b3eb3cSopenharmony_ci abilityContext->GetMissionId(missionId); 151723b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetMissionId(missionId); 151823b3eb3cSopenharmony_ci } 151923b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetProcessName(context->GetBundleName()); 152023b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetPackageName(context->GetBundleName()); 152123b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetDataFileDirPath(context->GetFilesDir()); 152223b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetApiTargetVersion(context->GetApplicationInfo()->apiTargetVersion); 152323b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetAppVersionName(context->GetApplicationInfo()->versionName); 152423b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetAppVersionCode(context->GetApplicationInfo()->versionCode); 152523b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetUid(IPCSkeleton::GetCallingUid()); 152623b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetPid(IPCSkeleton::GetCallingRealPid()); 152723b3eb3cSopenharmony_ci CapabilityRegistry::Register(); 152823b3eb3cSopenharmony_ci ImageFileCache::GetInstance().SetImageCacheFilePath(context->GetCacheDir()); 152923b3eb3cSopenharmony_ci ImageFileCache::GetInstance().SetCacheFileInfo(); 153023b3eb3cSopenharmony_ci XcollieInterface::GetInstance().SetTimerCount("HIT_EMPTY_WARNING", TIMEOUT_LIMIT, COUNT_LIMIT); 153123b3eb3cSopenharmony_ci }); 153223b3eb3cSopenharmony_ci AceNewPipeJudgement::InitAceNewPipeConfig(); 153323b3eb3cSopenharmony_ci auto apiCompatibleVersion = context->GetApplicationInfo()->apiCompatibleVersion; 153423b3eb3cSopenharmony_ci auto apiReleaseType = context->GetApplicationInfo()->apiReleaseType; 153523b3eb3cSopenharmony_ci auto apiTargetVersion = context->GetApplicationInfo()->apiTargetVersion; 153623b3eb3cSopenharmony_ci const auto& hapModuleInfo = context->GetHapModuleInfo(); 153723b3eb3cSopenharmony_ci std::vector<OHOS::AppExecFwk::Metadata> metaData; 153823b3eb3cSopenharmony_ci if (hapModuleInfo) { 153923b3eb3cSopenharmony_ci metaData = hapModuleInfo->metadata; 154023b3eb3cSopenharmony_ci } 154123b3eb3cSopenharmony_ci bool closeArkTSPartialUpdate = std::any_of(metaData.begin(), metaData.end(), [](const auto& metaDataItem) { 154223b3eb3cSopenharmony_ci return metaDataItem.name == "ArkTSPartialUpdate" && metaDataItem.value == "false"; 154323b3eb3cSopenharmony_ci }); 154423b3eb3cSopenharmony_ci 154523b3eb3cSopenharmony_ci auto useNewPipe = 154623b3eb3cSopenharmony_ci AceNewPipeJudgement::QueryAceNewPipeEnabledStage(AceApplicationInfo::GetInstance().GetPackageName(), 154723b3eb3cSopenharmony_ci apiCompatibleVersion, apiTargetVersion, apiReleaseType, closeArkTSPartialUpdate); 154823b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetIsUseNewPipeline(useNewPipe); 154923b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: UIContent: apiCompatibleVersion: %{public}d, apiTargetVersion: " 155023b3eb3cSopenharmony_ci "%{public}d, and apiReleaseType: %{public}s, " 155123b3eb3cSopenharmony_ci "useNewPipe: %{public}d", 155223b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, apiCompatibleVersion, apiTargetVersion, 155323b3eb3cSopenharmony_ci apiReleaseType.c_str(), useNewPipe); 155423b3eb3cSopenharmony_ci#ifndef NG_BUILD 155523b3eb3cSopenharmony_ci#ifdef ENABLE_ROSEN_BACKEND 155623b3eb3cSopenharmony_ci std::shared_ptr<OHOS::Rosen::RSUIDirector> rsUiDirector; 155723b3eb3cSopenharmony_ci if (SystemProperties::GetRosenBackendEnabled() && !useNewPipe) { 155823b3eb3cSopenharmony_ci rsUiDirector = OHOS::Rosen::RSUIDirector::Create(); 155923b3eb3cSopenharmony_ci if (rsUiDirector) { 156023b3eb3cSopenharmony_ci rsUiDirector->SetRSSurfaceNode(window->GetSurfaceNode()); 156123b3eb3cSopenharmony_ci rsUiDirector->SetCacheDir(context->GetCacheDir()); 156223b3eb3cSopenharmony_ci rsUiDirector->Init(); 156323b3eb3cSopenharmony_ci } 156423b3eb3cSopenharmony_ci } 156523b3eb3cSopenharmony_ci#endif 156623b3eb3cSopenharmony_ci#endif 156723b3eb3cSopenharmony_ci int32_t deviceWidth = 0; 156823b3eb3cSopenharmony_ci int32_t deviceHeight = 0; 156923b3eb3cSopenharmony_ci float density = 1.0f; 157023b3eb3cSopenharmony_ci float defaultDensity = 1.0f; 157123b3eb3cSopenharmony_ci int32_t devicePhysicalWidth = 0; 157223b3eb3cSopenharmony_ci int32_t devicePhysicalHeight = 0; 157323b3eb3cSopenharmony_ci 157423b3eb3cSopenharmony_ci bool isSceneBoardWindow = window_->GetType() == Rosen::WindowType::WINDOW_TYPE_SCENE_BOARD; 157523b3eb3cSopenharmony_ci if (isSceneBoardWindow) { 157623b3eb3cSopenharmony_ci auto screenProperties = Rosen::ScreenSessionManagerClient::GetInstance().GetAllScreensProperties(); 157723b3eb3cSopenharmony_ci if (!screenProperties.empty()) { 157823b3eb3cSopenharmony_ci auto iter = screenProperties.begin(); 157923b3eb3cSopenharmony_ci defaultDensity = iter->second.GetDefaultDensity(); 158023b3eb3cSopenharmony_ci } 158123b3eb3cSopenharmony_ci } 158223b3eb3cSopenharmony_ci 158323b3eb3cSopenharmony_ci auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay(); 158423b3eb3cSopenharmony_ci if (defaultDisplay) { 158523b3eb3cSopenharmony_ci density = defaultDisplay->GetVirtualPixelRatio(); 158623b3eb3cSopenharmony_ci if (isSceneBoardWindow && !NearEqual(defaultDensity, 1.0f)) { 158723b3eb3cSopenharmony_ci density = defaultDensity; 158823b3eb3cSopenharmony_ci } 158923b3eb3cSopenharmony_ci deviceWidth = defaultDisplay->GetWidth(); 159023b3eb3cSopenharmony_ci deviceHeight = defaultDisplay->GetHeight(); 159123b3eb3cSopenharmony_ci devicePhysicalWidth = defaultDisplay->GetPhysicalWidth(); 159223b3eb3cSopenharmony_ci devicePhysicalHeight = defaultDisplay->GetPhysicalHeight(); 159323b3eb3cSopenharmony_ci } 159423b3eb3cSopenharmony_ci SystemProperties::InitDeviceInfo(deviceWidth, deviceHeight, deviceHeight >= deviceWidth ? 0 : 1, density, false); 159523b3eb3cSopenharmony_ci SystemProperties::SetDevicePhysicalWidth(devicePhysicalWidth); 159623b3eb3cSopenharmony_ci SystemProperties::SetDevicePhysicalHeight(devicePhysicalHeight); 159723b3eb3cSopenharmony_ci // Initialize performance check parameters 159823b3eb3cSopenharmony_ci AceChecker::InitPerformanceParameters(); 159923b3eb3cSopenharmony_ci AcePerformanceCheck::Start(); 160023b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::LIGHT); 160123b3eb3cSopenharmony_ci 160223b3eb3cSopenharmony_ci std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig()); 160323b3eb3cSopenharmony_ci auto resourceManager = context->GetResourceManager(); 160423b3eb3cSopenharmony_ci if (resourceManager != nullptr) { 160523b3eb3cSopenharmony_ci resourceManager->GetResConfig(*resConfig); 160623b3eb3cSopenharmony_ci auto localeInfo = resConfig->GetLocaleInfo(); 160723b3eb3cSopenharmony_ci Platform::AceApplicationInfoImpl::GetInstance().SetResourceManager(resourceManager); 160823b3eb3cSopenharmony_ci if (localeInfo != nullptr) { 160923b3eb3cSopenharmony_ci auto language = localeInfo->getLanguage(); 161023b3eb3cSopenharmony_ci auto region = localeInfo->getCountry(); 161123b3eb3cSopenharmony_ci auto script = localeInfo->getScript(); 161223b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetLocale((language == nullptr) ? "" : language, 161323b3eb3cSopenharmony_ci (region == nullptr) ? "" : region, (script == nullptr) ? "" : script, ""); 161423b3eb3cSopenharmony_ci } 161523b3eb3cSopenharmony_ci if (resConfig->GetColorMode() == OHOS::Global::Resource::ColorMode::DARK) { 161623b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::DARK); 161723b3eb3cSopenharmony_ci } else { 161823b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::LIGHT); 161923b3eb3cSopenharmony_ci } 162023b3eb3cSopenharmony_ci SystemProperties::SetDeviceAccess( 162123b3eb3cSopenharmony_ci resConfig->GetInputDevice() == Global::Resource::InputDevice::INPUTDEVICE_POINTINGDEVICE); 162223b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: SetLanguage: %{public}s, colorMode: %{public}s, " 162323b3eb3cSopenharmony_ci "deviceAccess: %{public}d", 162423b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, 162523b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().GetLanguage().c_str(), 162623b3eb3cSopenharmony_ci SystemProperties::GetColorMode() == ColorMode::DARK ? "dark" : "light", 162723b3eb3cSopenharmony_ci SystemProperties::GetDeviceAccess()); 162823b3eb3cSopenharmony_ci } 162923b3eb3cSopenharmony_ci 163023b3eb3cSopenharmony_ci auto abilityContext = OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::AbilityContext>(context); 163123b3eb3cSopenharmony_ci std::shared_ptr<OHOS::AppExecFwk::AbilityInfo> info; 163223b3eb3cSopenharmony_ci if (abilityContext) { 163323b3eb3cSopenharmony_ci info = abilityContext->GetAbilityInfo(); 163423b3eb3cSopenharmony_ci } else { 163523b3eb3cSopenharmony_ci auto extensionContext = 163623b3eb3cSopenharmony_ci OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::ExtensionContext>(context); 163723b3eb3cSopenharmony_ci if (!extensionContext) { 163823b3eb3cSopenharmony_ci return UIContentErrorCode::NULL_POINTER; 163923b3eb3cSopenharmony_ci } 164023b3eb3cSopenharmony_ci info = extensionContext->GetAbilityInfo(); 164123b3eb3cSopenharmony_ci } 164223b3eb3cSopenharmony_ci if (info) { 164323b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetAbilityName(info->name); 164423b3eb3cSopenharmony_ci } 164523b3eb3cSopenharmony_ci RefPtr<AssetManagerImpl> assetManagerImpl = Referenced::MakeRefPtr<AssetManagerImpl>(); 164623b3eb3cSopenharmony_ci bool isModelJson = info != nullptr ? info->isModuleJson : false; 164723b3eb3cSopenharmony_ci std::string moduleName = info != nullptr ? info->moduleName : ""; 164823b3eb3cSopenharmony_ci auto appInfo = context->GetApplicationInfo(); 164923b3eb3cSopenharmony_ci auto bundleName = info != nullptr ? info->bundleName : ""; 165023b3eb3cSopenharmony_ci auto abilityName = info != nullptr ? info->name : ""; 165123b3eb3cSopenharmony_ci std::string moduleHapPath = info != nullptr ? info->hapPath : ""; 165223b3eb3cSopenharmony_ci std::string resPath; 165323b3eb3cSopenharmony_ci std::string pageProfile; 165423b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: Initialize UIContent isModelJson:%{public}s", bundleName_.c_str(), 165523b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_, isModelJson ? "true" : "false"); 165623b3eb3cSopenharmony_ci if (isModelJson) { 165723b3eb3cSopenharmony_ci std::string hapPath = info != nullptr ? info->hapPath : ""; 165823b3eb3cSopenharmony_ci // first use hap provider 165923b3eb3cSopenharmony_ci if (assetManagerImpl && !hapPath.empty()) { 166023b3eb3cSopenharmony_ci auto hapAssetProvider = AceType::MakeRefPtr<HapAssetProviderImpl>(); 166123b3eb3cSopenharmony_ci if (hapAssetProvider->Initialize(hapPath, { "", "ets/", "resources/base/profile/" })) { 166223b3eb3cSopenharmony_ci assetManagerImpl->PushBack(std::move(hapAssetProvider)); 166323b3eb3cSopenharmony_ci } 166423b3eb3cSopenharmony_ci } 166523b3eb3cSopenharmony_ci 166623b3eb3cSopenharmony_ci if (appInfo) { 166723b3eb3cSopenharmony_ci std::vector<OHOS::AppExecFwk::ModuleInfo> moduleList = appInfo->moduleInfos; 166823b3eb3cSopenharmony_ci for (const auto& module : moduleList) { 166923b3eb3cSopenharmony_ci if (module.moduleName == moduleName) { 167023b3eb3cSopenharmony_ci std::regex pattern(ABS_BUNDLE_CODE_PATH + bundleName + FILE_SEPARATOR); 167123b3eb3cSopenharmony_ci auto moduleSourceDir = std::regex_replace(module.moduleSourceDir, pattern, LOCAL_BUNDLE_CODE_PATH); 167223b3eb3cSopenharmony_ci resPath = moduleSourceDir + "/"; 167323b3eb3cSopenharmony_ci break; 167423b3eb3cSopenharmony_ci } 167523b3eb3cSopenharmony_ci } 167623b3eb3cSopenharmony_ci } 167723b3eb3cSopenharmony_ci 167823b3eb3cSopenharmony_ci // second use file provider, will remove later 167923b3eb3cSopenharmony_ci auto assetBasePathStr = { std::string("ets/"), std::string("resources/base/profile/") }; 168023b3eb3cSopenharmony_ci if (assetManagerImpl && !resPath.empty()) { 168123b3eb3cSopenharmony_ci auto fileAssetProvider = AceType::MakeRefPtr<FileAssetProviderImpl>(); 168223b3eb3cSopenharmony_ci if (fileAssetProvider->Initialize(resPath, assetBasePathStr)) { 168323b3eb3cSopenharmony_ci assetManagerImpl->PushBack(std::move(fileAssetProvider)); 168423b3eb3cSopenharmony_ci } 168523b3eb3cSopenharmony_ci } 168623b3eb3cSopenharmony_ci 168723b3eb3cSopenharmony_ci if (hapModuleInfo) { 168823b3eb3cSopenharmony_ci pageProfile = hapModuleInfo->pages; 168923b3eb3cSopenharmony_ci const std::string profilePrefix = "$profile:"; 169023b3eb3cSopenharmony_ci if (pageProfile.compare(0, profilePrefix.size(), profilePrefix) == 0) { 169123b3eb3cSopenharmony_ci pageProfile = pageProfile.substr(profilePrefix.length()).append(".json"); 169223b3eb3cSopenharmony_ci } 169323b3eb3cSopenharmony_ci } 169423b3eb3cSopenharmony_ci } else { 169523b3eb3cSopenharmony_ci auto packagePathStr = context->GetBundleCodeDir(); 169623b3eb3cSopenharmony_ci if (hapModuleInfo != nullptr) { 169723b3eb3cSopenharmony_ci packagePathStr += "/" + hapModuleInfo->package + "/"; 169823b3eb3cSopenharmony_ci } 169923b3eb3cSopenharmony_ci std::string srcPath = ""; 170023b3eb3cSopenharmony_ci if (info != nullptr && !info->srcPath.empty()) { 170123b3eb3cSopenharmony_ci srcPath = info->srcPath; 170223b3eb3cSopenharmony_ci } 170323b3eb3cSopenharmony_ci 170423b3eb3cSopenharmony_ci auto assetBasePathStr = { "assets/js/" + (srcPath.empty() ? "default" : srcPath) + "/", 170523b3eb3cSopenharmony_ci std::string("assets/js/share/") }; 170623b3eb3cSopenharmony_ci 170723b3eb3cSopenharmony_ci if (assetManagerImpl && !packagePathStr.empty()) { 170823b3eb3cSopenharmony_ci auto fileAssetProvider = AceType::MakeRefPtr<FileAssetProviderImpl>(); 170923b3eb3cSopenharmony_ci if (fileAssetProvider->Initialize(packagePathStr, assetBasePathStr)) { 171023b3eb3cSopenharmony_ci assetManagerImpl->PushBack(std::move(fileAssetProvider)); 171123b3eb3cSopenharmony_ci } 171223b3eb3cSopenharmony_ci } 171323b3eb3cSopenharmony_ci if (appInfo) { 171423b3eb3cSopenharmony_ci std::vector<OHOS::AppExecFwk::ModuleInfo> moduleList = appInfo->moduleInfos; 171523b3eb3cSopenharmony_ci for (const auto& module : moduleList) { 171623b3eb3cSopenharmony_ci if (module.moduleName == moduleName) { 171723b3eb3cSopenharmony_ci std::regex pattern(ABS_BUNDLE_CODE_PATH + bundleName + FILE_SEPARATOR); 171823b3eb3cSopenharmony_ci auto moduleSourceDir = std::regex_replace(module.moduleSourceDir, pattern, LOCAL_BUNDLE_CODE_PATH); 171923b3eb3cSopenharmony_ci resPath = moduleSourceDir + "/assets/" + module.moduleName + "/"; 172023b3eb3cSopenharmony_ci break; 172123b3eb3cSopenharmony_ci } 172223b3eb3cSopenharmony_ci } 172323b3eb3cSopenharmony_ci } 172423b3eb3cSopenharmony_ci } 172523b3eb3cSopenharmony_ci 172623b3eb3cSopenharmony_ci std::string hapPath; // hap path in sandbox 172723b3eb3cSopenharmony_ci if (!moduleHapPath.empty()) { 172823b3eb3cSopenharmony_ci if (moduleHapPath.find(ABS_BUNDLE_CODE_PATH) == std::string::npos) { 172923b3eb3cSopenharmony_ci hapPath = moduleHapPath; 173023b3eb3cSopenharmony_ci } else { 173123b3eb3cSopenharmony_ci auto pos = moduleHapPath.find_last_of('/'); 173223b3eb3cSopenharmony_ci if (pos != std::string::npos) { 173323b3eb3cSopenharmony_ci hapPath = LOCAL_BUNDLE_CODE_PATH + moduleHapPath.substr(pos + 1); 173423b3eb3cSopenharmony_ci } 173523b3eb3cSopenharmony_ci } 173623b3eb3cSopenharmony_ci } 173723b3eb3cSopenharmony_ci 173823b3eb3cSopenharmony_ci#ifdef PLUGIN_COMPONENT_SUPPORTED 173923b3eb3cSopenharmony_ci auto pluginUtils = std::make_shared<PluginUtilsImpl>(); 174023b3eb3cSopenharmony_ci PluginManager::GetInstance().SetAceAbility(nullptr, pluginUtils); 174123b3eb3cSopenharmony_ci#endif 174223b3eb3cSopenharmony_ci // create container 174323b3eb3cSopenharmony_ci auto isCJFrontend = CJUtils::IsCJFrontendContext(context.get()); 174423b3eb3cSopenharmony_ci if (runtime_ || isCJFrontend) { 174523b3eb3cSopenharmony_ci instanceId_ = Container::GenerateId<STAGE_CONTAINER>(); 174623b3eb3cSopenharmony_ci } else { 174723b3eb3cSopenharmony_ci instanceId_ = Container::GenerateId<FA_SUBWINDOW_CONTAINER>(); 174823b3eb3cSopenharmony_ci } 174923b3eb3cSopenharmony_ci#ifdef FORM_SUPPORTED 175023b3eb3cSopenharmony_ci auto formUtils = std::make_shared<FormUtilsImpl>(); 175123b3eb3cSopenharmony_ci FormManager::GetInstance().SetFormUtils(formUtils); 175223b3eb3cSopenharmony_ci#endif 175323b3eb3cSopenharmony_ci#ifdef APS_ENABLE 175423b3eb3cSopenharmony_ci auto apsMonitor = std::make_shared<ApsMonitorImpl>(); 175523b3eb3cSopenharmony_ci PerfMonitor::GetPerfMonitor()->SetApsMonitor(apsMonitor); 175623b3eb3cSopenharmony_ci#endif 175723b3eb3cSopenharmony_ci auto frontendType = isCJFrontend? FrontendType::DECLARATIVE_CJ : FrontendType::DECLARATIVE_JS; 175823b3eb3cSopenharmony_ci auto container = 175923b3eb3cSopenharmony_ci AceType::MakeRefPtr<Platform::AceContainer>(instanceId_, frontendType, context_, info, 176023b3eb3cSopenharmony_ci std::make_unique<ContentEventCallback>( 176123b3eb3cSopenharmony_ci [window = window_] { 176223b3eb3cSopenharmony_ci CHECK_NULL_VOID(window); 176323b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_ROUTER, "router back to window"); 176423b3eb3cSopenharmony_ci window->PerformBack(); 176523b3eb3cSopenharmony_ci }, 176623b3eb3cSopenharmony_ci [context = context_](const std::string& address) { 176723b3eb3cSopenharmony_ci auto sharedContext = context.lock(); 176823b3eb3cSopenharmony_ci CHECK_NULL_VOID(sharedContext); 176923b3eb3cSopenharmony_ci auto abilityContext = 177023b3eb3cSopenharmony_ci OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::AbilityContext>(sharedContext); 177123b3eb3cSopenharmony_ci CHECK_NULL_VOID(abilityContext); 177223b3eb3cSopenharmony_ci LOGI("startAbility: %{private}s", address.c_str()); 177323b3eb3cSopenharmony_ci AAFwk::Want want; 177423b3eb3cSopenharmony_ci want.AddEntity(Want::ENTITY_BROWSER); 177523b3eb3cSopenharmony_ci want.SetUri(address); 177623b3eb3cSopenharmony_ci want.SetAction(ACTION_VIEWDATA); 177723b3eb3cSopenharmony_ci abilityContext->StartAbility(want, REQUEST_CODE); 177823b3eb3cSopenharmony_ci }), 177923b3eb3cSopenharmony_ci false, false, useNewPipe); 178023b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, UIContentErrorCode::NULL_POINTER); 178123b3eb3cSopenharmony_ci container->SetUIContentType(uIContentType_); 178223b3eb3cSopenharmony_ci container->SetWindowName(window_->GetWindowName()); 178323b3eb3cSopenharmony_ci container->SetWindowId(window_->GetWindowId()); 178423b3eb3cSopenharmony_ci auto token = context->GetToken(); 178523b3eb3cSopenharmony_ci container->SetToken(token); 178623b3eb3cSopenharmony_ci container->SetParentToken(parentToken_); 178723b3eb3cSopenharmony_ci if (!isCJFrontend) { 178823b3eb3cSopenharmony_ci container->SetPageUrlChecker(AceType::MakeRefPtr<PageUrlCheckerOhos>(context, info)); 178923b3eb3cSopenharmony_ci } 179023b3eb3cSopenharmony_ci container->SetNavigationRoute(AceType::MakeRefPtr<NavigationRouteOhos>(context->GetBundleName())); 179123b3eb3cSopenharmony_ci // Mark the relationship between windowId and containerId, it is 1:1 179223b3eb3cSopenharmony_ci SubwindowManager::GetInstance()->AddContainerId(window->GetWindowId(), instanceId_); 179323b3eb3cSopenharmony_ci AceEngine::Get().AddContainer(instanceId_, container); 179423b3eb3cSopenharmony_ci ContainerScope::Add(instanceId_); 179523b3eb3cSopenharmony_ci if (runtime_) { 179623b3eb3cSopenharmony_ci container->GetSettings().SetUsingSharedRuntime(true); 179723b3eb3cSopenharmony_ci container->SetSharedRuntime(runtime_); 179823b3eb3cSopenharmony_ci } else if (isCJFrontend) { 179923b3eb3cSopenharmony_ci container->GetSettings().SetUsingSharedRuntime(true); 180023b3eb3cSopenharmony_ci } else { 180123b3eb3cSopenharmony_ci container->GetSettings().SetUsingSharedRuntime(false); 180223b3eb3cSopenharmony_ci } 180323b3eb3cSopenharmony_ci container->SetPageProfile(pageProfile); 180423b3eb3cSopenharmony_ci container->Initialize(); 180523b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 180623b3eb3cSopenharmony_ci auto front = container->GetFrontend(); 180723b3eb3cSopenharmony_ci if (front) { 180823b3eb3cSopenharmony_ci front->UpdateState(Frontend::State::ON_CREATE); 180923b3eb3cSopenharmony_ci front->SetJsMessageDispatcher(container); 181023b3eb3cSopenharmony_ci } 181123b3eb3cSopenharmony_ci auto aceResCfg = container->GetResourceConfiguration(); 181223b3eb3cSopenharmony_ci aceResCfg.SetOrientation(SystemProperties::GetDeviceOrientation()); 181323b3eb3cSopenharmony_ci aceResCfg.SetDensity(SystemProperties::GetResolution()); 181423b3eb3cSopenharmony_ci aceResCfg.SetDeviceType(SystemProperties::GetDeviceType()); 181523b3eb3cSopenharmony_ci aceResCfg.SetColorMode(SystemProperties::GetColorMode()); 181623b3eb3cSopenharmony_ci aceResCfg.SetDeviceAccess(SystemProperties::GetDeviceAccess()); 181723b3eb3cSopenharmony_ci AddResConfigInfo(context, aceResCfg); 181823b3eb3cSopenharmony_ci AddSetAppColorModeToResConfig(context, aceResCfg); 181923b3eb3cSopenharmony_ci container->SetResourceConfiguration(aceResCfg); 182023b3eb3cSopenharmony_ci container->SetPackagePathStr(resPath); 182123b3eb3cSopenharmony_ci container->SetHapPath(hapPath); 182223b3eb3cSopenharmony_ci container->SetAssetManager(assetManagerImpl); 182323b3eb3cSopenharmony_ci 182423b3eb3cSopenharmony_ci container->SetBundlePath(context->GetBundleCodeDir()); 182523b3eb3cSopenharmony_ci container->SetFilesDataPath(context->GetFilesDir()); 182623b3eb3cSopenharmony_ci container->SetBundleName(hapModuleInfo->bundleName); 182723b3eb3cSopenharmony_ci container->SetModuleName(hapModuleInfo->moduleName); 182823b3eb3cSopenharmony_ci container->SetIsModule(hapModuleInfo->compileMode == AppExecFwk::CompileMode::ES_MODULE); 182923b3eb3cSopenharmony_ci container->SetApiTargetVersion(apiTargetVersion); 183023b3eb3cSopenharmony_ci 183123b3eb3cSopenharmony_ci // for atomic service 183223b3eb3cSopenharmony_ci container->SetInstallationFree(hapModuleInfo && hapModuleInfo->installationFree); 183323b3eb3cSopenharmony_ci if (hapModuleInfo->installationFree) { 183423b3eb3cSopenharmony_ci container->SetSharePanelCallback( 183523b3eb3cSopenharmony_ci [context = context_](const std::string& bundleName, const std::string& abilityName) { 183623b3eb3cSopenharmony_ci auto sharedContext = context.lock(); 183723b3eb3cSopenharmony_ci CHECK_NULL_VOID(sharedContext); 183823b3eb3cSopenharmony_ci auto abilityContext = 183923b3eb3cSopenharmony_ci OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::AbilityContext>(sharedContext); 184023b3eb3cSopenharmony_ci CHECK_NULL_VOID(abilityContext); 184123b3eb3cSopenharmony_ci auto abilityInfo = abilityContext->GetAbilityInfo(); 184223b3eb3cSopenharmony_ci AAFwk::Want want; 184323b3eb3cSopenharmony_ci want.SetParam("abilityName", abilityInfo->name); 184423b3eb3cSopenharmony_ci want.SetParam("bundleName", abilityInfo->bundleName); 184523b3eb3cSopenharmony_ci want.SetParam("moduleName", abilityInfo->moduleName); 184623b3eb3cSopenharmony_ci want.SetParam("hostPkgName", abilityInfo->bundleName); 184723b3eb3cSopenharmony_ci want.SetElementName(bundleName, abilityName); 184823b3eb3cSopenharmony_ci abilityContext->StartAbility(want, REQUEST_CODE); 184923b3eb3cSopenharmony_ci }); 185023b3eb3cSopenharmony_ci } 185123b3eb3cSopenharmony_ci 185223b3eb3cSopenharmony_ci if (window_->IsDecorEnable()) { 185323b3eb3cSopenharmony_ci container->SetWindowModal(WindowModal::CONTAINER_MODAL); 185423b3eb3cSopenharmony_ci } 185523b3eb3cSopenharmony_ci dragWindowListener_ = new DragWindowListener(instanceId_); 185623b3eb3cSopenharmony_ci window_->RegisterDragListener(dragWindowListener_); 185723b3eb3cSopenharmony_ci occupiedAreaChangeListener_ = new OccupiedAreaChangeListener(instanceId_); 185823b3eb3cSopenharmony_ci window_->RegisterOccupiedAreaChangeListener(occupiedAreaChangeListener_); 185923b3eb3cSopenharmony_ci foldStatusListener_ = new FoldScreenListener(instanceId_); 186023b3eb3cSopenharmony_ci OHOS::Rosen::DisplayManager::GetInstance().RegisterFoldStatusListener(foldStatusListener_); 186123b3eb3cSopenharmony_ci foldDisplayModeListener_ = new FoldDisplayModeListener(instanceId_); 186223b3eb3cSopenharmony_ci OHOS::Rosen::DisplayManager::GetInstance().RegisterDisplayModeListener(foldDisplayModeListener_); 186323b3eb3cSopenharmony_ci 186423b3eb3cSopenharmony_ci // create ace_view 186523b3eb3cSopenharmony_ci auto aceView = 186623b3eb3cSopenharmony_ci Platform::AceViewOhos::CreateView(instanceId_, false, container->GetSettings().usePlatformAsUIThread); 186723b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfaceCreated(aceView, window_); 186823b3eb3cSopenharmony_ci#ifndef NG_BUILD 186923b3eb3cSopenharmony_ci if (!useNewPipe) { 187023b3eb3cSopenharmony_ci Ace::Platform::UIEnvCallback callback = nullptr; 187123b3eb3cSopenharmony_ci#ifdef ENABLE_ROSEN_BACKEND 187223b3eb3cSopenharmony_ci callback = [id = instanceId_, container, rsUiDirector]( 187323b3eb3cSopenharmony_ci const OHOS::Ace::RefPtr<OHOS::Ace::PipelineContext>& context) { 187423b3eb3cSopenharmony_ci if (rsUiDirector) { 187523b3eb3cSopenharmony_ci ACE_SCOPED_TRACE("OHOS::Rosen::RSUIDirector::Create()"); 187623b3eb3cSopenharmony_ci rsUiDirector->SetUITaskRunner( 187723b3eb3cSopenharmony_ci [taskExecutor = container->GetTaskExecutor(), id]( 187823b3eb3cSopenharmony_ci const std::function<void()>& task, uint32_t delay) { 187923b3eb3cSopenharmony_ci ContainerScope scope(id); 188023b3eb3cSopenharmony_ci taskExecutor->PostDelayedTask( 188123b3eb3cSopenharmony_ci task, TaskExecutor::TaskType::UI, delay, "ArkUIRenderServiceTask", PriorityType::HIGH); 188223b3eb3cSopenharmony_ci }, id); 188323b3eb3cSopenharmony_ci auto context = AceType::DynamicCast<PipelineContext>(container->GetPipelineContext()); 188423b3eb3cSopenharmony_ci if (context != nullptr) { 188523b3eb3cSopenharmony_ci context->SetRSUIDirector(rsUiDirector); 188623b3eb3cSopenharmony_ci } 188723b3eb3cSopenharmony_ci } 188823b3eb3cSopenharmony_ci }; 188923b3eb3cSopenharmony_ci#endif 189023b3eb3cSopenharmony_ci // set view 189123b3eb3cSopenharmony_ci Platform::AceContainer::SetView(aceView, density, 0, 0, window_, callback); 189223b3eb3cSopenharmony_ci } else { 189323b3eb3cSopenharmony_ci errorCode = Platform::AceContainer::SetViewNew(aceView, density, 0, 0, window_); 189423b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 189523b3eb3cSopenharmony_ci } 189623b3eb3cSopenharmony_ci#else 189723b3eb3cSopenharmony_ci errorCode = Platform::AceContainer::SetViewNew(aceView, density, 0, 0, window_); 189823b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 189923b3eb3cSopenharmony_ci#endif 190023b3eb3cSopenharmony_ci // set focus window id for ui extension after pipeline context created. 190123b3eb3cSopenharmony_ci if (focusWindowId != 0) { 190223b3eb3cSopenharmony_ci container->SetFocusWindowId(focusWindowId); 190323b3eb3cSopenharmony_ci } 190423b3eb3cSopenharmony_ci 190523b3eb3cSopenharmony_ci auto realHostWindowId = window_->GetRealParentId(); 190623b3eb3cSopenharmony_ci if (realHostWindowId != 0) { 190723b3eb3cSopenharmony_ci container->SetRealHostWindowId(static_cast<uint32_t>(realHostWindowId)); 190823b3eb3cSopenharmony_ci } 190923b3eb3cSopenharmony_ci LOGI("focusWindowId: %{public}u, realHostWindowId: %{public}d", 191023b3eb3cSopenharmony_ci focusWindowId, realHostWindowId); 191123b3eb3cSopenharmony_ci 191223b3eb3cSopenharmony_ci // after frontend initialize 191323b3eb3cSopenharmony_ci if (window_->IsFocused()) { 191423b3eb3cSopenharmony_ci Focus(); 191523b3eb3cSopenharmony_ci } 191623b3eb3cSopenharmony_ci 191723b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfaceChanged(aceView, 0, 0, deviceHeight >= deviceWidth ? 0 : 1); 191823b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 191923b3eb3cSopenharmony_ci // Use metadata to control the center-alignment of text at line height. 192023b3eb3cSopenharmony_ci bool halfLeading = std::any_of(metaData.begin(), metaData.end(), 192123b3eb3cSopenharmony_ci [](const auto& metaDataItem) { return metaDataItem.name == "half_leading" && metaDataItem.value == "true"; }); 192223b3eb3cSopenharmony_ci pipeline->SetHalfLeading(halfLeading); 192323b3eb3cSopenharmony_ci bool hasPreviewTextOption = std::any_of(metaData.begin(), metaData.end(), 192423b3eb3cSopenharmony_ci [pipelineWeak = AceType::WeakClaim(AceType::RawPtr(pipeline))](const auto& metaDataItem) { 192523b3eb3cSopenharmony_ci if (metaDataItem.name == "can_preview_text") { 192623b3eb3cSopenharmony_ci auto pipeline = pipelineWeak.Upgrade(); 192723b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipeline, false); 192823b3eb3cSopenharmony_ci pipeline->SetSupportPreviewText(metaDataItem.value == "false"); 192923b3eb3cSopenharmony_ci return true; 193023b3eb3cSopenharmony_ci } 193123b3eb3cSopenharmony_ci return false; 193223b3eb3cSopenharmony_ci }); 193323b3eb3cSopenharmony_ci pipeline->SetHasPreviewTextOption(hasPreviewTextOption); 193423b3eb3cSopenharmony_ci // Use metadata to control whether the cutout safeArea takes effect. 193523b3eb3cSopenharmony_ci bool useCutout = std::any_of(metaData.begin(), metaData.end(), 193623b3eb3cSopenharmony_ci [](const auto& metaDataItem) { return metaDataItem.name == "avoid_cutout" && metaDataItem.value == "true"; }); 193723b3eb3cSopenharmony_ci pipeline->SetUseCutout(useCutout); 193823b3eb3cSopenharmony_ci container->CheckAndSetFontFamily(); 193923b3eb3cSopenharmony_ci SetFontScaleAndWeightScale(container, instanceId_); 194023b3eb3cSopenharmony_ci if (pipeline) { 194123b3eb3cSopenharmony_ci auto rsConfig = window_->GetKeyboardAnimationConfig(); 194223b3eb3cSopenharmony_ci KeyboardAnimationCurve curveIn = { 194323b3eb3cSopenharmony_ci rsConfig.curveIn.curveType_, rsConfig.curveIn.curveParams_, rsConfig.curveIn.duration_}; 194423b3eb3cSopenharmony_ci KeyboardAnimationCurve curveOut = { 194523b3eb3cSopenharmony_ci rsConfig.curveOut.curveType_, rsConfig.curveOut.curveParams_, rsConfig.curveOut.duration_}; 194623b3eb3cSopenharmony_ci KeyboardAnimationConfig config = {curveIn, curveOut}; 194723b3eb3cSopenharmony_ci pipeline->SetKeyboardAnimationConfig(config); 194823b3eb3cSopenharmony_ci } 194923b3eb3cSopenharmony_ci // Use metadata to control whether dirty mark is blocked. 195023b3eb3cSopenharmony_ci bool isOpenInvisibleFreeze = std::any_of(metaData.begin(), metaData.end(), [](const auto& metaDataItem) { 195123b3eb3cSopenharmony_ci return metaDataItem.name == "ArkUIInvisibleFreeze" && metaDataItem.value == "true"; 195223b3eb3cSopenharmony_ci }); 195323b3eb3cSopenharmony_ci LOGI("ArkUIInvisibleFreeze: %{public}d", isOpenInvisibleFreeze); 195423b3eb3cSopenharmony_ci pipeline->SetOpenInvisibleFreeze(isOpenInvisibleFreeze); 195523b3eb3cSopenharmony_ci // Set sdk version in module json mode 195623b3eb3cSopenharmony_ci if (isModelJson) { 195723b3eb3cSopenharmony_ci if (pipeline && appInfo) { 195823b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: SetMinPlatformVersion is %{public}d", bundleName_.c_str(), 195923b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_, appInfo->apiCompatibleVersion); 196023b3eb3cSopenharmony_ci pipeline->SetMinPlatformVersion(appInfo->apiCompatibleVersion); 196123b3eb3cSopenharmony_ci } 196223b3eb3cSopenharmony_ci } 196323b3eb3cSopenharmony_ci if (runtime_) { 196423b3eb3cSopenharmony_ci auto nativeEngine = reinterpret_cast<NativeEngine*>(runtime_); 196523b3eb3cSopenharmony_ci if (!storage) { 196623b3eb3cSopenharmony_ci container->SetLocalStorage(nullptr, context); 196723b3eb3cSopenharmony_ci } else { 196823b3eb3cSopenharmony_ci auto env = reinterpret_cast<napi_env>(nativeEngine); 196923b3eb3cSopenharmony_ci napi_ref ref = nullptr; 197023b3eb3cSopenharmony_ci napi_create_reference(env, storage, 1, &ref); 197123b3eb3cSopenharmony_ci container->SetLocalStorage(reinterpret_cast<NativeReference*>(ref), context); 197223b3eb3cSopenharmony_ci } 197323b3eb3cSopenharmony_ci } 197423b3eb3cSopenharmony_ci 197523b3eb3cSopenharmony_ci InitializeSafeArea(container); 197623b3eb3cSopenharmony_ci InitializeDisplayAvailableRect(container); 197723b3eb3cSopenharmony_ci InitDragSummaryMap(container); 197823b3eb3cSopenharmony_ci 197923b3eb3cSopenharmony_ci // set container temp dir 198023b3eb3cSopenharmony_ci if (abilityContext) { 198123b3eb3cSopenharmony_ci if (!abilityContext->GetTempDir().empty()) { 198223b3eb3cSopenharmony_ci container->SetTempDir(abilityContext->GetTempDir()); 198323b3eb3cSopenharmony_ci } 198423b3eb3cSopenharmony_ci } 198523b3eb3cSopenharmony_ci 198623b3eb3cSopenharmony_ci LayoutInspector::SetCallback(instanceId_); 198723b3eb3cSopenharmony_ci 198823b3eb3cSopenharmony_ci // setLogFunc of current app 198923b3eb3cSopenharmony_ci AddAlarmLogFunc(); 199023b3eb3cSopenharmony_ci // set get inspector tree function for ui session manager 199123b3eb3cSopenharmony_ci auto callback = [weakContext = WeakPtr(pipeline)]() { 199223b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(weakContext.Upgrade()); 199323b3eb3cSopenharmony_ci if (pipeline == nullptr) { 199423b3eb3cSopenharmony_ci pipeline = NG::PipelineContext::GetCurrentContextSafely(); 199523b3eb3cSopenharmony_ci } 199623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 199723b3eb3cSopenharmony_ci auto taskExecutor = pipeline->GetTaskExecutor(); 199823b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 199923b3eb3cSopenharmony_ci taskExecutor->PostTask( 200023b3eb3cSopenharmony_ci [weakContext = WeakPtr(pipeline)]() { 200123b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(weakContext.Upgrade()); 200223b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 200323b3eb3cSopenharmony_ci ContainerScope scope(pipeline->GetInstanceId()); 200423b3eb3cSopenharmony_ci pipeline->GetInspectorTree(); 200523b3eb3cSopenharmony_ci UiSessionManager::GetInstance().WebTaskNumsChange(-1); 200623b3eb3cSopenharmony_ci }, 200723b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "UiSessionGetInspectorTree"); 200823b3eb3cSopenharmony_ci }; 200923b3eb3cSopenharmony_ci UiSessionManager::GetInstance().SaveInspectorTreeFunction(callback); 201023b3eb3cSopenharmony_ci auto webCallback = [weakContext = WeakPtr(pipeline)](bool isRegister) { 201123b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(weakContext.Upgrade()); 201223b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 201323b3eb3cSopenharmony_ci auto taskExecutor = pipeline->GetTaskExecutor(); 201423b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 201523b3eb3cSopenharmony_ci taskExecutor->PostTask( 201623b3eb3cSopenharmony_ci [weakContext = WeakPtr(pipeline), isRegister]() { 201723b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(weakContext.Upgrade()); 201823b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 201923b3eb3cSopenharmony_ci pipeline->NotifyAllWebPattern(isRegister); 202023b3eb3cSopenharmony_ci }, 202123b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "UiSessionRegisterWebPattern"); 202223b3eb3cSopenharmony_ci }; 202323b3eb3cSopenharmony_ci UiSessionManager::GetInstance().SaveRegisterForWebFunction(webCallback); 202423b3eb3cSopenharmony_ci UiSessionManager::GetInstance().SaveBaseInfo(std::string("bundleName:") 202523b3eb3cSopenharmony_ci .append(bundleName) 202623b3eb3cSopenharmony_ci .append(",moduleName:") 202723b3eb3cSopenharmony_ci .append(moduleName) 202823b3eb3cSopenharmony_ci .append(",abilityName:") 202923b3eb3cSopenharmony_ci .append(abilityName)); 203023b3eb3cSopenharmony_ci UpdateFontScale(context->GetConfiguration()); 203123b3eb3cSopenharmony_ci auto thpExtraManager = AceType::MakeRefPtr<NG::THPExtraManagerImpl>(); 203223b3eb3cSopenharmony_ci if (thpExtraManager->Init()) { 203323b3eb3cSopenharmony_ci pipeline->SetTHPExtraManager(thpExtraManager); 203423b3eb3cSopenharmony_ci } 203523b3eb3cSopenharmony_ci return errorCode; 203623b3eb3cSopenharmony_ci} 203723b3eb3cSopenharmony_ci 203823b3eb3cSopenharmony_civoid UIContentImpl::InitializeSafeArea(const RefPtr<Platform::AceContainer>& container) 203923b3eb3cSopenharmony_ci{ 204023b3eb3cSopenharmony_ci constexpr static int32_t PLATFORM_VERSION_TEN = 10; 204123b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 204223b3eb3cSopenharmony_ci if (pipeline && pipeline->GetMinPlatformVersion() >= PLATFORM_VERSION_TEN && 204323b3eb3cSopenharmony_ci (pipeline->GetIsAppWindow() || container->IsUIExtensionWindow())) { 204423b3eb3cSopenharmony_ci avoidAreaChangedListener_ = new PretendChangedListener(instanceId_); 204523b3eb3cSopenharmony_ci window_->RegisterAvoidAreaChangeListener(avoidAreaChangedListener_); 204623b3eb3cSopenharmony_ci pipeline->UpdateSystemSafeArea(container->GetViewSafeAreaByType(Rosen::AvoidAreaType::TYPE_SYSTEM)); 204723b3eb3cSopenharmony_ci if (pipeline->GetUseCutout()) { 204823b3eb3cSopenharmony_ci pipeline->UpdateCutoutSafeArea(container->GetViewSafeAreaByType(Rosen::AvoidAreaType::TYPE_CUTOUT)); 204923b3eb3cSopenharmony_ci } 205023b3eb3cSopenharmony_ci pipeline->UpdateNavSafeArea(container->GetViewSafeAreaByType(Rosen::AvoidAreaType::TYPE_NAVIGATION_INDICATOR)); 205123b3eb3cSopenharmony_ci } 205223b3eb3cSopenharmony_ci} 205323b3eb3cSopenharmony_ci 205423b3eb3cSopenharmony_civoid UIContentImpl::InitializeDisplayAvailableRect(const RefPtr<Platform::AceContainer>& container) 205523b3eb3cSopenharmony_ci{ 205623b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 205723b3eb3cSopenharmony_ci auto& DMManager = Rosen::DisplayManager::GetInstance(); 205823b3eb3cSopenharmony_ci availableAreaChangedListener_ = new AvailableAreaChangedListener(instanceId_); 205923b3eb3cSopenharmony_ci DMManager.RegisterAvailableAreaListener(availableAreaChangedListener_); 206023b3eb3cSopenharmony_ci Rosen::DMRect availableArea; 206123b3eb3cSopenharmony_ci auto defaultDisplay = DMManager.GetDefaultDisplay(); 206223b3eb3cSopenharmony_ci if (pipeline && defaultDisplay) { 206323b3eb3cSopenharmony_ci Rosen::DMError ret = defaultDisplay->GetAvailableArea(availableArea); 206423b3eb3cSopenharmony_ci if (ret == Rosen::DMError::DM_OK) { 206523b3eb3cSopenharmony_ci pipeline->UpdateDisplayAvailableRect(ConvertDMRect2Rect(availableArea)); 206623b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_WINDOW, 206723b3eb3cSopenharmony_ci "InitializeDisplayAvailableRect : %{public}d, %{public}d, %{public}d, %{public}d", availableArea.posX_, 206823b3eb3cSopenharmony_ci availableArea.posY_, availableArea.width_, availableArea.height_); 206923b3eb3cSopenharmony_ci } 207023b3eb3cSopenharmony_ci } 207123b3eb3cSopenharmony_ci} 207223b3eb3cSopenharmony_ci 207323b3eb3cSopenharmony_civoid UIContentImpl::InitDragSummaryMap(const RefPtr<Platform::AceContainer>& container) 207423b3eb3cSopenharmony_ci{ 207523b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 207623b3eb3cSopenharmony_ci if (pipeline && container->IsUIExtensionWindow()) { 207723b3eb3cSopenharmony_ci pipeline->RequireSummary(); 207823b3eb3cSopenharmony_ci } 207923b3eb3cSopenharmony_ci} 208023b3eb3cSopenharmony_ci 208123b3eb3cSopenharmony_civoid UIContentImpl::Foreground() 208223b3eb3cSopenharmony_ci{ 208323b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: window foreground", bundleName_.c_str(), moduleName_.c_str(), 208423b3eb3cSopenharmony_ci instanceId_); 208523b3eb3cSopenharmony_ci if (window_ != nullptr && window_->GetType() == Rosen::WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) { 208623b3eb3cSopenharmony_ci PerfMonitor::GetPerfMonitor()->SetAppStartStatus(); 208723b3eb3cSopenharmony_ci } 208823b3eb3cSopenharmony_ci ContainerScope::UpdateRecentForeground(instanceId_); 208923b3eb3cSopenharmony_ci Platform::AceContainer::OnShow(instanceId_); 209023b3eb3cSopenharmony_ci // set the flag isForegroundCalled to be true 209123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 209223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 209323b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 209423b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 209523b3eb3cSopenharmony_ci pipelineContext->SetForegroundCalled(true); 209623b3eb3cSopenharmony_ci 209723b3eb3cSopenharmony_ci CHECK_NULL_VOID(window_); 209823b3eb3cSopenharmony_ci std::string windowName = window_->GetWindowName(); 209923b3eb3cSopenharmony_ci Recorder::EventRecorder::Get().SetContainerInfo(windowName, instanceId_, true); 210023b3eb3cSopenharmony_ci} 210123b3eb3cSopenharmony_ci 210223b3eb3cSopenharmony_civoid UIContentImpl::Background() 210323b3eb3cSopenharmony_ci{ 210423b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: window background", bundleName_.c_str(), moduleName_.c_str(), 210523b3eb3cSopenharmony_ci instanceId_); 210623b3eb3cSopenharmony_ci Platform::AceContainer::OnHide(instanceId_); 210723b3eb3cSopenharmony_ci 210823b3eb3cSopenharmony_ci CHECK_NULL_VOID(window_); 210923b3eb3cSopenharmony_ci std::string windowName = window_->GetWindowName(); 211023b3eb3cSopenharmony_ci Recorder::EventRecorder::Get().SetContainerInfo(windowName, instanceId_, false); 211123b3eb3cSopenharmony_ci} 211223b3eb3cSopenharmony_ci 211323b3eb3cSopenharmony_civoid UIContentImpl::ReloadForm(const std::string& url) 211423b3eb3cSopenharmony_ci{ 211523b3eb3cSopenharmony_ci startUrl_ = url; 211623b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: ReloadForm startUrl = %{public}s", bundleName_.c_str(), 211723b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_, startUrl_.c_str()); 211823b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 211923b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 212023b3eb3cSopenharmony_ci auto assetManager = AceType::DynamicCast<AssetManagerImpl>(container->GetAssetManager()); 212123b3eb3cSopenharmony_ci assetManager->ReloadProvider(); 212223b3eb3cSopenharmony_ci container->UpdateResource(); 212323b3eb3cSopenharmony_ci Platform::AceContainer::RunPage(instanceId_, startUrl_, ""); 212423b3eb3cSopenharmony_ci} 212523b3eb3cSopenharmony_ci 212623b3eb3cSopenharmony_ciSerializedGesture UIContentImpl::GetFormSerializedGesture() 212723b3eb3cSopenharmony_ci{ 212823b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 212923b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, SerializedGesture {}); 213023b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 213123b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipelineContext, SerializedGesture {}); 213223b3eb3cSopenharmony_ci return pipelineContext->GetSerializedGesture(); 213323b3eb3cSopenharmony_ci} 213423b3eb3cSopenharmony_ci 213523b3eb3cSopenharmony_civoid UIContentImpl::Focus() 213623b3eb3cSopenharmony_ci{ 213723b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: window focus", bundleName_.c_str(), moduleName_.c_str(), instanceId_); 213823b3eb3cSopenharmony_ci ContainerScope::UpdateRecentActive(instanceId_); 213923b3eb3cSopenharmony_ci Platform::AceContainer::OnActive(instanceId_); 214023b3eb3cSopenharmony_ci CHECK_NULL_VOID(window_); 214123b3eb3cSopenharmony_ci std::string windowName = window_->GetWindowName(); 214223b3eb3cSopenharmony_ci Recorder::EventRecorder::Get().SetFocusContainerInfo(windowName, instanceId_); 214323b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 214423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 214523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 214623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 214723b3eb3cSopenharmony_ci} 214823b3eb3cSopenharmony_ci 214923b3eb3cSopenharmony_civoid UIContentImpl::UnFocus() 215023b3eb3cSopenharmony_ci{ 215123b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: window unfocus", bundleName_.c_str(), moduleName_.c_str(), instanceId_); 215223b3eb3cSopenharmony_ci Platform::AceContainer::OnInactive(instanceId_); 215323b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 215423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 215523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 215623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 215723b3eb3cSopenharmony_ci} 215823b3eb3cSopenharmony_ci 215923b3eb3cSopenharmony_civoid UIContentImpl::Destroy() 216023b3eb3cSopenharmony_ci{ 216123b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: window destroy", bundleName_.c_str(), moduleName_.c_str(), instanceId_); 216223b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 216323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 216423b3eb3cSopenharmony_ci // stop performance check and output json file 216523b3eb3cSopenharmony_ci AcePerformanceCheck::Stop(); 216623b3eb3cSopenharmony_ci if (AceType::InstanceOf<Platform::DialogContainer>(container)) { 216723b3eb3cSopenharmony_ci Platform::DialogContainer::DestroyContainer(instanceId_); 216823b3eb3cSopenharmony_ci } else { 216923b3eb3cSopenharmony_ci Platform::AceContainer::DestroyContainer(instanceId_); 217023b3eb3cSopenharmony_ci } 217123b3eb3cSopenharmony_ci ContainerScope::RemoveAndCheck(instanceId_); 217223b3eb3cSopenharmony_ci} 217323b3eb3cSopenharmony_ci 217423b3eb3cSopenharmony_civoid UIContentImpl::OnNewWant(const OHOS::AAFwk::Want& want) 217523b3eb3cSopenharmony_ci{ 217623b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: UIContent OnNewWant", bundleName_.c_str(), moduleName_.c_str(), 217723b3eb3cSopenharmony_ci instanceId_); 217823b3eb3cSopenharmony_ci std::string params = want.GetStringParam(START_PARAMS_KEY); 217923b3eb3cSopenharmony_ci Platform::AceContainer::OnNewRequest(instanceId_, params); 218023b3eb3cSopenharmony_ci} 218123b3eb3cSopenharmony_ci 218223b3eb3cSopenharmony_ciuint32_t UIContentImpl::GetBackgroundColor() 218323b3eb3cSopenharmony_ci{ 218423b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 218523b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, 0x000000); 218623b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 218723b3eb3cSopenharmony_ci CHECK_NULL_RETURN(taskExecutor, 0x000000); 218823b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 218923b3eb3cSopenharmony_ci uint32_t bgColor = 0x000000; 219023b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 219123b3eb3cSopenharmony_ci [&bgColor, container]() { 219223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 219323b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 219423b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 219523b3eb3cSopenharmony_ci bgColor = pipelineContext->GetAppBgColor().GetValue(); 219623b3eb3cSopenharmony_ci }, 219723b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIGetAppBackgroundColor"); 219823b3eb3cSopenharmony_ci 219923b3eb3cSopenharmony_ci LOGD("[%{public}s][%{public}s][%{public}d]: GetBackgroundColor:%{public}u", 220023b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, bgColor); 220123b3eb3cSopenharmony_ci return bgColor; 220223b3eb3cSopenharmony_ci} 220323b3eb3cSopenharmony_ci 220423b3eb3cSopenharmony_civoid UIContentImpl::SetBackgroundColor(uint32_t color) 220523b3eb3cSopenharmony_ci{ 220623b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: SetBackgroundColor:%{public}u", 220723b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, color); 220823b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 220923b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 221023b3eb3cSopenharmony_ci auto aceContainer = AceType::DynamicCast<Platform::AceContainer>(container); 221123b3eb3cSopenharmony_ci if (aceContainer) { 221223b3eb3cSopenharmony_ci aceContainer->SetIsUseCustomBg(true); 221323b3eb3cSopenharmony_ci } 221423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 221523b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 221623b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 221723b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 221823b3eb3cSopenharmony_ci [container, bgColor = color]() { 221923b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 222023b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 222123b3eb3cSopenharmony_ci pipelineContext->SetAppBgColor(Color(bgColor)); 222223b3eb3cSopenharmony_ci pipelineContext->ChangeDarkModeBrightness(); 222323b3eb3cSopenharmony_ci }, 222423b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetAppBackgroundColor"); 222523b3eb3cSopenharmony_ci} 222623b3eb3cSopenharmony_ci 222723b3eb3cSopenharmony_civoid UIContentImpl::SetWindowContainerColor(uint32_t activeColor, uint32_t inactiveColor) 222823b3eb3cSopenharmony_ci{ 222923b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_APPBAR, "[%{public}s][%{public}s][%{public}d]: SetWindowContainerColor:" 223023b3eb3cSopenharmony_ci "active color %{public}u, inactive color %{public}u", 223123b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, activeColor, inactiveColor); 223223b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 223323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 223423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 223523b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 223623b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 223723b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 223823b3eb3cSopenharmony_ci [container, activeColor, inactiveColor]() { 223923b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 224023b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 224123b3eb3cSopenharmony_ci pipelineContext->SetWindowContainerColor(Color(activeColor), Color(inactiveColor)); 224223b3eb3cSopenharmony_ci }, 224323b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetWindowContainerColor"); 224423b3eb3cSopenharmony_ci} 224523b3eb3cSopenharmony_ci 224623b3eb3cSopenharmony_civoid UIContentImpl::GetAppPaintSize(OHOS::Rosen::Rect& paintRect) 224723b3eb3cSopenharmony_ci{ 224823b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 224923b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 225023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 225123b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 225223b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 225323b3eb3cSopenharmony_ci auto stageManager = pipelineContext->GetStageManager(); 225423b3eb3cSopenharmony_ci CHECK_NULL_VOID(stageManager); 225523b3eb3cSopenharmony_ci auto stageNode = stageManager->GetStageNode(); 225623b3eb3cSopenharmony_ci CHECK_NULL_VOID(stageNode); 225723b3eb3cSopenharmony_ci auto renderContext = stageNode->GetRenderContext(); 225823b3eb3cSopenharmony_ci CHECK_NULL_VOID(renderContext); 225923b3eb3cSopenharmony_ci auto rect = renderContext->GetPaintRectWithoutTransform(); 226023b3eb3cSopenharmony_ci auto offset = stageNode->GetPaintRectOffset(false); 226123b3eb3cSopenharmony_ci paintRect.posX_ = static_cast<int32_t>(offset.GetX()); 226223b3eb3cSopenharmony_ci paintRect.posY_ = static_cast<int32_t>(offset.GetY()); 226323b3eb3cSopenharmony_ci paintRect.width_ = static_cast<uint32_t>(rect.Width()); 226423b3eb3cSopenharmony_ci paintRect.height_ = static_cast<uint32_t>(rect.Height()); 226523b3eb3cSopenharmony_ci} 226623b3eb3cSopenharmony_ci 226723b3eb3cSopenharmony_civoid UIContentImpl::GetWindowPaintSize(OHOS::Rosen::Rect& paintRect) 226823b3eb3cSopenharmony_ci{ 226923b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 227023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 227123b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 227223b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 227323b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 227423b3eb3cSopenharmony_ci CHECK_NULL_VOID(window_); 227523b3eb3cSopenharmony_ci auto windowRect = window_->GetRect(); 227623b3eb3cSopenharmony_ci NG::RectInt rect; 227723b3eb3cSopenharmony_ci rect.SetRect(0, 0, windowRect.width_, windowRect.height_); 227823b3eb3cSopenharmony_ci pipelineContext->GetWindowPaintRectWithoutMeasureAndLayout(rect); 227923b3eb3cSopenharmony_ci paintRect.posX_ = static_cast<int32_t>(rect.GetX()); 228023b3eb3cSopenharmony_ci paintRect.posY_ = static_cast<int32_t>(rect.GetY()); 228123b3eb3cSopenharmony_ci paintRect.width_ = static_cast<uint32_t>(rect.Width()); 228223b3eb3cSopenharmony_ci paintRect.height_ = static_cast<uint32_t>(rect.Height()); 228323b3eb3cSopenharmony_ci} 228423b3eb3cSopenharmony_ci 228523b3eb3cSopenharmony_cibool UIContentImpl::ProcessBackPressed() 228623b3eb3cSopenharmony_ci{ 228723b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: OnBackPressed called", bundleName_.c_str(), moduleName_.c_str(), 228823b3eb3cSopenharmony_ci instanceId_); 228923b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 229023b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 229123b3eb3cSopenharmony_ci if (container->IsUIExtensionWindow() && !container->WindowIsShow()) { 229223b3eb3cSopenharmony_ci return false; 229323b3eb3cSopenharmony_ci } 229423b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 229523b3eb3cSopenharmony_ci CHECK_NULL_RETURN(taskExecutor, false); 229623b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 229723b3eb3cSopenharmony_ci if (pipeline) { 229823b3eb3cSopenharmony_ci auto uiExtMgr = pipeline->GetUIExtensionManager(); 229923b3eb3cSopenharmony_ci if (uiExtMgr && uiExtMgr->OnBackPressed()) { 230023b3eb3cSopenharmony_ci LOGI("UIExtension consumed backpressed event"); 230123b3eb3cSopenharmony_ci return true; 230223b3eb3cSopenharmony_ci } 230323b3eb3cSopenharmony_ci } 230423b3eb3cSopenharmony_ci bool ret = false; 230523b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 230623b3eb3cSopenharmony_ci [container, this, &ret]() { 230723b3eb3cSopenharmony_ci if (AceType::InstanceOf<Platform::DialogContainer>(container)) { 230823b3eb3cSopenharmony_ci if (Platform::DialogContainer::OnBackPressed(instanceId_)) { 230923b3eb3cSopenharmony_ci ret = true; 231023b3eb3cSopenharmony_ci } 231123b3eb3cSopenharmony_ci } else { 231223b3eb3cSopenharmony_ci PerfMonitor::GetPerfMonitor()->RecordInputEvent(LAST_UP, UNKNOWN_SOURCE, 0); 231323b3eb3cSopenharmony_ci if (Platform::AceContainer::OnBackPressed(instanceId_)) { 231423b3eb3cSopenharmony_ci ret = true; 231523b3eb3cSopenharmony_ci } 231623b3eb3cSopenharmony_ci } 231723b3eb3cSopenharmony_ci }, 231823b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIProcessBackPressed"); 231923b3eb3cSopenharmony_ci return ret; 232023b3eb3cSopenharmony_ci} 232123b3eb3cSopenharmony_ci 232223b3eb3cSopenharmony_cibool UIContentImpl::ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) 232323b3eb3cSopenharmony_ci{ 232423b3eb3cSopenharmony_ci auto container = AceType::DynamicCast<Platform::AceContainer>(AceEngine::Get().GetContainer(instanceId_)); 232523b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 232623b3eb3cSopenharmony_ci if (pointerEvent->GetPointerAction() != MMI::PointerEvent::POINTER_ACTION_MOVE) { 232723b3eb3cSopenharmony_ci TAG_LOGD(AceLogTag::ACE_INPUTTRACKING, 232823b3eb3cSopenharmony_ci "PointerEvent Process to ui_content, eventInfo: id:%{public}d, " 232923b3eb3cSopenharmony_ci "WindowName = %{public}s, WindowId = %{public}d, ViewWidth = %{public}d, ViewHeight = %{public}d, " 233023b3eb3cSopenharmony_ci "ViewPosX = %{public}d, ViewPosY = %{public}d", 233123b3eb3cSopenharmony_ci pointerEvent->GetId(), container->GetWindowName().c_str(), container->GetWindowId(), 233223b3eb3cSopenharmony_ci container->GetViewWidth(), container->GetViewHeight(), container->GetViewPosX(), container->GetViewPosY()); 233323b3eb3cSopenharmony_ci } 233423b3eb3cSopenharmony_ci auto aceView = AceType::DynamicCast<Platform::AceViewOhos>(container->GetAceView()); 233523b3eb3cSopenharmony_ci Platform::AceViewOhos::DispatchTouchEvent(aceView, pointerEvent); 233623b3eb3cSopenharmony_ci return true; 233723b3eb3cSopenharmony_ci} 233823b3eb3cSopenharmony_ci 233923b3eb3cSopenharmony_cibool UIContentImpl::ProcessPointerEventWithCallback( 234023b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent, const std::function<void()>& callback) 234123b3eb3cSopenharmony_ci{ 234223b3eb3cSopenharmony_ci auto container = AceType::DynamicCast<Platform::AceContainer>(AceEngine::Get().GetContainer(instanceId_)); 234323b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 234423b3eb3cSopenharmony_ci if (pointerEvent->GetPointerAction() != MMI::PointerEvent::POINTER_ACTION_MOVE) { 234523b3eb3cSopenharmony_ci TAG_LOGD(AceLogTag::ACE_INPUTTRACKING, 234623b3eb3cSopenharmony_ci "PointerEvent Process to ui_content, eventInfo: id:%{public}d, " 234723b3eb3cSopenharmony_ci "WindowName = %{public}s, WindowId = %{public}d, ViewWidth = %{public}d, ViewHeight = %{public}d, " 234823b3eb3cSopenharmony_ci "ViewPosX = %{public}d, ViewPosY = %{public}d", 234923b3eb3cSopenharmony_ci pointerEvent->GetId(), container->GetWindowName().c_str(), container->GetWindowId(), 235023b3eb3cSopenharmony_ci container->GetViewWidth(), container->GetViewHeight(), container->GetViewPosX(), container->GetViewPosY()); 235123b3eb3cSopenharmony_ci } 235223b3eb3cSopenharmony_ci auto aceView = AceType::DynamicCast<Platform::AceViewOhos>(container->GetAceView()); 235323b3eb3cSopenharmony_ci Platform::AceViewOhos::DispatchTouchEvent(aceView, pointerEvent, nullptr, callback); 235423b3eb3cSopenharmony_ci return true; 235523b3eb3cSopenharmony_ci} 235623b3eb3cSopenharmony_ci 235723b3eb3cSopenharmony_cibool UIContentImpl::ProcessKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& touchEvent, bool isPreIme) 235823b3eb3cSopenharmony_ci{ 235923b3eb3cSopenharmony_ci TAG_LOGD(AceLogTag::ACE_INPUTTRACKING, 236023b3eb3cSopenharmony_ci "KeyEvent Process to ui_content, eventInfo: id:%{public}d, " 236123b3eb3cSopenharmony_ci "keyEvent info: keyCode is %{private}d, " 236223b3eb3cSopenharmony_ci "keyAction is %{public}d, keyActionTime is %{public}" PRId64, 236323b3eb3cSopenharmony_ci touchEvent->GetId(), touchEvent->GetKeyCode(), touchEvent->GetKeyAction(), touchEvent->GetActionTime()); 236423b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 236523b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 236623b3eb3cSopenharmony_ci auto aceView = AceType::DynamicCast<Platform::AceViewOhos>(container->GetAceView()); 236723b3eb3cSopenharmony_ci return Platform::AceViewOhos::DispatchKeyEvent(aceView, touchEvent, isPreIme); 236823b3eb3cSopenharmony_ci} 236923b3eb3cSopenharmony_ci 237023b3eb3cSopenharmony_cibool UIContentImpl::ProcessAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) 237123b3eb3cSopenharmony_ci{ 237223b3eb3cSopenharmony_ci return false; 237323b3eb3cSopenharmony_ci} 237423b3eb3cSopenharmony_ci 237523b3eb3cSopenharmony_cibool UIContentImpl::ProcessVsyncEvent(uint64_t timeStampNanos) 237623b3eb3cSopenharmony_ci{ 237723b3eb3cSopenharmony_ci return false; 237823b3eb3cSopenharmony_ci} 237923b3eb3cSopenharmony_ci 238023b3eb3cSopenharmony_civoid UIContentImpl::UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) 238123b3eb3cSopenharmony_ci{ 238223b3eb3cSopenharmony_ci CHECK_NULL_VOID(config); 238323b3eb3cSopenharmony_ci 238423b3eb3cSopenharmony_ci auto dialogContainer = Platform::DialogContainer::GetContainer(instanceId_); 238523b3eb3cSopenharmony_ci if (dialogContainer) { 238623b3eb3cSopenharmony_ci UpdateDialogContainerConfig(config); 238723b3eb3cSopenharmony_ci return; 238823b3eb3cSopenharmony_ci } 238923b3eb3cSopenharmony_ci 239023b3eb3cSopenharmony_ci StoreConfiguration(config); 239123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 239223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 239323b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 239423b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 239523b3eb3cSopenharmony_ci bool formFontUseDefault = isFormRender_ && !fontScaleFollowSystem_; 239623b3eb3cSopenharmony_ci taskExecutor->PostTask( 239723b3eb3cSopenharmony_ci [weakContainer = WeakPtr<Platform::AceContainer>(container), config, instanceId = instanceId_, 239823b3eb3cSopenharmony_ci bundleName = bundleName_, moduleName = moduleName_, formFontUseDefault]() { 239923b3eb3cSopenharmony_ci auto container = weakContainer.Upgrade(); 240023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 240123b3eb3cSopenharmony_ci Platform::ParsedConfig parsedConfig; 240223b3eb3cSopenharmony_ci parsedConfig.colorMode = config->GetItem(OHOS::AppExecFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); 240323b3eb3cSopenharmony_ci parsedConfig.deviceAccess = config->GetItem(OHOS::AppExecFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE); 240423b3eb3cSopenharmony_ci parsedConfig.direction = config->GetItem(OHOS::AppExecFwk::ConfigurationInner::APPLICATION_DIRECTION); 240523b3eb3cSopenharmony_ci parsedConfig.densitydpi = config->GetItem(OHOS::AppExecFwk::ConfigurationInner::APPLICATION_DENSITYDPI); 240623b3eb3cSopenharmony_ci parsedConfig.fontFamily = config->GetItem(OHOS::AppExecFwk::ConfigurationInner::APPLICATION_FONT); 240723b3eb3cSopenharmony_ci parsedConfig.themeTag = config->GetItem("ohos.application.theme"); 240823b3eb3cSopenharmony_ci parsedConfig.colorModeIsSetByApp = 240923b3eb3cSopenharmony_ci config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP); 241023b3eb3cSopenharmony_ci parsedConfig.mcc = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_MCC); 241123b3eb3cSopenharmony_ci parsedConfig.mnc = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_MNC); 241223b3eb3cSopenharmony_ci // Process system language and preferred language 241323b3eb3cSopenharmony_ci auto isPreferredLanguage = config->GetItem(OHOS::AppExecFwk::GlobalConfigurationKey::IS_PREFERRED_LANGUAGE); 241423b3eb3cSopenharmony_ci if (isPreferredLanguage == IS_PREFERRED_LANGUAGE) { 241523b3eb3cSopenharmony_ci parsedConfig.preferredLanguage = 241623b3eb3cSopenharmony_ci config->GetItem(OHOS::AppExecFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); 241723b3eb3cSopenharmony_ci } else { 241823b3eb3cSopenharmony_ci parsedConfig.languageTag = config->GetItem(OHOS::AppExecFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); 241923b3eb3cSopenharmony_ci } 242023b3eb3cSopenharmony_ci // EtsCard Font followSytem disable 242123b3eb3cSopenharmony_ci if (formFontUseDefault) { 242223b3eb3cSopenharmony_ci parsedConfig.fontScale = "1.0"; 242323b3eb3cSopenharmony_ci } else { 242423b3eb3cSopenharmony_ci parsedConfig.fontScale = config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_FONT_SIZE_SCALE); 242523b3eb3cSopenharmony_ci } 242623b3eb3cSopenharmony_ci parsedConfig.fontWeightScale = 242723b3eb3cSopenharmony_ci config->GetItem(OHOS::AAFwk::GlobalConfigurationKey::SYSTEM_FONT_WEIGHT_SCALE); 242823b3eb3cSopenharmony_ci container->UpdateConfiguration(parsedConfig, config->GetName()); 242923b3eb3cSopenharmony_ci LOGI("[%{public}d][%{public}s][%{public}s] UpdateConfiguration, name:%{public}s", 243023b3eb3cSopenharmony_ci instanceId, bundleName.c_str(), moduleName.c_str(), config->GetName().c_str()); 243123b3eb3cSopenharmony_ci }, 243223b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUIContentUpdateConfiguration"); 243323b3eb3cSopenharmony_ci} 243423b3eb3cSopenharmony_ci 243523b3eb3cSopenharmony_civoid UIContentImpl::UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason, 243623b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction, 243723b3eb3cSopenharmony_ci const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas) 243823b3eb3cSopenharmony_ci{ 243923b3eb3cSopenharmony_ci if (SystemProperties::GetWindowRectResizeEnabled()) { 244023b3eb3cSopenharmony_ci PerfMonitor::GetPerfMonitor()->RecordWindowRectResize(static_cast<OHOS::Ace::WindowSizeChangeReason>(reason), 244123b3eb3cSopenharmony_ci bundleName_); 244223b3eb3cSopenharmony_ci } 244323b3eb3cSopenharmony_ci UpdateViewportConfigWithAnimation(config, reason, {}, rsTransaction, avoidAreas); 244423b3eb3cSopenharmony_ci} 244523b3eb3cSopenharmony_ci 244623b3eb3cSopenharmony_civoid UIContentImpl::UpdateViewportConfigWithAnimation(const ViewportConfig& config, 244723b3eb3cSopenharmony_ci OHOS::Rosen::WindowSizeChangeReason reason, AnimationOption animationOpt, 244823b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction, 244923b3eb3cSopenharmony_ci const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas) 245023b3eb3cSopenharmony_ci{ 245123b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: UpdateViewportConfig %{public}s, windowSizeChangeReason %d", 245223b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, config.ToString().c_str(), 245323b3eb3cSopenharmony_ci static_cast<uint32_t>(reason)); 245423b3eb3cSopenharmony_ci bool isOrientationChanged = static_cast<int32_t>(SystemProperties::GetDeviceOrientation()) != config.Orientation(); 245523b3eb3cSopenharmony_ci SystemProperties::SetDeviceOrientation(config.Orientation()); 245623b3eb3cSopenharmony_ci TAG_LOGI( 245723b3eb3cSopenharmony_ci AceLogTag::ACE_WINDOW, "Update orientation to : %{public}d", static_cast<uint32_t>(config.Orientation())); 245823b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 245923b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 246023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 246123b3eb3cSopenharmony_ci if (container->IsSubContainer()) { 246223b3eb3cSopenharmony_ci auto rect = NG::RectF(config.Left(), config.Top(), config.Width(), config.Height()); 246323b3eb3cSopenharmony_ci SubwindowManager::GetInstance()->SetRect(rect, instanceId_); 246423b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_WINDOW, "UpdateViewportConfig for subContainer: %{public}s", 246523b3eb3cSopenharmony_ci rect.ToString().c_str()); 246623b3eb3cSopenharmony_ci } 246723b3eb3cSopenharmony_ci // The density of sub windows related to dialog needs to be consistent with the main window. 246823b3eb3cSopenharmony_ci auto modifyConfig = config; 246923b3eb3cSopenharmony_ci if (instanceId_ >= MIN_SUBCONTAINER_ID) { 247023b3eb3cSopenharmony_ci auto parentContainer = Platform::AceContainer::GetContainer(container->GetParentId()); 247123b3eb3cSopenharmony_ci CHECK_NULL_VOID(parentContainer); 247223b3eb3cSopenharmony_ci auto parentPipeline = parentContainer->GetPipelineContext(); 247323b3eb3cSopenharmony_ci CHECK_NULL_VOID(parentPipeline); 247423b3eb3cSopenharmony_ci modifyConfig.SetDensity(parentPipeline->GetDensity()); 247523b3eb3cSopenharmony_ci } 247623b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 247723b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 247823b3eb3cSopenharmony_ci auto updateDensityTask = [container, modifyConfig]() { 247923b3eb3cSopenharmony_ci auto aceView = AceType::DynamicCast<Platform::AceViewOhos>(container->GetAceView()); 248023b3eb3cSopenharmony_ci CHECK_NULL_VOID(aceView); 248123b3eb3cSopenharmony_ci Platform::AceViewOhos::SetViewportMetrics(aceView, modifyConfig); // update density into pipeline 248223b3eb3cSopenharmony_ci }; 248323b3eb3cSopenharmony_ci auto updateDeviceOrientationTask = [container, modifyConfig, reason]() { 248423b3eb3cSopenharmony_ci if (reason == OHOS::Rosen::WindowSizeChangeReason::ROTATION) { 248523b3eb3cSopenharmony_ci container->UpdateResourceOrientation(modifyConfig.Orientation()); 248623b3eb3cSopenharmony_ci } 248723b3eb3cSopenharmony_ci }; 248823b3eb3cSopenharmony_ci if (taskExecutor->WillRunOnCurrentThread(TaskExecutor::TaskType::UI)) { 248923b3eb3cSopenharmony_ci updateDensityTask(); // ensure density has been updated before load first page 249023b3eb3cSopenharmony_ci updateDeviceOrientationTask(); 249123b3eb3cSopenharmony_ci } else { 249223b3eb3cSopenharmony_ci taskExecutor->PostTask(std::move(updateDensityTask), TaskExecutor::TaskType::UI, "ArkUIUpdateDensity"); 249323b3eb3cSopenharmony_ci taskExecutor->PostTask( 249423b3eb3cSopenharmony_ci std::move(updateDeviceOrientationTask), TaskExecutor::TaskType::UI, "ArkUIDeviceOrientation"); 249523b3eb3cSopenharmony_ci } 249623b3eb3cSopenharmony_ci RefPtr<NG::SafeAreaManager> safeAreaManager = nullptr; 249723b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 249823b3eb3cSopenharmony_ci auto context = AceType::DynamicCast<NG::PipelineContext>(pipelineContext); 249923b3eb3cSopenharmony_ci std::map<OHOS::Rosen::AvoidAreaType, NG::SafeAreaInsets> updatingInsets; 250023b3eb3cSopenharmony_ci if (context) { 250123b3eb3cSopenharmony_ci safeAreaManager = context->GetSafeAreaManager(); 250223b3eb3cSopenharmony_ci context->FireSizeChangeByRotateCallback(isOrientationChanged, rsTransaction); 250323b3eb3cSopenharmony_ci } 250423b3eb3cSopenharmony_ci 250523b3eb3cSopenharmony_ci if (viewportConfigMgr_->IsConfigsEqual(config) && (rsTransaction == nullptr)) { 250623b3eb3cSopenharmony_ci taskExecutor->PostTask( 250723b3eb3cSopenharmony_ci [context, config, avoidAreas] { 250823b3eb3cSopenharmony_ci if (avoidAreas.empty()) { 250923b3eb3cSopenharmony_ci return; 251023b3eb3cSopenharmony_ci } 251123b3eb3cSopenharmony_ci if (ParseAvoidAreasUpdate(context, avoidAreas, config)) { 251223b3eb3cSopenharmony_ci context->AnimateOnSafeAreaUpdate(); 251323b3eb3cSopenharmony_ci } 251423b3eb3cSopenharmony_ci AvoidAreasUpdateOnUIExtension(context, avoidAreas); 251523b3eb3cSopenharmony_ci }, 251623b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUpdateOriginAvoidArea"); 251723b3eb3cSopenharmony_ci return; 251823b3eb3cSopenharmony_ci } 251923b3eb3cSopenharmony_ci 252023b3eb3cSopenharmony_ci auto task = [config = modifyConfig, container, reason, rsTransaction, rsWindow = window_, 252123b3eb3cSopenharmony_ci isDynamicRender = isDynamicRender_, animationOpt, avoidAreas]() { 252223b3eb3cSopenharmony_ci container->SetWindowPos(config.Left(), config.Top()); 252323b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 252423b3eb3cSopenharmony_ci if (pipelineContext) { 252523b3eb3cSopenharmony_ci auto uiExtensionFlushFinishCallback = [rsWindow]() { 252623b3eb3cSopenharmony_ci CHECK_NULL_VOID(rsWindow); 252723b3eb3cSopenharmony_ci rsWindow->NotifyExtensionEventAsync(0); 252823b3eb3cSopenharmony_ci }; 252923b3eb3cSopenharmony_ci if (container->IsUIExtensionWindow()) { 253023b3eb3cSopenharmony_ci pipelineContext->EnWaitFlushFinish(); 253123b3eb3cSopenharmony_ci pipelineContext->SetUIExtensionFlushFinishCallback(uiExtensionFlushFinishCallback); 253223b3eb3cSopenharmony_ci } 253323b3eb3cSopenharmony_ci UpdateSafeArea(pipelineContext, avoidAreas, config, container); 253423b3eb3cSopenharmony_ci pipelineContext->SetDisplayWindowRectInfo( 253523b3eb3cSopenharmony_ci Rect(Offset(config.Left(), config.Top()), Size(config.Width(), config.Height()))); 253623b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_WINDOW, "Update displayAvailableRect in UpdateViewportConfig to : %{public}s", 253723b3eb3cSopenharmony_ci pipelineContext->GetDisplayWindowRectInfo().ToString().c_str()); 253823b3eb3cSopenharmony_ci if (rsWindow) { 253923b3eb3cSopenharmony_ci pipelineContext->SetIsLayoutFullScreen( 254023b3eb3cSopenharmony_ci rsWindow->GetMode() == Rosen::WindowMode::WINDOW_MODE_FULLSCREEN); 254123b3eb3cSopenharmony_ci auto isNeedAvoidWindowMode = IsNeedAvoidWindowMode(rsWindow); 254223b3eb3cSopenharmony_ci pipelineContext->SetIsNeedAvoidWindow(isNeedAvoidWindowMode); 254323b3eb3cSopenharmony_ci } 254423b3eb3cSopenharmony_ci if (reason == OHOS::Rosen::WindowSizeChangeReason::ROTATION) { 254523b3eb3cSopenharmony_ci pipelineContext->FlushBuild(); 254623b3eb3cSopenharmony_ci pipelineContext->StartWindowAnimation(); 254723b3eb3cSopenharmony_ci container->NotifyDirectionUpdate(); 254823b3eb3cSopenharmony_ci } 254923b3eb3cSopenharmony_ci } 255023b3eb3cSopenharmony_ci auto aceView = AceType::DynamicCast<Platform::AceViewOhos>(container->GetAceView()); 255123b3eb3cSopenharmony_ci CHECK_NULL_VOID(aceView); 255223b3eb3cSopenharmony_ci Platform::AceViewOhos::TransformHintChanged(aceView, config.TransformHint()); 255323b3eb3cSopenharmony_ci if (isDynamicRender && animationOpt.IsValid()) { 255423b3eb3cSopenharmony_ci AnimationUtils::Animate(animationOpt, [pipelineContext, aceView, config, reason, rsTransaction] { 255523b3eb3cSopenharmony_ci ContainerScope scope(aceView->GetInstanceId()); 255623b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfaceChanged(aceView, config.Width(), config.Height(), config.Orientation(), 255723b3eb3cSopenharmony_ci static_cast<WindowSizeChangeReason>(reason), rsTransaction); 255823b3eb3cSopenharmony_ci pipelineContext->OnSurfaceChanged( 255923b3eb3cSopenharmony_ci config.Width(), config.Height(), static_cast<WindowSizeChangeReason>(reason), rsTransaction); 256023b3eb3cSopenharmony_ci pipelineContext->FlushUITasks(true); 256123b3eb3cSopenharmony_ci }); 256223b3eb3cSopenharmony_ci } else { 256323b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfaceChanged(aceView, config.Width(), config.Height(), config.Orientation(), 256423b3eb3cSopenharmony_ci static_cast<WindowSizeChangeReason>(reason), rsTransaction); 256523b3eb3cSopenharmony_ci } 256623b3eb3cSopenharmony_ci Platform::AceViewOhos::SurfacePositionChanged(aceView, config.Left(), config.Top()); 256723b3eb3cSopenharmony_ci SubwindowManager::GetInstance()->OnWindowSizeChanged(container->GetInstanceId(), 256823b3eb3cSopenharmony_ci Rect(Offset(config.Left(), config.Top()), Size(config.Width(), config.Height())), 256923b3eb3cSopenharmony_ci static_cast<WindowSizeChangeReason>(reason)); 257023b3eb3cSopenharmony_ci }; 257123b3eb3cSopenharmony_ci auto changeBrightnessTask = [container]() { 257223b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 257323b3eb3cSopenharmony_ci if (pipelineContext) { 257423b3eb3cSopenharmony_ci pipelineContext->ChangeDarkModeBrightness(); 257523b3eb3cSopenharmony_ci } 257623b3eb3cSopenharmony_ci }; 257723b3eb3cSopenharmony_ci taskExecutor->PostTask(std::move(changeBrightnessTask), TaskExecutor::TaskType::UI, "ArkUIUpdateBrightness"); 257823b3eb3cSopenharmony_ci AceViewportConfig aceViewportConfig(modifyConfig, reason, rsTransaction); 257923b3eb3cSopenharmony_ci bool isReasonRotationOrDPI = (reason == OHOS::Rosen::WindowSizeChangeReason::ROTATION || 258023b3eb3cSopenharmony_ci reason == OHOS::Rosen::WindowSizeChangeReason::UPDATE_DPI_SYNC); 258123b3eb3cSopenharmony_ci if (container->IsUseStageModel() && isReasonRotationOrDPI) { 258223b3eb3cSopenharmony_ci viewportConfigMgr_->UpdateConfigSync(aceViewportConfig, std::move(task)); 258323b3eb3cSopenharmony_ci } else if (rsTransaction != nullptr || !avoidAreas.empty()) { 258423b3eb3cSopenharmony_ci // When rsTransaction is not nullptr, the task contains animation. It shouldn't be cancled. 258523b3eb3cSopenharmony_ci // When avoidAreas need updating, the task shouldn't be cancelled. 258623b3eb3cSopenharmony_ci viewportConfigMgr_->UpdatePromiseConfig(aceViewportConfig, std::move(task), container, 258723b3eb3cSopenharmony_ci "ArkUIPromiseViewportConfig"); 258823b3eb3cSopenharmony_ci } else { 258923b3eb3cSopenharmony_ci viewportConfigMgr_->UpdateConfig(aceViewportConfig, std::move(task), container, "ArkUIUpdateViewportConfig"); 259023b3eb3cSopenharmony_ci } 259123b3eb3cSopenharmony_ci viewportConfigMgr_->StoreConfig(aceViewportConfig); 259223b3eb3cSopenharmony_ci UIExtensionUpdateViewportConfig(config); 259323b3eb3cSopenharmony_ci} 259423b3eb3cSopenharmony_ci 259523b3eb3cSopenharmony_civoid UIContentImpl::UIExtensionUpdateViewportConfig(const ViewportConfig& config) 259623b3eb3cSopenharmony_ci{ 259723b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 259823b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 259923b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 260023b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 260123b3eb3cSopenharmony_ci auto context = NG::PipelineContext::GetCurrentContext(); 260223b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 260323b3eb3cSopenharmony_ci auto updateSessionViewportConfigTask = [id = instanceId_, config]() { 260423b3eb3cSopenharmony_ci ContainerScope scope(id); 260523b3eb3cSopenharmony_ci auto context = NG::PipelineContext::GetCurrentContext(); 260623b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 260723b3eb3cSopenharmony_ci auto uiExtMgr = context->GetUIExtensionManager(); 260823b3eb3cSopenharmony_ci if (uiExtMgr) { 260923b3eb3cSopenharmony_ci uiExtMgr->UpdateSessionViewportConfig(config); 261023b3eb3cSopenharmony_ci } 261123b3eb3cSopenharmony_ci }; 261223b3eb3cSopenharmony_ci taskExecutor->PostTask( 261323b3eb3cSopenharmony_ci std::move(updateSessionViewportConfigTask), TaskExecutor::TaskType::UI, "ArkUIUpdateSessionViewportConfig"); 261423b3eb3cSopenharmony_ci} 261523b3eb3cSopenharmony_ci 261623b3eb3cSopenharmony_civoid UIContentImpl::SetIgnoreViewSafeArea(bool ignoreViewSafeArea) 261723b3eb3cSopenharmony_ci{ 261823b3eb3cSopenharmony_ci TAG_LOGI(ACE_LAYOUT, "[%{public}s][%{public}s][%{public}d]: SetIgnoreViewSafeArea:%{public}u", 261923b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, ignoreViewSafeArea); 262023b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 262123b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 262223b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 262323b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 262423b3eb3cSopenharmony_ci const static int32_t PLATFORM_VERSION_TEN = 10; 262523b3eb3cSopenharmony_ci CHECK_NULL_VOID( 262623b3eb3cSopenharmony_ci pipeline && pipeline->GetMinPlatformVersion() >= PLATFORM_VERSION_TEN && pipeline->GetIsAppWindow()); 262723b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 262823b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 262923b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 263023b3eb3cSopenharmony_ci [container, ignoreSafeArea = ignoreViewSafeArea]() { 263123b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 263223b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 263323b3eb3cSopenharmony_ci pipelineContext->SetIgnoreViewSafeArea(ignoreSafeArea); 263423b3eb3cSopenharmony_ci }, 263523b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetIgnoreViewSafeArea"); 263623b3eb3cSopenharmony_ci} 263723b3eb3cSopenharmony_ci 263823b3eb3cSopenharmony_civoid UIContentImpl::UpdateWindowMode(OHOS::Rosen::WindowMode mode, bool hasDeco) 263923b3eb3cSopenharmony_ci{ 264023b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: UpdateWindowMode: %{public}d, hasDeco: %{public}d", 264123b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, mode, hasDeco); 264223b3eb3cSopenharmony_ci UpdateDecorVisible(mode == OHOS::Rosen::WindowMode::WINDOW_MODE_FLOATING, hasDeco); 264323b3eb3cSopenharmony_ci} 264423b3eb3cSopenharmony_ci 264523b3eb3cSopenharmony_civoid UIContentImpl::UpdateDecorVisible(bool visible, bool hasDeco) 264623b3eb3cSopenharmony_ci{ 264723b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: UpdateWindowVisible: %{public}d, hasDeco: %{public}d", 264823b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, visible, hasDeco); 264923b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 265023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 265123b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 265223b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 265323b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 265423b3eb3cSopenharmony_ci auto task = [container, visible, hasDeco]() { 265523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 265623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 265723b3eb3cSopenharmony_ci pipelineContext->ShowContainerTitle(visible, hasDeco); 265823b3eb3cSopenharmony_ci pipelineContext->ChangeDarkModeBrightness(); 265923b3eb3cSopenharmony_ci }; 266023b3eb3cSopenharmony_ci 266123b3eb3cSopenharmony_ci // Cancel the pending task 266223b3eb3cSopenharmony_ci updateDecorVisibleTask_.Cancel(); 266323b3eb3cSopenharmony_ci auto uiTaskRunner = SingleTaskExecutor::Make(taskExecutor, TaskExecutor::TaskType::UI); 266423b3eb3cSopenharmony_ci if (uiTaskRunner.IsRunOnCurrentThread()) { 266523b3eb3cSopenharmony_ci task(); 266623b3eb3cSopenharmony_ci } else { 266723b3eb3cSopenharmony_ci updateDecorVisibleTask_ = SingleTaskExecutor::CancelableTask(std::move(task)); 266823b3eb3cSopenharmony_ci taskExecutor->PostTask(updateDecorVisibleTask_, 266923b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUpdateDecorVisible"); 267023b3eb3cSopenharmony_ci } 267123b3eb3cSopenharmony_ci} 267223b3eb3cSopenharmony_ci 267323b3eb3cSopenharmony_civoid UIContentImpl::SetUIContentType(UIContentType uIContentType) 267423b3eb3cSopenharmony_ci{ 267523b3eb3cSopenharmony_ci uIContentType_ = uIContentType; 267623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 267723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 267823b3eb3cSopenharmony_ci container->SetUIContentType(uIContentType); 267923b3eb3cSopenharmony_ci} 268023b3eb3cSopenharmony_ci 268123b3eb3cSopenharmony_civoid UIContentImpl::UpdateMaximizeMode(OHOS::Rosen::MaximizeMode mode) 268223b3eb3cSopenharmony_ci{ 268323b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: UpdateMaximizeMode: %{public}d", bundleName_.c_str(), 268423b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_, mode); 268523b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 268623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 268723b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 268823b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 268923b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 269023b3eb3cSopenharmony_ci auto task = [container, mode]() { 269123b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 269223b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 269323b3eb3cSopenharmony_ci auto windowManager = pipelineContext->GetWindowManager(); 269423b3eb3cSopenharmony_ci CHECK_NULL_VOID(windowManager); 269523b3eb3cSopenharmony_ci windowManager->SetCurrentWindowMaximizeMode(static_cast<OHOS::Ace::MaximizeMode>(mode)); 269623b3eb3cSopenharmony_ci pipelineContext->ShowContainerTitle(true, true, true); 269723b3eb3cSopenharmony_ci }; 269823b3eb3cSopenharmony_ci auto uiTaskRunner = SingleTaskExecutor::Make(taskExecutor, TaskExecutor::TaskType::UI); 269923b3eb3cSopenharmony_ci if (uiTaskRunner.IsRunOnCurrentThread()) { 270023b3eb3cSopenharmony_ci task(); 270123b3eb3cSopenharmony_ci } else { 270223b3eb3cSopenharmony_ci taskExecutor->PostTask(std::move(task), TaskExecutor::TaskType::UI, "ArkUIUpdateMaximizeMode"); 270323b3eb3cSopenharmony_ci } 270423b3eb3cSopenharmony_ci} 270523b3eb3cSopenharmony_ci 270623b3eb3cSopenharmony_cibool UIContentImpl::NeedSoftKeyboard() 270723b3eb3cSopenharmony_ci{ 270823b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 270923b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 271023b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 271123b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipeline, false); 271223b3eb3cSopenharmony_ci return pipeline->NeedSoftKeyboard(); 271323b3eb3cSopenharmony_ci} 271423b3eb3cSopenharmony_ci 271523b3eb3cSopenharmony_civoid UIContentImpl::SetOnWindowFocused(const std::function<void()>& callback) 271623b3eb3cSopenharmony_ci{ 271723b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 271823b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 271923b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 272023b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 272123b3eb3cSopenharmony_ci pipeline->SetOnWindowFocused(callback); 272223b3eb3cSopenharmony_ci} 272323b3eb3cSopenharmony_ci 272423b3eb3cSopenharmony_civoid UIContentImpl::HideWindowTitleButton(bool hideSplit, bool hideMaximize, bool hideMinimize, bool hideClose) 272523b3eb3cSopenharmony_ci{ 272623b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: HideWindowTitleButton hideSplit: %{public}d, hideMaximize: %{public}d, " 272723b3eb3cSopenharmony_ci "hideMinimize: %{public}d, hideClose: %{public}d", 272823b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, hideSplit, hideMaximize, hideMinimize, hideClose); 272923b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 273023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 273123b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 273223b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 273323b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 273423b3eb3cSopenharmony_ci taskExecutor->PostTask( 273523b3eb3cSopenharmony_ci [container, hideSplit, hideMaximize, hideMinimize, hideClose]() { 273623b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 273723b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 273823b3eb3cSopenharmony_ci pipelineContext->SetContainerButtonHide(hideSplit, hideMaximize, hideMinimize, hideClose); 273923b3eb3cSopenharmony_ci }, 274023b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIHideWindowTitleButton"); 274123b3eb3cSopenharmony_ci} 274223b3eb3cSopenharmony_ci 274323b3eb3cSopenharmony_civoid UIContentImpl::UpdateTitleInTargetPos(bool isShow, int32_t height) 274423b3eb3cSopenharmony_ci{ 274523b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: UpdateTitleInTargetPos, isShow: %{public}d, height: " 274623b3eb3cSopenharmony_ci "%{public}d", 274723b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, isShow, height); 274823b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 274923b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 275023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 275123b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 275223b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 275323b3eb3cSopenharmony_ci taskExecutor->PostTask( 275423b3eb3cSopenharmony_ci [container, isShow, height]() { 275523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 275623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 275723b3eb3cSopenharmony_ci pipelineContext->UpdateTitleInTargetPos(isShow, height); 275823b3eb3cSopenharmony_ci }, 275923b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUpdateTitleInTargetPos"); 276023b3eb3cSopenharmony_ci} 276123b3eb3cSopenharmony_ci 276223b3eb3cSopenharmony_civoid UIContentImpl::NotifyRotationAnimationEnd() 276323b3eb3cSopenharmony_ci{ 276423b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 276523b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 276623b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 276723b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 276823b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 276923b3eb3cSopenharmony_ci taskExecutor->PostTask( 277023b3eb3cSopenharmony_ci [container]() { 277123b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 277223b3eb3cSopenharmony_ci if (pipelineContext) { 277323b3eb3cSopenharmony_ci pipelineContext->StopWindowAnimation(); 277423b3eb3cSopenharmony_ci } 277523b3eb3cSopenharmony_ci }, 277623b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUINotifyRotationAnimationEnd"); 277723b3eb3cSopenharmony_ci} 277823b3eb3cSopenharmony_ci 277923b3eb3cSopenharmony_civoid UIContentImpl::DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) 278023b3eb3cSopenharmony_ci{ 278123b3eb3cSopenharmony_ci std::string currentPid = std::to_string(getpid()); 278223b3eb3cSopenharmony_ci for (auto param : params) { 278323b3eb3cSopenharmony_ci if (param == currentPid) { 278423b3eb3cSopenharmony_ci LOGE("DumpInfo pid has appeared"); 278523b3eb3cSopenharmony_ci return; 278623b3eb3cSopenharmony_ci } 278723b3eb3cSopenharmony_ci } 278823b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 278923b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 279023b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 279123b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 279223b3eb3cSopenharmony_ci auto ret = taskExecutor->PostSyncTaskTimeout( 279323b3eb3cSopenharmony_ci [&]() { container->Dump(params, info); }, TaskExecutor::TaskType::UI, 1500, "ArkUIDumpInfo"); // timeout 1.5s 279423b3eb3cSopenharmony_ci if (!ret) { 279523b3eb3cSopenharmony_ci LOGE("DumpInfo failed"); 279623b3eb3cSopenharmony_ci } 279723b3eb3cSopenharmony_ci} 279823b3eb3cSopenharmony_ci 279923b3eb3cSopenharmony_civoid UIContentImpl::UpdateDialogResourceConfiguration(RefPtr<Container>& container, 280023b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::AbilityRuntime::Context>& context) 280123b3eb3cSopenharmony_ci{ 280223b3eb3cSopenharmony_ci auto dialogContainer = AceType::DynamicCast<Platform::DialogContainer>(container); 280323b3eb3cSopenharmony_ci if (dialogContainer) { 280423b3eb3cSopenharmony_ci std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig()); 280523b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 280623b3eb3cSopenharmony_ci auto resourceManager = context->GetResourceManager(); 280723b3eb3cSopenharmony_ci if (resourceManager != nullptr) { 280823b3eb3cSopenharmony_ci resourceManager->GetResConfig(*resConfig); 280923b3eb3cSopenharmony_ci if (resConfig->GetColorMode() == OHOS::Global::Resource::ColorMode::DARK) { 281023b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::DARK); 281123b3eb3cSopenharmony_ci } else { 281223b3eb3cSopenharmony_ci SystemProperties::SetColorMode(ColorMode::LIGHT); 281323b3eb3cSopenharmony_ci } 281423b3eb3cSopenharmony_ci } 281523b3eb3cSopenharmony_ci auto aceResCfg = dialogContainer->GetResourceConfiguration(); 281623b3eb3cSopenharmony_ci aceResCfg.SetOrientation(SystemProperties::GetDeviceOrientation()); 281723b3eb3cSopenharmony_ci aceResCfg.SetDensity(SystemProperties::GetResolution()); 281823b3eb3cSopenharmony_ci aceResCfg.SetDeviceType(SystemProperties::GetDeviceType()); 281923b3eb3cSopenharmony_ci aceResCfg.SetColorMode(SystemProperties::GetColorMode()); 282023b3eb3cSopenharmony_ci aceResCfg.SetDeviceAccess(SystemProperties::GetDeviceAccess()); 282123b3eb3cSopenharmony_ci aceResCfg.SetColorModeIsSetByApp(true); 282223b3eb3cSopenharmony_ci dialogContainer->SetResourceConfiguration(aceResCfg); 282323b3eb3cSopenharmony_ci } 282423b3eb3cSopenharmony_ci} 282523b3eb3cSopenharmony_ci 282623b3eb3cSopenharmony_civoid UIContentImpl::InitializeSubWindow(OHOS::Rosen::Window* window, bool isDialog) 282723b3eb3cSopenharmony_ci{ 282823b3eb3cSopenharmony_ci window_ = window; 282923b3eb3cSopenharmony_ci LOGI("InitSubwindow: %{public}s", window->GetWindowName().c_str()); 283023b3eb3cSopenharmony_ci CHECK_NULL_VOID(window_); 283123b3eb3cSopenharmony_ci RefPtr<Container> container; 283223b3eb3cSopenharmony_ci instanceId_ = Container::GenerateId<COMPONENT_SUBWINDOW_CONTAINER>(); 283323b3eb3cSopenharmony_ci int32_t deviceWidth = 0; 283423b3eb3cSopenharmony_ci int32_t deviceHeight = 0; 283523b3eb3cSopenharmony_ci float density = 1.0f; 283623b3eb3cSopenharmony_ci auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay(); 283723b3eb3cSopenharmony_ci if (defaultDisplay) { 283823b3eb3cSopenharmony_ci auto displayInfo = defaultDisplay->GetDisplayInfo(); 283923b3eb3cSopenharmony_ci if (displayInfo) { 284023b3eb3cSopenharmony_ci density = displayInfo->GetDensityInCurResolution(); 284123b3eb3cSopenharmony_ci } 284223b3eb3cSopenharmony_ci deviceWidth = defaultDisplay->GetWidth(); 284323b3eb3cSopenharmony_ci deviceHeight = defaultDisplay->GetHeight(); 284423b3eb3cSopenharmony_ci } 284523b3eb3cSopenharmony_ci SystemProperties::InitDeviceInfo(deviceWidth, deviceHeight, deviceHeight >= deviceWidth ? 0 : 1, density, false); 284623b3eb3cSopenharmony_ci std::weak_ptr<OHOS::AppExecFwk::AbilityInfo> abilityInfo; 284723b3eb3cSopenharmony_ci auto context = context_.lock(); 284823b3eb3cSopenharmony_ci bool isCJFrontend = CJUtils::IsCJFrontendContext(context.get()); 284923b3eb3cSopenharmony_ci auto frontendType = isCJFrontend ? FrontendType::DECLARATIVE_CJ : FrontendType::DECLARATIVE_JS; 285023b3eb3cSopenharmony_ci if (isDialog) { 285123b3eb3cSopenharmony_ci UErrorCode status = U_ZERO_ERROR; 285223b3eb3cSopenharmony_ci icu::Locale locale = icu::Locale::forLanguageTag(Global::I18n::LocaleConfig::GetSystemLanguage(), status); 285323b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetLocale(locale.getLanguage(), locale.getCountry(), locale.getScript(), ""); 285423b3eb3cSopenharmony_ci container = AceType::MakeRefPtr<Platform::DialogContainer>(instanceId_, FrontendType::DECLARATIVE_JS); 285523b3eb3cSopenharmony_ci UpdateDialogResourceConfiguration(container, context); 285623b3eb3cSopenharmony_ci } else { 285723b3eb3cSopenharmony_ci#ifdef NG_BUILD 285823b3eb3cSopenharmony_ci container = AceType::MakeRefPtr<Platform::AceContainer>(instanceId_, frontendType, 285923b3eb3cSopenharmony_ci context, abilityInfo, std::make_unique<ContentEventCallback>([] { 286023b3eb3cSopenharmony_ci // Sub-window ,just return. 286123b3eb3cSopenharmony_ci }), false, true, true); 286223b3eb3cSopenharmony_ci#else 286323b3eb3cSopenharmony_ci if (Container::IsCurrentUseNewPipeline()) { 286423b3eb3cSopenharmony_ci container = AceType::MakeRefPtr<Platform::AceContainer>(instanceId_, frontendType, 286523b3eb3cSopenharmony_ci context, abilityInfo, std::make_unique<ContentEventCallback>([] { 286623b3eb3cSopenharmony_ci // Sub-window ,just return. 286723b3eb3cSopenharmony_ci }), false, true, true); 286823b3eb3cSopenharmony_ci } else { 286923b3eb3cSopenharmony_ci container = AceType::MakeRefPtr<Platform::AceContainer>(instanceId_, frontendType, 287023b3eb3cSopenharmony_ci context, abilityInfo, std::make_unique<ContentEventCallback>([] { 287123b3eb3cSopenharmony_ci // Sub-window ,just return. 287223b3eb3cSopenharmony_ci }), false, true); 287323b3eb3cSopenharmony_ci } 287423b3eb3cSopenharmony_ci#endif 287523b3eb3cSopenharmony_ci } 287623b3eb3cSopenharmony_ci if (context) { 287723b3eb3cSopenharmony_ci if (context->GetApplicationInfo()) { 287823b3eb3cSopenharmony_ci auto appInfo = context->GetApplicationInfo(); 287923b3eb3cSopenharmony_ci container->SetApiTargetVersion(appInfo->apiTargetVersion); 288023b3eb3cSopenharmony_ci } 288123b3eb3cSopenharmony_ci 288223b3eb3cSopenharmony_ci container->SetBundlePath(context->GetBundleCodeDir()); 288323b3eb3cSopenharmony_ci container->SetFilesDataPath(context->GetFilesDir()); 288423b3eb3cSopenharmony_ci } else { 288523b3eb3cSopenharmony_ci // if window don't have context,like service eject a toast,find target version in bundle. 288623b3eb3cSopenharmony_ci auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); 288723b3eb3cSopenharmony_ci CHECK_NULL_VOID(systemAbilityMgr); 288823b3eb3cSopenharmony_ci auto bundleObj = systemAbilityMgr->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); 288923b3eb3cSopenharmony_ci CHECK_NULL_VOID(bundleObj); 289023b3eb3cSopenharmony_ci auto bundleMgrProxy = iface_cast<AppExecFwk::IBundleMgr>(bundleObj); 289123b3eb3cSopenharmony_ci CHECK_NULL_VOID(bundleMgrProxy); 289223b3eb3cSopenharmony_ci AppExecFwk::BundleInfo bundleInfo; 289323b3eb3cSopenharmony_ci bundleMgrProxy->GetBundleInfoForSelf( 289423b3eb3cSopenharmony_ci static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo); 289523b3eb3cSopenharmony_ci container->SetApiTargetVersion(bundleInfo.targetVersion % 1000); 289623b3eb3cSopenharmony_ci } 289723b3eb3cSopenharmony_ci SubwindowManager::GetInstance()->AddContainerId(window->GetWindowId(), instanceId_); 289823b3eb3cSopenharmony_ci AceEngine::Get().AddContainer(instanceId_, container); 289923b3eb3cSopenharmony_ci if (!StringUtils::StartWith(window_->GetWindowName(), SUBWINDOW_TOAST_PREFIX)) { 290023b3eb3cSopenharmony_ci touchOutsideListener_ = new TouchOutsideListener(instanceId_); 290123b3eb3cSopenharmony_ci window_->RegisterTouchOutsideListener(touchOutsideListener_); 290223b3eb3cSopenharmony_ci } 290323b3eb3cSopenharmony_ci dragWindowListener_ = new DragWindowListener(instanceId_); 290423b3eb3cSopenharmony_ci window_->RegisterDragListener(dragWindowListener_); 290523b3eb3cSopenharmony_ci occupiedAreaChangeListener_ = new OccupiedAreaChangeListener(instanceId_); 290623b3eb3cSopenharmony_ci window_->RegisterOccupiedAreaChangeListener(occupiedAreaChangeListener_); 290723b3eb3cSopenharmony_ci foldStatusListener_ = new FoldScreenListener(instanceId_); 290823b3eb3cSopenharmony_ci OHOS::Rosen::DisplayManager::GetInstance().RegisterFoldStatusListener(foldStatusListener_); 290923b3eb3cSopenharmony_ci foldDisplayModeListener_ = new FoldDisplayModeListener(instanceId_, isDialog); 291023b3eb3cSopenharmony_ci OHOS::Rosen::DisplayManager::GetInstance().RegisterDisplayModeListener(foldDisplayModeListener_); 291123b3eb3cSopenharmony_ci} 291223b3eb3cSopenharmony_ci 291323b3eb3cSopenharmony_civoid UIContentImpl::SetNextFrameLayoutCallback(std::function<void()>&& callback) 291423b3eb3cSopenharmony_ci{ 291523b3eb3cSopenharmony_ci CHECK_NULL_VOID(callback); 291623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 291723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 291823b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 291923b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 292023b3eb3cSopenharmony_ci pipelineContext->SetNextFrameLayoutCallback(std::move(callback)); 292123b3eb3cSopenharmony_ci} 292223b3eb3cSopenharmony_ci 292323b3eb3cSopenharmony_civoid UIContentImpl::SetFrameLayoutFinishCallback(std::function<void()>&& callback) 292423b3eb3cSopenharmony_ci{ 292523b3eb3cSopenharmony_ci CHECK_NULL_VOID(callback); 292623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 292723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 292823b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 292923b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 293023b3eb3cSopenharmony_ci pipelineContext->AddPersistAfterLayoutTask(std::move(callback)); 293123b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: SetFrameLayoutFinishCallback", bundleName_.c_str(), 293223b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_); 293323b3eb3cSopenharmony_ci} 293423b3eb3cSopenharmony_ci 293523b3eb3cSopenharmony_civoid UIContentImpl::SetLastestFrameLayoutFinishCallback(std::function<void()>&& callback) 293623b3eb3cSopenharmony_ci{ 293723b3eb3cSopenharmony_ci CHECK_NULL_VOID(callback); 293823b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 293923b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 294023b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 294123b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 294223b3eb3cSopenharmony_ci pipelineContext->AddLastestFrameLayoutFinishTask(std::move(callback)); 294323b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: SetLastestFrameLayoutFinishCallback", bundleName_.c_str(), 294423b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_); 294523b3eb3cSopenharmony_ci} 294623b3eb3cSopenharmony_ci 294723b3eb3cSopenharmony_civoid UIContentImpl::NotifyMemoryLevel(int32_t level) 294823b3eb3cSopenharmony_ci{ 294923b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: NotifyMemoryLevel: %{public}d", 295023b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, level); 295123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 295223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 295323b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 295423b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 295523b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 295623b3eb3cSopenharmony_ci pipelineContext->NotifyMemoryLevel(level); 295723b3eb3cSopenharmony_ci} 295823b3eb3cSopenharmony_ci 295923b3eb3cSopenharmony_civoid UIContentImpl::SetAppWindowTitle(const std::string& title) 296023b3eb3cSopenharmony_ci{ 296123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 296223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 296323b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 296423b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 296523b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 296623b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: setAppTitle", bundleName_.c_str(), moduleName_.c_str(), instanceId_); 296723b3eb3cSopenharmony_ci pipelineContext->SetAppTitle(title); 296823b3eb3cSopenharmony_ci} 296923b3eb3cSopenharmony_ci 297023b3eb3cSopenharmony_civoid UIContentImpl::SetAppWindowIcon(const std::shared_ptr<Media::PixelMap>& pixelMap) 297123b3eb3cSopenharmony_ci{ 297223b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 297323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 297423b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 297523b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 297623b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 297723b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: setAppIcon", bundleName_.c_str(), moduleName_.c_str(), instanceId_); 297823b3eb3cSopenharmony_ci pipelineContext->SetAppIcon(AceType::MakeRefPtr<PixelMapOhos>(pixelMap)); 297923b3eb3cSopenharmony_ci} 298023b3eb3cSopenharmony_ci 298123b3eb3cSopenharmony_civoid UIContentImpl::UpdateFormData(const std::string& data) 298223b3eb3cSopenharmony_ci{ 298323b3eb3cSopenharmony_ci if (isFormRenderInit_) { 298423b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 298523b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 298623b3eb3cSopenharmony_ci container->UpdateFormData(data); 298723b3eb3cSopenharmony_ci } else { 298823b3eb3cSopenharmony_ci formData_ = data; 298923b3eb3cSopenharmony_ci } 299023b3eb3cSopenharmony_ci} 299123b3eb3cSopenharmony_ci 299223b3eb3cSopenharmony_civoid UIContentImpl::UpdateFormSharedImage(const std::map<std::string, sptr<OHOS::AppExecFwk::FormAshmem>>& imageDataMap) 299323b3eb3cSopenharmony_ci{ 299423b3eb3cSopenharmony_ci if (isFormRenderInit_) { 299523b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 299623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 299723b3eb3cSopenharmony_ci container->UpdateFormSharedImage(imageDataMap); 299823b3eb3cSopenharmony_ci } else { 299923b3eb3cSopenharmony_ci formImageDataMap_ = imageDataMap; 300023b3eb3cSopenharmony_ci } 300123b3eb3cSopenharmony_ci} 300223b3eb3cSopenharmony_ci 300323b3eb3cSopenharmony_civoid UIContentImpl::SetActionEventHandler(std::function<void(const std::string& action)>&& actionCallback) 300423b3eb3cSopenharmony_ci{ 300523b3eb3cSopenharmony_ci CHECK_NULL_VOID(actionCallback); 300623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 300723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 300823b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 300923b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 301023b3eb3cSopenharmony_ci pipelineContext->SetActionEventHandler(std::move(actionCallback)); 301123b3eb3cSopenharmony_ci} 301223b3eb3cSopenharmony_ci 301323b3eb3cSopenharmony_civoid UIContentImpl::SetFormLinkInfoUpdateHandler(std::function<void(const std::vector<std::string>&)>&& callback) 301423b3eb3cSopenharmony_ci{ 301523b3eb3cSopenharmony_ci CHECK_NULL_VOID(callback); 301623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 301723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 301823b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 301923b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 302023b3eb3cSopenharmony_ci pipelineContext->SetFormLinkInfoUpdateHandler(std::move(callback)); 302123b3eb3cSopenharmony_ci} 302223b3eb3cSopenharmony_ci 302323b3eb3cSopenharmony_civoid UIContentImpl::RegisterAccessibilityChildTree( 302423b3eb3cSopenharmony_ci uint32_t parentWindowId, int32_t parentTreeId, int64_t parentElementId) 302523b3eb3cSopenharmony_ci{ 302623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 302723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 302823b3eb3cSopenharmony_ci auto front = container->GetFrontend(); 302923b3eb3cSopenharmony_ci CHECK_NULL_VOID(front); 303023b3eb3cSopenharmony_ci auto accessibilityManager = front->GetAccessibilityManager(); 303123b3eb3cSopenharmony_ci CHECK_NULL_VOID(accessibilityManager); 303223b3eb3cSopenharmony_ci accessibilityManager->RegisterInteractionOperationAsChildTree(parentWindowId, parentTreeId, parentElementId); 303323b3eb3cSopenharmony_ci} 303423b3eb3cSopenharmony_ci 303523b3eb3cSopenharmony_civoid UIContentImpl::SetAccessibilityGetParentRectHandler(std::function<void(int32_t&, int32_t&)>&& callback) 303623b3eb3cSopenharmony_ci{ 303723b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 303823b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 303923b3eb3cSopenharmony_ci auto front = container->GetFrontend(); 304023b3eb3cSopenharmony_ci CHECK_NULL_VOID(front); 304123b3eb3cSopenharmony_ci auto accessibilityManager = front->GetAccessibilityManager(); 304223b3eb3cSopenharmony_ci CHECK_NULL_VOID(accessibilityManager); 304323b3eb3cSopenharmony_ci accessibilityManager->SetAccessibilityGetParentRectHandler(std::move(callback)); 304423b3eb3cSopenharmony_ci} 304523b3eb3cSopenharmony_ci 304623b3eb3cSopenharmony_civoid UIContentImpl::SetAccessibilityGetParentRectHandler( 304723b3eb3cSopenharmony_ci std::function<void(AccessibilityParentRectInfo&)>&& callback) 304823b3eb3cSopenharmony_ci{ 304923b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 305023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 305123b3eb3cSopenharmony_ci auto front = container->GetFrontend(); 305223b3eb3cSopenharmony_ci CHECK_NULL_VOID(front); 305323b3eb3cSopenharmony_ci auto accessibilityManager = front->GetAccessibilityManager(); 305423b3eb3cSopenharmony_ci CHECK_NULL_VOID(accessibilityManager); 305523b3eb3cSopenharmony_ci accessibilityManager->SetAccessibilityGetParentRectHandler(std::move(callback)); 305623b3eb3cSopenharmony_ci} 305723b3eb3cSopenharmony_ci 305823b3eb3cSopenharmony_civoid UIContentImpl::DeregisterAccessibilityChildTree() 305923b3eb3cSopenharmony_ci{ 306023b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 306123b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 306223b3eb3cSopenharmony_ci auto front = container->GetFrontend(); 306323b3eb3cSopenharmony_ci CHECK_NULL_VOID(front); 306423b3eb3cSopenharmony_ci auto accessibilityManager = front->GetAccessibilityManager(); 306523b3eb3cSopenharmony_ci CHECK_NULL_VOID(accessibilityManager); 306623b3eb3cSopenharmony_ci accessibilityManager->DeregisterInteractionOperationAsChildTree(); 306723b3eb3cSopenharmony_ci} 306823b3eb3cSopenharmony_ci 306923b3eb3cSopenharmony_civoid UIContentImpl::AccessibilityDumpChildInfo(const std::vector<std::string>& params, std::vector<std::string>& info) 307023b3eb3cSopenharmony_ci{ 307123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 307223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 307323b3eb3cSopenharmony_ci container->Dump(params, info); 307423b3eb3cSopenharmony_ci} 307523b3eb3cSopenharmony_ci 307623b3eb3cSopenharmony_civoid UIContentImpl::SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& errorCallback) 307723b3eb3cSopenharmony_ci{ 307823b3eb3cSopenharmony_ci CHECK_NULL_VOID(errorCallback); 307923b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 308023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 308123b3eb3cSopenharmony_ci auto front = container->GetFrontend(); 308223b3eb3cSopenharmony_ci CHECK_NULL_VOID(front); 308323b3eb3cSopenharmony_ci return front->SetErrorEventHandler(std::move(errorCallback)); 308423b3eb3cSopenharmony_ci} 308523b3eb3cSopenharmony_ci 308623b3eb3cSopenharmony_civoid UIContentImpl::OnFormSurfaceChange(float width, float height, OHOS::Rosen::WindowSizeChangeReason type, 308723b3eb3cSopenharmony_ci const std::shared_ptr<Rosen::RSTransaction>& rsTransaction) 308823b3eb3cSopenharmony_ci{ 308923b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 309023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 309123b3eb3cSopenharmony_ci int32_t formWidth = round(width); 309223b3eb3cSopenharmony_ci int32_t formHeight = round(height); 309323b3eb3cSopenharmony_ci auto aceView = AceType::DynamicCast<Platform::AceViewOhos>(container->GetAceView()); 309423b3eb3cSopenharmony_ci Platform::AceViewOhos::ChangeViewSize(aceView, formWidth, formHeight); 309523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 309623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 309723b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 309823b3eb3cSopenharmony_ci auto density = pipelineContext->GetDensity(); 309923b3eb3cSopenharmony_ci pipelineContext->SetRootSize(density, formWidth, formHeight); 310023b3eb3cSopenharmony_ci pipelineContext->OnSurfaceChanged(formWidth, formHeight, static_cast<WindowSizeChangeReason>(type), rsTransaction); 310123b3eb3cSopenharmony_ci} 310223b3eb3cSopenharmony_ci 310323b3eb3cSopenharmony_civoid UIContentImpl::SetFormBackgroundColor(const std::string& color) 310423b3eb3cSopenharmony_ci{ 310523b3eb3cSopenharmony_ci LOGI("[%{public}s][%{public}s][%{public}d]: SetFormBackgroundColor: %{public}s", 310623b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, color.c_str()); 310723b3eb3cSopenharmony_ci if (!Rosen::RSSystemProperties::GetUniRenderEnabled()) { 310823b3eb3cSopenharmony_ci // cannot set transparent background effects in not-uniform-render mode 310923b3eb3cSopenharmony_ci return; 311023b3eb3cSopenharmony_ci } 311123b3eb3cSopenharmony_ci Color bgColor; 311223b3eb3cSopenharmony_ci if (!Color::ParseColorString(color, bgColor)) { 311323b3eb3cSopenharmony_ci return; 311423b3eb3cSopenharmony_ci } 311523b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 311623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 311723b3eb3cSopenharmony_ci auto aceContainer = AceType::DynamicCast<Platform::AceContainer>(container); 311823b3eb3cSopenharmony_ci if (aceContainer) { 311923b3eb3cSopenharmony_ci aceContainer->SetIsUseCustomBg(true); 312023b3eb3cSopenharmony_ci } 312123b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 312223b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 312323b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 312423b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 312523b3eb3cSopenharmony_ci [container, bgColor]() { 312623b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 312723b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 312823b3eb3cSopenharmony_ci pipelineContext->SetAppBgColor(bgColor); 312923b3eb3cSopenharmony_ci }, 313023b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetFormBackgroundColor"); 313123b3eb3cSopenharmony_ci} 313223b3eb3cSopenharmony_ci 313323b3eb3cSopenharmony_civoid UIContentImpl::SetFontScaleFollowSystem(const bool fontScaleFollowSystem) 313423b3eb3cSopenharmony_ci{ 313523b3eb3cSopenharmony_ci LOGI("SetFontScaleFollowSystem: %{public}d", fontScaleFollowSystem); 313623b3eb3cSopenharmony_ci fontScaleFollowSystem_ = fontScaleFollowSystem; 313723b3eb3cSopenharmony_ci} 313823b3eb3cSopenharmony_ci 313923b3eb3cSopenharmony_civoid UIContentImpl::SetFormRenderingMode(int8_t renderMode) 314023b3eb3cSopenharmony_ci{ 314123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 314223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 314323b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 314423b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 314523b3eb3cSopenharmony_ci pipelineContext->SetFormRenderingMode(renderMode); 314623b3eb3cSopenharmony_ci} 314723b3eb3cSopenharmony_ci 314823b3eb3cSopenharmony_civoid UIContentImpl::GetResourcePaths(std::vector<std::string>& resourcesPaths, std::string& assetRootPath, 314923b3eb3cSopenharmony_ci std::vector<std::string>& assetBasePaths, std::string& resFolderName) 315023b3eb3cSopenharmony_ci{ 315123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 315223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 315323b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 315423b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 315523b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 315623b3eb3cSopenharmony_ci taskExecutor->PostTask( 315723b3eb3cSopenharmony_ci [container]() { 315823b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 315923b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 316023b3eb3cSopenharmony_ci }, 316123b3eb3cSopenharmony_ci TaskExecutor::TaskType::PLATFORM, "ArkUIGetResourcePaths"); 316223b3eb3cSopenharmony_ci} 316323b3eb3cSopenharmony_ci 316423b3eb3cSopenharmony_civoid UIContentImpl::SetResourcePaths(const std::vector<std::string>& resourcesPaths, const std::string& assetRootPath, 316523b3eb3cSopenharmony_ci const std::vector<std::string>& assetBasePaths) 316623b3eb3cSopenharmony_ci{ 316723b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 316823b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 316923b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 317023b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 317123b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 317223b3eb3cSopenharmony_ci taskExecutor->PostTask( 317323b3eb3cSopenharmony_ci [container, resourcesPaths, assetRootPath, assetBasePaths]() { 317423b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 317523b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 317623b3eb3cSopenharmony_ci auto assetManager = pipelineContext->GetAssetManager(); 317723b3eb3cSopenharmony_ci CHECK_NULL_VOID(assetManager); 317823b3eb3cSopenharmony_ci auto themeManager = pipelineContext->GetThemeManager(); 317923b3eb3cSopenharmony_ci CHECK_NULL_VOID(themeManager); 318023b3eb3cSopenharmony_ci 318123b3eb3cSopenharmony_ci if (resourcesPaths.empty() && assetRootPath.empty()) { 318223b3eb3cSopenharmony_ci return; 318323b3eb3cSopenharmony_ci } 318423b3eb3cSopenharmony_ci 318523b3eb3cSopenharmony_ci if (!assetRootPath.empty()) { 318623b3eb3cSopenharmony_ci auto fileAssetProviderImpl = AceType::MakeRefPtr<FileAssetProviderImpl>(); 318723b3eb3cSopenharmony_ci if (fileAssetProviderImpl->Initialize(assetRootPath, assetBasePaths)) { 318823b3eb3cSopenharmony_ci assetManager->PushBack(std::move(fileAssetProviderImpl)); 318923b3eb3cSopenharmony_ci } 319023b3eb3cSopenharmony_ci return; 319123b3eb3cSopenharmony_ci } 319223b3eb3cSopenharmony_ci for (auto iter = resourcesPaths.begin(); iter != resourcesPaths.end(); iter++) { 319323b3eb3cSopenharmony_ci auto hapAssetProviderImpl = AceType::MakeRefPtr<HapAssetProviderImpl>(); 319423b3eb3cSopenharmony_ci if (hapAssetProviderImpl->Initialize(*iter, assetBasePaths)) { 319523b3eb3cSopenharmony_ci assetManager->PushBack(std::move(hapAssetProviderImpl)); 319623b3eb3cSopenharmony_ci } 319723b3eb3cSopenharmony_ci } 319823b3eb3cSopenharmony_ci }, 319923b3eb3cSopenharmony_ci TaskExecutor::TaskType::PLATFORM, "ArkUISetResourcePaths"); 320023b3eb3cSopenharmony_ci} 320123b3eb3cSopenharmony_ci 320223b3eb3cSopenharmony_civoid UIContentImpl::SetIsFocusActive(bool isFocusActive) 320323b3eb3cSopenharmony_ci{ 320423b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 320523b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 320623b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 320723b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 320823b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 320923b3eb3cSopenharmony_ci taskExecutor->PostTask( 321023b3eb3cSopenharmony_ci [container, isFocusActive]() { 321123b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 321223b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 321323b3eb3cSopenharmony_ci ContainerScope scope(container->GetInstanceId()); 321423b3eb3cSopenharmony_ci pipelineContext->SetIsFocusActive(isFocusActive); 321523b3eb3cSopenharmony_ci }, 321623b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetIsFocusActive"); 321723b3eb3cSopenharmony_ci} 321823b3eb3cSopenharmony_ci 321923b3eb3cSopenharmony_civoid UIContentImpl::UpdateResource() 322023b3eb3cSopenharmony_ci{ 322123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 322223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 322323b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 322423b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 322523b3eb3cSopenharmony_ci taskExecutor->PostTask([container]() { container->UpdateResource(); }, 322623b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUpdateResource"); 322723b3eb3cSopenharmony_ci} 322823b3eb3cSopenharmony_ci 322923b3eb3cSopenharmony_ciint32_t UIContentImpl::CreateModalUIExtension( 323023b3eb3cSopenharmony_ci const AAFwk::Want& want, const ModalUIExtensionCallbacks& callbacks, const ModalUIExtensionConfig& config) 323123b3eb3cSopenharmony_ci{ 323223b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 323323b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, 0); 323423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 323523b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 323623b3eb3cSopenharmony_ci CHECK_NULL_RETURN(taskExecutor, 0); 323723b3eb3cSopenharmony_ci int32_t sessionId = 0; 323823b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 323923b3eb3cSopenharmony_ci [container, &sessionId, want, callbacks = callbacks, config = config]() { 324023b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 324123b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 324223b3eb3cSopenharmony_ci auto overlay = pipeline->GetOverlayManager(); 324323b3eb3cSopenharmony_ci CHECK_NULL_VOID(overlay); 324423b3eb3cSopenharmony_ci sessionId = overlay->CreateModalUIExtension(want, callbacks, config); 324523b3eb3cSopenharmony_ci }, 324623b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUICreateModalUIExtension"); 324723b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_UIEXTENSIONCOMPONENT, 324823b3eb3cSopenharmony_ci "[%{public}s][%{public}s][%{public}d]: create modal page, " 324923b3eb3cSopenharmony_ci "sessionId=%{public}d, isProhibitBack=%{public}d, isAsyncModalBinding=%{public}d, " 325023b3eb3cSopenharmony_ci "isAllowedBeCovered=%{public}d, prohibitedRemoveByRouter=%{public}d, " 325123b3eb3cSopenharmony_ci "isAllowAddChildBelowModalUec=%{public}d", 325223b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, sessionId, config.isProhibitBack, 325323b3eb3cSopenharmony_ci config.isAsyncModalBinding, config.isAllowedBeCovered, config.prohibitedRemoveByRouter, 325423b3eb3cSopenharmony_ci config.isAllowAddChildBelowModalUec); 325523b3eb3cSopenharmony_ci return sessionId; 325623b3eb3cSopenharmony_ci} 325723b3eb3cSopenharmony_ci 325823b3eb3cSopenharmony_civoid UIContentImpl::CloseModalUIExtension(int32_t sessionId) 325923b3eb3cSopenharmony_ci{ 326023b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_UIEXTENSIONCOMPONENT, 326123b3eb3cSopenharmony_ci "[%{public}s][%{public}s][%{public}d]: close modal page, " 326223b3eb3cSopenharmony_ci "sessionId=%{public}d", 326323b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, sessionId); 326423b3eb3cSopenharmony_ci if (sessionId == 0) { 326523b3eb3cSopenharmony_ci LOGW("UIExtension refuse to close modal page"); 326623b3eb3cSopenharmony_ci return; 326723b3eb3cSopenharmony_ci } 326823b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 326923b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 327023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 327123b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 327223b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 327323b3eb3cSopenharmony_ci taskExecutor->PostTask( 327423b3eb3cSopenharmony_ci [container, sessionId]() { 327523b3eb3cSopenharmony_ci auto pipeline = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 327623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 327723b3eb3cSopenharmony_ci auto overlay = pipeline->GetOverlayManager(); 327823b3eb3cSopenharmony_ci CHECK_NULL_VOID(overlay); 327923b3eb3cSopenharmony_ci overlay->CloseModalUIExtension(sessionId); 328023b3eb3cSopenharmony_ci }, 328123b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUICloseModalUIExtension"); 328223b3eb3cSopenharmony_ci} 328323b3eb3cSopenharmony_ci 328423b3eb3cSopenharmony_civoid UIContentImpl::SetParentToken(sptr<IRemoteObject> token) 328523b3eb3cSopenharmony_ci{ 328623b3eb3cSopenharmony_ci parentToken_ = token; 328723b3eb3cSopenharmony_ci} 328823b3eb3cSopenharmony_ci 328923b3eb3cSopenharmony_cisptr<IRemoteObject> UIContentImpl::GetParentToken() 329023b3eb3cSopenharmony_ci{ 329123b3eb3cSopenharmony_ci return parentToken_; 329223b3eb3cSopenharmony_ci} 329323b3eb3cSopenharmony_ci 329423b3eb3cSopenharmony_cibool UIContentImpl::CheckNeedAutoSave() 329523b3eb3cSopenharmony_ci{ 329623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 329723b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 329823b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 329923b3eb3cSopenharmony_ci CHECK_NULL_RETURN(taskExecutor, false); 330023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 330123b3eb3cSopenharmony_ci bool needAutoSave = false; 330223b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 330323b3eb3cSopenharmony_ci [&needAutoSave, container]() { 330423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 330523b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 330623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 330723b3eb3cSopenharmony_ci needAutoSave = pipelineContext->CheckNeedAutoSave(); 330823b3eb3cSopenharmony_ci }, 330923b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUICheckNeedAutoSave"); 331023b3eb3cSopenharmony_ci 331123b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "UIContentImpl CheckNeedAutoSave, value is %{public}d", needAutoSave); 331223b3eb3cSopenharmony_ci return needAutoSave; 331323b3eb3cSopenharmony_ci} 331423b3eb3cSopenharmony_ci 331523b3eb3cSopenharmony_cibool UIContentImpl::DumpViewData(AbilityBase::ViewData& viewData, AbilityBase::AutoFillType& type) 331623b3eb3cSopenharmony_ci{ 331723b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 331823b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 331923b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 332023b3eb3cSopenharmony_ci CHECK_NULL_RETURN(taskExecutor, false); 332123b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 332223b3eb3cSopenharmony_ci bool ret = false; 332323b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 332423b3eb3cSopenharmony_ci [this, &ret, &viewData]() { 332523b3eb3cSopenharmony_ci auto viewDataWrap = ViewDataWrap::CreateViewDataWrap(); 332623b3eb3cSopenharmony_ci CHECK_NULL_VOID(viewDataWrap); 332723b3eb3cSopenharmony_ci ret = DumpViewData(nullptr, viewDataWrap); 332823b3eb3cSopenharmony_ci auto viewDataWrapOhos = AceType::DynamicCast<ViewDataWrapOhos>(viewDataWrap); 332923b3eb3cSopenharmony_ci CHECK_NULL_VOID(viewDataWrapOhos); 333023b3eb3cSopenharmony_ci viewData = viewDataWrapOhos->GetViewData(); 333123b3eb3cSopenharmony_ci }, 333223b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIDumpViewData"); 333323b3eb3cSopenharmony_ci type = ViewDataWrap::ViewDataToType(viewData); 333423b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "UIContentImpl DumpViewData, ret is %{public}d", ret); 333523b3eb3cSopenharmony_ci return ret; 333623b3eb3cSopenharmony_ci} 333723b3eb3cSopenharmony_ci 333823b3eb3cSopenharmony_cibool UIContentImpl::DumpViewData(const RefPtr<NG::FrameNode>& node, RefPtr<ViewDataWrap> viewDataWrap, 333923b3eb3cSopenharmony_ci bool skipSubAutoFillContainer, bool needsRecordData) 334023b3eb3cSopenharmony_ci{ 334123b3eb3cSopenharmony_ci CHECK_NULL_RETURN(viewDataWrap, false); 334223b3eb3cSopenharmony_ci auto context = context_.lock(); 334323b3eb3cSopenharmony_ci auto abilityContext = OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::AbilityContext>(context); 334423b3eb3cSopenharmony_ci std::shared_ptr<OHOS::AppExecFwk::AbilityInfo> info; 334523b3eb3cSopenharmony_ci if (abilityContext) { 334623b3eb3cSopenharmony_ci info = abilityContext->GetAbilityInfo(); 334723b3eb3cSopenharmony_ci } else { 334823b3eb3cSopenharmony_ci auto extensionContext = 334923b3eb3cSopenharmony_ci OHOS::AbilityRuntime::Context::ConvertTo<OHOS::AbilityRuntime::ExtensionContext>(context); 335023b3eb3cSopenharmony_ci if (extensionContext) { 335123b3eb3cSopenharmony_ci info = extensionContext->GetAbilityInfo(); 335223b3eb3cSopenharmony_ci } else { 335323b3eb3cSopenharmony_ci TAG_LOGE(AceLogTag::ACE_AUTO_FILL, "context is not AbilityContext or ExtensionContext."); 335423b3eb3cSopenharmony_ci return false; 335523b3eb3cSopenharmony_ci } 335623b3eb3cSopenharmony_ci } 335723b3eb3cSopenharmony_ci CHECK_NULL_RETURN(info, false); 335823b3eb3cSopenharmony_ci viewDataWrap->SetAbilityName(info->name); 335923b3eb3cSopenharmony_ci viewDataWrap->SetModuleName(info->moduleName); 336023b3eb3cSopenharmony_ci viewDataWrap->SetBundleName(info->bundleName); 336123b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_AUTO_FILL, "bundleName=[%{private}s], moduleName=[%{private}s], abilityName=[%{private}s]", 336223b3eb3cSopenharmony_ci info->bundleName.c_str(), info->moduleName.c_str(), info->name.c_str()); 336323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 336423b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 336523b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 336623b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipelineContext, false); 336723b3eb3cSopenharmony_ci return pipelineContext->DumpPageViewData(node, viewDataWrap, skipSubAutoFillContainer, needsRecordData); 336823b3eb3cSopenharmony_ci} 336923b3eb3cSopenharmony_ci 337023b3eb3cSopenharmony_civoid UIContentImpl::SearchElementInfoByAccessibilityId( 337123b3eb3cSopenharmony_ci int64_t elementId, int32_t mode, int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& output) 337223b3eb3cSopenharmony_ci{ 337323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 337423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 337523b3eb3cSopenharmony_ci container->SearchElementInfoByAccessibilityIdNG(elementId, mode, baseParent, output); 337623b3eb3cSopenharmony_ci} 337723b3eb3cSopenharmony_ci 337823b3eb3cSopenharmony_civoid UIContentImpl::SearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent, 337923b3eb3cSopenharmony_ci std::list<Accessibility::AccessibilityElementInfo>& output) 338023b3eb3cSopenharmony_ci{ 338123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 338223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 338323b3eb3cSopenharmony_ci container->SearchElementInfosByTextNG(elementId, text, baseParent, output); 338423b3eb3cSopenharmony_ci} 338523b3eb3cSopenharmony_ci 338623b3eb3cSopenharmony_civoid UIContentImpl::FindFocusedElementInfo( 338723b3eb3cSopenharmony_ci int64_t elementId, int32_t focusType, int64_t baseParent, Accessibility::AccessibilityElementInfo& output) 338823b3eb3cSopenharmony_ci{ 338923b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 339023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 339123b3eb3cSopenharmony_ci container->FindFocusedElementInfoNG(elementId, focusType, baseParent, output); 339223b3eb3cSopenharmony_ci} 339323b3eb3cSopenharmony_ci 339423b3eb3cSopenharmony_civoid UIContentImpl::FocusMoveSearch( 339523b3eb3cSopenharmony_ci int64_t elementId, int32_t direction, int64_t baseParent, Accessibility::AccessibilityElementInfo& output) 339623b3eb3cSopenharmony_ci{ 339723b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 339823b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 339923b3eb3cSopenharmony_ci container->FocusMoveSearchNG(elementId, direction, baseParent, output); 340023b3eb3cSopenharmony_ci} 340123b3eb3cSopenharmony_ci 340223b3eb3cSopenharmony_cibool UIContentImpl::NotifyExecuteAction( 340323b3eb3cSopenharmony_ci int64_t elementId, const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t offset) 340423b3eb3cSopenharmony_ci{ 340523b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 340623b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, false); 340723b3eb3cSopenharmony_ci return container->NotifyExecuteAction(elementId, actionArguments, action, offset); 340823b3eb3cSopenharmony_ci} 340923b3eb3cSopenharmony_ci 341023b3eb3cSopenharmony_civoid UIContentImpl::HandleAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, 341123b3eb3cSopenharmony_ci int32_t eventType, int64_t timeMs) 341223b3eb3cSopenharmony_ci{ 341323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 341423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 341523b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_ACCESSIBILITY, "HandleAccessibilityHoverEvent Point:[%{public}f, %{public}f] " 341623b3eb3cSopenharmony_ci "source:%{public}d type:%{public}d time:%{public}" PRId64, 341723b3eb3cSopenharmony_ci pointX, pointY, sourceType, eventType, timeMs); 341823b3eb3cSopenharmony_ci container->HandleAccessibilityHoverEvent(pointX, pointY, sourceType, eventType, timeMs); 341923b3eb3cSopenharmony_ci} 342023b3eb3cSopenharmony_ci 342123b3eb3cSopenharmony_cistd::string UIContentImpl::RecycleForm() 342223b3eb3cSopenharmony_ci{ 342323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 342423b3eb3cSopenharmony_ci std::string statusData; 342523b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, statusData); 342623b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 342723b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipeline, statusData); 342823b3eb3cSopenharmony_ci return pipeline->OnFormRecycle(); 342923b3eb3cSopenharmony_ci} 343023b3eb3cSopenharmony_ci 343123b3eb3cSopenharmony_civoid UIContentImpl::RecoverForm(const std::string& statusData) 343223b3eb3cSopenharmony_ci{ 343323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 343423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 343523b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 343623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 343723b3eb3cSopenharmony_ci return pipeline->OnFormRecover(statusData); 343823b3eb3cSopenharmony_ci} 343923b3eb3cSopenharmony_ci 344023b3eb3cSopenharmony_ciRefPtr<PopupParam> UIContentImpl::CreateCustomPopupParam(bool isShow, const CustomPopupUIExtensionConfig& config) 344123b3eb3cSopenharmony_ci{ 344223b3eb3cSopenharmony_ci auto popupParam = AceType::MakeRefPtr<PopupParam>(); 344323b3eb3cSopenharmony_ci popupParam->SetIsShow(isShow); 344423b3eb3cSopenharmony_ci popupParam->SetUseCustomComponent(true); 344523b3eb3cSopenharmony_ci popupParam->SetShowInSubWindow(config.isShowInSubWindow); 344623b3eb3cSopenharmony_ci popupParam->SetShadow(GetPopupShadow()); 344723b3eb3cSopenharmony_ci if (config.isAutoCancel.has_value()) { 344823b3eb3cSopenharmony_ci popupParam->SetHasAction(!config.isAutoCancel.value()); 344923b3eb3cSopenharmony_ci } 345023b3eb3cSopenharmony_ci 345123b3eb3cSopenharmony_ci if (config.isEnableArrow.has_value()) { 345223b3eb3cSopenharmony_ci popupParam->SetEnableArrow(config.isEnableArrow.value()); 345323b3eb3cSopenharmony_ci } 345423b3eb3cSopenharmony_ci 345523b3eb3cSopenharmony_ci if (config.targetOffset.has_value()) { 345623b3eb3cSopenharmony_ci PopupOffset targetOffset = config.targetOffset.value(); 345723b3eb3cSopenharmony_ci DimensionUnit unit = static_cast<DimensionUnit>(targetOffset.unit); 345823b3eb3cSopenharmony_ci if (unit != DimensionUnit::PERCENT) { // not support percent settings 345923b3eb3cSopenharmony_ci CalcDimension dx(targetOffset.deltaX, unit); 346023b3eb3cSopenharmony_ci CalcDimension dy(targetOffset.deltaY, unit); 346123b3eb3cSopenharmony_ci popupParam->SetTargetOffset(Offset(dx.ConvertToPx(), dy.ConvertToPx())); 346223b3eb3cSopenharmony_ci } 346323b3eb3cSopenharmony_ci } 346423b3eb3cSopenharmony_ci 346523b3eb3cSopenharmony_ci if (config.targetSpace.has_value()) { 346623b3eb3cSopenharmony_ci PopupLength targetSpace = config.targetSpace.value(); 346723b3eb3cSopenharmony_ci DimensionUnit unit = static_cast<DimensionUnit>(targetSpace.unit); 346823b3eb3cSopenharmony_ci popupParam->SetTargetSpace(CalcDimension(targetSpace.length, unit)); 346923b3eb3cSopenharmony_ci } 347023b3eb3cSopenharmony_ci 347123b3eb3cSopenharmony_ci if (config.arrowOffset.has_value()) { 347223b3eb3cSopenharmony_ci PopupLength arrowOffset = config.arrowOffset.value(); 347323b3eb3cSopenharmony_ci DimensionUnit unit = static_cast<DimensionUnit>(arrowOffset.unit); 347423b3eb3cSopenharmony_ci popupParam->SetArrowOffset(CalcDimension(arrowOffset.length, unit)); 347523b3eb3cSopenharmony_ci } 347623b3eb3cSopenharmony_ci 347723b3eb3cSopenharmony_ci if (config.placement.has_value()) { 347823b3eb3cSopenharmony_ci popupParam->SetPlacement(static_cast<Placement>(config.placement.value())); 347923b3eb3cSopenharmony_ci } 348023b3eb3cSopenharmony_ci 348123b3eb3cSopenharmony_ci if (config.backgroundColor.has_value()) { 348223b3eb3cSopenharmony_ci popupParam->SetBackgroundColor(Color(config.backgroundColor.value())); 348323b3eb3cSopenharmony_ci } 348423b3eb3cSopenharmony_ci 348523b3eb3cSopenharmony_ci if (config.maskColor.has_value()) { 348623b3eb3cSopenharmony_ci popupParam->SetMaskColor(Color(config.maskColor.value())); 348723b3eb3cSopenharmony_ci } 348823b3eb3cSopenharmony_ci return popupParam; 348923b3eb3cSopenharmony_ci} 349023b3eb3cSopenharmony_ci 349123b3eb3cSopenharmony_ciShadow UIContentImpl::GetPopupShadow() 349223b3eb3cSopenharmony_ci{ 349323b3eb3cSopenharmony_ci Shadow shadow; 349423b3eb3cSopenharmony_ci auto colorMode = SystemProperties::GetColorMode(); 349523b3eb3cSopenharmony_ci auto container = Container::Current(); 349623b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, shadow); 349723b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 349823b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipelineContext, shadow); 349923b3eb3cSopenharmony_ci auto shadowTheme = pipelineContext->GetTheme<ShadowTheme>(); 350023b3eb3cSopenharmony_ci CHECK_NULL_RETURN(shadowTheme, shadow); 350123b3eb3cSopenharmony_ci return shadowTheme->GetShadow(ShadowStyle::OuterDefaultMD, colorMode); 350223b3eb3cSopenharmony_ci} 350323b3eb3cSopenharmony_ci 350423b3eb3cSopenharmony_civoid UIContentImpl::OnPopupStateChange( 350523b3eb3cSopenharmony_ci const std::string& event, const CustomPopupUIExtensionConfig& config, int32_t nodeId) 350623b3eb3cSopenharmony_ci{ 350723b3eb3cSopenharmony_ci if (config.onStateChange) { 350823b3eb3cSopenharmony_ci config.onStateChange(event); 350923b3eb3cSopenharmony_ci } 351023b3eb3cSopenharmony_ci 351123b3eb3cSopenharmony_ci auto visible = JsonUtil::ParseJsonString(event); 351223b3eb3cSopenharmony_ci CHECK_NULL_VOID(visible); 351323b3eb3cSopenharmony_ci bool isVisible = visible->GetBool("isVisible"); 351423b3eb3cSopenharmony_ci if (isVisible) { 351523b3eb3cSopenharmony_ci return; 351623b3eb3cSopenharmony_ci } 351723b3eb3cSopenharmony_ci 351823b3eb3cSopenharmony_ci LOGD("Created custom popup is invisible"); 351923b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 352023b3eb3cSopenharmony_ci customPopupConfigMap_.erase(nodeId); 352123b3eb3cSopenharmony_ci popupUIExtensionRecords_.erase(nodeId); 352223b3eb3cSopenharmony_ci} 352323b3eb3cSopenharmony_ci 352423b3eb3cSopenharmony_civoid UIContentImpl::SetCustomPopupConfig(int32_t nodeId, const CustomPopupUIExtensionConfig& config, int32_t popupId) 352523b3eb3cSopenharmony_ci{ 352623b3eb3cSopenharmony_ci customPopupConfigMap_[nodeId] = config; 352723b3eb3cSopenharmony_ci popupUIExtensionRecords_[nodeId] = popupId; 352823b3eb3cSopenharmony_ci} 352923b3eb3cSopenharmony_ci 353023b3eb3cSopenharmony_cibool UIContentImpl::GetTargetNode( 353123b3eb3cSopenharmony_ci int32_t& nodeIdLabel, RefPtr<NG::FrameNode>& targetNode, const CustomPopupUIExtensionConfig& config) 353223b3eb3cSopenharmony_ci{ 353323b3eb3cSopenharmony_ci if (config.nodeId > -1) { 353423b3eb3cSopenharmony_ci nodeIdLabel = config.nodeId; 353523b3eb3cSopenharmony_ci targetNode = ElementRegister::GetInstance()->GetSpecificItemById<NG::FrameNode>(nodeIdLabel); 353623b3eb3cSopenharmony_ci CHECK_NULL_RETURN(targetNode, false); 353723b3eb3cSopenharmony_ci } else if (!config.inspectorId.empty()) { 353823b3eb3cSopenharmony_ci targetNode = NG::Inspector::GetFrameNodeByKey(config.inspectorId); 353923b3eb3cSopenharmony_ci CHECK_NULL_RETURN(targetNode, false); 354023b3eb3cSopenharmony_ci nodeIdLabel = targetNode->GetId(); 354123b3eb3cSopenharmony_ci } else { 354223b3eb3cSopenharmony_ci CHECK_NULL_RETURN(targetNode, false); 354323b3eb3cSopenharmony_ci } 354423b3eb3cSopenharmony_ci return true; 354523b3eb3cSopenharmony_ci} 354623b3eb3cSopenharmony_ci 354723b3eb3cSopenharmony_ciint32_t UIContentImpl::CreateCustomPopupUIExtension( 354823b3eb3cSopenharmony_ci const AAFwk::Want& want, const ModalUIExtensionCallbacks& callbacks, const CustomPopupUIExtensionConfig& config) 354923b3eb3cSopenharmony_ci{ 355023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 355123b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 355223b3eb3cSopenharmony_ci CHECK_NULL_RETURN(taskExecutor, 0); 355323b3eb3cSopenharmony_ci int32_t nodeId = 0; 355423b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 355523b3eb3cSopenharmony_ci [want, &nodeId, callbacks = callbacks, config = config, this]() { 355623b3eb3cSopenharmony_ci int32_t nodeIdLabel = -1; 355723b3eb3cSopenharmony_ci RefPtr<NG::FrameNode> targetNode = nullptr; 355823b3eb3cSopenharmony_ci if (!GetTargetNode(nodeIdLabel, targetNode, config)) { 355923b3eb3cSopenharmony_ci return; 356023b3eb3cSopenharmony_ci } 356123b3eb3cSopenharmony_ci if (customPopupConfigMap_.find(nodeIdLabel) != customPopupConfigMap_.end()) { 356223b3eb3cSopenharmony_ci LOGW("Nodeid=%{public}d has unclosed popup, cannot create new", nodeIdLabel); 356323b3eb3cSopenharmony_ci return; 356423b3eb3cSopenharmony_ci } 356523b3eb3cSopenharmony_ci auto popupParam = CreateCustomPopupParam(true, config); 356623b3eb3cSopenharmony_ci popupParam->SetBlockEvent(false); 356723b3eb3cSopenharmony_ci auto uiExtNode = ModalUIExtension::Create(want, callbacks, false, false); 356823b3eb3cSopenharmony_ci auto focusHub = uiExtNode->GetFocusHub(); 356923b3eb3cSopenharmony_ci if (focusHub) { 357023b3eb3cSopenharmony_ci focusHub->SetFocusable(config.isFocusable); 357123b3eb3cSopenharmony_ci } 357223b3eb3cSopenharmony_ci if (config.targetSize.has_value()) { 357323b3eb3cSopenharmony_ci auto layoutProperty = uiExtNode->GetLayoutProperty(); 357423b3eb3cSopenharmony_ci CHECK_NULL_VOID(layoutProperty); 357523b3eb3cSopenharmony_ci PopupSize targetSize = config.targetSize.value(); 357623b3eb3cSopenharmony_ci DimensionUnit unit = static_cast<DimensionUnit>(targetSize.unit); 357723b3eb3cSopenharmony_ci auto width = NG::CalcLength(targetSize.width, unit); 357823b3eb3cSopenharmony_ci auto height = NG::CalcLength(targetSize.height, unit); 357923b3eb3cSopenharmony_ci layoutProperty->UpdateUserDefinedIdealSize(NG::CalcSize(width, height)); 358023b3eb3cSopenharmony_ci } 358123b3eb3cSopenharmony_ci uiExtNode->MarkModifyDone(); 358223b3eb3cSopenharmony_ci nodeId = nodeIdLabel; 358323b3eb3cSopenharmony_ci popupParam->SetOnStateChange([config, nodeId, UICONTENT_IMPL_HELPER(content)](const std::string& event) { 358423b3eb3cSopenharmony_ci UICONTENT_IMPL_HELPER_GUARD(content, return); 358523b3eb3cSopenharmony_ci UICONTENT_IMPL_PTR(content)->OnPopupStateChange(event, config, nodeId); 358623b3eb3cSopenharmony_ci }); 358723b3eb3cSopenharmony_ci NG::ViewAbstract::BindPopup(popupParam, targetNode, AceType::DynamicCast<NG::UINode>(uiExtNode)); 358823b3eb3cSopenharmony_ci SetCustomPopupConfig(nodeId, config, uiExtNode->GetId()); 358923b3eb3cSopenharmony_ci }, 359023b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUIExtensionCreateCustomPopup"); 359123b3eb3cSopenharmony_ci TAG_LOGI( 359223b3eb3cSopenharmony_ci AceLogTag::ACE_UIEXTENSIONCOMPONENT, "Create custom popup with UIExtension end, nodeId=%{public}d", nodeId); 359323b3eb3cSopenharmony_ci return nodeId; 359423b3eb3cSopenharmony_ci} 359523b3eb3cSopenharmony_ci 359623b3eb3cSopenharmony_civoid UIContentImpl::DestroyCustomPopupUIExtension(int32_t nodeId) 359723b3eb3cSopenharmony_ci{ 359823b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_UIEXTENSIONCOMPONENT, 359923b3eb3cSopenharmony_ci "[%{public}s][%{public}s][%{public}d]: Destroy custom popup start, nodeId=%{public}d", bundleName_.c_str(), 360023b3eb3cSopenharmony_ci moduleName_.c_str(), instanceId_, nodeId); 360123b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 360223b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 360323b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 360423b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 360523b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 360623b3eb3cSopenharmony_ci auto popupConfig = customPopupConfigMap_.find(nodeId); 360723b3eb3cSopenharmony_ci if (popupConfig == customPopupConfigMap_.end()) { 360823b3eb3cSopenharmony_ci LOGW("Node doesn't hava popup or closed already"); 360923b3eb3cSopenharmony_ci return; 361023b3eb3cSopenharmony_ci } 361123b3eb3cSopenharmony_ci auto config = popupConfig->second; 361223b3eb3cSopenharmony_ci taskExecutor->PostTask( 361323b3eb3cSopenharmony_ci [container, nodeId, config, UICONTENT_IMPL_HELPER(content)]() { 361423b3eb3cSopenharmony_ci UICONTENT_IMPL_HELPER_GUARD(content, return); 361523b3eb3cSopenharmony_ci auto targetNode = 361623b3eb3cSopenharmony_ci AceType::DynamicCast<NG::FrameNode>(ElementRegister::GetInstance()->GetUINodeById(nodeId)); 361723b3eb3cSopenharmony_ci CHECK_NULL_VOID(targetNode); 361823b3eb3cSopenharmony_ci auto popupParam = UICONTENT_IMPL_PTR(content)->CreateCustomPopupParam(false, config); 361923b3eb3cSopenharmony_ci NG::ViewAbstract::BindPopup(popupParam, targetNode, nullptr); 362023b3eb3cSopenharmony_ci UICONTENT_IMPL_PTR(content)->customPopupConfigMap_.erase(nodeId); 362123b3eb3cSopenharmony_ci UICONTENT_IMPL_PTR(content)->popupUIExtensionRecords_.erase(nodeId); 362223b3eb3cSopenharmony_ci }, 362323b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUIExtensionDestroyCustomPopup"); 362423b3eb3cSopenharmony_ci} 362523b3eb3cSopenharmony_ci 362623b3eb3cSopenharmony_civoid UIContentImpl::UpdateCustomPopupUIExtension(const CustomPopupUIExtensionConfig& config) 362723b3eb3cSopenharmony_ci{ 362823b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 362923b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 363023b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 363123b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 363223b3eb3cSopenharmony_ci [config, this]() { 363323b3eb3cSopenharmony_ci int32_t targetId = config.nodeId; 363423b3eb3cSopenharmony_ci auto record = popupUIExtensionRecords_.find(targetId); 363523b3eb3cSopenharmony_ci int32_t uiExtNodeId = (record != popupUIExtensionRecords_.end()) ? record->second : 0; 363623b3eb3cSopenharmony_ci auto uiExtNode = NG::FrameNode::GetFrameNode(V2::UI_EXTENSION_COMPONENT_ETS_TAG, uiExtNodeId); 363723b3eb3cSopenharmony_ci CHECK_NULL_VOID(uiExtNode); 363823b3eb3cSopenharmony_ci if (config.targetSize.has_value()) { 363923b3eb3cSopenharmony_ci auto layoutProperty = uiExtNode->GetLayoutProperty(); 364023b3eb3cSopenharmony_ci CHECK_NULL_VOID(layoutProperty); 364123b3eb3cSopenharmony_ci PopupSize targetSize = config.targetSize.value(); 364223b3eb3cSopenharmony_ci DimensionUnit unit = static_cast<DimensionUnit>(targetSize.unit); 364323b3eb3cSopenharmony_ci auto width = NG::CalcLength(targetSize.width, unit); 364423b3eb3cSopenharmony_ci auto height = NG::CalcLength(targetSize.height, unit); 364523b3eb3cSopenharmony_ci layoutProperty->UpdateUserDefinedIdealSize(NG::CalcSize(width, height)); 364623b3eb3cSopenharmony_ci } 364723b3eb3cSopenharmony_ci auto popupParam = CreateCustomPopupParam(true, config); 364823b3eb3cSopenharmony_ci popupParam->SetIsCaretMode(false); 364923b3eb3cSopenharmony_ci popupParam->SetBlockEvent(false); 365023b3eb3cSopenharmony_ci auto popupConfig = customPopupConfigMap_.find(targetId); 365123b3eb3cSopenharmony_ci if (popupConfig != customPopupConfigMap_.end()) { 365223b3eb3cSopenharmony_ci auto createConfig = popupConfig->second; 365323b3eb3cSopenharmony_ci popupParam->SetShowInSubWindow(createConfig.isShowInSubWindow); 365423b3eb3cSopenharmony_ci popupParam->SetOnStateChange( 365523b3eb3cSopenharmony_ci [createConfig, targetId, UICONTENT_IMPL_HELPER(content)](const std::string& event) { 365623b3eb3cSopenharmony_ci UICONTENT_IMPL_HELPER_GUARD(content, return); 365723b3eb3cSopenharmony_ci UICONTENT_IMPL_PTR(content)->OnPopupStateChange(event, createConfig, targetId); 365823b3eb3cSopenharmony_ci }); 365923b3eb3cSopenharmony_ci } 366023b3eb3cSopenharmony_ci auto targetNode = 366123b3eb3cSopenharmony_ci AceType::DynamicCast<NG::FrameNode>(ElementRegister::GetInstance()->GetUINodeById(targetId)); 366223b3eb3cSopenharmony_ci CHECK_NULL_VOID(targetNode); 366323b3eb3cSopenharmony_ci NG::ViewAbstract::BindPopup(popupParam, targetNode, nullptr); 366423b3eb3cSopenharmony_ci }, 366523b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUIExtensionUpdateCustomPopup"); 366623b3eb3cSopenharmony_ci} 366723b3eb3cSopenharmony_ci 366823b3eb3cSopenharmony_civoid UIContentImpl::SetContainerModalTitleVisible(bool customTitleSettedShow, bool floatingTitleSettedShow) 366923b3eb3cSopenharmony_ci{ 367023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 367123b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 367223b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 367323b3eb3cSopenharmony_ci auto task = [customTitleSettedShow, floatingTitleSettedShow]() { 367423b3eb3cSopenharmony_ci auto pipeline = NG::PipelineContext::GetCurrentContext(); 367523b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 367623b3eb3cSopenharmony_ci pipeline->SetContainerModalTitleVisible(customTitleSettedShow, floatingTitleSettedShow); 367723b3eb3cSopenharmony_ci }; 367823b3eb3cSopenharmony_ci auto uiTaskRunner = SingleTaskExecutor::Make(taskExecutor, TaskExecutor::TaskType::UI); 367923b3eb3cSopenharmony_ci if (uiTaskRunner.IsRunOnCurrentThread()) { 368023b3eb3cSopenharmony_ci task(); 368123b3eb3cSopenharmony_ci } else { 368223b3eb3cSopenharmony_ci taskExecutor->PostTask(std::move(task), TaskExecutor::TaskType::UI, "ArkUISetContainerModalTitleVisible"); 368323b3eb3cSopenharmony_ci } 368423b3eb3cSopenharmony_ci} 368523b3eb3cSopenharmony_ci 368623b3eb3cSopenharmony_civoid UIContentImpl::SetContainerModalTitleHeight(int32_t height) 368723b3eb3cSopenharmony_ci{ 368823b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 368923b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 369023b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 369123b3eb3cSopenharmony_ci auto task = [height]() { 369223b3eb3cSopenharmony_ci auto pipeline = NG::PipelineContext::GetCurrentContext(); 369323b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 369423b3eb3cSopenharmony_ci pipeline->SetContainerModalTitleHeight(height); 369523b3eb3cSopenharmony_ci }; 369623b3eb3cSopenharmony_ci auto uiTaskRunner = SingleTaskExecutor::Make(taskExecutor, TaskExecutor::TaskType::UI); 369723b3eb3cSopenharmony_ci if (uiTaskRunner.IsRunOnCurrentThread()) { 369823b3eb3cSopenharmony_ci task(); 369923b3eb3cSopenharmony_ci } else { 370023b3eb3cSopenharmony_ci taskExecutor->PostTask(std::move(task), TaskExecutor::TaskType::UI, "ArkUISetContainerModalTitleHeight"); 370123b3eb3cSopenharmony_ci } 370223b3eb3cSopenharmony_ci} 370323b3eb3cSopenharmony_ci 370423b3eb3cSopenharmony_ciint32_t UIContentImpl::GetContainerModalTitleHeight() 370523b3eb3cSopenharmony_ci{ 370623b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 370723b3eb3cSopenharmony_ci auto pipeline = NG::PipelineContext::GetCurrentContext(); 370823b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipeline, -1); 370923b3eb3cSopenharmony_ci return pipeline->GetContainerModalTitleHeight(); 371023b3eb3cSopenharmony_ci} 371123b3eb3cSopenharmony_ci 371223b3eb3cSopenharmony_cibool UIContentImpl::GetContainerModalButtonsRect(Rosen::Rect& containerModal, Rosen::Rect& buttons) 371323b3eb3cSopenharmony_ci{ 371423b3eb3cSopenharmony_ci NG::RectF floatContainerModal; 371523b3eb3cSopenharmony_ci NG::RectF floatButtons; 371623b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 371723b3eb3cSopenharmony_ci auto pipeline = NG::PipelineContext::GetCurrentContext(); 371823b3eb3cSopenharmony_ci CHECK_NULL_RETURN(pipeline, false); 371923b3eb3cSopenharmony_ci if (!pipeline->GetContainerModalButtonsRect(floatContainerModal, floatButtons)) { 372023b3eb3cSopenharmony_ci return false; 372123b3eb3cSopenharmony_ci } 372223b3eb3cSopenharmony_ci containerModal = ConvertToRSRect(floatContainerModal); 372323b3eb3cSopenharmony_ci buttons = ConvertToRSRect(floatButtons); 372423b3eb3cSopenharmony_ci return true; 372523b3eb3cSopenharmony_ci} 372623b3eb3cSopenharmony_ci 372723b3eb3cSopenharmony_civoid UIContentImpl::SubscribeContainerModalButtonsRectChange( 372823b3eb3cSopenharmony_ci std::function<void(Rosen::Rect& containerModal, Rosen::Rect& buttons)>&& callback) 372923b3eb3cSopenharmony_ci{ 373023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 373123b3eb3cSopenharmony_ci auto pipeline = NG::PipelineContext::GetCurrentContext(); 373223b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 373323b3eb3cSopenharmony_ci 373423b3eb3cSopenharmony_ci if (callback == nullptr) { 373523b3eb3cSopenharmony_ci pipeline->SubscribeContainerModalButtonsRectChange(nullptr); 373623b3eb3cSopenharmony_ci return; 373723b3eb3cSopenharmony_ci } 373823b3eb3cSopenharmony_ci std::function<void(NG::RectF&, NG::RectF&)> wrapFunc = [cb = std::move(callback)](NG::RectF& floatContainerModal, 373923b3eb3cSopenharmony_ci NG::RectF& floatButtons) { 374023b3eb3cSopenharmony_ci Rosen::Rect containerModal = ConvertToRSRect(floatContainerModal); 374123b3eb3cSopenharmony_ci Rosen::Rect buttons = ConvertToRSRect(floatButtons); 374223b3eb3cSopenharmony_ci cb(containerModal, buttons); 374323b3eb3cSopenharmony_ci }; 374423b3eb3cSopenharmony_ci pipeline->SubscribeContainerModalButtonsRectChange(std::move(wrapFunc)); 374523b3eb3cSopenharmony_ci} 374623b3eb3cSopenharmony_ci 374723b3eb3cSopenharmony_civoid UIContentImpl::ChangeSensitiveNodes(bool isSensitive) 374823b3eb3cSopenharmony_ci{ 374923b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 375023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 375123b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 375223b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 375323b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 375423b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 375523b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 375623b3eb3cSopenharmony_ci taskExecutor->PostTask( 375723b3eb3cSopenharmony_ci [pipeline, isSensitive]() { pipeline->ChangeSensitiveNodes(isSensitive); }, 375823b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIChangeSensitiveNodes"); 375923b3eb3cSopenharmony_ci} 376023b3eb3cSopenharmony_ci 376123b3eb3cSopenharmony_civoid UIContentImpl::UpdateTransform(const OHOS::Rosen::Transform& transform) 376223b3eb3cSopenharmony_ci{ 376323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 376423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 376523b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 376623b3eb3cSopenharmony_ci auto taskExecutor = Container::CurrentTaskExecutor(); 376723b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 376823b3eb3cSopenharmony_ci auto windowScale = transform.scaleX_; 376923b3eb3cSopenharmony_ci taskExecutor->PostTask( 377023b3eb3cSopenharmony_ci [container, windowScale]() { container->SetWindowScale(windowScale); }, 377123b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetWindowScale"); 377223b3eb3cSopenharmony_ci} 377323b3eb3cSopenharmony_ci 377423b3eb3cSopenharmony_civoid UIContentImpl::AddWatchSystemParameter() 377523b3eb3cSopenharmony_ci{ 377623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 377723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 377823b3eb3cSopenharmony_ci container->AddWatchSystemParameter(); 377923b3eb3cSopenharmony_ci} 378023b3eb3cSopenharmony_ci 378123b3eb3cSopenharmony_cistd::vector<Ace::RectF> UIContentImpl::GetOverlayNodePositions() const 378223b3eb3cSopenharmony_ci{ 378323b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 378423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 378523b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, {}); 378623b3eb3cSopenharmony_ci return container->GetOverlayNodePositions(); 378723b3eb3cSopenharmony_ci} 378823b3eb3cSopenharmony_ci 378923b3eb3cSopenharmony_civoid UIContentImpl::RegisterOverlayNodePositionsUpdateCallback( 379023b3eb3cSopenharmony_ci const std::function<void(std::vector<Ace::RectF>)>& callback) const 379123b3eb3cSopenharmony_ci{ 379223b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 379323b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 379423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 379523b3eb3cSopenharmony_ci container->RegisterOverlayNodePositionsUpdateCallback(std::move(callback)); 379623b3eb3cSopenharmony_ci} 379723b3eb3cSopenharmony_ci 379823b3eb3cSopenharmony_civoid UIContentImpl::SetContentNodeGrayScale(float grayscale) 379923b3eb3cSopenharmony_ci{ 380023b3eb3cSopenharmony_ci if (LessNotEqual(grayscale, 0.001f)) { 380123b3eb3cSopenharmony_ci grayscale = 0.0f; 380223b3eb3cSopenharmony_ci } 380323b3eb3cSopenharmony_ci if (GreatNotEqual(grayscale, 1.0)) { 380423b3eb3cSopenharmony_ci grayscale = 1.0f; 380523b3eb3cSopenharmony_ci } 380623b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 380723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 380823b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 380923b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 381023b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 381123b3eb3cSopenharmony_ci auto rootElement = pipelineContext->GetRootElement(); 381223b3eb3cSopenharmony_ci CHECK_NULL_VOID(rootElement); 381323b3eb3cSopenharmony_ci auto renderContext = rootElement->GetRenderContext(); 381423b3eb3cSopenharmony_ci CHECK_NULL_VOID(renderContext); 381523b3eb3cSopenharmony_ci renderContext->UpdateFrontGrayScale(Dimension(grayscale)); 381623b3eb3cSopenharmony_ci pipelineContext->SetDragNodeGrayscale(grayscale); 381723b3eb3cSopenharmony_ci} 381823b3eb3cSopenharmony_ci 381923b3eb3cSopenharmony_civoid UIContentImpl::PreLayout() 382023b3eb3cSopenharmony_ci{ 382123b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_WINDOW, "PreLayoutBegin"); 382223b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 382323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 382423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 382523b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 382623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 382723b3eb3cSopenharmony_ci 382823b3eb3cSopenharmony_ci auto stageManager = pipelineContext->GetStageManager(); 382923b3eb3cSopenharmony_ci CHECK_NULL_VOID(stageManager); 383023b3eb3cSopenharmony_ci auto stageNode = stageManager->GetStageNode(); 383123b3eb3cSopenharmony_ci CHECK_NULL_VOID(stageNode); 383223b3eb3cSopenharmony_ci auto renderContext = stageNode->GetRenderContext(); 383323b3eb3cSopenharmony_ci CHECK_NULL_VOID(renderContext); 383423b3eb3cSopenharmony_ci auto paintRectf = renderContext->GetPaintRectWithoutTransform(); 383523b3eb3cSopenharmony_ci if (LessOrEqual(static_cast<uint32_t>(paintRectf.Width()), 0) || 383623b3eb3cSopenharmony_ci LessOrEqual(static_cast<uint32_t>(paintRectf.Height()), 0)) { 383723b3eb3cSopenharmony_ci TAG_LOGW(AceLogTag::ACE_WINDOW, "width:%{public}f, height:%{public}f", paintRectf.Width(), 383823b3eb3cSopenharmony_ci paintRectf.Height()); 383923b3eb3cSopenharmony_ci return ; 384023b3eb3cSopenharmony_ci } 384123b3eb3cSopenharmony_ci 384223b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 384323b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 384423b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 384523b3eb3cSopenharmony_ci [pipelineContext] { 384623b3eb3cSopenharmony_ci pipelineContext->PreLayout(pipelineContext->GetTimeFromExternalTimer(), 0); 384723b3eb3cSopenharmony_ci }, 384823b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIPreLayout"); 384923b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_WINDOW, "ArkUIPreLayoutEnd"); 385023b3eb3cSopenharmony_ci} 385123b3eb3cSopenharmony_ci 385223b3eb3cSopenharmony_civoid UIContentImpl::SetStatusBarItemColor(uint32_t color) 385323b3eb3cSopenharmony_ci{ 385423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 385523b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 385623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 385723b3eb3cSopenharmony_ci auto appBar = container->GetAppBar(); 385823b3eb3cSopenharmony_ci CHECK_NULL_VOID(appBar); 385923b3eb3cSopenharmony_ci appBar->SetStatusBarItemColor(IsDarkColor(color)); 386023b3eb3cSopenharmony_ci} 386123b3eb3cSopenharmony_ci 386223b3eb3cSopenharmony_civoid UIContentImpl::SetForceSplitEnable(bool isForceSplit, const std::string& homePage) 386323b3eb3cSopenharmony_ci{ 386423b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 386523b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 386623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 386723b3eb3cSopenharmony_ci auto context = AceType::DynamicCast<NG::PipelineContext>(container->GetPipelineContext()); 386823b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 386923b3eb3cSopenharmony_ci context->SetForceSplitEnable(isForceSplit, homePage); 387023b3eb3cSopenharmony_ci} 387123b3eb3cSopenharmony_ci 387223b3eb3cSopenharmony_civoid UIContentImpl::UpdateDialogContainerConfig(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) 387323b3eb3cSopenharmony_ci{ 387423b3eb3cSopenharmony_ci CHECK_NULL_VOID(config); 387523b3eb3cSopenharmony_ci auto container = Platform::DialogContainer::GetContainer(instanceId_); 387623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 387723b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 387823b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 387923b3eb3cSopenharmony_ci taskExecutor->PostTask( 388023b3eb3cSopenharmony_ci [weakContainer = WeakPtr<Platform::DialogContainer>(container), config, instanceId = instanceId_, 388123b3eb3cSopenharmony_ci bundleName = bundleName_, moduleName = moduleName_]() { 388223b3eb3cSopenharmony_ci auto container = weakContainer.Upgrade(); 388323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 388423b3eb3cSopenharmony_ci Platform::ParsedConfig parsedConfig; 388523b3eb3cSopenharmony_ci parsedConfig.colorMode = config->GetItem(OHOS::AppExecFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); 388623b3eb3cSopenharmony_ci container->UpdateConfiguration(parsedConfig); 388723b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_DIALOG, 388823b3eb3cSopenharmony_ci "[%{public}d][%{public}s][%{public}s] UIContentImpl: UpdateDialogContainerConfig called End, " 388923b3eb3cSopenharmony_ci "name:%{public}s", 389023b3eb3cSopenharmony_ci instanceId, bundleName.c_str(), moduleName.c_str(), config->GetName().c_str()); 389123b3eb3cSopenharmony_ci }, 389223b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUIContentUpdateConfiguration"); 389323b3eb3cSopenharmony_ci} 389423b3eb3cSopenharmony_ci 389523b3eb3cSopenharmony_civoid UIContentImpl::ProcessDestructCallbacks() 389623b3eb3cSopenharmony_ci{ 389723b3eb3cSopenharmony_ci for (auto& [_, callback] : destructCallbacks_) { 389823b3eb3cSopenharmony_ci callback(); 389923b3eb3cSopenharmony_ci } 390023b3eb3cSopenharmony_ci} 390123b3eb3cSopenharmony_ci} // namespace OHOS::Ace 3902