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_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H 18 19 #include <string> 20 21 #include "parcel.h" 22 #include "application_info.h" 23 #include "extension_ability_info.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 enum AbilityInfoFlag { 28 GET_ABILITY_INFO_DEFAULT = 0x00000000, 29 GET_ABILITY_INFO_WITH_PERMISSION = 0x00000002, 30 GET_ABILITY_INFO_WITH_APPLICATION = 0x00000004, 31 GET_ABILITY_INFO_WITH_METADATA = 0x00000020, 32 GET_ABILITY_INFO_SYSTEMAPP_ONLY = 0x00000080, 33 GET_ABILITY_INFO_WITH_DISABLE = 0x00000100, 34 GET_ABILITY_INFO_WITH_SKILL_URI = 0x00000200, 35 }; 36 37 enum class GetAbilityInfoFlag { 38 GET_ABILITY_INFO_DEFAULT = 0x00000000, 39 GET_ABILITY_INFO_WITH_PERMISSION = 0x00000001, 40 GET_ABILITY_INFO_WITH_APPLICATION = 0x00000002, 41 GET_ABILITY_INFO_WITH_METADATA = 0x00000004, 42 GET_ABILITY_INFO_WITH_DISABLE = 0x00000008, 43 GET_ABILITY_INFO_ONLY_SYSTEM_APP = 0x00000010, 44 }; 45 46 enum class AbilityType { 47 UNKNOWN = 0, 48 PAGE, 49 SERVICE, 50 DATA, 51 FORM, 52 EXTENSION, 53 }; 54 55 enum class BackgroundMode { 56 DEFAULT = 0, 57 DATA_TRANSFER = 1 << 0, 58 AUDIO_PLAYBACK = 1 << 1, 59 AUDIO_RECORDING = 1 << 2, 60 LOCATION = 1 << 3, 61 BLUETOOTH_INTERACTION = 1 << 4, 62 MULTI_DEVICE_CONNECTION = 1 << 5, 63 WIFI_INTERACTION = 1 << 6, 64 VOIP = 1 << 7, 65 TASK_KEEPING = 1 << 8, 66 }; 67 68 enum class AbilitySubType { 69 UNSPECIFIED = 0, 70 CA, 71 }; 72 73 enum class DisplayOrientation { 74 UNSPECIFIED = 0, 75 LANDSCAPE, 76 PORTRAIT, 77 FOLLOWRECENT, 78 LANDSCAPE_INVERTED, 79 PORTRAIT_INVERTED, 80 AUTO_ROTATION, 81 AUTO_ROTATION_LANDSCAPE, 82 AUTO_ROTATION_PORTRAIT, 83 AUTO_ROTATION_RESTRICTED, 84 AUTO_ROTATION_LANDSCAPE_RESTRICTED, 85 AUTO_ROTATION_PORTRAIT_RESTRICTED, 86 LOCKED, 87 }; 88 89 enum class LaunchMode { 90 SINGLETON = 0, 91 STANDARD, // support more than one instance 92 SPECIFIED, 93 }; 94 95 enum class SupportWindowMode { 96 FULLSCREEN = 0, 97 SPLIT, 98 FLOATING, 99 }; 100 101 struct AbilityInfo; 102 103 /* 104 * According to Ability profile 1.0 105 */ 106 struct CompatibleAbilityInfo : public Parcelable { 107 // deprecated: ability code class simple name, use 'className' instead. 108 std::string package; 109 std::string name; 110 std::string label; // display name on screen. 111 std::string description; 112 std::string iconPath; // used as icon data (base64) for WEB Ability. 113 std::string uri; // uri of ability. 114 std::string moduleName; // indicates the name of the .hap package to which the capability belongs. 115 std::string process; 116 std::string targetAbility; 117 std::string appName; 118 std::string privacyUrl; 119 std::string privacyName; 120 std::string downloadUrl; 121 std::string versionName; 122 uint32_t backgroundModes = 0; 123 uint32_t packageSize = 0; // The size of the package that AbilityInfo.uri points to. 124 bool visible = false; 125 bool formEnabled = false; 126 bool multiUserShared = false; 127 // deprecated: remove this field in new package format. 128 AbilityType type = AbilityType::UNKNOWN; 129 AbilitySubType subType = AbilitySubType::UNSPECIFIED; 130 DisplayOrientation orientation = DisplayOrientation::UNSPECIFIED; 131 LaunchMode launchMode = LaunchMode::SINGLETON; 132 std::vector<std::string> permissions; 133 std::vector<std::string> deviceTypes; 134 std::vector<std::string> deviceCapabilities; 135 bool supportPipMode = false; 136 bool grantPermission = false; 137 std::string readPermission; 138 std::string writePermission; 139 std::string uriPermissionMode; 140 std::string uriPermissionPath; 141 bool directLaunch = true; 142 143 // set when install 144 std::string bundleName; // bundle name which has this ability. 145 std::string className; // the ability full class name. 146 std::string originalClassName; // the original ability full class name 147 std::string deviceId; // device UDID information. 148 CompatibleApplicationInfo applicationInfo; 149 150 // form widget info 151 uint32_t formEntity = 1; // where form can be displayed 152 int32_t minFormHeight = 0; // minimum height of ability. 153 int32_t defaultFormHeight = 0; // default height of ability. 154 int32_t minFormWidth = 0; // minimum width of ability. 155 int32_t defaultFormWidth = 0; // default width of ability. 156 157 int32_t iconId = 0; 158 int32_t labelId = 0; 159 int32_t descriptionId = 0; 160 bool enabled = true; 161 162 bool ReadFromParcel(Parcel& parcel); 163 virtual bool Marshalling(Parcel& parcel) const override; 164 static CompatibleAbilityInfo* Unmarshalling(Parcel& parcel); 165 166 void ConvertToAbilityInfo(AbilityInfo& abilityInfo) const; 167 }; 168 169 // configuration information about an ability 170 struct AbilityInfo : public Parcelable { 171 std::string name; // ability name, only the main class name 172 std::string label; 173 std::string description; 174 std::string iconPath; 175 int32_t labelId; 176 int32_t descriptionId; 177 int32_t iconId; 178 std::string theme; 179 bool visible = false; 180 std::string kind; // ability category 181 AbilityType type = AbilityType::UNKNOWN; 182 ExtensionAbilityType extensionAbilityType = ExtensionAbilityType::UNSPECIFIED; 183 DisplayOrientation orientation = DisplayOrientation::UNSPECIFIED; 184 LaunchMode launchMode = LaunchMode::SINGLETON; 185 std::string srcPath; 186 std::string srcLanguage = "js"; 187 std::vector<std::string> permissions; 188 189 std::string process; 190 std::vector<std::string> deviceTypes; 191 std::vector<std::string> deviceCapabilities; 192 std::string uri; 193 std::string targetAbility; 194 ApplicationInfo applicationInfo; 195 bool isLauncherAbility = false; 196 bool isNativeAbility = false; 197 bool enabled = false; 198 bool supportPipMode = false; 199 bool formEnabled = false; 200 bool removeMissionAfterTerminate = false; 201 std::string readPermission; 202 std::string writePermission; 203 std::vector<std::string> configChanges; 204 uint32_t formEntity = 0; 205 int32_t minFormHeight = 0; 206 int32_t defaultFormHeight = 0; 207 int32_t minFormWidth = 0; 208 int32_t defaultFormWidth = 0; 209 MetaData metaData; 210 uint32_t backgroundModes = 0; 211 212 // for Check flags, add to abilityInfo and extensionAbilityInfo 213 std::vector<SkillUriForAbilityAndExtension> skillUri; 214 215 // set when install 216 std::string package; // the "module.package" in config.json 217 std::string bundleName; 218 std::string moduleName; // the "module.name" in config.json 219 std::string applicationName; // the "bundlename" in config.json 220 221 std::string codePath; // ability main code path with name 222 std::string resourcePath; // resource path for resource init 223 std::string hapPath; 224 225 std::string srcEntrance; 226 std::vector<Metadata> metadata; 227 bool isModuleJson = false; 228 bool isStageBasedModel = false; 229 bool continuable = false; 230 int32_t priority = 0; 231 232 // configuration fields on startup page 233 std::string startWindowIcon; 234 int32_t startWindowIconId; 235 std::string startWindowBackground; 236 int32_t startWindowBackgroundId; 237 // whether to display in the missions list 238 bool excludeFromMissions = false; 239 bool unclearableMission = false; 240 // whether to support recover UI interface 241 bool recoverable = false; 242 243 // support windows mode 244 std::vector<SupportWindowMode> windowModes; 245 double maxWindowRatio = 0; 246 double minWindowRatio = 0; 247 uint32_t maxWindowWidth = 0; 248 uint32_t minWindowWidth = 0; 249 uint32_t maxWindowHeight = 0; 250 uint32_t minWindowHeight = 0; 251 // for NAPI, save self query cache 252 int32_t uid = -1; 253 CompileMode compileMode = CompileMode::JS_BUNDLE; 254 255 // unused 256 std::string originalBundleName; 257 std::string appName; 258 std::string privacyUrl; 259 std::string privacyName; 260 std::string downloadUrl; 261 std::string versionName; 262 std::string className; 263 std::string originalClassName; 264 std::string uriPermissionMode; 265 std::string uriPermissionPath; 266 uint32_t packageSize = 0; 267 bool multiUserShared = false; 268 bool grantPermission = false; 269 bool directLaunch = true; 270 AbilitySubType subType = AbilitySubType::UNSPECIFIED; 271 std::string libPath; 272 std::string deviceId; 273 int64_t installTime; 274 std::vector<std::string> supportExtNames; 275 std::vector<std::string> supportMimeTypes; 276 277 bool ReadFromParcel(Parcel &parcel); 278 virtual bool Marshalling(Parcel &parcel) const override; 279 static AbilityInfo *Unmarshalling(Parcel &parcel); 280 void Dump(std::string prefix, int fd); 281 void ConvertToCompatiableAbilityInfo(CompatibleAbilityInfo& compatibleAbilityInfo) const; 282 }; 283 } // namespace AppExecFwk 284 } // namespace OHOS 285 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_ABILITY_INFO_H 286