1 /* 2 * Copyright (c) 2023 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_ABILITY_RUNTIME_SIMULATOR_COMMON_ABILITY_INFO_H 17 #define FOUNDATION_ABILITY_RUNTIME_SIMULATOR_COMMON_ABILITY_INFO_H 18 19 #include <string> 20 #include <unordered_set> 21 #include <vector> 22 23 #include "application_info.h" 24 #include "extension_ability_info.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 enum class AbilityType { 29 UNKNOWN = 0, 30 PAGE, 31 SERVICE, 32 DATA, 33 FORM, 34 EXTENSION, 35 }; 36 37 enum class BackgroundMode { 38 DEFAULT = 0, 39 DATA_TRANSFER = 1 << 0, 40 AUDIO_PLAYBACK = 1 << 1, 41 AUDIO_RECORDING = 1 << 2, 42 LOCATION = 1 << 3, 43 BLUETOOTH_INTERACTION = 1 << 4, 44 MULTI_DEVICE_CONNECTION = 1 << 5, 45 WIFI_INTERACTION = 1 << 6, 46 VOIP = 1 << 7, 47 TASK_KEEPING = 1 << 8, 48 }; 49 50 enum class AbilitySubType { 51 UNSPECIFIED = 0, 52 CA, 53 }; 54 55 enum class DisplayOrientation { 56 UNSPECIFIED = 0, 57 LANDSCAPE, 58 PORTRAIT, 59 FOLLOWRECENT, 60 LANDSCAPE_INVERTED, 61 PORTRAIT_INVERTED, 62 AUTO_ROTATION, 63 AUTO_ROTATION_LANDSCAPE, 64 AUTO_ROTATION_PORTRAIT, 65 AUTO_ROTATION_RESTRICTED, 66 AUTO_ROTATION_LANDSCAPE_RESTRICTED, 67 AUTO_ROTATION_PORTRAIT_RESTRICTED, 68 LOCKED, 69 }; 70 71 enum class LaunchMode { 72 SINGLETON = 0, 73 STANDARD, // support more than one instance 74 SPECIFIED, 75 }; 76 77 enum class SupportWindowMode { 78 FULLSCREEN = 0, 79 SPLIT, 80 FLOATING, 81 }; 82 83 enum class LinkType : uint8_t { 84 DEEP_LINK = 0, 85 APP_LINK, 86 DEFAULT_APP, 87 }; 88 89 struct StartWindowResource { 90 uint32_t startWindowAppIconId = 0; 91 uint32_t startWindowIllustrationId = 0; 92 uint32_t startWindowBrandingImageId = 0; 93 uint32_t startWindowBackgroundColorId = 0; 94 uint32_t startWindowBackgroundImageId = 0; 95 std::string startWindowBackgroundImageFit = "Cover"; 96 }; 97 98 // configuration information about an ability 99 struct AbilityInfo { 100 std::string name; // ability name, only the main class name 101 std::string label; 102 std::string description; 103 std::string iconPath; 104 int32_t labelId; 105 int32_t descriptionId; 106 int32_t iconId; 107 std::string theme; 108 bool visible = false; 109 std::string kind; // ability category 110 AbilityType type = AbilityType::UNKNOWN; 111 ExtensionAbilityType extensionAbilityType = ExtensionAbilityType::UNSPECIFIED; 112 DisplayOrientation orientation = DisplayOrientation::UNSPECIFIED; 113 LaunchMode launchMode = LaunchMode::SINGLETON; 114 std::string srcPath; 115 std::string srcLanguage = "js"; 116 std::vector<std::string> permissions; 117 118 std::string process; 119 std::vector<std::string> deviceTypes; 120 std::vector<std::string> deviceCapabilities; 121 std::string uri; 122 std::string targetAbility; 123 ApplicationInfo applicationInfo; 124 bool isLauncherAbility = false; 125 bool isNativeAbility = false; 126 bool enabled = false; 127 bool supportPipMode = false; 128 bool formEnabled = false; 129 bool removeMissionAfterTerminate = false; 130 std::string readPermission; 131 std::string writePermission; 132 std::vector<std::string> configChanges; 133 uint32_t formEntity = 0; 134 int32_t minFormHeight = 0; 135 int32_t defaultFormHeight = 0; 136 int32_t minFormWidth = 0; 137 int32_t defaultFormWidth = 0; 138 MetaData metaData; 139 uint32_t backgroundModes = 0; 140 141 std::vector<SkillUriForAbilityAndExtension> skillUri; 142 143 // set when install 144 std::string package; // the "module.package" in config.json 145 std::string bundleName; 146 std::string moduleName; // the "module.name" in config.json 147 std::string applicationName; // the "bundlename" in config.json 148 149 std::string codePath; // ability main code path with name 150 std::string resourcePath; // resource path for resource init 151 std::string hapPath; 152 153 std::string srcEntrance; 154 std::vector<Metadata> metadata; 155 bool isModuleJson = false; 156 bool isStageBasedModel = false; 157 bool continuable = false; 158 int32_t priority = 0; 159 160 // configuration fields on startup page 161 std::string startWindow; 162 std::string startWindowIcon; 163 int32_t startWindowIconId; 164 std::string startWindowBackground; 165 int32_t startWindowBackgroundId; 166 std::string preferMultiWindowOrientation = "default"; 167 // whether to display in the missions list 168 bool excludeFromMissions = false; 169 bool unclearableMission = false; 170 bool excludeFromDock = false; 171 // whether to support recover UI interface 172 bool recoverable = false; 173 bool isolationProcess = false; 174 LinkType linkType = LinkType::DEEP_LINK; 175 uint32_t orientationId = 0; 176 uint32_t startWindowId = 0; 177 int32_t appIndex = 0; 178 179 // support windows mode 180 std::vector<SupportWindowMode> windowModes; 181 std::vector<std::string> continueType; 182 std::unordered_set<std::string> continueBundleNames; 183 double maxWindowRatio = 0; 184 double minWindowRatio = 0; 185 uint32_t maxWindowWidth = 0; 186 uint32_t minWindowWidth = 0; 187 uint32_t maxWindowHeight = 0; 188 uint32_t minWindowHeight = 0; 189 StartWindowResource startWindowResource; 190 // for NAPI, save self query cache 191 int32_t uid = -1; 192 CompileMode compileMode = CompileMode::JS_BUNDLE; 193 194 // unused 195 std::string originalBundleName; 196 std::string appName; 197 std::string privacyUrl; 198 std::string privacyName; 199 std::string downloadUrl; 200 std::string versionName; 201 std::string className; 202 std::string originalClassName; 203 std::string uriPermissionMode; 204 std::string uriPermissionPath; 205 uint32_t packageSize = 0; 206 bool multiUserShared = false; 207 bool grantPermission = false; 208 bool directLaunch = true; 209 AbilitySubType subType = AbilitySubType::UNSPECIFIED; 210 std::string libPath; 211 std::string deviceId; 212 int64_t installTime; 213 std::vector<std::string> supportExtNames; 214 std::vector<std::string> supportMimeTypes; 215 }; 216 } // namespace AppExecFwk 217 } // namespace OHOS 218 #endif // FOUNDATION_ABILITY_RUNTIME_SIMULATOR_COMMON_ABILITY_INFO_H 219