diff --git a/services/devicemanagerservice/include/requestauth/request_session.h b/services/devicemanagerservice/include/requestauth/request_session.h index aa805d9f95560e79f57247c83ddd9c14c962663b..b08b81ce69d3d62ea31c458ebf6727105bbb5007 100644 --- a/services/devicemanagerservice/include/requestauth/request_session.h +++ b/services/devicemanagerservice/include/requestauth/request_session.h @@ -28,8 +28,8 @@ namespace OHOS { namespace DistributedHardware { class RequestSession { public: - RequestSession(std::string &hostPkgName, const DmDeviceInfo &devReqInfo, const DmAppImageInfo &imageInfo, - std::string &extrasJson); + RequestSession(std::string &hostPkgName, std::string &targetPkgName, const DmDeviceInfo &devReqInfo, + const DmAppImageInfo &imageInfo); ~RequestSession() = default; std::vector GetRequestCommand(std::string &extrasJson); int32_t GetPinToken(); diff --git a/services/devicemanagerservice/src/requestauth/auth_manager.cpp b/services/devicemanagerservice/src/requestauth/auth_manager.cpp index 2a01cd06084a813fc5977b60910be30d02471c0c..363377913a5d8cb675700d699bcfbc2dbc5cf2d0 100644 --- a/services/devicemanagerservice/src/requestauth/auth_manager.cpp +++ b/services/devicemanagerservice/src/requestauth/auth_manager.cpp @@ -64,6 +64,11 @@ void AuthManager::AuthAppGroup(std::string &hostPkgName, const DmDeviceInfo &dev DMLOG(DM_LOG_ERROR, "AuthAppGroup extrasJson error"); return; } + if (!jsonObject.contains(TARGET_PKG_NAME_KEY)) { + DMLOG(DM_LOG_ERROR, "TARGET_PKG_NAME is not in extrasJson"); + return; + } + std::string targetPkgName = jsonObject[TARGET_PKG_NAME_KEY]; if (!jsonObject.contains(DISPLAY_OWNER)) { DMLOG(DM_LOG_WARN, "AuthAppGroup DISPLAY_OWNER error"); @@ -77,7 +82,7 @@ void AuthManager::AuthAppGroup(std::string &hostPkgName, const DmDeviceInfo &dev mPendingReqSessionPtr_->NotifyHostAppAuthResult(ERROR_DUPLICATE_REQUEST); return; } - auto curSessionPtr = std::make_shared(hostPkgName, devReqInfo, imageInfo, extrasJson); + auto curSessionPtr = std::make_shared(hostPkgName, targetPkgName, devReqInfo, imageInfo); mPendingReqSessionPtr_ = curSessionPtr; std::vector msgInfo = curSessionPtr->GetRequestCommand(extrasJson); int32_t channelId = SoftbusSession::GetInstance().SendMessages(devReqInfo.deviceId, msgInfo); diff --git a/services/devicemanagerservice/src/requestauth/request_session.cpp b/services/devicemanagerservice/src/requestauth/request_session.cpp index 5514cce0ca117d0e95c3febcbeaa7cb8f7f3efdf..939290965c1419a4b55238f77ff66654a072e4c5 100644 --- a/services/devicemanagerservice/src/requestauth/request_session.cpp +++ b/services/devicemanagerservice/src/requestauth/request_session.cpp @@ -31,23 +31,12 @@ namespace OHOS { namespace DistributedHardware { -RequestSession::RequestSession(std::string &hostPkgName, const DmDeviceInfo &devReqInfo, - const DmAppImageInfo &imageInfo, std::string &extrasJson) +RequestSession::RequestSession(std::string &hostPkgName, std::string &targetPkgName, const DmDeviceInfo &devReqInfo, + const DmAppImageInfo &imageInfo) { DMLOG(DM_LOG_INFO, "RequestSession construction started"); - nlohmann::json jsonObject = nlohmann::json::parse(extrasJson, nullptr, false); - if (jsonObject.is_discarded()) { - DMLOG(DM_LOG_ERROR, "extrasJson error"); - } - - if (!jsonObject.contains(TARGET_PKG_NAME_KEY)) { - DMLOG(DM_LOG_ERROR, "TARGET_PKG_NAME is not in extrasJson"); - return; - } - std::string targetPkgName = jsonObject[TARGET_PKG_NAME_KEY]; mDevInfo_ = devReqInfo; mImageInfo_ = imageInfo; - DMLOG(DM_LOG_ERROR, "imageinfo appIcon:%p:%p", mImageInfo_.GetAppIcon(), imageInfo.GetAppIcon()); mHostPkgName_ = hostPkgName; mTargetPkgName = targetPkgName; mPinToken_ = IpcServerAdapter::GenRandInt(MIN_PIN_TOKEN, MAX_PIN_TOKEN);