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 BUNDLE_MGR_H 17 #define BUNDLE_MGR_H 18 #include <vector> 19 20 #include "napi/native_api.h" 21 #include "napi/native_common.h" 22 #include "napi/native_node_api.h" 23 24 #include "application_info.h" 25 #include "bundle_death_recipient.h" 26 #include "bundle_mgr_interface.h" 27 #include "cleancache_callback.h" 28 #include "js_runtime_utils.h" 29 #ifdef BUNDLE_FRAMEWORK_GRAPHICS 30 #include "pixel_map.h" 31 #endif 32 #include "want.h" 33 34 namespace OHOS { 35 namespace AppExecFwk { 36 struct AsyncWorkData { 37 explicit AsyncWorkData(napi_env napiEnv); 38 virtual ~AsyncWorkData(); 39 napi_env env; 40 napi_async_work asyncWork = nullptr; 41 napi_deferred deferred = nullptr; 42 napi_ref callback = nullptr; 43 }; 44 45 struct QueryParameter { 46 int flags; 47 std::string userId; 48 }; 49 50 struct BundleOptions { 51 int32_t userId = Constants::UNSPECIFIED_USERID; 52 }; 53 54 struct AsyncAbilityInfoCallbackInfo : public AsyncWorkData { AsyncAbilityInfoCallbackInfoAsyncAbilityInfoCallbackInfo55 explicit AsyncAbilityInfoCallbackInfo(napi_env env) : AsyncWorkData(env) {} 56 OHOS::AAFwk::Want want; 57 int32_t flags = 0; 58 int32_t userId = Constants::UNSPECIFIED_USERID; 59 std::vector<OHOS::AppExecFwk::AbilityInfo> abilityInfos; 60 bool ret = false; 61 int32_t err = 0; 62 }; 63 64 struct AsyncAbilityInfosCallbackInfo : public AsyncWorkData { AsyncAbilityInfosCallbackInfoAsyncAbilityInfosCallbackInfo65 explicit AsyncAbilityInfosCallbackInfo(napi_env env) : AsyncWorkData(env) {} 66 int32_t flags = 0; 67 std::string bundleName; 68 std::string abilityName; 69 std::string moduleName = ""; 70 bool hasModuleName = false; 71 OHOS::AppExecFwk::AbilityInfo abilityInfo; 72 bool ret = false; 73 int32_t err = 0; 74 std::string message; 75 }; 76 77 struct AsyncBundleInfoCallbackInfo : public AsyncWorkData { AsyncBundleInfoCallbackInfoAsyncBundleInfoCallbackInfo78 explicit AsyncBundleInfoCallbackInfo(napi_env env) : AsyncWorkData(env) {} 79 std::string param; 80 int32_t flags = 0; 81 OHOS::AppExecFwk::BundleInfo bundleInfo; 82 bool ret = false; 83 int32_t err = 0; 84 std::string message; 85 BundleOptions bundleOptions; 86 }; 87 88 struct AsyncApplicationInfoCallbackInfo : public AsyncWorkData { AsyncApplicationInfoCallbackInfoAsyncApplicationInfoCallbackInfo89 explicit AsyncApplicationInfoCallbackInfo(napi_env env) : AsyncWorkData(env) {} 90 std::string bundleName; 91 int32_t flags = 0; 92 int32_t userId = Constants::UNSPECIFIED_USERID; 93 OHOS::AppExecFwk::ApplicationInfo appInfo; 94 bool ret = false; 95 int32_t err = 0; 96 std::string message; 97 }; 98 99 struct AsyncPermissionDefCallbackInfo : public AsyncWorkData { AsyncPermissionDefCallbackInfoAsyncPermissionDefCallbackInfo100 explicit AsyncPermissionDefCallbackInfo(napi_env env) : AsyncWorkData(env) {} 101 std::string permissionName; 102 OHOS::AppExecFwk::PermissionDef permissionDef; 103 bool ret = false; 104 int32_t err = 0; 105 std::string message; 106 }; 107 108 struct AsyncBundleInfosCallbackInfo : public AsyncWorkData { AsyncBundleInfosCallbackInfoAsyncBundleInfosCallbackInfo109 explicit AsyncBundleInfosCallbackInfo(napi_env env) : AsyncWorkData(env) {} 110 int32_t flags = 0; 111 std::vector<OHOS::AppExecFwk::BundleInfo> bundleInfos; 112 bool ret = false; 113 int32_t err = 0; 114 std::string message; 115 int32_t userId = Constants::UNSPECIFIED_USERID; 116 }; 117 118 struct AsyncApplicationInfosCallbackInfo : public AsyncWorkData { AsyncApplicationInfosCallbackInfoAsyncApplicationInfosCallbackInfo119 explicit AsyncApplicationInfosCallbackInfo(napi_env env) : AsyncWorkData(env) {} 120 int32_t flags = 0; 121 int32_t userId = Constants::UNSPECIFIED_USERID; 122 std::vector<OHOS::AppExecFwk::ApplicationInfo> appInfos; 123 bool ret = false; 124 int32_t err = 0; 125 std::string message; 126 }; 127 128 struct AsyncAbilityLabelCallbackInfo : public AsyncWorkData { AsyncAbilityLabelCallbackInfoAsyncAbilityLabelCallbackInfo129 explicit AsyncAbilityLabelCallbackInfo(napi_env env) : AsyncWorkData(env) {} 130 std::string bundleName; 131 std::string className; 132 std::string moduleName = ""; 133 bool hasModuleName = false; 134 std::string abilityLabel; 135 int32_t err = 0; 136 std::string message; 137 }; 138 139 struct InstallResult { 140 std::string resultMsg; 141 int32_t resultCode = 0; 142 }; 143 144 struct AsyncInstallCallbackInfo : public AsyncWorkData { AsyncInstallCallbackInfoAsyncInstallCallbackInfo145 explicit AsyncInstallCallbackInfo(napi_env env) : AsyncWorkData(env) {} 146 std::vector<std::string> hapFiles; 147 std::string bundleName; 148 std::string param; 149 OHOS::AppExecFwk::InstallParam installParam; 150 InstallResult installResult; 151 int32_t errCode = 0; 152 }; 153 154 struct AsyncGetBundleInstallerCallbackInfo : public AsyncWorkData { AsyncGetBundleInstallerCallbackInfoAsyncGetBundleInstallerCallbackInfo155 explicit AsyncGetBundleInstallerCallbackInfo(napi_env env) : AsyncWorkData(env) {} 156 }; 157 158 struct AsyncFormInfosCallbackInfo : public AsyncWorkData { AsyncFormInfosCallbackInfoAsyncFormInfosCallbackInfo159 explicit AsyncFormInfosCallbackInfo(napi_env env) : AsyncWorkData(env) {} 160 std::vector<OHOS::AppExecFwk::FormInfo> formInfos; 161 bool ret = false; 162 }; 163 164 struct AsyncFormInfosByModuleCallbackInfo : public AsyncWorkData { AsyncFormInfosByModuleCallbackInfoAsyncFormInfosByModuleCallbackInfo165 explicit AsyncFormInfosByModuleCallbackInfo(napi_env env) : AsyncWorkData(env) {} 166 std::string bundleName; 167 std::string moduleName; 168 std::vector<OHOS::AppExecFwk::FormInfo> formInfos; 169 bool ret = false; 170 }; 171 172 struct AsyncFormInfosByAppCallbackInfo : public AsyncWorkData { AsyncFormInfosByAppCallbackInfoAsyncFormInfosByAppCallbackInfo173 explicit AsyncFormInfosByAppCallbackInfo(napi_env env) : AsyncWorkData(env) {} 174 std::string bundleName; 175 std::vector<OHOS::AppExecFwk::FormInfo> formInfos; 176 bool ret = false; 177 }; 178 179 struct AsyncLaunchWantForBundleCallbackInfo : public AsyncWorkData { AsyncLaunchWantForBundleCallbackInfoAsyncLaunchWantForBundleCallbackInfo180 explicit AsyncLaunchWantForBundleCallbackInfo(napi_env env) : AsyncWorkData(env) {} 181 std::string bundleName; 182 OHOS::AAFwk::Want want; 183 bool ret = false; 184 int32_t err = 0; 185 }; 186 187 struct AsyncGetBundleGidsCallbackInfo : public AsyncWorkData { AsyncGetBundleGidsCallbackInfoAsyncGetBundleGidsCallbackInfo188 explicit AsyncGetBundleGidsCallbackInfo(napi_env env) : AsyncWorkData(env) {} 189 std::string bundleName; 190 std::vector<int32_t> gids; 191 int32_t err = 0; 192 bool ret = false; 193 std::string message; 194 }; 195 196 struct AsyncGetNameByUidInfo : public AsyncWorkData { AsyncGetNameByUidInfoAsyncGetNameByUidInfo197 explicit AsyncGetNameByUidInfo(napi_env env) : AsyncWorkData(env) {} 198 int32_t uid = 0; 199 std::string bundleName; 200 int32_t err = 0; 201 bool ret = false; 202 }; 203 204 struct AsyncHandleBundleContext : public AsyncWorkData { AsyncHandleBundleContextAsyncHandleBundleContext205 explicit AsyncHandleBundleContext(napi_env env) : AsyncWorkData(env) {} 206 OHOS::sptr<CleanCacheCallback> cleanCacheCallback; 207 std::string bundleName; 208 std::string className; 209 int32_t labelId = 0; 210 int32_t iconId = 0; 211 bool ret = false; 212 int32_t err = 0; 213 }; 214 215 struct EnabledInfo : public AsyncWorkData { EnabledInfoEnabledInfo216 explicit EnabledInfo(napi_env env) : AsyncWorkData(env) {} 217 std::string bundleName; 218 OHOS::AppExecFwk::AbilityInfo abilityInfo; 219 bool isEnable = false; 220 bool result = false; 221 int32_t errCode = 0; 222 std::string errMssage; 223 }; 224 225 struct AsyncAbilityInfo : public AsyncWorkData { AsyncAbilityInfoAsyncAbilityInfo226 explicit AsyncAbilityInfo(napi_env env) : AsyncWorkData(env) {} 227 std::string bundleName; 228 std::string abilityName; 229 std::string moduleName = ""; 230 bool hasModuleName = false; 231 #ifdef BUNDLE_FRAMEWORK_GRAPHICS 232 std::shared_ptr<Media::PixelMap> pixelMap; 233 #endif 234 int32_t errCode = 0; 235 bool result = false; 236 std::string errMssage; 237 }; 238 239 struct Query { 240 std::string bundleName_; 241 std::string interfaceType_; 242 int32_t flags_ = 0; 243 int32_t userId_ = Constants::UNSPECIFIED_USERID; 244 napi_env env_; QueryQuery245 Query(const std::string &bundleName, const std::string &interfaceType, int32_t flags, int32_t userId, napi_env env) 246 : bundleName_(bundleName), interfaceType_(interfaceType), flags_(flags), userId_(userId), env_(env) {} 247 248 bool operator==(const Query &query) const 249 { 250 return bundleName_ == query.bundleName_ && interfaceType_ == query.interfaceType_ && 251 flags_ == query.flags_ && userId_ == query.userId_ && env_ == query.env_; 252 } 253 }; 254 255 struct QueryHash { operatorQueryHash256 size_t operator()(const Query &query) const 257 { 258 return std::hash<std::string>()(query.bundleName_) ^ std::hash<std::string>()(query.interfaceType_) ^ 259 std::hash<int32_t>()(query.flags_) ^ std::hash<int32_t>()(query.userId_); 260 } 261 }; 262 263 class BundleMgrDeathRecipient : public IRemoteObject::DeathRecipient { 264 virtual void OnRemoteDied([[maybe_unused]] const wptr<IRemoteObject>& remote) override; 265 }; 266 267 extern thread_local napi_ref g_classBundleInstaller; 268 269 napi_value WrapVoidToJS(napi_env env); 270 napi_value GetApplicationInfos(napi_env env, napi_callback_info info); 271 napi_value QueryAbilityInfos(napi_env env, napi_callback_info info); 272 napi_value GetBundleInfos(napi_env env, napi_callback_info info); 273 napi_value GetPermissionDef(napi_env env, napi_callback_info info); 274 napi_value GetAllFormsInfo(napi_env env, napi_callback_info info); 275 napi_value GetFormsInfoByApp(napi_env env, napi_callback_info info); 276 napi_value GetFormsInfoByModule(napi_env env, napi_callback_info info); 277 napi_value GetShortcutInfos(napi_env env, napi_callback_info info); 278 napi_value UnregisterPermissionsChanged(napi_env env, napi_callback_info info); 279 napi_value ClearBundleCache(napi_env env, napi_callback_info info); 280 napi_value SetApplicationEnabled(napi_env env, napi_callback_info info); 281 napi_value SetAbilityEnabled(napi_env env, napi_callback_info info); 282 napi_value GetBundleGids(napi_env env, napi_callback_info info); 283 bool UnwrapAbilityInfo(napi_env env, napi_value param, OHOS::AppExecFwk::AbilityInfo& abilityInfo); 284 285 NativeValue *CreateAbilityTypeObject(NativeEngine *engine); 286 NativeValue *CreateAbilitySubTypeObject(NativeEngine *engine); 287 NativeValue *CreateDisplayOrientationObject(NativeEngine *engine); 288 NativeValue *CreateLaunchModeObject(NativeEngine *engine); 289 NativeValue *CreateColorModeObject(NativeEngine *engine); 290 NativeValue *CreateGrantStatusObject(NativeEngine *engine); 291 NativeValue *CreateModuleRemoveFlagObject(NativeEngine *engine); 292 NativeValue *CreateSignatureCompareResultObject(NativeEngine *engine); 293 NativeValue *CreateShortcutExistenceObject(NativeEngine *engine); 294 NativeValue *CreateQueryShortCutFlagObject(NativeEngine *engine); 295 NativeValue *CreateInstallErrorCodeObject(NativeEngine *engine); 296 NativeValue *CreateBundleFlagObject(NativeEngine *engine); 297 class JsBundleMgr { 298 public: 299 JsBundleMgr() = default; 300 ~JsBundleMgr() = default; 301 302 struct JsAbilityInfo { 303 std::string bundleName; 304 std::string abilityName; 305 std::string moduleName = ""; 306 bool hasModuleName = false; 307 OHOS::AppExecFwk::AbilityInfo abilityInfo; 308 bool ret = false; 309 }; 310 311 struct JsNameForUid { 312 std::string bundleName; 313 int32_t uid; 314 bool ret = false; 315 }; 316 317 struct JsAbilityLabel { 318 std::string bundleName; 319 std::string className; 320 std::string moduleName = ""; 321 bool hasModuleName = false; 322 std::string abilityLabel; 323 }; 324 325 struct JsAbilityIcon { 326 std::string bundleName; 327 std::string abilityName; 328 std::string moduleName = ""; 329 bool hasModuleName = false; 330 }; 331 332 struct JsGetPermissionDef { 333 std::string permissionName; 334 OHOS::AppExecFwk::PermissionDef permissionDef; 335 bool ret = false; 336 }; 337 338 struct JsQueryAbilityInfo { 339 std::vector<AbilityInfo> abilityInfos; 340 bool ret = false; 341 bool getCache = false; 342 }; 343 static void Finalizer(NativeEngine *engine, void *data, void *hint); 344 static NativeValue* GetAllApplicationInfo(NativeEngine *engine, NativeCallbackInfo *info); 345 static NativeValue* GetApplicationInfo(NativeEngine *engine, NativeCallbackInfo *info); 346 static NativeValue* GetBundleArchiveInfo(NativeEngine *engine, NativeCallbackInfo *info); 347 static NativeValue* GetLaunchWantForBundle(NativeEngine *engine, NativeCallbackInfo *info); 348 static NativeValue* IsAbilityEnabled(NativeEngine *engine, NativeCallbackInfo *info); 349 static NativeValue* IsApplicationEnabled(NativeEngine *engine, NativeCallbackInfo *info); 350 static NativeValue* GetBundleInfo(NativeEngine *engine, NativeCallbackInfo *info); 351 static NativeValue* GetAbilityIcon(NativeEngine *engine, NativeCallbackInfo *info); 352 static NativeValue* GetNameForUid(NativeEngine *engine, NativeCallbackInfo *info); 353 static NativeValue* GetAbilityInfo(NativeEngine *engine, NativeCallbackInfo *info); 354 static NativeValue* GetAbilityLabel(NativeEngine *engine, NativeCallbackInfo *info); 355 static NativeValue* SetAbilityEnabled(NativeEngine *engine, NativeCallbackInfo *info); 356 static NativeValue* SetApplicationEnabled(NativeEngine *engine, NativeCallbackInfo *info); 357 static NativeValue* QueryAbilityInfos(NativeEngine *engine, NativeCallbackInfo *info); 358 static NativeValue* GetAllBundleInfo(NativeEngine *engine, NativeCallbackInfo *info); 359 static NativeValue* GetBundleInstaller(NativeEngine *engine, NativeCallbackInfo *info); 360 static NativeValue* GetPermissionDef(NativeEngine *engine, NativeCallbackInfo *info); 361 std::string errMessage_; 362 363 private: 364 NativeValue* OnGetAllApplicationInfo(NativeEngine &engine, NativeCallbackInfo &info); 365 NativeValue* OnGetApplicationInfo(NativeEngine &engine, NativeCallbackInfo &info); 366 NativeValue* OnGetBundleArchiveInfo(NativeEngine &engine, NativeCallbackInfo &info); 367 NativeValue* OnGetLaunchWantForBundle(NativeEngine &engine, NativeCallbackInfo &info); 368 NativeValue* OnIsAbilityEnabled(NativeEngine &engine, NativeCallbackInfo &info); 369 NativeValue* OnIsApplicationEnabled(NativeEngine &engine, NativeCallbackInfo &info); 370 NativeValue* OnGetBundleInfo(NativeEngine &engine, NativeCallbackInfo &info); 371 NativeValue* OnGetAbilityIcon(NativeEngine &engine, NativeCallbackInfo &info); 372 NativeValue* OnGetNameForUid(NativeEngine &engine, NativeCallbackInfo &info); 373 NativeValue* OnGetAbilityInfo(NativeEngine &engine, NativeCallbackInfo &info); 374 NativeValue* OnGetAbilityLabel(NativeEngine &engine, NativeCallbackInfo &info); 375 NativeValue* OnSetAbilityEnabled(NativeEngine &engine, const NativeCallbackInfo &info); 376 NativeValue* OnSetApplicationEnabled(NativeEngine &engine, const NativeCallbackInfo &info); 377 NativeValue* OnQueryAbilityInfos(NativeEngine &engine, NativeCallbackInfo &info); 378 static int32_t InitGetAbilityIcon(NativeEngine &engine, NativeCallbackInfo &info, NativeValue *&lastParam, 379 std::string &errMessage, std::shared_ptr<JsAbilityIcon> abilityIcon); 380 static int32_t InitGetAbilityLabel(NativeEngine &engine, NativeCallbackInfo &info, NativeValue *&lastParam, 381 std::string &errMessage, std::shared_ptr<JsAbilityLabel> abilityLabel); 382 NativeValue* OnGetAllBundleInfo(NativeEngine &engine, NativeCallbackInfo &info); 383 NativeValue* OnGetBundleInstaller(NativeEngine &engine, const NativeCallbackInfo &info); 384 NativeValue* OnGetPermissionDef(NativeEngine &engine, NativeCallbackInfo &info); 385 NativeValue* CreateCustomizeMetaDatas( 386 NativeEngine &engine, const std::map<std::string, std::vector<CustomizeData>> &metaData); 387 NativeValue* CreateInnerMetaDatas( 388 NativeEngine &engine, const std::map<std::string, std::vector<Metadata>> &metaData); 389 NativeValue* CreateInnerMetaDatas(NativeEngine &engine, const std::vector<Metadata> &metaData); 390 NativeValue* CreateCustomizeMetaData(NativeEngine &engine, const CustomizeData &customizeData); 391 NativeValue* CreateInnerMetaData(NativeEngine &engine, const Metadata &metadata); 392 NativeValue* CreateResource(NativeEngine &engine, const Resource &resource); 393 NativeValue* CreateModuleInfos(NativeEngine &engine, const std::vector<ModuleInfo> &moduleInfos); 394 NativeValue* CreateModuleInfo(NativeEngine &engine, const ModuleInfo &modInfo); 395 NativeValue* CreateAppInfo(NativeEngine &engine, const ApplicationInfo &appInfo); 396 static int32_t InitGetAbilityInfo(NativeEngine &engine, NativeCallbackInfo &info, 397 NativeValue *&lastParam, std::string &errMessage, std::shared_ptr<JsAbilityInfo> abilityInfo); 398 NativeValue* CreateAbilityInfo(NativeEngine &engine, const AbilityInfo &abilityInfo); 399 NativeValue* CreateMetaData(NativeEngine &engine, const MetaData &metaData); 400 NativeValue* CreateUsedScene(NativeEngine &engine, const RequestPermissionUsedScene &usedScene); 401 NativeValue* CreateAppInfos(NativeEngine &engine, const std::vector<ApplicationInfo> &appInfos); 402 NativeValue* CreateBundleInfos(NativeEngine &engine, const std::vector<BundleInfo> &bundleInfos); 403 NativeValue* CreateBundleInfo(NativeEngine &engine, const BundleInfo &bundleInfo); 404 NativeValue* CreateAbilityInfos(NativeEngine &engine, const std::vector<AbilityInfo> &abilityInfos); 405 NativeValue* CreateHapModuleInfos(NativeEngine &engine, const std::vector<HapModuleInfo> &hapModuleInfos); 406 NativeValue* CreateHapModuleInfo(NativeEngine &engine, const HapModuleInfo &hapModuleInfo); 407 NativeValue* CreateRequestPermissions(NativeEngine &engine, 408 const std::vector<RequestPermission> &requestPermissions); 409 NativeValue* CreateRequestPermission(NativeEngine &engine, const RequestPermission &requestPermission); 410 NativeValue* CreateWant(NativeEngine &engine, const OHOS::AAFwk::Want &want); 411 NativeValue* CreatePermissionDef(NativeEngine &engine, const PermissionDef &permissionDef); 412 static NativeValue* UnwarpQueryAbilityInfoParams(NativeEngine &engine, NativeCallbackInfo &info, int32_t &userId, 413 int32_t &errCode); 414 static bool UnwarpUserIdThreeParams(NativeEngine &engine, NativeCallbackInfo &info, int32_t &userId); 415 static bool UnwarpUserIdFourParams(NativeEngine &engine, NativeCallbackInfo &info, int32_t &userId); 416 static bool UnwarpUserIdFiveParams(NativeEngine &engine, NativeCallbackInfo &info, int32_t &userId); 417 static bool UnwarpBundleOptionsParams(NativeEngine &engine, NativeCallbackInfo &info, 418 BundleOptions &options, bool &unwarpBundleOptionsParamsResult); 419 NativeValue* JsBundleInstallInit(NativeEngine &engine); 420 NativeValue* CreateBundlePackInfo(NativeEngine &engine, const int32_t &flags, const BundlePackInfo &bundlePackInfo); 421 NativeValue* CreatePackages(NativeEngine &engine, const BundlePackInfo &bundlePackInfo); 422 NativeValue* CreateSummary(NativeEngine &engine, const BundlePackInfo &bundlePackInfo); 423 NativeValue* CreateSummaryApp(NativeEngine &engine, const BundlePackInfo &bundlePackInfo); 424 NativeValue* CreateSummaryModules(NativeEngine &engine, const BundlePackInfo &bundlePackInfo); 425 NativeValue* CreateSummaryModule(NativeEngine &engine, const PackageModule &moduleInfo); 426 NativeValue* CreateSummaryAppVersion(NativeEngine &engine, const BundlePackInfo &bundlePackInfo); 427 NativeValue* CreateModulesApiVersion(NativeEngine &engine, const OHOS::AppExecFwk::PackageModule &module); 428 NativeValue* CreateDistro(NativeEngine &engine, const OHOS::AppExecFwk::PackageModule &module); 429 NativeValue* CreateAbilities(NativeEngine &engine, const OHOS::AppExecFwk::PackageModule &module); 430 NativeValue* CreateAbility(NativeEngine &engine, const ModuleAbilityInfo &ability); 431 NativeValue* CreateFormsInfos(NativeEngine &engine, const std::vector<OHOS::AppExecFwk::AbilityFormInfo> &forms); 432 NativeValue* CreateFormsInfo(NativeEngine &engine, const AbilityFormInfo &form); 433 NativeValue* CreateExtensionAbilities(NativeEngine &engine, const OHOS::AppExecFwk::PackageModule &module); 434 NativeValue* CreateExtensionAbility(NativeEngine &engine, const ExtensionAbilities &extensionAbility); 435 }; 436 437 class JsBundleInstall { 438 public: 439 JsBundleInstall() = default; 440 ~JsBundleInstall() = default; 441 struct BundleInstallResult { 442 int32_t resCode = 0; 443 std::string resMessage; 444 }; 445 static void Finalizer(NativeEngine *engine, void *data, void *hint); 446 static NativeValue* Install(NativeEngine *engine, NativeCallbackInfo *info); 447 static NativeValue* Recover(NativeEngine *engine, NativeCallbackInfo *info); 448 static NativeValue* Uninstall(NativeEngine *engine, NativeCallbackInfo *info); 449 private: 450 NativeValue* OnInstall(NativeEngine &engine, NativeCallbackInfo &info); 451 NativeValue* OnRecover(NativeEngine &engine, NativeCallbackInfo &info); 452 NativeValue* OnUninstall(NativeEngine &engine, NativeCallbackInfo &info); 453 NativeValue* CreateInstallStatus(NativeEngine &engine, 454 const std::shared_ptr<BundleInstallResult> bundleInstallResult); 455 bool GetStringsValue(NativeEngine &engine, NativeValue *object, std::vector<std::string> &strList); 456 static bool GetInstallParamValue(NativeEngine &engine, NativeValue *object, InstallParam &installParam); 457 static void ConvertInstallResult(std::shared_ptr<BundleInstallResult> installResult); 458 }; 459 460 } // namespace AppExecFwk 461 } // namespace OHOS 462 #endif /* BUNDLE_MGR_H */ 463