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_BUNDLE_INFO_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H 18 19 #include <string> 20 #include <vector> 21 22 #include "parcel.h" 23 24 #include "ability_info.h" 25 #include "application_info.h" 26 #include "extension_ability_info.h" 27 #include "hap_module_info.h" 28 #include "message_parcel.h" 29 30 namespace OHOS { 31 namespace AppExecFwk { 32 enum BundleFlag { 33 // get bundle info except abilityInfos 34 GET_BUNDLE_DEFAULT = 0x00000000, 35 // get bundle info include abilityInfos 36 GET_BUNDLE_WITH_ABILITIES = 0x00000001, 37 // get bundle info include request permissions 38 GET_BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010, 39 // get bundle info include extension info 40 GET_BUNDLE_WITH_EXTENSION_INFO = 0x00000020, 41 // get bundle info include hash value 42 GET_BUNDLE_WITH_HASH_VALUE = 0x00000030, 43 }; 44 45 enum class GetBundleInfoFlag { 46 GET_BUNDLE_INFO_DEFAULT = 0x00000000, 47 GET_BUNDLE_INFO_WITH_APPLICATION = 0x00000001, 48 GET_BUNDLE_INFO_WITH_HAP_MODULE = 0x00000002, 49 GET_BUNDLE_INFO_WITH_ABILITY = 0x00000004, 50 GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY = 0x00000008, 51 GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION = 0x00000010, 52 GET_BUNDLE_INFO_WITH_METADATA = 0x00000020, 53 GET_BUNDLE_INFO_WITH_DISABLE = 0x00000040, 54 GET_BUNDLE_INFO_WITH_SIGNATURE_INFO = 0x00000080, 55 }; 56 57 struct RequestPermissionUsedScene : public Parcelable { 58 std::vector<std::string> abilities; 59 std::string when; 60 61 bool ReadFromParcel(Parcel &parcel); 62 virtual bool Marshalling(Parcel &parcel) const override; 63 static RequestPermissionUsedScene *Unmarshalling(Parcel &parcel); 64 }; 65 66 struct RequestPermission : public Parcelable { 67 std::string name; 68 std::string reason; 69 int32_t reasonId = 0; 70 RequestPermissionUsedScene usedScene; 71 72 bool ReadFromParcel(Parcel &parcel); 73 virtual bool Marshalling(Parcel &parcel) const override; 74 static RequestPermission *Unmarshalling(Parcel &parcel); 75 }; 76 77 struct SignatureInfo : public Parcelable { 78 std::string appId; 79 std::string fingerprint; 80 81 bool ReadFromParcel(Parcel &parcel); 82 virtual bool Marshalling(Parcel &parcel) const override; 83 static SignatureInfo *Unmarshalling(Parcel &parcel); 84 }; 85 // configuration information about a bundle 86 struct BundleInfo : public Parcelable { 87 std::string name; 88 89 uint32_t versionCode = 0; 90 std::string versionName; 91 uint32_t minCompatibleVersionCode = 0; 92 93 uint32_t compatibleVersion = 0; 94 uint32_t targetVersion = 0; 95 96 bool isKeepAlive = false; 97 bool singleton = false; 98 bool isPreInstallApp = false; 99 100 std::string vendor; 101 std::string releaseType; 102 bool isNativeApp = false; 103 104 std::string mainEntry; // modulePackage 105 std::string entryModuleName; // moduleName 106 bool entryInstallationFree = false; // application : false; atomic service : true 107 bool asanEnabled = false; 108 109 std::string appId; 110 111 // user related fields, assign when calling the get interface 112 int uid = -1; 113 int gid = -1; 114 int64_t installTime = 0; 115 int64_t updateTime = 0; 116 int32_t appIndex = 0; // index for sandbox app 117 118 ApplicationInfo applicationInfo; 119 std::vector<AbilityInfo> abilityInfos; 120 std::vector<ExtensionAbilityInfo> extensionInfos; 121 std::vector<HapModuleInfo> hapModuleInfos; 122 std::vector<std::string> hapModuleNames; // the "module.package" in each config.json 123 std::vector<std::string> moduleNames; // the "module.name" in each config.json 124 std::vector<std::string> modulePublicDirs; // the public paths of all modules of the application. 125 std::vector<std::string> moduleDirs; // the paths of all modules of the application. 126 std::vector<std::string> moduleResPaths; // the paths of all resources paths. 127 128 std::vector<std::string> reqPermissions; 129 std::vector<std::string> defPermissions; 130 std::vector<int32_t> reqPermissionStates; 131 std::vector<RequestPermission> reqPermissionDetails; 132 133 // unused 134 std::string cpuAbi; 135 std::string seInfo; 136 std::string label; 137 std::string description; 138 std::string jointUserId; 139 int32_t minSdkVersion = -1; 140 int32_t maxSdkVersion = -1; 141 bool isDifferentName = false; 142 143 SignatureInfo signatureInfo; 144 145 bool ReadFromParcel(Parcel &parcel); 146 virtual bool Marshalling(Parcel &parcel) const override; 147 static BundleInfo *Unmarshalling(Parcel &parcel); 148 }; 149 } // namespace AppExecFwk 150 } // namespace OHOS 151 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H 152