1 /* 2 * Copyright (c) 2021-2022 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 #ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_RUN_OPTIONS_H 17 #define FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_RUN_OPTIONS_H 18 19 #include <functional> 20 #include <string> 21 #include <map> 22 23 #include "base/utils/device_config.h" 24 #include "base/utils/device_type.h" 25 #include "base/utils/macros.h" 26 27 namespace OHOS::Ace::Platform { 28 29 using SendRenderDataCallback = bool (*)(const void*, const size_t, const int32_t, const int32_t, const uint64_t); 30 using SendCurrentRouterCallback = bool (*)(const std::string currentRouterPath); 31 using FastPreviewErrorCallback = void (*)(const std::string& jsonStr); 32 33 constexpr uint32_t OHOS_THEME_ID = 125829872; 34 35 enum class AceVersion { 36 ACE_1_0, 37 ACE_2_0, 38 }; 39 40 enum class ProjectModel { 41 FA, 42 STAGE, 43 }; 44 45 struct ConfigChanges { 46 bool watchLocale = false; 47 bool watchLayout = false; 48 bool watchFontSize = false; 49 bool watchOrientation = false; 50 bool watchDensity = false; 51 }; 52 53 struct SystemParams { 54 int32_t deviceWidth { 0 }; 55 int32_t deviceHeight { 0 }; 56 bool isRound = false; 57 double density { 1.0 }; 58 std::string language = "zh"; 59 std::string region = "CN"; 60 std::string script = ""; 61 OHOS::Ace::DeviceType deviceType { DeviceType::PHONE }; 62 OHOS::Ace::ColorMode colorMode { ColorMode::LIGHT }; 63 OHOS::Ace::DeviceOrientation orientation { DeviceOrientation::PORTRAIT }; 64 }; 65 66 struct ACE_FORCE_EXPORT AceRunArgs { 67 // the adopted project model 68 ProjectModel projectModel = ProjectModel::FA; 69 // stores routing information 70 std::string pageProfile = ""; 71 // The absolute path end of "default". 72 std::string assetPath; 73 // The absolute path of system resources. 74 std::string systemResourcesPath; 75 // The absolute path of app resources. 76 std::string appResourcesPath; 77 78 // Indicate light or dark theme. 79 uint32_t themeId = OHOS_THEME_ID; 80 81 OHOS::Ace::DeviceConfig deviceConfig = { 82 .orientation = DeviceOrientation::PORTRAIT, 83 .density = 1.0, 84 .deviceType = DeviceType::PHONE, 85 .colorMode = ColorMode::LIGHT, 86 }; 87 88 // Set page path to launch directly, or launch the main page in default. 89 std::string url; 90 91 std::string windowTitle; 92 93 bool isRound = false; 94 int32_t viewWidth = 0; 95 int32_t viewHeight = 0; 96 int32_t deviceWidth = 0; 97 int32_t deviceHeight = 0; 98 99 // Locale 100 std::string language = "zh"; 101 std::string region = "CN"; 102 std::string script = ""; 103 104 std::string configChanges; 105 106 AceVersion aceVersion = AceVersion::ACE_1_0; 107 108 bool formsEnabled = false; 109 110 SendRenderDataCallback onRender = nullptr; 111 SendCurrentRouterCallback onRouterChange = nullptr; 112 FastPreviewErrorCallback onError = nullptr; 113 114 // Container sdk path. 115 std::string containerSdkPath = ""; 116 bool isComponentMode = false; 117 118 // for strict mode 119 std::map<std::string, std::string> pkgContextInfoJsonStringMap; 120 std::map<std::string, std::string> packageNameList; 121 122 // Component test 123 bool isComponentTestMode = false; 124 std::string componentTestConfig = ""; 125 }; 126 127 } // namespace OHOS::Ace::Platform 128 129 #endif // FOUNDATION_ACE_ADAPTER_PREVIEW_ACE_RUN_OPTIONS_H 130