diff --git a/services/abilitymgr/include/want_receiver_stub.h b/services/abilitymgr/include/want_receiver_stub.h index 3fe98628d0..8f27e0b4ac 100644 --- a/services/abilitymgr/include/want_receiver_stub.h +++ b/services/abilitymgr/include/want_receiver_stub.h @@ -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 requestFuncMap_; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/want_sender_stub.h b/services/abilitymgr/include/want_sender_stub.h index 0109723c9f..be789a76ff 100644 --- a/services/abilitymgr/include/want_sender_stub.h +++ b/services/abilitymgr/include/want_sender_stub.h @@ -34,8 +34,6 @@ public: private: int SendInner(MessageParcel &data, MessageParcel &reply); - using RequestFuncType = int (WantSenderStub::*)(MessageParcel &data, MessageParcel &reply); - std::map requestFuncMap_; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/want_receiver_stub.cpp b/services/abilitymgr/src/want_receiver_stub.cpp index 3a94df4a7d..c4099c7706 100644 --- a/services/abilitymgr/src/want_receiver_stub.cpp +++ b/services/abilitymgr/src/want_receiver_stub.cpp @@ -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); diff --git a/services/abilitymgr/src/want_sender_stub.cpp b/services/abilitymgr/src/want_sender_stub.cpp index c61e09125c..15f8adfb24 100644 --- a/services/abilitymgr/src/want_sender_stub.cpp +++ b/services/abilitymgr/src/want_sender_stub.cpp @@ -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);