• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_SERVICES_BUNDLEMGR_INCLUDE_INNER_COMMON_INFO_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_COMMON_INFO_H
18 
19 #include "nocopyable.h"
20 
21 #include "ability_info.h"
22 #include "access_token.h"
23 #include "bundle_constants.h"
24 #include "bundle_info.h"
25 #include "common_event_info.h"
26 #include "common_profile.h"
27 #include "data_group_info.h"
28 #include "distributed_bundle_info.h"
29 #include "extension_ability_info.h"
30 #include "form_info.h"
31 #include "hap_module_info.h"
32 #include "json_util.h"
33 #include "shortcut_info.h"
34 #include "want.h"
35 
36 namespace OHOS {
37 namespace AppExecFwk {
38 struct Distro {
39     bool deliveryWithInstall = false;
40     std::string moduleName;
41     std::string moduleType;
42     bool installationFree = false;
43 };
44 
45 struct DefinePermission {
46     std::string name;
47     std::string grantMode = Profile::DEFINEPERMISSION_GRANT_MODE_SYSTEM_GRANT;
48     std::string availableLevel = Profile::DEFINEPERMISSION_AVAILABLE_LEVEL_DEFAULT_VALUE;
49     bool provisionEnable = true;
50     bool distributedSceneEnable = false;
51     std::string label;
52     int32_t labelId = 0;
53     std::string description;
54     int32_t descriptionId = 0;
55     std::string availableType;
56 };
57 
58 struct InnerModuleInfo {
59     std::string name;
60     std::string modulePackage;
61     std::string moduleName;
62     std::string modulePath;
63     std::string moduleDataDir;
64     std::string moduleResPath;
65     std::string label;
66     std::string hapPath;
67     int32_t labelId = 0;
68     std::string description;
69     int32_t descriptionId = 0;
70     std::string icon;
71     int32_t iconId = 0;
72     std::string mainAbility; // config.json : mainAbility; module.json : mainElement
73     std::string entryAbilityKey; // skills contains "action.system.home" and "entity.system.home"
74     std::string srcPath;
75     std::string hashValue;
76     bool isEntry = false;
77     bool installationFree = false;
78     // all user's value of isRemovable
79     // key:userId
80     // value:isRemovable true or flase
81     std::map<std::string, bool> isRemovable;
82     MetaData metaData;
83     ModuleColorMode colorMode = ModuleColorMode::AUTO;
84     Distro distro;
85     std::vector<std::string> reqCapabilities;
86     std::vector<std::string> abilityKeys;
87     std::vector<std::string> skillKeys;
88     // new version fields
89     std::string pages;
90     std::string process;
91     std::string srcEntrance;
92     std::string uiSyntax;
93     std::string virtualMachine;
94     bool isModuleJson = false;
95     bool isStageBasedModel = false;
96     std::vector<DefinePermission> definePermissions;
97     std::vector<RequestPermission> requestPermissions;
98     std::vector<std::string> deviceTypes;
99     std::vector<std::string> extensionKeys;
100     std::vector<std::string> extensionSkillKeys;
101     std::vector<Metadata> metadata;
102     int32_t upgradeFlag = 0;
103     std::vector<Dependency> dependencies;
104     std::string compileMode;
105     bool isLibIsolated = false;
106     std::string nativeLibraryPath;
107     std::string cpuAbi;
108     std::string targetModuleName;
109     int32_t targetPriority;
110     std::vector<OverlayModuleInfo> overlayModuleInfo;
111     std::vector<std::string> preloads;
112     BundleType bundleType = BundleType::SHARED;
113     uint32_t versionCode = 0;
114     std::string versionName;
115     std::vector<ProxyData> proxyDatas;
116     std::string buildHash;
117     std::string isolationMode;
118     bool compressNativeLibs = true;
119     std::vector<std::string> nativeLibraryFileNames;
120     AOTCompileStatus aotCompileStatus = AOTCompileStatus::NOT_COMPILED;
121     std::string fileContextMenu;
122     bool isEncrypted = false;
123 };
124 
125 struct SkillUri {
126     std::string scheme;
127     std::string host;
128     std::string port;
129     std::string path;
130     std::string pathStartWith;
131     std::string pathRegex;
132     std::string type;
133     std::string utd;
134     int32_t maxFileSupported = 0;
135 };
136 
137 struct Skill {
138 public:
139     std::vector<std::string> actions;
140     std::vector<std::string> entities;
141     std::vector<SkillUri> uris;
142     bool Match(const OHOS::AAFwk::Want &want) const;
143     bool MatchLauncher(const OHOS::AAFwk::Want &want) const;
144     bool MatchType(const std::string &type, const std::string &skillUriType) const;
145     bool MatchUtd(const std::string &utd, int32_t count) const;
146 private:
147     bool MatchAction(const std::string &action) const;
148     bool MatchEntities(const std::vector<std::string> &paramEntities) const;
149     bool MatchUriAndType(const std::string &uriString, const std::string &type) const;
150     bool MatchUri(const std::string &uriString, const SkillUri &skillUri) const;
151     bool StartsWith(const std::string &sourceString, const std::string &targetPrefix) const;
152     bool MatchMimeType(const std::string &uriString) const;
153     bool MatchUtd(const OHOS::AAFwk::Want &want);
154     std::string GetOptParamUri(const std::string &uriString) const;
155 };
156 
157 enum InstallExceptionStatus : int32_t {
158     INSTALL_START = 1,
159     INSTALL_FINISH,
160     UPDATING_EXISTED_START,
161     UPDATING_NEW_START,
162     UPDATING_FINISH,
163     UNINSTALL_BUNDLE_START,
164     UNINSTALL_PACKAGE_START,
165     UNKNOWN_STATUS,
166 };
167 
168 struct InstallMark {
169     std::string bundleName;
170     std::string packageName;
171     int32_t status = InstallExceptionStatus::UNKNOWN_STATUS;
172 };
173 
174 void from_json(const nlohmann::json &jsonObject, InnerModuleInfo &info);
175 void from_json(const nlohmann::json &jsonObject, SkillUri &uri);
176 void from_json(const nlohmann::json &jsonObject, Skill &skill);
177 void from_json(const nlohmann::json &jsonObject, Distro &distro);
178 void from_json(const nlohmann::json &jsonObject, InstallMark &installMark);
179 void from_json(const nlohmann::json &jsonObject, DefinePermission &definePermission);
180 void from_json(const nlohmann::json &jsonObject, Dependency &dependency);
181 void from_json(const nlohmann::json &jsonObject, OverlayBundleInfo &overlayBundleInfo);
182 void to_json(nlohmann::json &jsonObject, const Distro &distro);
183 void to_json(nlohmann::json &jsonObject, const DefinePermission &definePermission);
184 void to_json(nlohmann::json &jsonObject, const Dependency &dependency);
185 void to_json(nlohmann::json &jsonObject, const InnerModuleInfo &info);
186 void to_json(nlohmann::json &jsonObject, const SkillUri &uri);
187 void to_json(nlohmann::json &jsonObject, const Skill &skill);
188 void to_json(nlohmann::json &jsonObject, const InstallMark &installMark);
189 }  // namespace AppExecFwk
190 }  // namespace OHOS
191 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_INNER_COMMON_INFO_H
192