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 #include "overlay/overlay_bundle_info.h" 30 31 namespace OHOS { 32 namespace AppExecFwk { 33 enum BundleFlag { 34 // get bundle info except abilityInfos 35 GET_BUNDLE_DEFAULT = 0x00000000, 36 // get bundle info include abilityInfos 37 GET_BUNDLE_WITH_ABILITIES = 0x00000001, 38 // get bundle info include request permissions 39 GET_BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010, 40 // get bundle info include extension info 41 GET_BUNDLE_WITH_EXTENSION_INFO = 0x00000020, 42 // get bundle info include hash value 43 GET_BUNDLE_WITH_HASH_VALUE = 0x00000030, 44 // get bundle info inlcude menu, only for dump usage 45 GET_BUNDLE_WITH_MENU = 0x00000040, 46 // get bundle info inlcude router map, only for dump usage 47 GET_BUNDLE_WITH_ROUTER_MAP = 0x00000080, 48 // get bundle info include skill info 49 GET_BUNDLE_WITH_SKILL = 0x00000800, 50 }; 51 52 enum class GetBundleInfoFlag { 53 GET_BUNDLE_INFO_DEFAULT = 0x00000000, 54 GET_BUNDLE_INFO_WITH_APPLICATION = 0x00000001, 55 GET_BUNDLE_INFO_WITH_HAP_MODULE = 0x00000002, 56 GET_BUNDLE_INFO_WITH_ABILITY = 0x00000004, 57 GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY = 0x00000008, 58 GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION = 0x00000010, 59 GET_BUNDLE_INFO_WITH_METADATA = 0x00000020, 60 GET_BUNDLE_INFO_WITH_DISABLE = 0x00000040, 61 GET_BUNDLE_INFO_WITH_SIGNATURE_INFO = 0x00000080, 62 GET_BUNDLE_INFO_WITH_MENU = 0x00000100, 63 GET_BUNDLE_INFO_WITH_ROUTER_MAP = 0x00000200, 64 GET_BUNDLE_INFO_WITH_SKILL = 0x00000800, 65 GET_BUNDLE_INFO_ONLY_WITH_LAUNCHER_ABILITY = 0x00001000, 66 GET_BUNDLE_INFO_OF_ANY_USER = 0x00002000, 67 GET_BUNDLE_INFO_EXCLUDE_CLONE = 0x00004000, 68 }; 69 70 struct RequestPermissionUsedScene : public Parcelable { 71 std::vector<std::string> abilities; 72 std::string when; 73 74 bool ReadFromParcel(Parcel &parcel); 75 virtual bool Marshalling(Parcel &parcel) const override; 76 static RequestPermissionUsedScene *Unmarshalling(Parcel &parcel); 77 }; 78 79 struct RequestPermission : public Parcelable { 80 std::string name; 81 std::string moduleName; 82 std::string reason; 83 uint32_t reasonId = 0; 84 RequestPermissionUsedScene usedScene; 85 86 bool ReadFromParcel(Parcel &parcel); 87 virtual bool Marshalling(Parcel &parcel) const override; 88 static RequestPermission *Unmarshalling(Parcel &parcel); 89 }; 90 91 struct SignatureInfo : public Parcelable { 92 std::string appId; 93 std::string fingerprint; 94 std::string appIdentifier; 95 std::string certificate; 96 97 bool ReadFromParcel(Parcel &parcel); 98 virtual bool Marshalling(Parcel &parcel) const override; 99 static SignatureInfo *Unmarshalling(Parcel &parcel); 100 }; 101 102 struct SimpleAppInfo : public Parcelable { 103 int32_t uid = -1; 104 std::string bundleName; 105 int32_t appIndex = -1; 106 ErrCode ret = ERR_OK; 107 108 bool ReadFromParcel(Parcel &parcel); 109 virtual bool Marshalling(Parcel &parcel) const override; 110 static SimpleAppInfo *Unmarshalling(Parcel &parcel); 111 std::string ToString() const; 112 }; 113 114 // configuration information about a bundle 115 struct BundleInfo : public Parcelable { 116 std::string name; 117 118 bool isNewVersion = false; 119 uint32_t versionCode = 0; 120 std::string versionName; 121 uint32_t minCompatibleVersionCode = 0; 122 123 uint32_t compatibleVersion = 0; 124 uint32_t targetVersion = 0; 125 126 bool isKeepAlive = false; 127 bool singleton = false; 128 bool isPreInstallApp = false; 129 130 std::string vendor; 131 std::string releaseType; 132 bool isNativeApp = false; 133 134 std::string mainEntry; // modulePackage 135 std::string entryModuleName; // moduleName 136 bool entryInstallationFree = false; // application : false; atomic service : true 137 std::string appId; 138 std::vector<std::string> oldAppIds; // used for appId changed 139 140 // user related fields, assign when calling the get interface 141 int uid = -1; 142 int gid = -1; 143 int64_t installTime = 0; 144 int64_t updateTime = 0; 145 int32_t appIndex = 0; // index for sandbox app 146 147 ApplicationInfo applicationInfo; 148 std::vector<AbilityInfo> abilityInfos; 149 std::vector<ExtensionAbilityInfo> extensionInfos; 150 std::vector<HapModuleInfo> hapModuleInfos; 151 std::vector<std::string> hapModuleNames; // the "module.package" in each config.json 152 std::vector<std::string> moduleNames; // the "module.name" in each config.json 153 std::vector<std::string> modulePublicDirs; // the public paths of all modules of the application. 154 std::vector<std::string> moduleDirs; // the paths of all modules of the application. 155 std::vector<std::string> moduleResPaths; // the paths of all resources paths. 156 157 std::vector<std::string> reqPermissions; 158 std::vector<std::string> defPermissions; 159 std::vector<int32_t> reqPermissionStates; 160 std::vector<RequestPermission> reqPermissionDetails; 161 std::vector<OverlayBundleInfo> overlayBundleInfos; 162 163 std::string cpuAbi; 164 std::string seInfo; 165 std::string label; 166 std::string description; 167 std::string jointUserId; 168 int32_t minSdkVersion = -1; 169 int32_t maxSdkVersion = -1; 170 bool isDifferentName = false; 171 int32_t overlayType = NON_OVERLAY_TYPE; 172 173 SignatureInfo signatureInfo; 174 std::vector<RouterItem> routerArray; 175 176 bool ReadFromParcel(Parcel &parcel); 177 virtual bool Marshalling(Parcel &parcel) const override; 178 static BundleInfo *Unmarshalling(Parcel &parcel); 179 }; 180 } // namespace AppExecFwk 181 } // namespace OHOS 182 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_INFO_H 183