mirror of
https://gitee.com/openharmony/communication_ipc
synced 2024-11-23 07:50:24 +00:00
commit
09be225858
@ -353,7 +353,7 @@ private:
|
||||
bool IsSameLoadSaItem(const std::string& srcNetworkId, int32_t systemAbilityId,
|
||||
std::shared_ptr<DHandleEntryTxRx> loadSaItem);
|
||||
std::shared_ptr<struct DHandleEntryTxRx> PopLoadSaItem(const std::string& srcNetworkId, int32_t systemAbilityId);
|
||||
void SendMessageToRemote(uint32_t dBinderCode, uint32_t reason,
|
||||
void SendReplyMessageToRemote(uint32_t dBinderCode, uint32_t reason,
|
||||
std::shared_ptr<struct DHandleEntryTxRx> replyMessage);
|
||||
|
||||
private:
|
||||
|
@ -501,7 +501,7 @@ void DBinderService::LoadSystemAbilityComplete(const std::string& srcNetworkId,
|
||||
break;
|
||||
}
|
||||
if (remoteObject == nullptr) {
|
||||
SendMessageToRemote(MESSAGE_AS_REMOTE_ERROR, SA_NOT_FOUND, replyMessage);
|
||||
SendReplyMessageToRemote(MESSAGE_AS_REMOTE_ERROR, SA_NOT_FOUND, replyMessage);
|
||||
DBINDER_LOGE(LOG_LABEL, "GetSystemAbility from samgr error, saId:%{public}d", systemAbilityId);
|
||||
continue;
|
||||
}
|
||||
@ -511,7 +511,7 @@ void DBinderService::LoadSystemAbilityComplete(const std::string& srcNetworkId,
|
||||
/* When the stub object dies, you need to delete the corresponding busName information */
|
||||
sptr<IRemoteObject::DeathRecipient> death(new DbinderSaDeathRecipient(binderObject));
|
||||
if (!saProxy->AddDeathRecipient(death)) {
|
||||
SendMessageToRemote(MESSAGE_AS_REMOTE_ERROR, SA_NOT_FOUND, replyMessage);
|
||||
SendReplyMessageToRemote(MESSAGE_AS_REMOTE_ERROR, SA_NOT_FOUND, replyMessage);
|
||||
DBINDER_LOGE(LOG_LABEL, "fail to add death recipient");
|
||||
continue;
|
||||
}
|
||||
@ -521,7 +521,7 @@ void DBinderService::LoadSystemAbilityComplete(const std::string& srcNetworkId,
|
||||
}
|
||||
std::string deviceId = replyMessage->deviceIdInfo.fromDeviceId;
|
||||
if (replyMessage->transType != IRemoteObject::DATABUS_TYPE) {
|
||||
SendMessageToRemote(MESSAGE_AS_REMOTE_ERROR, SA_INVOKE_FAILED, replyMessage);
|
||||
SendReplyMessageToRemote(MESSAGE_AS_REMOTE_ERROR, SA_INVOKE_FAILED, replyMessage);
|
||||
DBINDER_LOGE(LOG_LABEL, "Invalid Message Type");
|
||||
} else {
|
||||
// peer device rpc version == 1, not support thokenId and message->deviceIdInfo.tokenId is random value
|
||||
@ -530,16 +530,16 @@ void DBinderService::LoadSystemAbilityComplete(const std::string& srcNetworkId,
|
||||
uint32_t result = OnRemoteInvokerDataBusMessage(saProxy, replyMessage.get(), deviceId,
|
||||
replyMessage->pid, replyMessage->uid, tokenId);
|
||||
if (result != 0) {
|
||||
SendMessageToRemote(MESSAGE_AS_REMOTE_ERROR, result, replyMessage);
|
||||
SendReplyMessageToRemote(MESSAGE_AS_REMOTE_ERROR, result, replyMessage);
|
||||
continue;
|
||||
}
|
||||
SendMessageToRemote(MESSAGE_AS_REPLY, 0, replyMessage);
|
||||
SendReplyMessageToRemote(MESSAGE_AS_REPLY, 0, replyMessage);
|
||||
}
|
||||
}
|
||||
DBINDER_LOGI(LOG_LABEL, "LoadSystemAbility complete");
|
||||
}
|
||||
|
||||
void DBinderService::SendMessageToRemote(uint32_t dBinderCode, uint32_t reason,
|
||||
void DBinderService::SendReplyMessageToRemote(uint32_t dBinderCode, uint32_t reason,
|
||||
std::shared_ptr<struct DHandleEntryTxRx> replyMessage)
|
||||
{
|
||||
std::shared_ptr<DBinderRemoteListener> remoteListener = GetRemoteListener();
|
||||
@ -551,7 +551,7 @@ void DBinderService::SendMessageToRemote(uint32_t dBinderCode, uint32_t reason,
|
||||
if (dBinderCode == MESSAGE_AS_REMOTE_ERROR) {
|
||||
replyMessage->transType = reason; // reuse transType send back error code
|
||||
}
|
||||
if (!remoteListener->SendDataToRemote(replyMessage->deviceIdInfo.fromDeviceId, replyMessage.get())) {
|
||||
if (!remoteListener->SendDataReply(replyMessage->deviceIdInfo.fromDeviceId, replyMessage.get())) {
|
||||
DBINDER_LOGE(LOG_LABEL, "fail to send data from server DBS to client DBS");
|
||||
}
|
||||
}
|
||||
|
@ -1145,20 +1145,20 @@ HWTEST_F(DBinderServiceUnitTest, PopLoadSaItemTest001, TestSize.Level1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: SendMessageToRemote001
|
||||
* @tc.desc: Verify the SendMessageToRemote function
|
||||
* @tc.name: SendReplyMessageToRemote001
|
||||
* @tc.desc: Verify the SendReplyMessageToRemote function
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DBinderServiceUnitTest, SendMessageToRemote001, TestSize.Level1)
|
||||
HWTEST_F(DBinderServiceUnitTest, SendReplyMessageToRemote001, TestSize.Level1)
|
||||
{
|
||||
uint32_t dBinderCode = 4;
|
||||
uint32_t reason = 0;
|
||||
std::shared_ptr<DHandleEntryTxRx> replyMessage = std::make_shared<DHandleEntryTxRx>();
|
||||
sptr<DBinderService> dBinderService = DBinderService::GetInstance();
|
||||
dBinderService->remoteListener_ = std::make_shared<DBinderRemoteListener>(dBinderService);
|
||||
dBinderService->SendMessageToRemote(dBinderCode, reason, replyMessage);
|
||||
dBinderService->SendReplyMessageToRemote(dBinderCode, reason, replyMessage);
|
||||
dBinderCode = 1;
|
||||
dBinderService->SendMessageToRemote(dBinderCode, reason, replyMessage);
|
||||
dBinderService->SendReplyMessageToRemote(dBinderCode, reason, replyMessage);
|
||||
DBinderService *temp = new DBinderService();
|
||||
DBinderService::instance_ = temp;
|
||||
dBinderService = DBinderService::GetInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user