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#ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_ENTRANCE_UI_CONTENT_IMPL_H 1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_ADAPTER_PREVIEW_ENTRANCE_UI_CONTENT_IMPL_H 1823b3eb3cSopenharmony_ci 1923b3eb3cSopenharmony_ci#include "interfaces/inner_api/ace/ui_content.h" 2023b3eb3cSopenharmony_ci#include "interfaces/inner_api/ace/viewport_config.h" 2123b3eb3cSopenharmony_ci#include "native_engine/native_engine.h" 2223b3eb3cSopenharmony_ci#include "native_engine/native_value.h" 2323b3eb3cSopenharmony_ci#include "previewer/include/window.h" 2423b3eb3cSopenharmony_ci 2523b3eb3cSopenharmony_ci#include "adapter/preview/entrance/ace_run_args.h" 2623b3eb3cSopenharmony_ci#include "adapter/preview/external/ability/context.h" 2723b3eb3cSopenharmony_ci#include "adapter/preview/external/ability/fa/fa_context.h" 2823b3eb3cSopenharmony_ci#include "adapter/preview/external/ability/stage/stage_context.h" 2923b3eb3cSopenharmony_ci 3023b3eb3cSopenharmony_cinamespace OHOS::Ace { 3123b3eb3cSopenharmony_ciclass ACE_FORCE_EXPORT UIContentImpl : public UIContent { 3223b3eb3cSopenharmony_cipublic: 3323b3eb3cSopenharmony_ci UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime); 3423b3eb3cSopenharmony_ci UIContentImpl(OHOS::AppExecFwk::Ability* ability); 3523b3eb3cSopenharmony_ci UIContentImpl(OHOS::AbilityRuntime::Context* context, void* runtime, bool isCard); 3623b3eb3cSopenharmony_ci ~UIContentImpl() 3723b3eb3cSopenharmony_ci { 3823b3eb3cSopenharmony_ci DestroyUIDirector(); 3923b3eb3cSopenharmony_ci DestroyCallback(); 4023b3eb3cSopenharmony_ci } 4123b3eb3cSopenharmony_ci 4223b3eb3cSopenharmony_ci // UI content lifeCycles 4323b3eb3cSopenharmony_ci UIContentErrorCode Initialize(OHOS::Rosen::Window* window, const std::string& url, napi_value storage) override; 4423b3eb3cSopenharmony_ci UIContentErrorCode Initialize(OHOS::Rosen::Window* window, 4523b3eb3cSopenharmony_ci const std::shared_ptr<std::vector<uint8_t>>& content, napi_value storage) override { 4623b3eb3cSopenharmony_ci return UIContentErrorCode::NO_ERRORS; 4723b3eb3cSopenharmony_ci } 4823b3eb3cSopenharmony_ci UIContentErrorCode InitializeByName(OHOS::Rosen::Window *window, const std::string &name, 4923b3eb3cSopenharmony_ci napi_value storage) override { 5023b3eb3cSopenharmony_ci return UIContentErrorCode::NO_ERRORS; 5123b3eb3cSopenharmony_ci } 5223b3eb3cSopenharmony_ci void InitializeDynamic(int32_t hostInstanceId, const std::string& hapPath, const std::string& abcPath, 5323b3eb3cSopenharmony_ci const std::string& entryPoint, const std::vector<std::string>& registerComponents) override {} 5423b3eb3cSopenharmony_ci void Initialize( 5523b3eb3cSopenharmony_ci OHOS::Rosen::Window* window, const std::string& url, napi_value storage, uint32_t focusWindowId) override {} 5623b3eb3cSopenharmony_ci void Foreground() override {} 5723b3eb3cSopenharmony_ci void Background() override {} 5823b3eb3cSopenharmony_ci void Focus() override {} 5923b3eb3cSopenharmony_ci void UnFocus() override {} 6023b3eb3cSopenharmony_ci void Destroy() override; 6123b3eb3cSopenharmony_ci void OnNewWant(const OHOS::AAFwk::Want& want) override {} 6223b3eb3cSopenharmony_ci 6323b3eb3cSopenharmony_ci // restore 6423b3eb3cSopenharmony_ci UIContentErrorCode Restore(OHOS::Rosen::Window* window, const std::string& contentInfo, 6523b3eb3cSopenharmony_ci napi_value storage, ContentInfoType type) override { 6623b3eb3cSopenharmony_ci return UIContentErrorCode::NO_ERRORS; 6723b3eb3cSopenharmony_ci } 6823b3eb3cSopenharmony_ci std::string GetContentInfo(ContentInfoType type) const override; 6923b3eb3cSopenharmony_ci void DestroyUIDirector() override; 7023b3eb3cSopenharmony_ci 7123b3eb3cSopenharmony_ci // UI content event process 7223b3eb3cSopenharmony_ci bool ProcessBackPressed() override; 7323b3eb3cSopenharmony_ci bool ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) override; 7423b3eb3cSopenharmony_ci bool ProcessPointerEventWithCallback( 7523b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent, const std::function<void()>& callback) override; 7623b3eb3cSopenharmony_ci bool ProcessKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent, bool isPreIme) override; 7723b3eb3cSopenharmony_ci bool ProcessAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) override; 7823b3eb3cSopenharmony_ci bool ProcessVsyncEvent(uint64_t timeStampNanos) override; 7923b3eb3cSopenharmony_ci void SetIsFocusActive(bool isFocusActive) override {} 8023b3eb3cSopenharmony_ci void UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) override; 8123b3eb3cSopenharmony_ci void UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason, 8223b3eb3cSopenharmony_ci const std::shared_ptr<OHOS::Rosen::RSTransaction>& rsTransaction = nullptr, 8323b3eb3cSopenharmony_ci const std::map<OHOS::Rosen::AvoidAreaType, OHOS::Rosen::AvoidArea>& avoidAreas = {}) override; 8423b3eb3cSopenharmony_ci void UpdateWindowMode(OHOS::Rosen::WindowMode mode, bool hasDeco = true) override {} 8523b3eb3cSopenharmony_ci void UpdateDecorVisible(bool visible, bool hasDeco = true) override {}; 8623b3eb3cSopenharmony_ci void HideWindowTitleButton(bool hideSplit, bool hideMaximize, bool hideMinimize, bool hideClose) override {} 8723b3eb3cSopenharmony_ci void SetIgnoreViewSafeArea(bool ignoreViewSafeArea) override {} 8823b3eb3cSopenharmony_ci void UpdateTitleInTargetPos(bool isShow, int32_t height) override {} 8923b3eb3cSopenharmony_ci 9023b3eb3cSopenharmony_ci // Window color 9123b3eb3cSopenharmony_ci uint32_t GetBackgroundColor() override; 9223b3eb3cSopenharmony_ci void SetBackgroundColor(uint32_t color) override; 9323b3eb3cSopenharmony_ci void SetWindowContainerColor(uint32_t activeColor, uint32_t inactiveColor) override; 9423b3eb3cSopenharmony_ci 9523b3eb3cSopenharmony_ci void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) override; 9623b3eb3cSopenharmony_ci 9723b3eb3cSopenharmony_ci // Set UIContent callback for custom window animation 9823b3eb3cSopenharmony_ci void SetNextFrameLayoutCallback(std::function<void()>&& callback) override; 9923b3eb3cSopenharmony_ci 10023b3eb3cSopenharmony_ci // Receive memory level notification 10123b3eb3cSopenharmony_ci void NotifyMemoryLevel(int32_t level) override; 10223b3eb3cSopenharmony_ci 10323b3eb3cSopenharmony_ci void SetAppWindowTitle(const std::string& title) override {} 10423b3eb3cSopenharmony_ci void SetAppWindowIcon(const std::shared_ptr<Media::PixelMap>& pixelMap) override {} 10523b3eb3cSopenharmony_ci void SetActionEventHandler(std::function<void(const std::string& action)>&& actionCallback) override {} 10623b3eb3cSopenharmony_ci void SetErrorEventHandler(std::function<void(const std::string&, const std::string&)>&& errorCallback) override {} 10723b3eb3cSopenharmony_ci void SetFormLinkInfoUpdateHandler(std::function<void(const std::vector<std::string>&)>&& callback) override {} 10823b3eb3cSopenharmony_ci 10923b3eb3cSopenharmony_ci // ArkTS Form 11023b3eb3cSopenharmony_ci void PreInitializeForm(OHOS::Rosen::Window* window, const std::string& url, napi_value storage) override {} 11123b3eb3cSopenharmony_ci void RunFormPage() override {} 11223b3eb3cSopenharmony_ci void OnFormSurfaceChange(float width, float height, 11323b3eb3cSopenharmony_ci OHOS::Rosen::WindowSizeChangeReason type = static_cast<OHOS::Rosen::WindowSizeChangeReason>(0), 11423b3eb3cSopenharmony_ci const std::shared_ptr<Rosen::RSTransaction>& rsTransaction = nullptr) override {} 11523b3eb3cSopenharmony_ci void UpdateFormData(const std::string& data) override {} 11623b3eb3cSopenharmony_ci void UpdateFormSharedImage(const std::map<std::string, sptr<OHOS::AppExecFwk::FormAshmem>>& imageDataMap) override 11723b3eb3cSopenharmony_ci {} 11823b3eb3cSopenharmony_ci void SetFormWidth(float width) override {} 11923b3eb3cSopenharmony_ci void SetFormHeight(float height) override {} 12023b3eb3cSopenharmony_ci float GetFormWidth() override 12123b3eb3cSopenharmony_ci { 12223b3eb3cSopenharmony_ci return 0.0; 12323b3eb3cSopenharmony_ci } 12423b3eb3cSopenharmony_ci float GetFormHeight() override 12523b3eb3cSopenharmony_ci { 12623b3eb3cSopenharmony_ci return 0.0; 12723b3eb3cSopenharmony_ci } 12823b3eb3cSopenharmony_ci std::shared_ptr<Rosen::RSSurfaceNode> GetFormRootNode() override 12923b3eb3cSopenharmony_ci { 13023b3eb3cSopenharmony_ci return nullptr; 13123b3eb3cSopenharmony_ci } 13223b3eb3cSopenharmony_ci 13323b3eb3cSopenharmony_ci int32_t CreateModalUIExtension(const AAFwk::Want& want, 13423b3eb3cSopenharmony_ci const ModalUIExtensionCallbacks& callbacks, const ModalUIExtensionConfig& config) override; 13523b3eb3cSopenharmony_ci void CloseModalUIExtension(int32_t sessionId) override; 13623b3eb3cSopenharmony_ci 13723b3eb3cSopenharmony_ci void SetParentToken(sptr<IRemoteObject> token) override {} 13823b3eb3cSopenharmony_ci sptr<IRemoteObject> GetParentToken() override 13923b3eb3cSopenharmony_ci { 14023b3eb3cSopenharmony_ci return nullptr; 14123b3eb3cSopenharmony_ci } 14223b3eb3cSopenharmony_ci 14323b3eb3cSopenharmony_ci SerializedGesture GetFormSerializedGesture() override 14423b3eb3cSopenharmony_ci { 14523b3eb3cSopenharmony_ci return SerializedGesture(); 14623b3eb3cSopenharmony_ci } 14723b3eb3cSopenharmony_ci 14823b3eb3cSopenharmony_ci void UpdateTransform(const OHOS::Rosen::Transform& transform) override {}; 14923b3eb3cSopenharmony_ci 15023b3eb3cSopenharmony_ci void SetContentNodeGrayScale(float grayscale) override {}; 15123b3eb3cSopenharmony_ci 15223b3eb3cSopenharmony_ci void PreLayout() override {}; 15323b3eb3cSopenharmony_ci 15423b3eb3cSopenharmony_ci void SetStatusBarItemColor(uint32_t color) override; 15523b3eb3cSopenharmony_ci 15623b3eb3cSopenharmony_ci void SetForceSplitEnable(bool isForceSplit, const std::string& homePage) override {}; 15723b3eb3cSopenharmony_ci 15823b3eb3cSopenharmony_ciprivate: 15923b3eb3cSopenharmony_ci UIContentErrorCode CommonInitialize(OHOS::Rosen::Window* window, const std::string& contentInfo, 16023b3eb3cSopenharmony_ci napi_value storage); 16123b3eb3cSopenharmony_ci void DestroyCallback() const; 16223b3eb3cSopenharmony_ci 16323b3eb3cSopenharmony_ciprivate: 16423b3eb3cSopenharmony_ci int32_t instanceId_ = -1; 16523b3eb3cSopenharmony_ci void* runtime_ = nullptr; 16623b3eb3cSopenharmony_ci // All parameters that need to be passed. 16723b3eb3cSopenharmony_ci std::string assetPath_; 16823b3eb3cSopenharmony_ci std::string systemResourcesPath_; 16923b3eb3cSopenharmony_ci std::string appResourcesPath_; 17023b3eb3cSopenharmony_ci std::string containerSdkPath_; 17123b3eb3cSopenharmony_ci std::string language_; 17223b3eb3cSopenharmony_ci std::string region_; 17323b3eb3cSopenharmony_ci std::string script_; 17423b3eb3cSopenharmony_ci uint32_t themeId_ = 0; 17523b3eb3cSopenharmony_ci int32_t deviceWidth_ = 0; 17623b3eb3cSopenharmony_ci int32_t deviceHeight_ = 0; 17723b3eb3cSopenharmony_ci bool isRound_ = false; 17823b3eb3cSopenharmony_ci Platform::SendCurrentRouterCallback onRouterChange_; 17923b3eb3cSopenharmony_ci DeviceConfig deviceConfig_; 18023b3eb3cSopenharmony_ci 18123b3eb3cSopenharmony_ci std::string bundleName_; 18223b3eb3cSopenharmony_ci std::string moduleName_; 18323b3eb3cSopenharmony_ci std::string compileMode_; 18423b3eb3cSopenharmony_ci std::string pageProfile_; 18523b3eb3cSopenharmony_ci int32_t compatibleVersion_ = 0; 18623b3eb3cSopenharmony_ci int32_t targetVersion_ = 0; 18723b3eb3cSopenharmony_ci bool installationFree_ = false; 18823b3eb3cSopenharmony_ci uint32_t labelId_ = 0; 18923b3eb3cSopenharmony_ci bool useNewPipeline_ = true; 19023b3eb3cSopenharmony_ci 19123b3eb3cSopenharmony_ci sptr<OHOS::Rosen::Window> rsWindow_; 19223b3eb3cSopenharmony_ci // ITouchOutsideListener is used for touching out of hot areas of window. 19323b3eb3cSopenharmony_ci OHOS::sptr<OHOS::Rosen::ITouchOutsideListener> touchOutsideListener_ = nullptr; 19423b3eb3cSopenharmony_ci OHOS::sptr<OHOS::Rosen::IWindowDragListener> dragWindowListener_ = nullptr; 19523b3eb3cSopenharmony_ci OHOS::sptr<OHOS::Rosen::IAvoidAreaChangedListener> avoidAreaChangedListener_ = nullptr; 19623b3eb3cSopenharmony_ci OHOS::sptr<OHOS::Rosen::IIgnoreViewSafeAreaListener> ignoreViewSafeAreaListener_ = nullptr; 19723b3eb3cSopenharmony_ci // ArkTS Form 19823b3eb3cSopenharmony_ci bool isFormRender_ = false; 19923b3eb3cSopenharmony_ci}; 20023b3eb3cSopenharmony_ci} // namespace OHOS::Ace 20123b3eb3cSopenharmony_ci 20223b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_ADAPTER_PREVIEW_ENTRANCE_UI_CONTENT_IMPL_H 203