1 /* 2 * Copyright (c) 2024 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 BUNDLE_MANAGER_UTILS_H 17 #define BUNDLE_MANAGER_UTILS_H 18 19 #include <cstdint> 20 21 namespace OHOS { 22 namespace CJSystemapi { 23 namespace BundleManager { 24 25 struct RetMetadata { 26 char* name; 27 char* value; 28 char* resource; 29 }; 30 31 struct CArrMetadata { 32 RetMetadata* head; 33 int64_t size; 34 }; 35 36 struct ModuleMetadata { 37 char* moduleName; 38 CArrMetadata metadata; 39 }; 40 41 struct CArrMoMeta { 42 ModuleMetadata* head; 43 int64_t size; 44 }; 45 46 struct CResource { 47 char* bundleName; 48 char* moduleName; 49 uint32_t id; 50 }; 51 52 struct CArrString { 53 char** head; 54 int64_t size; 55 }; 56 57 struct MultiAppMode { 58 uint8_t multiAppModeType; 59 int32_t count; 60 }; 61 62 struct RetApplicationInfo { 63 char* name; 64 char* description; 65 uint32_t descriptionId; 66 bool enabled; 67 char* label; 68 uint32_t labelId; 69 char* icon; 70 uint32_t iconId; 71 char* process; 72 CArrString permissions; 73 char* codePath; 74 CArrMoMeta metadataArray; 75 bool removable; 76 uint32_t accessTokenId; 77 int32_t uid; 78 CResource iconResource; 79 CResource labelResource; 80 CResource descriptionResource; 81 char* appDistributionType; 82 char* appProvisionType; 83 bool systemApp; 84 int32_t bundleType; 85 bool debug; 86 bool dataUnclearable; 87 bool cloudFileSyncEnabled; 88 }; 89 90 struct CArrInt32 { 91 int32_t* head; 92 int64_t size; 93 }; 94 95 struct RetWindowSize { 96 double maxWindowRatio; 97 double minWindowRatio; 98 uint32_t maxWindowWidth; 99 uint32_t minWindowWidth; 100 uint32_t maxWindowHeight; 101 uint32_t minWindowHeight; 102 }; 103 104 struct RetSkillUri { 105 char* scheme; 106 char* host; 107 char* port; 108 char* path; 109 char* pathStartWith; 110 char* pathRegex; 111 char* type; 112 char* utd; 113 int32_t maxFileSupported; 114 char* linkFeature; 115 }; 116 117 struct RetCArrSkillUri { 118 RetSkillUri* head; 119 int64_t size; 120 }; 121 122 struct RetSkill { 123 CArrString actions; 124 CArrString entities; 125 RetCArrSkillUri uris; 126 bool domainVerify; 127 }; 128 129 struct RetCArrSkill { 130 RetSkill* head; 131 int64_t size; 132 }; 133 134 struct RetAbilityInfo { 135 char* bundleName; 136 char* moduleName; 137 char* name; 138 char* label; 139 uint32_t labelId; 140 char* description; 141 uint32_t descriptionId; 142 char* icon; 143 uint32_t iconId; 144 char* process; 145 bool exported; 146 int32_t orientation; 147 int32_t launchType; 148 CArrString permissions; 149 CArrString deviceTypes; 150 RetApplicationInfo applicationInfo; 151 CArrMetadata metadata; 152 bool enabled; 153 CArrInt32 supportWindowModes; 154 RetWindowSize windowSize; 155 }; 156 157 struct CArrRetAbilityInfo { 158 RetAbilityInfo* head; 159 int64_t size; 160 }; 161 162 struct RetExtensionAbilityInfo { 163 char* bundleName; 164 char* moduleName; 165 char* name; 166 uint32_t labelId; 167 uint32_t descriptionId; 168 uint32_t iconId; 169 bool exported; 170 int32_t extensionAbilityType; 171 CArrString permissions; 172 RetApplicationInfo applicationInfo; 173 CArrMetadata metadata; 174 bool enabled; 175 char* readPermission; 176 char* writePermission; 177 char* extensionAbilityTypeName; 178 }; 179 180 struct CArrRetExtensionAbilityInfo { 181 RetExtensionAbilityInfo* head; 182 int64_t size; 183 }; 184 185 struct RetPreloadItem { 186 char* moduleName; 187 }; 188 189 struct CArrRetPreloadItem { 190 RetPreloadItem* head; 191 int64_t size; 192 }; 193 194 struct RetDependency { 195 char* bundleName; 196 char* moduleName; 197 uint32_t versionCode; 198 }; 199 200 struct CArrRetDependency { 201 RetDependency* head; 202 int64_t size; 203 }; 204 205 struct CDataItem { 206 char* key; 207 char* value; 208 }; 209 210 struct CArrDataItem { 211 CDataItem* head; 212 int64_t size; 213 }; 214 struct CRouterItem { 215 char* name; 216 char* pageSourceFile; 217 char* buildFunction; 218 CArrDataItem data; 219 char* customData; 220 }; 221 222 struct CArrRouterItem { 223 CRouterItem* head; 224 int64_t size; 225 }; 226 227 struct RetHapModuleInfo { 228 char* name; 229 char* icon; 230 uint32_t iconId; 231 char* label; 232 uint32_t labelId; 233 char* description; 234 uint32_t descriptionId; 235 char* mainElementName; 236 CArrRetAbilityInfo abilitiesInfo; 237 CArrRetExtensionAbilityInfo extensionAbilitiesInfo; 238 CArrMetadata metadata; 239 CArrString deviceTypes; 240 bool installationFree; 241 char* hashValue; 242 int32_t moduleType; 243 CArrRetPreloadItem preloads; 244 CArrRetDependency dependencies; 245 char* fileContextMenuConfig; 246 }; 247 248 struct CArrHapInfo { 249 RetHapModuleInfo* head; 250 int64_t size; 251 }; 252 253 struct RetUsedScene { 254 CArrString abilities; 255 char* when; 256 }; 257 258 struct RetReqPermissionDetail { 259 char* name; 260 char* moduleName; 261 char* reason; 262 uint32_t reasonId; 263 RetUsedScene usedScence; 264 }; 265 266 struct CArrReqPerDetail { 267 RetReqPermissionDetail* head; 268 int64_t size; 269 }; 270 271 struct RetSignatureInfo { 272 char* appId; 273 char* fingerprint; 274 char* appIdentifier; 275 }; 276 277 struct RetCArrString { 278 int32_t code; 279 CArrString value; 280 }; 281 282 struct CRecoverableApplicationInfo { 283 char* bundleName; 284 char* moduleName; 285 uint32_t labelId; 286 uint32_t iconId; 287 }; 288 289 struct CArrRecoverableApplicationInfo { 290 CRecoverableApplicationInfo* head; 291 int64_t size; 292 }; 293 294 struct RetRecoverableApplicationInfo { 295 int32_t code; 296 CArrRecoverableApplicationInfo data; 297 }; 298 299 struct RetBundleInfo { 300 char* name; 301 char* vendor; 302 uint32_t versionCode; 303 char* versionName; 304 uint32_t minCompatibleVersionCode; 305 uint32_t targetVersion; 306 RetApplicationInfo appInfo; 307 CArrHapInfo hapInfo; 308 CArrReqPerDetail perDetail; 309 CArrInt32 state; 310 RetSignatureInfo signInfo; 311 int64_t installTime; 312 int64_t updateTime; 313 int32_t uid; 314 }; 315 316 enum BundleFlag { 317 // get bundle info except abilityInfos 318 GET_BUNDLE_DEFAULT = 0x00000000, 319 // get bundle info include abilityInfos 320 GET_BUNDLE_WITH_ABILITIES = 0x00000001, 321 // get bundle info include request permissions 322 GET_BUNDLE_WITH_REQUESTED_PERMISSION = 0x00000010, 323 // get bundle info include extension info 324 GET_BUNDLE_WITH_EXTENSION_INFO = 0x00000020, 325 // get bundle info include hash value 326 GET_BUNDLE_WITH_HASH_VALUE = 0x00000030, 327 // get bundle info inlcude menu, only for dump usage 328 GET_BUNDLE_WITH_MENU = 0x00000040, 329 }; 330 331 enum class GetBundleInfoFlag { 332 GET_BUNDLE_INFO_DEFAULT = 0x00000000, 333 GET_BUNDLE_INFO_WITH_APPLICATION = 0x00000001, 334 GET_BUNDLE_INFO_WITH_HAP_MODULE = 0x00000002, 335 GET_BUNDLE_INFO_WITH_ABILITY = 0x00000004, 336 GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY = 0x00000008, 337 GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION = 0x00000010, 338 GET_BUNDLE_INFO_WITH_METADATA = 0x00000020, 339 GET_BUNDLE_INFO_WITH_DISABLE = 0x00000040, 340 GET_BUNDLE_INFO_WITH_SIGNATURE_INFO = 0x00000080, 341 GET_BUNDLE_INFO_WITH_MENU = 0x00000100, 342 GET_BUNDLE_INFO_WITH_ROUTER_MAP = 0x00000200, 343 GET_BUNDLE_INFO_WITH_SKILL = 0x00000800, 344 }; 345 346 347 struct RetApplicationInfoV2 { 348 char* name; 349 char* description; 350 uint32_t descriptionId; 351 bool enabled; 352 char* label; 353 uint32_t labelId; 354 char* icon; 355 uint32_t iconId; 356 char* process; 357 CArrString permissions; 358 char* codePath; 359 CArrMoMeta metadataArray; 360 bool removable; 361 uint32_t accessTokenId; 362 int32_t uid; 363 CResource iconResource; 364 CResource labelResource; 365 CResource descriptionResource; 366 char* appDistributionType; 367 char* appProvisionType; 368 bool systemApp; 369 int32_t bundleType; 370 bool debug; 371 bool dataUnclearable; 372 bool cloudFileSyncEnabled; 373 char* nativeLibraryPath; 374 MultiAppMode multiAppMode; 375 int32_t appIndex; 376 char* installSource; 377 char* releaseType; 378 }; 379 380 struct RetAbilityInfoV2 { 381 char* bundleName; 382 char* moduleName; 383 char* name; 384 char* label; 385 uint32_t labelId; 386 char* description; 387 uint32_t descriptionId; 388 char* icon; 389 uint32_t iconId; 390 char* process; 391 bool exported; 392 int32_t orientation; 393 int32_t launchType; 394 CArrString permissions; 395 CArrString deviceTypes; 396 RetApplicationInfoV2 applicationInfo; 397 CArrMetadata metadata; 398 bool enabled; 399 CArrInt32 supportWindowModes; 400 RetWindowSize windowSize; 401 bool excludeFromDock; 402 RetCArrSkill skills; 403 int32_t appIndex; 404 }; 405 406 struct CArrRetAbilityInfoV2 { 407 RetAbilityInfoV2* head; 408 int64_t size; 409 }; 410 411 struct RetExtensionAbilityInfoV2 { 412 char* bundleName; 413 char* moduleName; 414 char* name; 415 uint32_t labelId; 416 uint32_t descriptionId; 417 uint32_t iconId; 418 bool exported; 419 int32_t extensionAbilityType; 420 CArrString permissions; 421 RetApplicationInfoV2 applicationInfo; 422 CArrMetadata metadata; 423 bool enabled; 424 char* readPermission; 425 char* writePermission; 426 char* extensionAbilityTypeName; 427 RetCArrSkill skills; 428 int32_t appIndex; 429 }; 430 431 struct CArrRetExtensionAbilityInfoV2 { 432 RetExtensionAbilityInfoV2* head; 433 int64_t size; 434 }; 435 436 struct RetHapModuleInfoV2 { 437 char* name; 438 char* icon; 439 uint32_t iconId; 440 char* label; 441 uint32_t labelId; 442 char* description; 443 uint32_t descriptionId; 444 char* mainElementName; 445 CArrRetAbilityInfoV2 abilitiesInfo; 446 CArrRetExtensionAbilityInfoV2 extensionAbilitiesInfo; 447 CArrMetadata metadata; 448 CArrString deviceTypes; 449 bool installationFree; 450 char* hashValue; 451 int32_t moduleType; 452 CArrRetPreloadItem preloads; 453 CArrRetDependency dependencies; 454 char* fileContextMenuConfig; 455 CArrRouterItem routerMap; 456 char* codePath; 457 char* nativeLibraryPath; 458 }; 459 460 struct CArrHapInfoV2 { 461 RetHapModuleInfoV2* head; 462 int64_t size; 463 }; 464 465 struct RetBundleInfoV2 { 466 char* name; 467 char* vendor; 468 uint32_t versionCode; 469 char* versionName; 470 uint32_t minCompatibleVersionCode; 471 uint32_t targetVersion; 472 RetApplicationInfoV2 appInfo; 473 CArrHapInfoV2 hapInfo; 474 CArrReqPerDetail perDetail; 475 CArrInt32 state; 476 RetSignatureInfo signInfo; 477 int64_t installTime; 478 int64_t updateTime; 479 int32_t uid; 480 CArrRouterItem routerMap; 481 int32_t appIndex; 482 }; 483 } // BundleManager 484 } // CJSystemapi 485 } // OHOS 486 487 #endif