• Lv0
    粉丝0

积分0 / 贡献0

提问1答案被采纳0文章0

作者动态

    BMS: [bms_extension_profile.cpp(ReadFileIntoJson:50)]access failed /system/etc/app/bms-extensions.json errno:2

    火炬 显示全部楼层 发表于 4 天前

    【问题描述】

    1. HAP包iBundleInstaller->StreamInstall进行安装报错

    2. 
      auto sysAbilityMgr = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
          if (sysAbilityMgr == nullptr) {
              PHLOGE("get system ability manager fail.");
              DeleteFiles();
              return APP_ERR_SYSTEM_ABNORMALLY;
          }
      
          auto remoteObject = sysAbilityMgr->GetSystemAbility(OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
          auto iBundleMgr = iface_cast<AppExecFwk::IBundleMgr>(remoteObject);
          if (iBundleMgr == nullptr) {
              PHLOGE("can not get iBundleMgr");
              DeleteFiles();
              return APP_ERR_SYSTEM_ABNORMALLY;
          }
      
          auto iBundleInstaller = iBundleMgr->GetBundleInstaller();
          if ((iBundleInstaller == nullptr) || (iBundleInstaller->AsObject() == nullptr)) {
              PHLOGE("can not get iBundleInstaller");
              DeleteFiles();
              return APP_ERR_SYSTEM_ABNORMALLY;
          }
      
          sptr<AppInstallCallback> callback = new (std::nothrow) AppInstallCallback();
          if (callback == nullptr) {
              PHLOGE("AppInstallCallback failed");
              DeleteFiles();
              return APP_ERR_SYSTEM_ABNORMALLY;
          }
      
          AppExecFwk::InstallParam installParam;
          installParam.installFlag = AppExecFwk::InstallFlag::REPLACE_EXISTING;
          std::vector<std::string> realPaths = { hapPath };
      
          ErrCode ret = iBundleInstaller->StreamInstall(realPaths, installParam, callback);
          ret = callback->GetResultCode();
          std::string errorMessage = callback->GetResultMsg();
          PHLOGE("StreamInstall resultCode %{public}d resultMsg %{public}s.", ret, errorMessage.c_str());
    3. image.png

    4. 我尝试过修改hap包权限,修改bundle_permission_mgr.cpp中 VerifyCallingPermissionForAll直接返回ture

    5. hap能通过 iBundleInstaller->StreamInstall(realPaths, installParam, callback)正常安装到设备中

    【运行环境】

    硬件:rk3568 ROM版本:5.0.0 Release DevEvoStudio版本:DevEco Studio 5.0.0 Release SDK版本:12

    您尚未登录,无法参与评论,登录后可以:
    参与开源共建问题交流
    认同或收藏高质量问答
    获取积分成为开源共建先驱

    Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

    返回顶部