1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "JsAppImpl.h" 17#include "MockGlobalResult.h" 18 19JsAppImpl::JsAppImpl() noexcept : ability(nullptr), isStop(false) {} 20 21JsAppImpl::~JsAppImpl() {} 22 23JsAppImpl& JsAppImpl::GetInstance() 24{ 25 static JsAppImpl instance; 26 return instance; 27} 28 29void JsAppImpl::ResolutionChanged(ResolutionParam& param, int32_t screenDensity, std::string reason) 30{ 31 this->width = param.orignalWidth; 32 this->height = param.orignalHeight; 33} 34 35std::string JsAppImpl::GetOrientation() const 36{ 37 g_getOrientation = true; 38 return orientation; 39} 40 41void JsAppImpl::OrientationChanged(std::string commandOrientation) 42{ 43 orientation = commandOrientation; 44} 45 46std::string JsAppImpl::GetColorMode() const 47{ 48 g_getColorMode = true; 49 return colorMode; 50} 51 52void JsAppImpl::SetArgsColorMode(const std::string& value) 53{ 54 colorMode = value; 55} 56 57void JsAppImpl::ColorModeChanged(const std::string commandColorMode) 58{ 59 colorMode = commandColorMode; 60} 61 62bool JsAppImpl::MemoryRefresh(const std::string memoryRefreshArgs) const 63{ 64 g_memoryRefresh = true; 65 return true; 66} 67 68void JsAppImpl::LoadDocument(const std::string filePath, const std::string componentName, 69 const Json2::Value& previewContext) 70{ 71 g_loadDocument = true; 72} 73 74void JsAppImpl::ReloadRuntimePage(const std::string currentPage) 75{ 76 g_reloadRuntimePage = true; 77} 78 79void JsAppImpl::Restart() 80{ 81 g_restart = true; 82} 83 84std::string JsAppImpl::GetJSONTree() 85{ 86 g_getJSONTree = true; 87 return ""; 88} 89 90std::string JsAppImpl::GetDefaultJSONTree() 91{ 92 g_getDefaultJSONTree = true; 93 return ""; 94} 95 96void JsAppImpl::FoldStatusChanged(const std::string commandFoldStatus, int32_t currentWidth, int32_t currentHeight) 97{ 98 this->width = currentWidth; 99 this->height = currentHeight; 100} 101 102void JsAppImpl::Start() 103{ 104 isFinished = true; 105} 106 107void JsAppImpl::Interrupt() 108{ 109 isStop = true; 110} 111void JsAppImpl::SetArgsAceVersion(const std::string& value) 112{ 113 aceVersion = value; 114} 115 116void JsAppImpl::SetScreenDensity(const std::string value) 117{ 118 screenDensity = value; 119} 120 121void JsAppImpl::SetConfigChanges(const std::string value) 122{ 123 configChanges = value; 124} 125 126void JsAppImpl::DispatchBackPressedEvent() const 127{ 128 g_dispatchBackPressedEvent = true; 129} 130 131void JsAppImpl::DispatchPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) const 132{ 133 g_dispatchPointerEvent = true; 134} 135 136void JsAppImpl::DispatchAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) const 137{ 138 g_dispatchAxisEvent = true; 139} 140 141void JsAppImpl::DispatchInputMethodEvent(const unsigned int codePoint) const 142{ 143 g_dispatchInputMethodEvent = true; 144} 145 146void JsAppImpl::DispatchKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent) const 147{ 148 g_dispatchKeyEvent = true; 149} 150 151void JsAppImpl::SetAvoidArea(const AvoidAreas& areas) 152{ 153 avoidInitialAreas = areas; 154} 155 156void JsAppImpl::InitJsApp() {}