1 /* 2 * Copyright (c) 2021-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 #ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 23 #include "bundle_constants.h" 24 #include "module_info.h" 25 #include "parcel.h" 26 #include "quick_fix/app_quick_fix.h" 27 28 namespace OHOS { 29 namespace AppExecFwk { 30 namespace { 31 constexpr const char* AVAILABLELEVEL_NORMAL = "normal"; 32 constexpr const char* DEFAULT_ENTITY_TYPE = "unspecified"; 33 constexpr const char* DEFAULT_COMPILE_SDK_TYPE = "OpenHarmony"; 34 } 35 enum ApplicationFlag { 36 GET_BASIC_APPLICATION_INFO = 0x00000000, 37 GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000008, 38 GET_APPLICATION_INFO_WITH_METADATA = 0x00000040, 39 GET_APPLICATION_INFO_WITH_DISABLE = 0x00000200, 40 GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT = 0x00000400, 41 GET_ALL_APPLICATION_INFO = 0xFFFF0000, 42 }; 43 44 enum class GetApplicationFlag { 45 GET_APPLICATION_INFO_DEFAULT = 0x00000000, 46 GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000001, 47 GET_APPLICATION_INFO_WITH_METADATA = 0x00000002, 48 GET_APPLICATION_INFO_WITH_DISABLE = 0x00000004, 49 }; 50 51 enum class GetDependentBundleInfoFlag { 52 GET_APP_CROSS_HSP_BUNDLE_INFO = 0x00000000, 53 GET_APP_SERVICE_HSP_BUNDLE_INFO = 0x00000001, 54 GET_ALL_DEPENDENT_BUNDLE_INFO = 0x00000002, 55 }; 56 57 enum class BundleType { 58 APP = 0, 59 ATOMIC_SERVICE = 1, 60 SHARED = 2, 61 APP_SERVICE_FWK = 3, 62 }; 63 64 enum class CompatiblePolicy { 65 NORMAL = 0, 66 BACKWARD_COMPATIBILITY = 1, 67 }; 68 69 enum class ApplicationReservedFlag { 70 ENCRYPTED_APPLICATION = 0x00000001, 71 }; 72 73 enum class MultiAppModeType : uint8_t { 74 UNSPECIFIED = 0, 75 MULTI_INSTANCE = 1, 76 APP_CLONE = 2, 77 }; 78 79 enum class ApplicationInfoFlag { 80 FLAG_INSTALLED = 0x00000001, 81 /** 82 * Indicates the installation source of pre-installed applications 83 * App upgrades will not change installation source 84 * FLAG_BOOT_INSTALLED App installed during first boot 85 * FLAG_OTA_INSTALLED App installed during OTA 86 * FLAG_RECOVER_INSTALLED App recover 87 */ 88 FLAG_BOOT_INSTALLED = 0x00000002, 89 FLAG_OTA_INSTALLED = 0x00000004, 90 FLAG_RECOVER_INSTALLED = 0x00000008, 91 }; 92 93 struct MultiAppModeData : public Parcelable { 94 MultiAppModeType multiAppModeType = MultiAppModeType::UNSPECIFIED; 95 int32_t maxCount = 0; 96 bool ReadFromParcel(Parcel &parcel); 97 virtual bool Marshalling(Parcel &parcel) const override; 98 static MultiAppModeData *Unmarshalling(Parcel &parcel); 99 }; 100 101 struct Metadata : public Parcelable { 102 std::string name; 103 std::string value; 104 std::string resource; 105 Metadata() = default; 106 Metadata(const std::string ¶mName, const std::string ¶mValue, const std::string ¶mResource); 107 bool ReadFromParcel(Parcel &parcel); 108 virtual bool Marshalling(Parcel &parcel) const override; 109 static Metadata *Unmarshalling(Parcel &parcel); 110 }; 111 112 struct HnpPackage : public Parcelable { 113 std::string package; 114 std::string type; 115 116 bool ReadFromParcel(Parcel &parcel); 117 virtual bool Marshalling(Parcel &parcel) const override; 118 static HnpPackage *Unmarshalling(Parcel &parcel); 119 }; 120 121 struct CustomizeData : public Parcelable { 122 std::string name; 123 std::string value; 124 std::string extra; 125 CustomizeData() = default; 126 CustomizeData(std::string paramName, std::string paramValue, std::string paramExtra); 127 bool ReadFromParcel(Parcel &parcel); 128 virtual bool Marshalling(Parcel &parcel) const override; 129 static CustomizeData *Unmarshalling(Parcel &parcel); 130 }; 131 132 struct MetaData { 133 std::vector<CustomizeData> customizeData; 134 }; 135 136 struct Resource : public Parcelable { 137 /** the hap bundle name */ 138 std::string bundleName; 139 140 /** the hap module name */ 141 std::string moduleName; 142 143 /** the resource id in hap */ 144 uint32_t id = 0; 145 146 bool ReadFromParcel(Parcel &parcel); 147 virtual bool Marshalling(Parcel &parcel) const override; 148 static Resource *Unmarshalling(Parcel &parcel); 149 }; 150 151 struct ApplicationEnvironment : public Parcelable { 152 std::string name; 153 std::string value; 154 155 bool ReadFromParcel(Parcel &parcel); 156 virtual bool Marshalling(Parcel &parcel) const override; 157 static ApplicationEnvironment *Unmarshalling(Parcel &parcel); 158 }; 159 160 struct ApplicationInfo; 161 162 struct CompatibleApplicationInfo : public Parcelable { 163 // items set when installing. 164 std::string name; // application name. 165 std::string icon; // application icon resource index. 166 std::string label; // application name displayed to the user. 167 std::string description; // description of application. 168 std::string cpuAbi; // current device cpu abi. 169 std::string process; 170 bool isCompressNativeLibs = true; 171 172 uint32_t iconId = 0; 173 uint32_t labelId = 0; 174 uint32_t descriptionId = 0; 175 176 bool systemApp = false; 177 178 std::vector<std::string> permissions; 179 std::vector<ModuleInfo> moduleInfos; 180 181 int32_t supportedModes = 0; // supported modes. 182 bool enabled = true; 183 bool debug = false; 184 185 bool ReadFromParcel(Parcel& parcel); 186 virtual bool Marshalling(Parcel& parcel) const override; 187 static CompatibleApplicationInfo* Unmarshalling(Parcel& parcel); 188 void ConvertToApplicationInfo(ApplicationInfo& applicationInfo) const; 189 }; 190 191 // configuration information about an application 192 struct ApplicationInfo : public Parcelable { 193 std::string name; // application name is same to bundleName 194 std::string bundleName; 195 196 uint32_t versionCode = 0; 197 std::string versionName; 198 int32_t minCompatibleVersionCode = 0; 199 200 uint32_t apiCompatibleVersion = 0; 201 int32_t apiTargetVersion = 0; 202 int64_t crowdtestDeadline = Constants::INVALID_CROWDTEST_DEADLINE; 203 204 std::string iconPath; 205 uint32_t iconId = 0; 206 Resource iconResource; 207 208 std::string label; 209 uint32_t labelId = 0; 210 Resource labelResource; 211 212 std::string description; 213 uint32_t descriptionId = 0; 214 Resource descriptionResource; 215 216 bool keepAlive = false; 217 bool removable = true; 218 bool singleton = false; 219 bool userDataClearable = true; 220 bool allowAppRunWhenDeviceFirstLocked = false; 221 bool accessible = false; 222 bool runningResourcesApply = false; 223 bool associatedWakeUp = false; 224 bool hideDesktopIcon = false; 225 bool formVisibleNotify = false; 226 std::vector<std::string> allowCommonEvent; 227 std::vector<int32_t> resourcesApply; 228 229 bool isSystemApp = false; 230 bool isLauncherApp = false; 231 bool isFreeInstallApp = false; 232 bool asanEnabled = false; 233 std::string asanLogPath; 234 235 std::string codePath; 236 std::string dataDir; 237 std::string dataBaseDir; 238 std::string cacheDir; 239 std::string entryDir; 240 241 std::string apiReleaseType; 242 bool debug = false; 243 std::string deviceId; 244 bool distributedNotificationEnabled = true; 245 bool allowEnableNotification = false; 246 std::string entityType = DEFAULT_ENTITY_TYPE; 247 std::string process; 248 int32_t supportedModes = 0; // returns 0 if the application does not support the driving mode 249 std::string vendor; 250 bool gwpAsanEnabled = false; 251 252 // apl 253 std::string appPrivilegeLevel = AVAILABLELEVEL_NORMAL; 254 // provision 255 std::string appDistributionType = Constants::APP_DISTRIBUTION_TYPE_NONE; 256 std::string appProvisionType = Constants::APP_PROVISION_TYPE_RELEASE; 257 258 // user related fields, assign when calling the get interface 259 uint32_t accessTokenId = 0; 260 uint64_t accessTokenIdEx = 0; 261 bool enabled = false; 262 int32_t uid = -1; 263 int32_t appIndex = 0; 264 265 // native so 266 std::string nativeLibraryPath; 267 std::string cpuAbi; 268 std::string arkNativeFilePath; 269 std::string arkNativeFileAbi; 270 271 // assign when calling the get interface 272 std::vector<std::string> permissions; 273 std::vector<std::string> moduleSourceDirs; 274 std::vector<ModuleInfo> moduleInfos; 275 std::map<std::string, std::vector<HnpPackage>> hnpPackages; 276 std::map<std::string, std::vector<CustomizeData>> metaData; 277 std::map<std::string, std::vector<Metadata>> metadata; 278 // Installation-free 279 std::vector<std::string> targetBundleList; 280 281 std::string fingerprint; 282 // quick fix info 283 AppQuickFix appQuickFix; 284 285 std::string icon; 286 int32_t flags = 0; 287 std::string entryModuleName; 288 bool isCompressNativeLibs = true; 289 std::string signatureKey; 290 291 // switch 292 bool multiProjects = false; 293 294 // app detail ability 295 bool needAppDetail = false; 296 std::string appDetailAbilityLibraryPath; 297 298 // overlay installation 299 std::string targetBundleName; 300 int32_t targetPriority = 0; 301 int32_t overlayState = 0; 302 303 BundleType bundleType = BundleType::APP; 304 305 std::string compileSdkVersion; 306 std::string compileSdkType = DEFAULT_COMPILE_SDK_TYPE; 307 308 uint32_t applicationReservedFlag = 0; 309 bool tsanEnabled = false; 310 bool hwasanEnabled = false; 311 std::vector<ApplicationEnvironment> appEnvironments; 312 std::string organization; 313 314 MultiAppModeData multiAppMode; 315 int32_t maxChildProcess = 0; 316 317 std::string installSource; 318 bool cloudFileSyncEnabled = false; 319 320 std::string configuration; 321 322 int32_t applicationFlags = static_cast<uint32_t>(ApplicationInfoFlag::FLAG_INSTALLED); 323 324 bool ReadFromParcel(Parcel &parcel); 325 bool ReadMetaDataFromParcel(Parcel &parcel); 326 virtual bool Marshalling(Parcel &parcel) const override; 327 static ApplicationInfo *Unmarshalling(Parcel &parcel); 328 void Dump(std::string prefix, int fd); 329 void ConvertToCompatibleApplicationInfo(CompatibleApplicationInfo& compatibleApplicationInfo) const; 330 bool CheckNeedPreload(const std::string &moduleName) const; 331 }; 332 } // namespace AppExecFwk 333 } // namespace OHOS 334 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H 335