123b3eb3cSopenharmony_ci/* 223b3eb3cSopenharmony_ci * Copyright (c) 2021-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_ACE_ABILITY_H 1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_ABILITY_H 1823b3eb3cSopenharmony_ci 1923b3eb3cSopenharmony_ci#include <atomic> 2023b3eb3cSopenharmony_ci#include <map> 2123b3eb3cSopenharmony_ci#include <memory> 2223b3eb3cSopenharmony_ci#include <refbase.h> 2323b3eb3cSopenharmony_ci#include <string> 2423b3eb3cSopenharmony_ci#include <thread> 2523b3eb3cSopenharmony_ci 2623b3eb3cSopenharmony_ci#include "adapter/preview/entrance/ace_run_args.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/external/ability/context.h" 3023b3eb3cSopenharmony_ci#include "adapter/preview/external/ability/fa/fa_context.h" 3123b3eb3cSopenharmony_ci#include "adapter/preview/external/ability/stage/stage_context.h" 3223b3eb3cSopenharmony_ci#include "adapter/preview/external/multimodalinput/axis_event.h" 3323b3eb3cSopenharmony_ci#include "adapter/preview/external/multimodalinput/key_event.h" 3423b3eb3cSopenharmony_ci#include "adapter/preview/external/multimodalinput/pointer_event.h" 3523b3eb3cSopenharmony_ci#include "frameworks/base/utils/macros.h" 3623b3eb3cSopenharmony_ci#include "frameworks/core/common/window_animation_config.h" 3723b3eb3cSopenharmony_ci 3823b3eb3cSopenharmony_cinamespace OHOS::Rosen { 3923b3eb3cSopenharmony_ciclass Window; 4023b3eb3cSopenharmony_ciclass IAvoidAreaChangedListener; 4123b3eb3cSopenharmony_ciclass IIgnoreViewSafeAreaListener; 4223b3eb3cSopenharmony_ci} 4323b3eb3cSopenharmony_ci 4423b3eb3cSopenharmony_cinamespace OHOS::Ace::Platform { 4523b3eb3cSopenharmony_ci 4623b3eb3cSopenharmony_cistruct ConfigChanges { 4723b3eb3cSopenharmony_ci bool watchLocale = false; 4823b3eb3cSopenharmony_ci bool watchLayout = false; 4923b3eb3cSopenharmony_ci bool watchFontSize = false; 5023b3eb3cSopenharmony_ci bool watchOrientation = false; 5123b3eb3cSopenharmony_ci bool watchDensity = false; 5223b3eb3cSopenharmony_ci}; 5323b3eb3cSopenharmony_ci 5423b3eb3cSopenharmony_cistruct SystemParams { 5523b3eb3cSopenharmony_ci int32_t deviceWidth { 0 }; 5623b3eb3cSopenharmony_ci int32_t deviceHeight { 0 }; 5723b3eb3cSopenharmony_ci bool isRound = false; 5823b3eb3cSopenharmony_ci double density { 1.0 }; 5923b3eb3cSopenharmony_ci std::string language = "zh"; 6023b3eb3cSopenharmony_ci std::string region = "CN"; 6123b3eb3cSopenharmony_ci std::string script = ""; 6223b3eb3cSopenharmony_ci OHOS::Ace::DeviceType deviceType { DeviceType::PHONE }; 6323b3eb3cSopenharmony_ci OHOS::Ace::ColorMode colorMode { ColorMode::LIGHT }; 6423b3eb3cSopenharmony_ci OHOS::Ace::DeviceOrientation orientation { DeviceOrientation::PORTRAIT }; 6523b3eb3cSopenharmony_ci}; 6623b3eb3cSopenharmony_ci 6723b3eb3cSopenharmony_ciclass ACE_FORCE_EXPORT AceAbility { 6823b3eb3cSopenharmony_cipublic: 6923b3eb3cSopenharmony_ci explicit AceAbility(const AceRunArgs& runArgs); 7023b3eb3cSopenharmony_ci ~AceAbility(); 7123b3eb3cSopenharmony_ci 7223b3eb3cSopenharmony_ci // Be called in Previewer frontend thread, which is not ACE platform thread. 7323b3eb3cSopenharmony_ci static std::unique_ptr<AceAbility> CreateInstance(AceRunArgs& runArgs); 7423b3eb3cSopenharmony_ci void SetMockModuleList(const std::map<std::string, std::string>& mockJsonInfo); 7523b3eb3cSopenharmony_ci void InitEnv(); 7623b3eb3cSopenharmony_ci void InitializeClipboard() const; 7723b3eb3cSopenharmony_ci void OnBackPressed() const; 7823b3eb3cSopenharmony_ci bool OnInputEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const; 7923b3eb3cSopenharmony_ci bool OnInputEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const; 8023b3eb3cSopenharmony_ci bool OnInputEvent(const std::shared_ptr<MMI::AxisEvent>& axisEvent) const; 8123b3eb3cSopenharmony_ci bool OnInputMethodEvent(const unsigned int codePoint) const; 8223b3eb3cSopenharmony_ci 8323b3eb3cSopenharmony_ci void OnConfigurationChanged(const DeviceConfig& newConfig); 8423b3eb3cSopenharmony_ci void SurfaceChanged( 8523b3eb3cSopenharmony_ci const DeviceOrientation& orientation, const double& resolution, int32_t& width, int32_t& height, 8623b3eb3cSopenharmony_ci WindowSizeChangeReason type = WindowSizeChangeReason::UNDEFINED); 8723b3eb3cSopenharmony_ci void ReplacePage(const std::string& url, const std::string& params); 8823b3eb3cSopenharmony_ci void LoadDocument(const std::string& url, const std::string& componentName, SystemParams& systemParams); 8923b3eb3cSopenharmony_ci 9023b3eb3cSopenharmony_ci std::string GetJSONTree(); 9123b3eb3cSopenharmony_ci std::string GetDefaultJSONTree(); 9223b3eb3cSopenharmony_ci bool OperateComponent(const std::string& attrsJson); 9323b3eb3cSopenharmony_ci void SetWindow(sptr<OHOS::Rosen::Window> rsWindow); 9423b3eb3cSopenharmony_ci sptr<OHOS::Rosen::Window> GetWindow(); 9523b3eb3cSopenharmony_ci 9623b3eb3cSopenharmony_ci std::string GetBundleName() 9723b3eb3cSopenharmony_ci { 9823b3eb3cSopenharmony_ci return bundleName_; 9923b3eb3cSopenharmony_ci } 10023b3eb3cSopenharmony_ci 10123b3eb3cSopenharmony_ci std::string GetModuleName() 10223b3eb3cSopenharmony_ci { 10323b3eb3cSopenharmony_ci return moduleName_; 10423b3eb3cSopenharmony_ci } 10523b3eb3cSopenharmony_ci 10623b3eb3cSopenharmony_ciprivate: 10723b3eb3cSopenharmony_ci void InitializeAppInfo(); 10823b3eb3cSopenharmony_ci void SetConfigChanges(const std::string& configChanges); 10923b3eb3cSopenharmony_ci 11023b3eb3cSopenharmony_ci AceRunArgs runArgs_; 11123b3eb3cSopenharmony_ci ConfigChanges configChanges_; 11223b3eb3cSopenharmony_ci sptr<OHOS::Rosen::Window> rsWindow_; 11323b3eb3cSopenharmony_ci sptr<OHOS::Rosen::IAvoidAreaChangedListener> avoidAreaChangedListener_; 11423b3eb3cSopenharmony_ci sptr<OHOS::Rosen::IIgnoreViewSafeAreaListener> ignoreViewSafeAreaListener_; 11523b3eb3cSopenharmony_ci 11623b3eb3cSopenharmony_ci std::string bundleName_; 11723b3eb3cSopenharmony_ci std::string moduleName_; 11823b3eb3cSopenharmony_ci std::string compileMode_; 11923b3eb3cSopenharmony_ci int32_t compatibleVersion_ = 0; 12023b3eb3cSopenharmony_ci bool installationFree_ = false; 12123b3eb3cSopenharmony_ci uint32_t labelId_ = 0; 12223b3eb3cSopenharmony_ci bool useNewPipeline_ = true; 12323b3eb3cSopenharmony_ci}; 12423b3eb3cSopenharmony_ci 12523b3eb3cSopenharmony_ci} // namespace OHOS::Ace::Platform 12623b3eb3cSopenharmony_ci 12723b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_ABILITY_H 128