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_HAP_MODULE_INFO_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_HAP_MODULE_INFO_H 18 19 #include <string> 20 21 #include "ability_info.h" 22 #include "extension_ability_info.h" 23 #include "overlay/overlay_module_info.h" 24 #include "parcel.h" 25 #include "quick_fix/hqf_info.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 enum class ModuleColorMode { 30 AUTO = -1, 31 DARK, 32 LIGHT, 33 }; 34 35 enum class ModuleType { 36 UNKNOWN = 0, 37 ENTRY = 1, 38 FEATURE = 2, 39 SHARED = 3 40 }; 41 42 enum class AtomicServiceModuleType { 43 NORMAL = 0, 44 MAIN = 1, 45 }; 46 47 enum class IsolationMode { 48 NONISOLATION_FIRST = 0, 49 ISOLATION_FIRST = 1, 50 ISOLATION_ONLY = 2, 51 NONISOLATION_ONLY = 3, 52 }; 53 54 enum class AOTCompileStatus { 55 NOT_COMPILED = 0, 56 COMPILE_SUCCESS = 1, 57 COMPILE_FAILED = 2, 58 COMPILE_CRASH = 3, 59 COMPILE_CANCELLED = 4, 60 }; 61 62 struct PreloadItem : public Parcelable { 63 std::string moduleName; 64 65 PreloadItem() = default; PreloadItemPreloadItem66 explicit PreloadItem(std::string name) : moduleName(name) {} 67 bool ReadFromParcel(Parcel &parcel); 68 virtual bool Marshalling(Parcel &parcel) const override; 69 static PreloadItem *Unmarshalling(Parcel &parcel); 70 }; 71 72 struct Dependency : public Parcelable { 73 std::string bundleName; 74 std::string moduleName; 75 uint32_t versionCode = 0; 76 77 bool ReadFromParcel(Parcel &parcel); 78 virtual bool Marshalling(Parcel &parcel) const override; 79 static Dependency *Unmarshalling(Parcel &parcel); 80 }; 81 82 struct ProxyData : public Parcelable { 83 std::string uri; 84 std::string requiredReadPermission; 85 std::string requiredWritePermission; 86 Metadata metadata; 87 88 bool ReadFromParcel(Parcel &parcel); 89 virtual bool Marshalling(Parcel &parcel) const override; 90 static ProxyData *Unmarshalling(Parcel &parcel); 91 }; 92 93 struct RouterItem : public Parcelable { 94 std::string name; 95 std::string pageSourceFile; 96 std::string buildFunction; 97 std::map<std::string, std::string> data; 98 std::string customData; 99 std::string ohmurl; 100 std::string bundleName; 101 std::string moduleName; 102 103 bool ReadFromParcel(Parcel &parcel); 104 virtual bool Marshalling(Parcel &parcel) const override; 105 static RouterItem *Unmarshalling(Parcel &parcel); 106 }; 107 108 struct AppEnvironment : public Parcelable { 109 std::string name; 110 std::string value; 111 112 bool ReadFromParcel(Parcel &parcel); 113 virtual bool Marshalling(Parcel &parcel) const override; 114 static AppEnvironment *Unmarshalling(Parcel &parcel); 115 }; 116 117 // configuration information about an module 118 struct HapModuleInfo : public Parcelable { 119 bool compressNativeLibs = true; 120 bool isLibIsolated = false; 121 uint32_t descriptionId = 0; 122 uint32_t iconId = 0; 123 uint32_t labelId = 0; 124 int supportedModes = 0; 125 std::string name; // module.name in config.json 126 std::string package; 127 std::string moduleName; // module.distro.moduleName in config.json 128 std::string description; 129 std::string iconPath; 130 std::string label; 131 std::string backgroundImg; 132 std::string mainAbility; 133 std::string srcPath; 134 std::string hashValue; 135 std::string hapPath; 136 std::string nativeLibraryPath; 137 std::string cpuAbi; 138 std::vector<std::string> nativeLibraryFileNames; 139 140 // quick fix hqf info 141 HqfInfo hqfInfo; 142 143 // overlay module info 144 std::vector<OverlayModuleInfo> overlayModuleInfos; 145 146 std::vector<std::string> reqCapabilities; 147 std::vector<std::string> deviceTypes; 148 std::vector<Dependency> dependencies; 149 std::vector<AbilityInfo> abilityInfos; 150 ModuleColorMode colorMode = ModuleColorMode::AUTO; 151 // new version fields 152 std::string bundleName; 153 std::string mainElementName; 154 std::string pages; 155 std::string process; 156 std::string resourcePath; 157 std::string srcEntrance; 158 std::string uiSyntax; 159 std::string virtualMachine; 160 bool deliveryWithInstall = false; 161 bool installationFree = false; 162 bool isModuleJson = false; 163 bool isStageBasedModel = false; 164 std::map<std::string, bool> isRemovable; 165 ModuleType moduleType = ModuleType::UNKNOWN; 166 std::vector<ExtensionAbilityInfo> extensionInfos; 167 std::vector<Metadata> metadata; 168 std::vector<ProxyData> proxyDatas; 169 int32_t upgradeFlag = 0; 170 CompileMode compileMode = CompileMode::JS_BUNDLE; 171 std::string moduleSourceDir; 172 std::vector<PreloadItem> preloads; 173 std::string buildHash; 174 IsolationMode isolationMode = IsolationMode::NONISOLATION_FIRST; 175 AOTCompileStatus aotCompileStatus = AOTCompileStatus::NOT_COMPILED; 176 std::string fileContextMenu; 177 std::string routerMap; 178 std::vector<RouterItem> routerArray; 179 std::vector<AppEnvironment> appEnvironments; 180 std::string packageName; 181 bool ReadFromParcel(Parcel &parcel); 182 virtual bool Marshalling(Parcel &parcel) const override; 183 static HapModuleInfo *Unmarshalling(Parcel &parcel); 184 std::string appStartup; 185 }; 186 } // namespace AppExecFwk 187 } // namespace OHOS 188 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_HAP_MODULE_INFO_H 189