123b3eb3cSopenharmony_ci/* 223b3eb3cSopenharmony_ci * Copyright (c) 2023 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/preview/entrance/ui_content_impl.h" 1723b3eb3cSopenharmony_ci 1823b3eb3cSopenharmony_ci#include <ui/rs_surface_node.h> 1923b3eb3cSopenharmony_ci#include <ui/rs_ui_director.h> 2023b3eb3cSopenharmony_ci 2123b3eb3cSopenharmony_ci#include "include/core/SkFontMgr.h" 2223b3eb3cSopenharmony_ci 2323b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/ace_new_pipe_judgement.h" 2423b3eb3cSopenharmony_ci#include "adapter/ohos/entrance/platform_event_callback.h" 2523b3eb3cSopenharmony_ci#include "adapter/preview/entrance/ace_application_info.h" 2623b3eb3cSopenharmony_ci#include "adapter/preview/entrance/ace_container.h" 2723b3eb3cSopenharmony_ci#include "adapter/preview/entrance/clipboard/clipboard_impl.h" 2823b3eb3cSopenharmony_ci#include "adapter/preview/entrance/clipboard/clipboard_proxy_impl.h" 2923b3eb3cSopenharmony_ci#include "adapter/preview/entrance/event_dispatcher.h" 3023b3eb3cSopenharmony_ci#include "adapter/preview/entrance/rs_dir_asset_provider.h" 3123b3eb3cSopenharmony_ci#include "adapter/preview/external/multimodalinput/axis_event.h" 3223b3eb3cSopenharmony_ci#include "adapter/preview/external/multimodalinput/key_event.h" 3323b3eb3cSopenharmony_ci#include "adapter/preview/external/multimodalinput/pointer_event.h" 3423b3eb3cSopenharmony_ci#include "adapter/preview/inspector/inspector_client.h" 3523b3eb3cSopenharmony_ci#include "base/log/log_wrapper.h" 3623b3eb3cSopenharmony_ci#include "frameworks/base/log/log.h" 3723b3eb3cSopenharmony_ci#include "frameworks/base/utils/utils.h" 3823b3eb3cSopenharmony_ci#include "frameworks/bridge/common/utils/utils.h" 3923b3eb3cSopenharmony_ci#include "frameworks/bridge/js_frontend/js_frontend.h" 4023b3eb3cSopenharmony_ci#include "frameworks/core/common/ace_engine.h" 4123b3eb3cSopenharmony_ci#ifdef INIT_ICU_DATA_PATH 4223b3eb3cSopenharmony_ci#include "unicode/putil.h" 4323b3eb3cSopenharmony_ci#endif 4423b3eb3cSopenharmony_ci 4523b3eb3cSopenharmony_ci#include "frameworks/simulator/common/include/context.h" 4623b3eb3cSopenharmony_ci 4723b3eb3cSopenharmony_cinamespace OHOS::Ace { 4823b3eb3cSopenharmony_ci 4923b3eb3cSopenharmony_ciusing namespace Platform; 5023b3eb3cSopenharmony_ci 5123b3eb3cSopenharmony_cinamespace { 5223b3eb3cSopenharmony_ci 5323b3eb3cSopenharmony_ci#ifdef WINDOWS_PLATFORM 5423b3eb3cSopenharmony_ciconstexpr char DELIMITER[] = "\\"; 5523b3eb3cSopenharmony_ciconstexpr char ASSET_PATH_SHARE_STAGE[] = "resources\\base\\profile"; 5623b3eb3cSopenharmony_ci#else 5723b3eb3cSopenharmony_ciconstexpr char DELIMITER[] = "/"; 5823b3eb3cSopenharmony_ciconstexpr char ASSET_PATH_SHARE_STAGE[] = "resources/base/profile"; 5923b3eb3cSopenharmony_ci#endif 6023b3eb3cSopenharmony_ci 6123b3eb3cSopenharmony_ciNG::SafeAreaInsets ConvertAvoidArea(const OHOS::Rosen::AvoidArea& avoidArea) 6223b3eb3cSopenharmony_ci{ 6323b3eb3cSopenharmony_ci return NG::SafeAreaInsets({ avoidArea.leftRect_.posX_, avoidArea.leftRect_.posX_ + avoidArea.leftRect_.width_ }, 6423b3eb3cSopenharmony_ci { avoidArea.topRect_.posY_, avoidArea.topRect_.posY_ + avoidArea.topRect_.height_ }, 6523b3eb3cSopenharmony_ci { avoidArea.rightRect_.posX_, avoidArea.rightRect_.posX_ + avoidArea.rightRect_.width_ }, 6623b3eb3cSopenharmony_ci { avoidArea.bottomRect_.posY_, avoidArea.bottomRect_.posY_ + avoidArea.bottomRect_.height_ }); 6723b3eb3cSopenharmony_ci} 6823b3eb3cSopenharmony_ci 6923b3eb3cSopenharmony_civoid SetFontMgrConfig(const std::string& containerSdkPath) 7023b3eb3cSopenharmony_ci{ 7123b3eb3cSopenharmony_ci // To check if use ohos or container fonts. 7223b3eb3cSopenharmony_ci std::string runtimeOS = "OHOS_Container"; 7323b3eb3cSopenharmony_ci std::string containerFontBasePath = containerSdkPath + DELIMITER + "resources" + DELIMITER + "fonts" + DELIMITER; 7423b3eb3cSopenharmony_ci RSDirAssetProvider dirAsset(containerFontBasePath); 7523b3eb3cSopenharmony_ci std::vector<std::string> fileList; 7623b3eb3cSopenharmony_ci dirAsset.GetAssetList("", fileList); 7723b3eb3cSopenharmony_ci if (containerSdkPath.empty() || fileList.empty()) { 7823b3eb3cSopenharmony_ci runtimeOS = "OHOS"; 7923b3eb3cSopenharmony_ci containerFontBasePath = ""; 8023b3eb3cSopenharmony_ci } 8123b3eb3cSopenharmony_ci SkFontMgr::SetFontMgrConfig(runtimeOS, containerFontBasePath); 8223b3eb3cSopenharmony_ci} 8323b3eb3cSopenharmony_ci 8423b3eb3cSopenharmony_ci} // namespace 8523b3eb3cSopenharmony_ci 8623b3eb3cSopenharmony_ciusing ContentFinishCallback = std::function<void()>; 8723b3eb3cSopenharmony_ciusing ContentStartAbilityCallback = std::function<void(const std::string& address)>; 8823b3eb3cSopenharmony_ciclass ContentEventCallback final : public PlatformEventCallback { 8923b3eb3cSopenharmony_cipublic: 9023b3eb3cSopenharmony_ci explicit ContentEventCallback(ContentFinishCallback onFinish) : onFinish_(onFinish) {} 9123b3eb3cSopenharmony_ci ContentEventCallback(ContentFinishCallback onFinish, ContentStartAbilityCallback onStartAbility) 9223b3eb3cSopenharmony_ci : onFinish_(onFinish), onStartAbility_(onStartAbility) 9323b3eb3cSopenharmony_ci {} 9423b3eb3cSopenharmony_ci ~ContentEventCallback() override = default; 9523b3eb3cSopenharmony_ci 9623b3eb3cSopenharmony_ci void OnFinish() const override 9723b3eb3cSopenharmony_ci { 9823b3eb3cSopenharmony_ci LOGI("UIContent OnFinish"); 9923b3eb3cSopenharmony_ci CHECK_NULL_VOID(onFinish_); 10023b3eb3cSopenharmony_ci onFinish_(); 10123b3eb3cSopenharmony_ci } 10223b3eb3cSopenharmony_ci 10323b3eb3cSopenharmony_ci void OnStartAbility(const std::string& address) override 10423b3eb3cSopenharmony_ci { 10523b3eb3cSopenharmony_ci LOGI("UIContent OnStartAbility"); 10623b3eb3cSopenharmony_ci CHECK_NULL_VOID(onStartAbility_); 10723b3eb3cSopenharmony_ci onStartAbility_(address); 10823b3eb3cSopenharmony_ci } 10923b3eb3cSopenharmony_ci 11023b3eb3cSopenharmony_ci void OnStatusBarBgColorChanged(uint32_t color) override 11123b3eb3cSopenharmony_ci { 11223b3eb3cSopenharmony_ci LOGI("UIContent OnStatusBarBgColorChanged"); 11323b3eb3cSopenharmony_ci } 11423b3eb3cSopenharmony_ci 11523b3eb3cSopenharmony_ciprivate: 11623b3eb3cSopenharmony_ci ContentFinishCallback onFinish_; 11723b3eb3cSopenharmony_ci ContentStartAbilityCallback onStartAbility_; 11823b3eb3cSopenharmony_ci}; 11923b3eb3cSopenharmony_ci 12023b3eb3cSopenharmony_ciclass DragWindowListener : public OHOS::Rosen::IWindowDragListener { 12123b3eb3cSopenharmony_cipublic: 12223b3eb3cSopenharmony_ci explicit DragWindowListener(int32_t instanceId) : instanceId_(instanceId) {} 12323b3eb3cSopenharmony_ci ~DragWindowListener() = default; 12423b3eb3cSopenharmony_ci void OnDrag(int32_t x, int32_t y, OHOS::Rosen::DragEvent event) 12523b3eb3cSopenharmony_ci { 12623b3eb3cSopenharmony_ci LOGI("[Engine Log] The feature is not supported on the previewer, and instanceId_ = %{public}d", instanceId_); 12723b3eb3cSopenharmony_ci } 12823b3eb3cSopenharmony_ci 12923b3eb3cSopenharmony_ciprivate: 13023b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 13123b3eb3cSopenharmony_ci}; 13223b3eb3cSopenharmony_ci 13323b3eb3cSopenharmony_ciclass TouchOutsideListener : public OHOS::Rosen::ITouchOutsideListener { 13423b3eb3cSopenharmony_cipublic: 13523b3eb3cSopenharmony_ci explicit TouchOutsideListener(int32_t instanceId) : instanceId_(instanceId) {} 13623b3eb3cSopenharmony_ci ~TouchOutsideListener() = default; 13723b3eb3cSopenharmony_ci 13823b3eb3cSopenharmony_ci void OnTouchOutside() const 13923b3eb3cSopenharmony_ci { 14023b3eb3cSopenharmony_ci LOGI("[Engine Log] The feature is not supported on the previewer, and instanceId_ = %{public}d", instanceId_); 14123b3eb3cSopenharmony_ci } 14223b3eb3cSopenharmony_ci 14323b3eb3cSopenharmony_ciprivate: 14423b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 14523b3eb3cSopenharmony_ci}; 14623b3eb3cSopenharmony_ci 14723b3eb3cSopenharmony_ciclass IIgnoreViewSafeAreaListener : public OHOS::Rosen::IIgnoreViewSafeAreaListener { 14823b3eb3cSopenharmony_cipublic: 14923b3eb3cSopenharmony_ci explicit IIgnoreViewSafeAreaListener(int32_t instanceId) : instanceId_(instanceId) {} 15023b3eb3cSopenharmony_ci ~IIgnoreViewSafeAreaListener() = default; 15123b3eb3cSopenharmony_ci 15223b3eb3cSopenharmony_ci void SetIgnoreViewSafeArea(bool ignoreViewSafeArea) 15323b3eb3cSopenharmony_ci { 15423b3eb3cSopenharmony_ci LOGD("[instanceId_:%{public}d]: SetIgnoreViewSafeArea:%{public}u", instanceId_, ignoreViewSafeArea); 15523b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 15623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 15723b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 15823b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 15923b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 16023b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 16123b3eb3cSopenharmony_ci [&pipelineContext, container, ignoreSafeArea = ignoreViewSafeArea]() { 16223b3eb3cSopenharmony_ci pipelineContext->SetIgnoreViewSafeArea(ignoreSafeArea); 16323b3eb3cSopenharmony_ci }, 16423b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetIgnoreViewSafeArea"); 16523b3eb3cSopenharmony_ci } 16623b3eb3cSopenharmony_ci 16723b3eb3cSopenharmony_ciprivate: 16823b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 16923b3eb3cSopenharmony_ci}; 17023b3eb3cSopenharmony_ci 17123b3eb3cSopenharmony_ciclass AvoidAreaChangedListener : public OHOS::Rosen::IAvoidAreaChangedListener { 17223b3eb3cSopenharmony_cipublic: 17323b3eb3cSopenharmony_ci explicit AvoidAreaChangedListener(int32_t instanceId) : instanceId_(instanceId) {} 17423b3eb3cSopenharmony_ci ~AvoidAreaChangedListener() = default; 17523b3eb3cSopenharmony_ci 17623b3eb3cSopenharmony_ci void OnAvoidAreaChanged(const OHOS::Rosen::AvoidArea avoidArea, OHOS::Rosen::AvoidAreaType type) 17723b3eb3cSopenharmony_ci { 17823b3eb3cSopenharmony_ci LOGD("Avoid area changed, type:%{public}d, topRect: avoidArea:x:%{public}d, y:%{public}d, " 17923b3eb3cSopenharmony_ci "width:%{public}d, height:%{public}d; bottomRect: avoidArea:x:%{public}d, y:%{public}d, " 18023b3eb3cSopenharmony_ci "width:%{public}d, height:%{public}d", 18123b3eb3cSopenharmony_ci type, avoidArea.topRect_.posX_, avoidArea.topRect_.posY_, (int32_t)avoidArea.topRect_.width_, 18223b3eb3cSopenharmony_ci (int32_t)avoidArea.topRect_.height_, avoidArea.bottomRect_.posX_, avoidArea.bottomRect_.posY_, 18323b3eb3cSopenharmony_ci (int32_t)avoidArea.bottomRect_.width_, (int32_t)avoidArea.bottomRect_.height_); 18423b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainerInstance(instanceId_); 18523b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 18623b3eb3cSopenharmony_ci auto pipeline = container->GetPipelineContext(); 18723b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipeline); 18823b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 18923b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 19023b3eb3cSopenharmony_ci if (type == Rosen::AvoidAreaType::TYPE_SYSTEM) { 19123b3eb3cSopenharmony_ci systemSafeArea_ = ConvertAvoidArea(avoidArea); 19223b3eb3cSopenharmony_ci } else if (type == Rosen::AvoidAreaType::TYPE_NAVIGATION_INDICATOR) { 19323b3eb3cSopenharmony_ci navigationBar_ = ConvertAvoidArea(avoidArea); 19423b3eb3cSopenharmony_ci } else if (type == Rosen::AvoidAreaType::TYPE_CUTOUT) { 19523b3eb3cSopenharmony_ci cutoutSafeArea_ = ConvertAvoidArea(avoidArea); 19623b3eb3cSopenharmony_ci } 19723b3eb3cSopenharmony_ci auto safeArea = systemSafeArea_; 19823b3eb3cSopenharmony_ci auto navSafeArea = navigationBar_; 19923b3eb3cSopenharmony_ci auto cutoutSafeArea = cutoutSafeArea_; 20023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 20123b3eb3cSopenharmony_ci taskExecutor->PostTask( 20223b3eb3cSopenharmony_ci [pipeline, safeArea, navSafeArea, cutoutSafeArea, type, avoidArea] { 20323b3eb3cSopenharmony_ci if (type == Rosen::AvoidAreaType::TYPE_SYSTEM) { 20423b3eb3cSopenharmony_ci pipeline->UpdateSystemSafeArea(safeArea); 20523b3eb3cSopenharmony_ci } else if (type == Rosen::AvoidAreaType::TYPE_NAVIGATION_INDICATOR) { 20623b3eb3cSopenharmony_ci pipeline->UpdateNavSafeArea(navSafeArea); 20723b3eb3cSopenharmony_ci } else if (type == Rosen::AvoidAreaType::TYPE_CUTOUT && pipeline->GetUseCutout()) { 20823b3eb3cSopenharmony_ci pipeline->UpdateCutoutSafeArea(cutoutSafeArea); 20923b3eb3cSopenharmony_ci } 21023b3eb3cSopenharmony_ci // for ui extension component 21123b3eb3cSopenharmony_ci pipeline->UpdateOriginAvoidArea(avoidArea, static_cast<uint32_t>(type)); 21223b3eb3cSopenharmony_ci }, 21323b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIUpdateOriginAvoidArea"); 21423b3eb3cSopenharmony_ci } 21523b3eb3cSopenharmony_ci 21623b3eb3cSopenharmony_ciprivate: 21723b3eb3cSopenharmony_ci NG::SafeAreaInsets systemSafeArea_; 21823b3eb3cSopenharmony_ci NG::SafeAreaInsets navigationBar_; 21923b3eb3cSopenharmony_ci NG::SafeAreaInsets cutoutSafeArea_; 22023b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 22123b3eb3cSopenharmony_ci}; 22223b3eb3cSopenharmony_ci 22323b3eb3cSopenharmony_ciextern "C" ACE_FORCE_EXPORT void* OHOS_ACE_CreateUIContent(void* context, void* runtime) 22423b3eb3cSopenharmony_ci{ 22523b3eb3cSopenharmony_ci return new UIContentImpl(reinterpret_cast<OHOS::AbilityRuntime::Context*>(context), runtime); 22623b3eb3cSopenharmony_ci} 22723b3eb3cSopenharmony_ci 22823b3eb3cSopenharmony_ciextern "C" ACE_FORCE_EXPORT void* OHOS_ACE_CreateFormContent(void* context, void* runtime, bool isCard) 22923b3eb3cSopenharmony_ci{ 23023b3eb3cSopenharmony_ci return new UIContentImpl(reinterpret_cast<OHOS::AbilityRuntime::Context*>(context), runtime, isCard); 23123b3eb3cSopenharmony_ci} 23223b3eb3cSopenharmony_ci 23323b3eb3cSopenharmony_ciextern "C" ACE_FORCE_EXPORT void* OHOS_ACE_CreateSubWindowUIContent(void* ability) 23423b3eb3cSopenharmony_ci{ 23523b3eb3cSopenharmony_ci return new UIContentImpl(reinterpret_cast<OHOS::AppExecFwk::Ability*>(ability)); 23623b3eb3cSopenharmony_ci} 23723b3eb3cSopenharmony_ci 23823b3eb3cSopenharmony_ciUIContentImpl::UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime) 23923b3eb3cSopenharmony_ci : instanceId_(ACE_INSTANCE_ID), runtime_(runtime) 24023b3eb3cSopenharmony_ci{ 24123b3eb3cSopenharmony_ci // 基于Options的方式传递参数 24223b3eb3cSopenharmony_ci auto options = context->GetOptions(); 24323b3eb3cSopenharmony_ci assetPath_ = options.assetPath; 24423b3eb3cSopenharmony_ci systemResourcesPath_ = options.systemResourcePath; 24523b3eb3cSopenharmony_ci appResourcesPath_ = options.appResourcePath; 24623b3eb3cSopenharmony_ci containerSdkPath_ = options.containerSdkPath; 24723b3eb3cSopenharmony_ci language_ = options.language; 24823b3eb3cSopenharmony_ci region_ = options.region; 24923b3eb3cSopenharmony_ci script_ = options.script; 25023b3eb3cSopenharmony_ci themeId_ = options.themeId; 25123b3eb3cSopenharmony_ci deviceWidth_ = options.deviceWidth; 25223b3eb3cSopenharmony_ci deviceHeight_ = options.deviceHeight; 25323b3eb3cSopenharmony_ci isRound_ = options.isRound; 25423b3eb3cSopenharmony_ci onRouterChange_ = options.onRouterChange; 25523b3eb3cSopenharmony_ci deviceConfig_.orientation = static_cast<DeviceOrientation>(options.deviceConfig.orientation); 25623b3eb3cSopenharmony_ci deviceConfig_.deviceType = static_cast<DeviceType>(options.deviceConfig.deviceType); 25723b3eb3cSopenharmony_ci deviceConfig_.colorMode = static_cast<ColorMode>(options.deviceConfig.colorMode); 25823b3eb3cSopenharmony_ci deviceConfig_.density = options.deviceConfig.density; 25923b3eb3cSopenharmony_ci deviceConfig_.fontRatio = options.deviceConfig.fontRatio; 26023b3eb3cSopenharmony_ci 26123b3eb3cSopenharmony_ci bundleName_ = options.bundleName; 26223b3eb3cSopenharmony_ci compatibleVersion_ = options.compatibleVersion; 26323b3eb3cSopenharmony_ci installationFree_ = options.installationFree; 26423b3eb3cSopenharmony_ci labelId_ = options.labelId; 26523b3eb3cSopenharmony_ci moduleName_ = options.moduleName; 26623b3eb3cSopenharmony_ci compileMode_ = options.compileMode; 26723b3eb3cSopenharmony_ci pageProfile_ = options.pageProfile; 26823b3eb3cSopenharmony_ci const std::string profilePrefix = "$profile:"; 26923b3eb3cSopenharmony_ci if (pageProfile_.compare(0, profilePrefix.size(), profilePrefix) == 0) { 27023b3eb3cSopenharmony_ci pageProfile_ = pageProfile_.substr(profilePrefix.length()).append(".json"); 27123b3eb3cSopenharmony_ci } 27223b3eb3cSopenharmony_ci targetVersion_ = options.targetVersion; 27323b3eb3cSopenharmony_ci auto releaseType = options.releaseType; 27423b3eb3cSopenharmony_ci bool enablePartialUpdate = options.enablePartialUpdate; 27523b3eb3cSopenharmony_ci useNewPipeline_ = AceNewPipeJudgement::QueryAceNewPipeEnabledStage( 27623b3eb3cSopenharmony_ci "", compatibleVersion_, targetVersion_, releaseType, !enablePartialUpdate); 27723b3eb3cSopenharmony_ci} 27823b3eb3cSopenharmony_ci 27923b3eb3cSopenharmony_ciUIContentImpl::UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime, bool isCard) 28023b3eb3cSopenharmony_ci : instanceId_(ACE_INSTANCE_ID), runtime_(runtime), isFormRender_(isCard) 28123b3eb3cSopenharmony_ci{ 28223b3eb3cSopenharmony_ci LOGI("The constructor is used to support ets card, isFormRender_ = %{public}d", isFormRender_); 28323b3eb3cSopenharmony_ci if (context) { 28423b3eb3cSopenharmony_ci auto options = context->GetOptions(); 28523b3eb3cSopenharmony_ci bundleName_ = options.bundleName; 28623b3eb3cSopenharmony_ci moduleName_ = options.moduleName; 28723b3eb3cSopenharmony_ci } 28823b3eb3cSopenharmony_ci} 28923b3eb3cSopenharmony_ci 29023b3eb3cSopenharmony_ciUIContentImpl::UIContentImpl(OHOS::AppExecFwk::Ability* ability) : instanceId_(ACE_INSTANCE_ID) {} 29123b3eb3cSopenharmony_ci 29223b3eb3cSopenharmony_civoid UIContentImpl::DestroyUIDirector() 29323b3eb3cSopenharmony_ci{ 29423b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 29523b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 29623b3eb3cSopenharmony_ci auto pipelineContext = AceType::DynamicCast<PipelineContext>(container->GetPipelineContext()); 29723b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 29823b3eb3cSopenharmony_ci auto rsUIDirector = pipelineContext->GetRSUIDirector(); 29923b3eb3cSopenharmony_ci CHECK_NULL_VOID(rsUIDirector); 30023b3eb3cSopenharmony_ci rsUIDirector->Destroy(); 30123b3eb3cSopenharmony_ci} 30223b3eb3cSopenharmony_ci 30323b3eb3cSopenharmony_civoid UIContentImpl::DestroyCallback() const 30423b3eb3cSopenharmony_ci{ 30523b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 30623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 30723b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 30823b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 30923b3eb3cSopenharmony_ci pipelineContext->SetNextFrameLayoutCallback(nullptr); 31023b3eb3cSopenharmony_ci} 31123b3eb3cSopenharmony_ci 31223b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::Initialize(OHOS::Rosen::Window* window, const std::string& url, 31323b3eb3cSopenharmony_ci napi_value storage) 31423b3eb3cSopenharmony_ci{ 31523b3eb3cSopenharmony_ci auto errorCode = UIContentErrorCode::NO_ERRORS; 31623b3eb3cSopenharmony_ci errorCode = CommonInitialize(window, url, storage); 31723b3eb3cSopenharmony_ci CHECK_ERROR_CODE_RETURN(errorCode); 31823b3eb3cSopenharmony_ci errorCode = AceContainer::RunPage(instanceId_, url, ""); 31923b3eb3cSopenharmony_ci return errorCode; 32023b3eb3cSopenharmony_ci} 32123b3eb3cSopenharmony_ci 32223b3eb3cSopenharmony_cistd::string UIContentImpl::GetContentInfo(ContentInfoType type) const 32323b3eb3cSopenharmony_ci{ 32423b3eb3cSopenharmony_ci return AceContainer::GetContentInfo(instanceId_, type); 32523b3eb3cSopenharmony_ci} 32623b3eb3cSopenharmony_ci 32723b3eb3cSopenharmony_ciUIContentErrorCode UIContentImpl::CommonInitialize(OHOS::Rosen::Window* window, 32823b3eb3cSopenharmony_ci const std::string& contentInfo, napi_value storage) 32923b3eb3cSopenharmony_ci{ 33023b3eb3cSopenharmony_ci static std::once_flag onceFlag; 33123b3eb3cSopenharmony_ci std::call_once(onceFlag, []() { 33223b3eb3cSopenharmony_ci#ifdef INIT_ICU_DATA_PATH 33323b3eb3cSopenharmony_ci std::string icuPath = "."; 33423b3eb3cSopenharmony_ci u_setDataDirectory(icuPath.c_str()); 33523b3eb3cSopenharmony_ci#endif 33623b3eb3cSopenharmony_ci Container::UpdateCurrent(INSTANCE_ID_PLATFORM); 33723b3eb3cSopenharmony_ci ClipboardProxy::GetInstance()->SetDelegate(std::make_unique<Platform::ClipboardProxyImpl>()); 33823b3eb3cSopenharmony_ci }); 33923b3eb3cSopenharmony_ci rsWindow_ = window; 34023b3eb3cSopenharmony_ci 34123b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetLocale(language_, region_, script_, ""); 34223b3eb3cSopenharmony_ci AceApplicationInfo::GetInstance().SetApiTargetVersion(targetVersion_); 34323b3eb3cSopenharmony_ci SetFontMgrConfig(containerSdkPath_); 34423b3eb3cSopenharmony_ci EventDispatcher::GetInstance().Initialize(); 34523b3eb3cSopenharmony_ci SystemProperties::SetExtSurfaceEnabled(!containerSdkPath_.empty()); 34623b3eb3cSopenharmony_ci SystemProperties::InitDeviceInfo(deviceWidth_, deviceHeight_, 34723b3eb3cSopenharmony_ci deviceConfig_.orientation == DeviceOrientation::PORTRAIT ? 0 : 1, deviceConfig_.density, isRound_); 34823b3eb3cSopenharmony_ci SystemProperties::InitDeviceType(deviceConfig_.deviceType); 34923b3eb3cSopenharmony_ci SystemProperties::SetColorMode(deviceConfig_.colorMode); 35023b3eb3cSopenharmony_ci LOGI("CreateContainer with JSDECLARATIVE frontend, set MinPlatformVersion to %{public}d", compatibleVersion_); 35123b3eb3cSopenharmony_ci AceContainer::CreateContainer(instanceId_, FrontendType::DECLARATIVE_JS, useNewPipeline_); 35223b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 35323b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, UIContentErrorCode::NULL_POINTER); 35423b3eb3cSopenharmony_ci container->SetContainerSdkPath(containerSdkPath_); 35523b3eb3cSopenharmony_ci container->SetIsFRSCardContainer(false); 35623b3eb3cSopenharmony_ci container->SetBundleName(bundleName_); 35723b3eb3cSopenharmony_ci container->SetModuleName(moduleName_); 35823b3eb3cSopenharmony_ci LOGI("Save bundle %{public}s, module %{public}s", bundleName_.c_str(), moduleName_.c_str()); 35923b3eb3cSopenharmony_ci if (runtime_) { 36023b3eb3cSopenharmony_ci container->GetSettings().SetUsingSharedRuntime(true); 36123b3eb3cSopenharmony_ci container->SetSharedRuntime(runtime_); 36223b3eb3cSopenharmony_ci } else { 36323b3eb3cSopenharmony_ci container->GetSettings().SetUsingSharedRuntime(false); 36423b3eb3cSopenharmony_ci } 36523b3eb3cSopenharmony_ci container->SetInstallationFree(installationFree_); 36623b3eb3cSopenharmony_ci container->SetLabelId(labelId_); 36723b3eb3cSopenharmony_ci auto config = container->GetResourceConfiguration(); 36823b3eb3cSopenharmony_ci config.SetDeviceType(SystemProperties::GetDeviceType()); 36923b3eb3cSopenharmony_ci config.SetOrientation(SystemProperties::GetDeviceOrientation()); 37023b3eb3cSopenharmony_ci config.SetDensity(SystemProperties::GetResolution()); 37123b3eb3cSopenharmony_ci config.SetColorMode(SystemProperties::GetColorMode()); 37223b3eb3cSopenharmony_ci config.SetFontRatio(deviceConfig_.fontRatio); 37323b3eb3cSopenharmony_ci container->SetResourceConfiguration(config); 37423b3eb3cSopenharmony_ci container->SetPageProfile(pageProfile_); 37523b3eb3cSopenharmony_ci container->SetApiTargetVersion(targetVersion_); 37623b3eb3cSopenharmony_ci std::vector<std::string> paths; 37723b3eb3cSopenharmony_ci paths.push_back(assetPath_); 37823b3eb3cSopenharmony_ci std::string appResourcesPath(appResourcesPath_); 37923b3eb3cSopenharmony_ci if (!OHOS::Ace::Framework::EndWith(appResourcesPath, DELIMITER)) { 38023b3eb3cSopenharmony_ci appResourcesPath.append(DELIMITER); 38123b3eb3cSopenharmony_ci } 38223b3eb3cSopenharmony_ci paths.push_back(appResourcesPath); 38323b3eb3cSopenharmony_ci paths.push_back(appResourcesPath + ASSET_PATH_SHARE_STAGE); 38423b3eb3cSopenharmony_ci if (!containerSdkPath_.empty()) { 38523b3eb3cSopenharmony_ci paths.push_back(containerSdkPath_); 38623b3eb3cSopenharmony_ci } 38723b3eb3cSopenharmony_ci AceContainer::AddAssetPath(instanceId_, "", paths); 38823b3eb3cSopenharmony_ci AceContainer::SetResourcesPathAndThemeStyle( 38923b3eb3cSopenharmony_ci instanceId_, systemResourcesPath_, containerSdkPath_, appResourcesPath_, themeId_, deviceConfig_.colorMode); 39023b3eb3cSopenharmony_ci 39123b3eb3cSopenharmony_ci auto view = AceViewPreview::CreateView(instanceId_, false, container->GetSettings().usePlatformAsUIThread); 39223b3eb3cSopenharmony_ci UIEnvCallback callback = [window = rsWindow_, id = instanceId_]( 39323b3eb3cSopenharmony_ci const OHOS::Ace::RefPtr<PipelineContext>& context) mutable { 39423b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 39523b3eb3cSopenharmony_ci CHECK_NULL_VOID(window); 39623b3eb3cSopenharmony_ci auto director = OHOS::Rosen::RSUIDirector::Create(); 39723b3eb3cSopenharmony_ci CHECK_NULL_VOID(director); 39823b3eb3cSopenharmony_ci director->SetRSSurfaceNode(window->GetSurfaceNode()); 39923b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(id); 40023b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 40123b3eb3cSopenharmony_ci auto func = [taskExecutor = container->GetTaskExecutor(), id]( 40223b3eb3cSopenharmony_ci const std::function<void()>& task, uint32_t delay) { 40323b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 40423b3eb3cSopenharmony_ci ContainerScope scope(id); 40523b3eb3cSopenharmony_ci taskExecutor->PostDelayedTask( 40623b3eb3cSopenharmony_ci task, TaskExecutor::TaskType::UI, delay, "ArkUIRenderServiceTask", PriorityType::HIGH); 40723b3eb3cSopenharmony_ci }; 40823b3eb3cSopenharmony_ci director->SetUITaskRunner(func, id); 40923b3eb3cSopenharmony_ci director->Init(); 41023b3eb3cSopenharmony_ci context->SetRSUIDirector(director); 41123b3eb3cSopenharmony_ci }; 41223b3eb3cSopenharmony_ci AceContainer::SetView(view, rsWindow_, deviceConfig_.density, deviceWidth_, deviceHeight_, callback); 41323b3eb3cSopenharmony_ci // Drive the native engine with the platform thread. 41423b3eb3cSopenharmony_ci container->RunNativeEngineLoop(); 41523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 41623b3eb3cSopenharmony_ci if (pipelineContext) { 41723b3eb3cSopenharmony_ci pipelineContext->SetMinPlatformVersion(compatibleVersion_); 41823b3eb3cSopenharmony_ci pipelineContext->SetDisplayWindowRectInfo( 41923b3eb3cSopenharmony_ci Rect(Offset(0.0f, 0.0f), Size(deviceWidth_, deviceHeight_))); 42023b3eb3cSopenharmony_ci } 42123b3eb3cSopenharmony_ci container->InitializeAppConfig(assetPath_, bundleName_, moduleName_, compileMode_); 42223b3eb3cSopenharmony_ci AceContainer::AddRouterChangeCallback(instanceId_, onRouterChange_); 42323b3eb3cSopenharmony_ci // Should make it possible to update surface changes by using viewWidth and viewHeight. 42423b3eb3cSopenharmony_ci view->NotifySurfaceChanged(deviceWidth_, deviceHeight_); 42523b3eb3cSopenharmony_ci view->NotifyDensityChanged(deviceConfig_.density); 42623b3eb3cSopenharmony_ci avoidAreaChangedListener_ = new AvoidAreaChangedListener(instanceId_); 42723b3eb3cSopenharmony_ci rsWindow_->RegisterAvoidAreaChangeListener(avoidAreaChangedListener_); 42823b3eb3cSopenharmony_ci ignoreViewSafeAreaListener_ = new IIgnoreViewSafeAreaListener(instanceId_); 42923b3eb3cSopenharmony_ci window->RegisterIgnoreViewSafeAreaListener(ignoreViewSafeAreaListener_); 43023b3eb3cSopenharmony_ci OHOS::Rosen::AvoidArea avoidArea; 43123b3eb3cSopenharmony_ci rsWindow_->GetAvoidAreaByType(OHOS::Rosen::AvoidAreaType::TYPE_SYSTEM, avoidArea); 43223b3eb3cSopenharmony_ci avoidAreaChangedListener_->OnAvoidAreaChanged(avoidArea, OHOS::Rosen::AvoidAreaType::TYPE_SYSTEM); 43323b3eb3cSopenharmony_ci rsWindow_->GetAvoidAreaByType(OHOS::Rosen::AvoidAreaType::TYPE_NAVIGATION_INDICATOR, avoidArea); 43423b3eb3cSopenharmony_ci avoidAreaChangedListener_->OnAvoidAreaChanged(avoidArea, OHOS::Rosen::AvoidAreaType::TYPE_NAVIGATION_INDICATOR); 43523b3eb3cSopenharmony_ci return UIContentErrorCode::NO_ERRORS; 43623b3eb3cSopenharmony_ci} 43723b3eb3cSopenharmony_ci 43823b3eb3cSopenharmony_civoid UIContentImpl::Destroy() 43923b3eb3cSopenharmony_ci{ 44023b3eb3cSopenharmony_ci LOGI("UIContentImpl: window destroy"); 44123b3eb3cSopenharmony_ci AceContainer::DestroyContainer(instanceId_); 44223b3eb3cSopenharmony_ci} 44323b3eb3cSopenharmony_ci 44423b3eb3cSopenharmony_ciuint32_t UIContentImpl::GetBackgroundColor() 44523b3eb3cSopenharmony_ci{ 44623b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 44723b3eb3cSopenharmony_ci CHECK_NULL_RETURN(container, 0x000000); 44823b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 44923b3eb3cSopenharmony_ci CHECK_NULL_RETURN(taskExecutor, 0x000000); 45023b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 45123b3eb3cSopenharmony_ci uint32_t bgColor = 0x000000; 45223b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 45323b3eb3cSopenharmony_ci [&bgColor, container]() { 45423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 45523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 45623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 45723b3eb3cSopenharmony_ci bgColor = pipelineContext->GetAppBgColor().GetValue(); 45823b3eb3cSopenharmony_ci }, 45923b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUIGetAppBackgroundColor"); 46023b3eb3cSopenharmony_ci 46123b3eb3cSopenharmony_ci return bgColor; 46223b3eb3cSopenharmony_ci} 46323b3eb3cSopenharmony_ci 46423b3eb3cSopenharmony_civoid UIContentImpl::SetBackgroundColor(uint32_t color) 46523b3eb3cSopenharmony_ci{ 46623b3eb3cSopenharmony_ci LOGI("UIContentImpl: SetBackgroundColor color is %{public}u", color); 46723b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 46823b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 46923b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 47023b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 47123b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 47223b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 47323b3eb3cSopenharmony_ci [container, bgColor = color]() { 47423b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 47523b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 47623b3eb3cSopenharmony_ci pipelineContext->SetAppBgColor(Color(bgColor)); 47723b3eb3cSopenharmony_ci }, 47823b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetAppBackgroundColor"); 47923b3eb3cSopenharmony_ci} 48023b3eb3cSopenharmony_ci 48123b3eb3cSopenharmony_civoid UIContentImpl::SetWindowContainerColor(uint32_t activeColor, uint32_t inactiveColor) 48223b3eb3cSopenharmony_ci{ 48323b3eb3cSopenharmony_ci TAG_LOGI(AceLogTag::ACE_APPBAR, "[%{public}s][%{public}s][%{public}d]: SetWindowContainerColor:" 48423b3eb3cSopenharmony_ci "active color %{public}u, inactive color %{public}u", 48523b3eb3cSopenharmony_ci bundleName_.c_str(), moduleName_.c_str(), instanceId_, activeColor, inactiveColor); 48623b3eb3cSopenharmony_ci auto container = AceEngine::Get().GetContainer(instanceId_); 48723b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 48823b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 48923b3eb3cSopenharmony_ci auto taskExecutor = container->GetTaskExecutor(); 49023b3eb3cSopenharmony_ci CHECK_NULL_VOID(taskExecutor); 49123b3eb3cSopenharmony_ci taskExecutor->PostSyncTask( 49223b3eb3cSopenharmony_ci [container, activeColor, inactiveColor]() { 49323b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 49423b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 49523b3eb3cSopenharmony_ci pipelineContext->SetWindowContainerColor(Color(activeColor), Color(inactiveColor)); 49623b3eb3cSopenharmony_ci }, 49723b3eb3cSopenharmony_ci TaskExecutor::TaskType::UI, "ArkUISetWindowContainerColor"); 49823b3eb3cSopenharmony_ci} 49923b3eb3cSopenharmony_ci 50023b3eb3cSopenharmony_cibool UIContentImpl::ProcessBackPressed() 50123b3eb3cSopenharmony_ci{ 50223b3eb3cSopenharmony_ci LOGI("Process Back Pressed Event"); 50323b3eb3cSopenharmony_ci return EventDispatcher::GetInstance().DispatchBackPressedEvent(); 50423b3eb3cSopenharmony_ci} 50523b3eb3cSopenharmony_ci 50623b3eb3cSopenharmony_cibool UIContentImpl::ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) 50723b3eb3cSopenharmony_ci{ 50823b3eb3cSopenharmony_ci return EventDispatcher::GetInstance().DispatchTouchEvent(pointerEvent); 50923b3eb3cSopenharmony_ci} 51023b3eb3cSopenharmony_ci 51123b3eb3cSopenharmony_cibool UIContentImpl::ProcessPointerEventWithCallback( 51223b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent, const std::function<void()>& callback) 51323b3eb3cSopenharmony_ci{ 51423b3eb3cSopenharmony_ci auto result = EventDispatcher::GetInstance().DispatchTouchEvent(pointerEvent); 51523b3eb3cSopenharmony_ci if (callback) { 51623b3eb3cSopenharmony_ci callback(); 51723b3eb3cSopenharmony_ci } 51823b3eb3cSopenharmony_ci return result; 51923b3eb3cSopenharmony_ci} 52023b3eb3cSopenharmony_ci 52123b3eb3cSopenharmony_cibool UIContentImpl::ProcessKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent, bool isPreIme) 52223b3eb3cSopenharmony_ci{ 52323b3eb3cSopenharmony_ci // previewer never gets preIme-key event because there is no window 52423b3eb3cSopenharmony_ci return EventDispatcher::GetInstance().DispatchKeyEvent(keyEvent); 52523b3eb3cSopenharmony_ci} 52623b3eb3cSopenharmony_ci 52723b3eb3cSopenharmony_cibool UIContentImpl::ProcessAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) 52823b3eb3cSopenharmony_ci{ 52923b3eb3cSopenharmony_ci return false; 53023b3eb3cSopenharmony_ci} 53123b3eb3cSopenharmony_ci 53223b3eb3cSopenharmony_cibool UIContentImpl::ProcessVsyncEvent(uint64_t timeStampNanos) 53323b3eb3cSopenharmony_ci{ 53423b3eb3cSopenharmony_ci return false; 53523b3eb3cSopenharmony_ci} 53623b3eb3cSopenharmony_ci 53723b3eb3cSopenharmony_civoid UIContentImpl::UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) {} 53823b3eb3cSopenharmony_ci 53923b3eb3cSopenharmony_civoid UIContentImpl::UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason, 54023b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction, 54123b3eb3cSopenharmony_ci const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas) 54223b3eb3cSopenharmony_ci{ 54323b3eb3cSopenharmony_ci LOGI("ViewportConfig: %{public}s", config.ToString().c_str()); 54423b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 54523b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 54623b3eb3cSopenharmony_ci auto context = container->GetPipelineContext(); 54723b3eb3cSopenharmony_ci CHECK_NULL_VOID(context); 54823b3eb3cSopenharmony_ci context->SetDisplayWindowRectInfo( 54923b3eb3cSopenharmony_ci Rect(Offset(config.Left(), config.Top()), Size(config.Width(), config.Height()))); 55023b3eb3cSopenharmony_ci auto viewPtr = AceType::DynamicCast<AceViewPreview>(container->GetAceView()); 55123b3eb3cSopenharmony_ci CHECK_NULL_VOID(viewPtr); 55223b3eb3cSopenharmony_ci SystemProperties::InitDeviceInfo( 55323b3eb3cSopenharmony_ci config.Width(), config.Height(), config.Height() >= config.Width() ? 0 : 1, config.Density(), false); 55423b3eb3cSopenharmony_ci deviceConfig_.orientation = 55523b3eb3cSopenharmony_ci config.Height() >= config.Width() ? DeviceOrientation::PORTRAIT : DeviceOrientation::LANDSCAPE; 55623b3eb3cSopenharmony_ci deviceConfig_.density = config.Density(); 55723b3eb3cSopenharmony_ci // Unlike the real machine, previewer require updating device configuration information to change window size. 55823b3eb3cSopenharmony_ci container->UpdateDeviceConfig(deviceConfig_); 55923b3eb3cSopenharmony_ci viewPtr->NotifyDensityChanged(config.Density()); 56023b3eb3cSopenharmony_ci viewPtr->NotifySurfaceChanged(config.Width(), config.Height()); 56123b3eb3cSopenharmony_ci} 56223b3eb3cSopenharmony_ci 56323b3eb3cSopenharmony_civoid UIContentImpl::DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) 56423b3eb3cSopenharmony_ci{ 56523b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 56623b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 56723b3eb3cSopenharmony_ci container->Dump(params, info); 56823b3eb3cSopenharmony_ci} 56923b3eb3cSopenharmony_ci 57023b3eb3cSopenharmony_civoid UIContentImpl::SetNextFrameLayoutCallback(std::function<void()>&& callback) 57123b3eb3cSopenharmony_ci{ 57223b3eb3cSopenharmony_ci CHECK_NULL_VOID(callback); 57323b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 57423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 57523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 57623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 57723b3eb3cSopenharmony_ci pipelineContext->SetNextFrameLayoutCallback(std::move(callback)); 57823b3eb3cSopenharmony_ci} 57923b3eb3cSopenharmony_ci 58023b3eb3cSopenharmony_civoid UIContentImpl::NotifyMemoryLevel(int32_t level) 58123b3eb3cSopenharmony_ci{ 58223b3eb3cSopenharmony_ci LOGI("Receive Memory level notification, level: %{public}d", level); 58323b3eb3cSopenharmony_ci auto container = AceContainer::GetContainerInstance(instanceId_); 58423b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 58523b3eb3cSopenharmony_ci auto pipelineContext = container->GetPipelineContext(); 58623b3eb3cSopenharmony_ci CHECK_NULL_VOID(pipelineContext); 58723b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 58823b3eb3cSopenharmony_ci pipelineContext->NotifyMemoryLevel(level); 58923b3eb3cSopenharmony_ci} 59023b3eb3cSopenharmony_ci 59123b3eb3cSopenharmony_ciint32_t UIContentImpl::CreateModalUIExtension( 59223b3eb3cSopenharmony_ci const AAFwk::Want& want, const ModalUIExtensionCallbacks& callbacks, const ModalUIExtensionConfig& config) 59323b3eb3cSopenharmony_ci{ 59423b3eb3cSopenharmony_ci return 0; 59523b3eb3cSopenharmony_ci} 59623b3eb3cSopenharmony_ci 59723b3eb3cSopenharmony_civoid UIContentImpl::CloseModalUIExtension(int32_t sessionId) {} 59823b3eb3cSopenharmony_ci 59923b3eb3cSopenharmony_civoid UIContentImpl::SetStatusBarItemColor(uint32_t color) 60023b3eb3cSopenharmony_ci{ 60123b3eb3cSopenharmony_ci ContainerScope scope(instanceId_); 60223b3eb3cSopenharmony_ci auto container = Platform::AceContainer::GetContainer(instanceId_); 60323b3eb3cSopenharmony_ci CHECK_NULL_VOID(container); 60423b3eb3cSopenharmony_ci auto appBar = container->GetAppBar(); 60523b3eb3cSopenharmony_ci CHECK_NULL_VOID(appBar); 60623b3eb3cSopenharmony_ci appBar->SetStatusBarItemColor(IsDarkColor(color)); 60723b3eb3cSopenharmony_ci} 60823b3eb3cSopenharmony_ci} // namespace OHOS::Ace 609