• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 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 OHOS_BUNDLE_COMMON_H
17 #define OHOS_BUNDLE_COMMON_H
18 
19 #include "pms.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 #ifdef __cplusplus
25 }
26 #endif
27 
28 #include "ability_info.h"
29 #include "module_info.h"
30 #include "stdint.h"
31 
32 namespace OHOS {
33 const char PROFILE_NAME[] = "config.json";
34 const char JSON_SUFFIX[] = ".json";
35 const char PATH_SEPARATOR[] = "/";
36 const char FILE_DELIMITER[] = "_";
37 const char MODULE_ENTRY[] = "entry";
38 const char MODULE_FEATURE[] = "feature";
39 const uint16_t PATH_LENGTH = 256;
40 const uint8_t ICON_NUM = 2;
41 const uint16_t MAX_METADATA_NAME = 255;
42 const uint16_t MAX_METADATA_VALUE = 255;
43 const uint16_t MAX_NAME_LEN = 255;
44 const uint16_t MAX_DECRIPTION_LEN = 255;
45 const uint16_t MAX_VENDOR_LEN = 255;
46 const uint8_t MAX_MODULENAME_LEN = 31;
47 const uint8_t MAX_ABILITY_NAME_LEN = 255;
48 const int8_t PROFILE_INVALID = -1;
49 const int8_t BUNDLENAME_INVALID = -2;
50 const int8_t VERSION_CODE_INVALID = -3;
51 const uint8_t MAX_SINGLE_DIGIT_VALUE = 10;
52 const uint8_t ZERO_ASCII_NUM = 48;
53 // bundle type
54 const uint8_t SYSTEM_APP_FLAG = 0;
55 const uint8_t THIRD_SYSTEM_APP_FLAG = 1;
56 const uint8_t THIRD_APP_FLAG = 2;
57 
58 const uint8_t MIN_BUNDLE_NAME_LEN = 7;
59 const uint8_t MAX_BUNDLE_NAME_LEN = 127;
60 
61 const char LABEL_ID[] = "labelId";
62 const char ICON_ID[] = "iconId";
63 const char MODULE_DES_ID[] = "descriptionId";
64 const char ABILITY_DES_ID[] = "descriptionId";
65 const char RESOURCES_INDEX[] = "/resources.index";
66 const char DEFAULT_LABEL_SETTING[] = "$string:";
67 const char DEFAULT_DESC_SETTING[] = "$string:";
68 const char DEFAULT_ICON_SETTING_BEGIN[] = "$media:";
69 // app config
70 const char PROFILE_KEY_APP[] = "app";
71 const char PROFILE_KEY_VENDOR[] = "vendor";
72 const char PROFILE_KEY_BUNDLENAME[] = "bundleName";
73 const char PROFILE_KEY_VERSION[] = "version";
74 const char PROFILE_KEY_VERSION_CODE[] = "code";
75 const char PROFILE_KEY_VERSION_NAME[] = "name";
76 const char PROFILE_KEY_APIVERSION[] = "apiVersion";
77 const char PROFILE_KEY_APIVERSION_COMPATIBLE[] = "compatible";
78 const char PROFILE_KEY_APIVERSION_TARGET[] = "target";
79 // deviceConfig
80 const char PROFILE_KEY_DEVICECONFIG[] = "deviceConfig";
81 const char PROFILE_KEY_DEVICECONFIG_DEFAULT[] = "default";
82 const char PROFILE_KEY_KEEPALIVE[] = "keepAlive";
83 // module config
84 const char PROFILE_KEY_MODULE[] = "module";
85 const char PROFILE_KEY_MODULE_NAME[] = "name";
86 const char PROFILE_KEY_MODULE_DESCRIPTION[] = "description";
87 const char PROFILE_KEY_MODULE_DEVICETYPE[] = "deviceType";
88 const char PROFILE_KEY_MODULE_DISTRO[] = "distro";
89 const char PROFILE_KEY_MODULE_DISTRO_DELIVERY[] = "deliveryWithInstall";
90 const char PROFILE_KEY_MODULE_DISTRO_MODULENAME[] = "moduleName";
91 const char PROFILE_KEY_MODULE_DISTRO_MODULETYPE[] = "moduleType";
92 const char PROFILE_KEY_MODULE_METADATA[] = "metaData";
93 const char PROFILE_KEY_MODULE_METADATA_CUSTOMIZEDATA[] = "customizeData";
94 const char PROFILE_KEY_MODULE_METADATA_NAME[] = "name";
95 const char PROFILE_KEY_MODULE_METADATA_VALUE[] = "value";
96 const char PROFILE_KEY_MODULE_METADATA_EXTRA[] = "extra";
97 const char PROFILE_KEY_MODULE_ABILITIES[] = "abilities";
98 const char PROFILE_KEY_MODULE_ABILITY_NAME[] = "name";
99 const char PROFILE_KEY_MODULE_ABLLITY_DESCRIPTION[] = "description";
100 const char PROFILE_KEY_MODULE_ABILITY_LABEL[] = "label";
101 const char PROFILE_KEY_MODULE_ABILITY_ICON[] = "icon";
102 const char PROFILE_KEY_MODULE_ABILITY_TYPE[] = "type";
103 const char PROFILE_KEY_MODULE_ABILITY_LAUNCHTYPE[] = "launchType";
104 const char PROFILE_KEY_MODULE_ABILITY_VISIBLE[] = "visible";
105 const char PROFILE_KEY_MODULE_ABILITY_DEVICE_CAP[] = "deviceCapability";
106 // js config
107 const char PROFILE_KEY_JS[] = "js";
108 
109 const char PROFILE_KEY_REQPERMISSIONS[] = "reqPermissions";
110 const char PROFILE_KEY_REQPERMISSIONS_NAME[] = "name";
111 const char PROFILE_KEY_REQPERMISSIONS_REASON[] = "reason";
112 const char PROFILE_KEY_REQPERMISSIONS_USEDSCENE[] = "usedScene";
113 const char PROFILE_KEY_REQPERMISSIONS_WHEN[] = "when";
114 
115 const char ASSETS[] = "/assets/";
116 
117 const char GRANTTIME_INUSE[] = "inuse";
118 const char GRANTTIME_ALWAYS[] = "always";
119 // shared lib path
120 const char SHARED_LIB_NAME[] = "shared_libs";
121 const char SHARED_LIB_PATH[] = "/storage/app/libs";
122 
123 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
124 const char DEFAULT_DEVICE_TYPE[] = "smartVision";
125 const char INSTALL_PATH[] = "/storage/app/run";
126 const char DATA_PATH[] = "/storage/app/data";
127 const char JSON_PATH[] = "/storage/app/etc/bundles/";
128 const char EXTEANAL_INSTALL_PATH[] = "/sdcard/app/run";
129 const char EXTEANAL_DATA_PATH[] = "/sdcard/app/data";
130 const char SYSTEM_BUNDLE_PATH[] = "/system/internal";
131 const char THIRD_SYSTEM_BUNDLE_PATH[] = "/system/external";
132 const char UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON[] = "/storage/app/etc/uninstalled_delbundle.json";
133 const char THIRD_SYSTEM_BUNDLE_JSON[] = "/storage/app/etc/third_system_bundle.json";
134 const char UID_GID_MAP[] = "uid_gid_map";
135 const char INSTALL_FILE_SUFFIX[] = ".hap";
136 // uid and gid
137 const int8_t INVALID_UID = -1;
138 const int8_t INVALID_GID = -1;
139 const uint32_t BASE_SYS_UID = 100;
140 const uint32_t BASE_SYS_VEN_UID = 1000;
141 const uint32_t MAX_SYS_VEN_UID = 9999;
142 const uint32_t BASE_APP_UID = 10000;
143 const char PROFILE_KEY_UID_SIZE[] = "size";
144 const char PROFILE_KEY_UID_AND_GID[] = "uid_and_gid";
145 
146 const uint8_t MAX_VERSION_NAME_LEN = 127;
147 const uint16_t MAX_LABLE_LEN = 255;
148 #else
149 const char DEFAULT_DEVICE_TYPE[] = "fitnessWatch";
150 const char INSTALL_PATH[] = "/data/user/ace/run";
151 const char DATA_PATH[] = "/data/user/ace/data";
152 const char SYSTEM_BUNDLE_PATH[] = "/data/system/ace/sys";
153 const char THIRD_SYSTEM_BUNDLE_PATH[] = "/data/system/ace/vendor";
154 const char UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON[] = "/data/user/ace/etc/uninstalled_delbundle.json";
155 const char THIRD_SYSTEM_BUNDLE_JSON[] = "/data/user/ace/etc/third_system_bundle.json";
156 const char JSON_PATH[] = "/data/user/ace/etc/bundles/";
157 const char JSON_PATH_NO_SLASH_END[] = "/data/user/ace/etc/bundles";
158 // store bundle permissions for IAM
159 const char PERMISSIONS_PATH[] = "/data/user/ace/etc/permissions";
160 const char ASSET_JS_PATH[] = "/assets/js/default";
161 const char ICON_NAME[] = "/icon.bin";
162 const char SMALL_ICON_NAME[] = "/icon_small.bin";
163 const char DEFAULT_ICON_SETTING[] = "$media:icon";
164 const char INSTALL_FILE_SUFFIX[] = ".bin";
165 const char TMP_RESOURCE_DIR[] = "/data/user/ace/run/tmpResource";
166 const char RESOURCES_RAW_FILE[] = "/resources/rawfile";
167 const char RAW_FILE[] = "/rawfile";
168 const uint16_t READ_SIZE = 1024 * 4;
169 const uint8_t MAGIC_NUMBER_LEN = 1;
170 const uint8_t INT_LENGTH = 4;
171 const uint8_t LONG_LENGTH = 8;
172 const uint16_t MAX_INT = 256;
173 const uint8_t MAX_VERSION_NAME_LEN = 20;
174 const uint8_t MAX_LABLE_LEN = 30;
175 const uint8_t MAX_THIRD_BUNDLE_NUMBER = 30;
176 
177 struct SignatureInfo {
178     char *bundleName;
179     char *appId;
180     char **restricPermission;
181     uint32_t restricNum;
182 };
183 #endif
184 // InstallRecord key
185 const char JSON_MAIN_KEY[] = "packages";
186 const char JSON_SUB_KEY_PACKAGE[] = "bundleName";
187 const char JSON_SUB_KEY_CODEPATH[] = "codePath";
188 const char JSON_SUB_KEY_APPID[] = "appID";
189 const char JSON_SUB_KEY_VERSIONCODE[] = "versionCode";
190 const char JSON_SUB_KEY_JSENGINE_VERSION[] = "JsEngineVersion";
191 const char JSON_SUB_KEY_TRANSFORM_RESULT[] = "transformResult";
192 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
193 const char JSON_SUB_KEY_UID[] = "uid";
194 const char JSON_SUB_KEY_GID[] = "gid";
195 #endif
196 
197 struct ProfileVersion {
198 #ifdef __LITEOS_M__
199     int32_t versionCode;
200 #else
201     uint32_t versionCode;
202 #endif
203     char *versionName;
204 };
205 
206 struct ProfileApiVersion {
207     int32_t minApiVersion;
208     int32_t maxApiVersion;
209 };
210 
211 struct AbilityRes {
212     uint32_t iconId;
213     uint32_t labelId;
214     uint32_t descriptionId;
215     uint32_t index;
216 };
217 
218 struct BundleRes {
219     char *bundleName;
220     uint32_t moduleDescriptionId;
221     AbilityRes *abilityRes;
222     uint32_t totalNumOfAbilityRes;
223 };
224 
225 struct BundleProfile {
226 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
227     bool isKeepAlive;
228     bool isNativeApp;
229 #endif
230     char *bundleName;
231     char *vendor;
232     char *label;
233     char *iconPath;
234     ProfileVersion profileVersion;
235     ProfileApiVersion profileApiVersion;
236     ModuleInfo moduleInfo;
237 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
238     AbilityInfo *abilityInfos;
239     uint32_t numOfAbility;
240 #endif
241 };
242 
243 struct Permissions {
244     int32_t permNum;
245     PermissionTrans *permissionTrans;
246 };
247 
248 struct InstallRecord {
249     char *bundleName;
250     char *codePath;
251     char *appId; // it contains bundleName and cert publicKey
252 #ifndef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
253 #ifndef __LINUX__
254 #ifdef BC_TRANS_ENABLE
255     char *jsEngineVersion;
256     int32_t transformResult; // 0: success, -1: fail
257 #endif
258 #endif
259 #endif
260     int32_t versionCode;
261 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
262     int32_t uid;
263     int32_t gid;
264 #endif
265 };
266 }  // namespace OHOS
267 #endif  // OHOS_BUNDLE_COMMON_H
268