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_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 const std::string AVAILABLELEVEL_NORMAL = "normal"; 32 const std::string DEFAULT_ENTITY_TYPE = "unspecified"; 33 } 34 enum ApplicationFlag { 35 GET_BASIC_APPLICATION_INFO = 0x00000000, 36 GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000008, 37 GET_APPLICATION_INFO_WITH_METADATA = 0x00000040, 38 GET_APPLICATION_INFO_WITH_DISABLE = 0x00000200, 39 GET_APPLICATION_INFO_WITH_CERTIFICATE_FINGERPRINT = 0x00000400, 40 GET_ALL_APPLICATION_INFO = 0xFFFF0000, 41 }; 42 43 enum class GetApplicationFlag { 44 GET_APPLICATION_INFO_DEFAULT = 0x00000000, 45 GET_APPLICATION_INFO_WITH_PERMISSION = 0x00000001, 46 GET_APPLICATION_INFO_WITH_METADATA = 0x00000002, 47 GET_APPLICATION_INFO_WITH_DISABLE = 0x00000004, 48 }; 49 50 enum class BundleType { 51 APP = 0, 52 ATOMIC_SERVICE = 1, 53 }; 54 55 struct Metadata : public Parcelable { 56 std::string name; 57 std::string value; 58 std::string resource; 59 Metadata() = default; 60 Metadata(const std::string ¶mName, const std::string ¶mValue, const std::string ¶mResource); 61 bool ReadFromParcel(Parcel &parcel); 62 virtual bool Marshalling(Parcel &parcel) const override; 63 static Metadata *Unmarshalling(Parcel &parcel); 64 }; 65 66 struct CustomizeData : public Parcelable { 67 std::string name; 68 std::string value; 69 std::string extra; 70 CustomizeData() = default; 71 CustomizeData(std::string paramName, std::string paramValue, std::string paramExtra); 72 bool ReadFromParcel(Parcel &parcel); 73 virtual bool Marshalling(Parcel &parcel) const override; 74 static CustomizeData *Unmarshalling(Parcel &parcel); 75 }; 76 77 struct MetaData { 78 std::vector<CustomizeData> customizeData; 79 }; 80 81 struct Resource : public Parcelable { 82 /** the hap bundle name */ 83 std::string bundleName; 84 85 /** the hap module name */ 86 std::string moduleName; 87 88 /** the resource id in hap */ 89 int32_t id = 0; 90 91 bool ReadFromParcel(Parcel &parcel); 92 virtual bool Marshalling(Parcel &parcel) const override; 93 static Resource *Unmarshalling(Parcel &parcel); 94 }; 95 96 struct ApplicationInfo; 97 98 struct CompatibleApplicationInfo : public Parcelable { 99 // items set when installing. 100 std::string name; // application name. 101 std::string icon; // application icon resource index. 102 std::string label; // application name displayed to the user. 103 std::string description; // description of application. 104 std::string cpuAbi; // current device cpu abi. 105 std::string process; 106 bool isCompressNativeLibs = true; 107 108 int32_t iconId = 0; 109 int32_t labelId = 0; 110 int32_t descriptionId = 0; 111 112 bool systemApp = false; 113 114 std::vector<std::string> permissions; 115 std::vector<ModuleInfo> moduleInfos; 116 117 int32_t supportedModes = 0; // supported modes. 118 bool enabled = true; 119 bool debug = false; 120 121 bool ReadFromParcel(Parcel& parcel); 122 virtual bool Marshalling(Parcel& parcel) const override; 123 static CompatibleApplicationInfo* Unmarshalling(Parcel& parcel); 124 void ConvertToApplicationInfo(ApplicationInfo& applicationInfo) const; 125 }; 126 127 // configuration information about an application 128 struct ApplicationInfo : public Parcelable { 129 std::string name; // application name is same to bundleName 130 std::string bundleName; 131 132 uint32_t versionCode = 0; 133 std::string versionName; 134 int32_t minCompatibleVersionCode = 0; 135 136 uint32_t apiCompatibleVersion = 0; 137 int32_t apiTargetVersion = 0; 138 int64_t crowdtestDeadline = Constants::INVALID_CROWDTEST_DEADLINE; 139 140 std::string iconPath; 141 int32_t iconId = 0; 142 Resource iconResource; 143 144 std::string label; 145 int32_t labelId = 0; 146 Resource labelResource; 147 148 std::string description; 149 int32_t descriptionId = 0; 150 Resource descriptionResource; 151 152 bool keepAlive = false; 153 bool removable = true; 154 bool singleton = false; 155 bool userDataClearable = true; 156 bool accessible = false; 157 bool runningResourcesApply = false; 158 bool associatedWakeUp = false; 159 bool hideDesktopIcon = false; 160 bool formVisibleNotify = false; 161 std::vector<std::string> allowCommonEvent; 162 163 bool isSystemApp = false; 164 bool isLauncherApp = false; 165 bool isFreeInstallApp = false; 166 bool asanEnabled = false; 167 std::string asanLogPath; 168 169 std::string codePath; 170 std::string dataDir; 171 std::string dataBaseDir; 172 std::string cacheDir; 173 std::string entryDir; 174 175 std::string apiReleaseType; 176 bool debug = false; 177 std::string deviceId; 178 bool distributedNotificationEnabled = true; 179 std::string entityType = DEFAULT_ENTITY_TYPE; 180 std::string process; 181 int32_t supportedModes = 0; // returns 0 if the application does not support the driving mode 182 std::string vendor; 183 184 // apl 185 std::string appPrivilegeLevel = AVAILABLELEVEL_NORMAL; 186 // provision 187 std::string appDistributionType = Constants::APP_DISTRIBUTION_TYPE_NONE; 188 std::string appProvisionType = Constants::APP_PROVISION_TYPE_RELEASE; 189 190 // user related fields, assign when calling the get interface 191 uint32_t accessTokenId = 0; 192 bool enabled = false; 193 int32_t uid = -1; 194 195 // native so 196 std::string nativeLibraryPath; 197 std::string cpuAbi; 198 std::string arkNativeFilePath; 199 std::string arkNativeFileAbi; 200 201 // assign when calling the get interface 202 std::vector<std::string> permissions; 203 std::vector<std::string> moduleSourceDirs; 204 std::vector<ModuleInfo> moduleInfos; 205 std::map<std::string, std::vector<CustomizeData>> metaData; 206 std::map<std::string, std::vector<Metadata>> metadata; 207 // Installation-free 208 std::vector<std::string> targetBundleList; 209 210 std::string fingerprint; 211 // quick fix info 212 AppQuickFix appQuickFix; 213 214 // unused 215 std::string icon; 216 int32_t flags = 0; 217 std::string entryModuleName; 218 bool isCompressNativeLibs = true; 219 std::string signatureKey; 220 221 // switch 222 bool multiProjects = false; 223 224 // app detail ability 225 bool needAppDetail = false; 226 std::string appDetailAbilityLibraryPath; 227 228 bool split = true; 229 BundleType bundleType = BundleType::APP; 230 231 bool ReadFromParcel(Parcel &parcel); 232 bool ReadMetaDataFromParcel(Parcel &parcel); 233 virtual bool Marshalling(Parcel &parcel) const override; 234 static ApplicationInfo *Unmarshalling(Parcel &parcel); 235 void Dump(std::string prefix, int fd); 236 void ConvertToCompatibleApplicationInfo(CompatibleApplicationInfo& compatibleApplicationInfo) const; 237 bool CheckNeedPreload(const std::string &moduleName) const; 238 }; 239 } // namespace AppExecFwk 240 } // namespace OHOS 241 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_APPLICATION_INFO_H 242