diff --git a/frameworks/native/backup_ext/src/ext_extension_stub.cpp b/frameworks/native/backup_ext/src/ext_extension_stub.cpp index f78037b07c77a3a96890c362691f517d379f31e1..ea15ecb6d9b42dd5d2b79cafc2e25c9015a0e51e 100644 --- a/frameworks/native/backup_ext/src/ext_extension_stub.cpp +++ b/frameworks/native/backup_ext/src/ext_extension_stub.cpp @@ -39,20 +39,19 @@ int32_t ExtExtensionStub::OnRemoteRequest(uint32_t code, MessageParcel &reply, MessageOption &option) { - HILOGI("Begin to call procedure indexed %{public}u", code); - auto interfaceIndex = opToInterfaceMap_.find(code); - if (interfaceIndex == opToInterfaceMap_.end() || !interfaceIndex->second) { - stringstream ss; - ss << "Cannot response request " << code << ": unknown procedure"; - return BError(BError::Codes::EXT_INVAL_ARG, ss.str()); - } - const std::u16string descriptor = ExtExtensionStub::GetDescriptor(); const std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { return BError(BError::Codes::EXT_INVAL_ARG, "Invalid remote descriptor"); } + HILOGI("Begin to call procedure indexed %{public}u", code); + auto interfaceIndex = opToInterfaceMap_.find(code); + if (interfaceIndex == opToInterfaceMap_.end() || !interfaceIndex->second) { + HILOGE("Cannot response request %{public}d : unknown procedure", code); + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return ExceptionCatcherLocked([&]() { return ErrCode((this->*(interfaceIndex->second))(data, reply)); }); } diff --git a/frameworks/native/backup_kit_inner/src/service_reverse_stub.cpp b/frameworks/native/backup_kit_inner/src/service_reverse_stub.cpp index 9445a28de715c2546eb93ccf8b3fc6d80c8f87f5..b9299c68f40ce43629ed4e51ca5e13c1180abe41 100644 --- a/frameworks/native/backup_kit_inner/src/service_reverse_stub.cpp +++ b/frameworks/native/backup_kit_inner/src/service_reverse_stub.cpp @@ -29,20 +29,18 @@ int32_t ServiceReverseStub::OnRemoteRequest(uint32_t code, MessageParcel &reply, MessageOption &option) { - HILOGI("Begin to call procedure indexed %{public}u", code); - auto interfaceIndex = opToInterfaceMap_.find(code); - if (interfaceIndex == opToInterfaceMap_.end() || !interfaceIndex->second) { - stringstream ss; - ss << "Cannot response request " << code << ": unknown procedure"; - return BError(BError::Codes::SA_INVAL_ARG, ss.str()); - } - const std::u16string descriptor = ServiceReverseStub::GetDescriptor(); const std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { return BError(BError::Codes::SA_INVAL_ARG, "Invalid remote descriptor"); } + HILOGI("Begin to call procedure indexed %{public}u", code); + auto interfaceIndex = opToInterfaceMap_.find(code); + if (interfaceIndex == opToInterfaceMap_.end() || !interfaceIndex->second) { + HILOGE("Cannot response request %{public}d : unknown procedure", code); + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } return (this->*(interfaceIndex->second))(data, reply); } diff --git a/services/backup_sa/src/module_ipc/service_stub.cpp b/services/backup_sa/src/module_ipc/service_stub.cpp index 8134ca92af399a2a043d99ed71171a1f85dd0afb..21f25220f20db94cb05aca7db9f96eab9eeefe31 100644 --- a/services/backup_sa/src/module_ipc/service_stub.cpp +++ b/services/backup_sa/src/module_ipc/service_stub.cpp @@ -44,20 +44,19 @@ ServiceStub::ServiceStub() int32_t ServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - HILOGI("Begin to call procedure indexed %{public}u", code); - auto interfaceIndex = opToInterfaceMap_.find(code); - if (interfaceIndex == opToInterfaceMap_.end() || !interfaceIndex->second) { - stringstream ss; - ss << "Cannot response request " << code << ": unknown procedure"; - return BError(BError::Codes::SA_INVAL_ARG, ss.str()); - } - const std::u16string descriptor = ServiceStub::GetDescriptor(); const std::u16string remoteDescriptor = data.ReadInterfaceToken(); if (descriptor != remoteDescriptor) { return BError(BError::Codes::SA_INVAL_ARG, "Invalid remote descriptor"); } + HILOGI("Begin to call procedure indexed %{public}u", code); + auto interfaceIndex = opToInterfaceMap_.find(code); + if (interfaceIndex == opToInterfaceMap_.end() || !interfaceIndex->second) { + HILOGE("Cannot response request %{public}d : unknown procedure", code); + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return (this->*(interfaceIndex->second))(data, reply); }