0719 Signed-off-by: 帝俊 <yexinjie@huawei.com>

This commit is contained in:
帝俊 2024-07-19 10:36:37 +08:00
parent 87287553cd
commit 879aa77fe2
4 changed files with 11 additions and 33 deletions

View File

@ -35,8 +35,6 @@ public:
private:
int SendInner(MessageParcel &data, MessageParcel &reply);
int PerformReceiveInner(MessageParcel &data, MessageParcel &reply);
using RequestFuncType = int (WantReceiverStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, RequestFuncType> requestFuncMap_;
};
} // namespace AAFwk
} // namespace OHOS

View File

@ -34,8 +34,6 @@ public:
private:
int SendInner(MessageParcel &data, MessageParcel &reply);
using RequestFuncType = int (WantSenderStub::*)(MessageParcel &data, MessageParcel &reply);
std::map<uint32_t, RequestFuncType> requestFuncMap_;
};
} // namespace AAFwk
} // namespace OHOS

View File

@ -22,16 +22,9 @@
namespace OHOS {
namespace AAFwk {
WantReceiverStub::WantReceiverStub()
{
requestFuncMap_[WANT_RECEIVER_SEND] = &WantReceiverStub::SendInner;
requestFuncMap_[WANT_RECEIVER_PERFORM_RECEIVE] = &WantReceiverStub::PerformReceiveInner;
}
WantReceiverStub::WantReceiverStub() {}
WantReceiverStub::~WantReceiverStub()
{
requestFuncMap_.clear();
}
WantReceiverStub::~WantReceiverStub() {}
int WantReceiverStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
@ -43,12 +36,11 @@ int WantReceiverStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messag
return ERR_INVALID_STATE;
}
auto itFunc = requestFuncMap_.find(code);
if (itFunc != requestFuncMap_.end()) {
auto requestFunc = itFunc->second;
if (requestFunc != nullptr) {
return (this->*requestFunc)(data, reply);
}
switch (code) {
case WANT_RECEIVER_SEND:
return SendInner(data, reply);
case WANT_RECEIVER_PERFORM_RECEIVE:
return PerformReceiveInner(data, reply);
}
TAG_LOGW(AAFwkTag::WANTAGENT, "WantReceiverStub::OnRemoteRequest, default case, need check.");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);

View File

@ -20,15 +20,9 @@
namespace OHOS {
namespace AAFwk {
WantSenderStub::WantSenderStub()
{
requestFuncMap_[WANT_SENDER_SEND] = &WantSenderStub::SendInner;
}
WantSenderStub::WantSenderStub() {}
WantSenderStub::~WantSenderStub()
{
requestFuncMap_.clear();
}
WantSenderStub::~WantSenderStub() {}
int WantSenderStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
@ -40,12 +34,8 @@ int WantSenderStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageP
return ERR_INVALID_STATE;
}
auto itFunc = requestFuncMap_.find(code);
if (itFunc != requestFuncMap_.end()) {
auto requestFunc = itFunc->second;
if (requestFunc != nullptr) {
return (this->*requestFunc)(data, reply);
}
if (code == (WANT_SENDER_SEND)) {
return SendInner(data, reply);
}
TAG_LOGW(AAFwkTag::WANTAGENT, "WantSenderStub::OnRemoteRequest, default case, need check.");
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);