OpenHarmony开发者论坛

标题: BMS: [bms_extension_profile.cpp(ReadFileIntoJson:50)]access failed /system/etc/app/bms-extensions.json errno:2 [打印本页]

作者: 火炬    时间: 4 天前
标题: BMS: [bms_extension_profile.cpp(ReadFileIntoJson:50)]access failed /system/etc/app/bms-extensions.json errno:2
[md]### 【问题描述】

1. HAP包iBundleInstaller->StreamInstall进行安装报错
2. ```c++
      
   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](https://forums-obs.openharmony.c ... t8fo82rm4ttmztt.png "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
[/md]




欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/) Powered by Discuz! X3.5