From f69c7b005f51f0375cf0ffbc567bfd6c19ad3d7f Mon Sep 17 00:00:00 2001 From: luwh0708 Date: Mon, 5 Jul 2021 11:53:21 +0800 Subject: [PATCH] patch for iface_cast Change-Id: I584a704d59d28b3d57972c17783b86eacb1148f5 --- interfaces/innerkits/ipc_core/BUILD.gn | 3 +++ .../innerkits/ipc_core/include/iremote_broker.h | 14 ++++++++++++++ ipc/native/src/core/source/iremote_broker.cpp | 1 + 3 files changed, 18 insertions(+) diff --git a/interfaces/innerkits/ipc_core/BUILD.gn b/interfaces/innerkits/ipc_core/BUILD.gn index 370a6aba..6eaba071 100755 --- a/interfaces/innerkits/ipc_core/BUILD.gn +++ b/interfaces/innerkits/ipc_core/BUILD.gn @@ -62,6 +62,9 @@ ohos_shared_library("ipc_core") { "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", ] + public_deps = [ + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + ] subsystem_name = "communication" part_name = "ipc" } diff --git a/interfaces/innerkits/ipc_core/include/iremote_broker.h b/interfaces/innerkits/ipc_core/include/iremote_broker.h index 4251a993..8d55ad5d 100755 --- a/interfaces/innerkits/ipc_core/include/iremote_broker.h +++ b/interfaces/innerkits/ipc_core/include/iremote_broker.h @@ -21,6 +21,18 @@ #include "iremote_object.h" #include "refbase.h" +#include +#include +#include +#include +constexpr OHOS::HiviewDFX::HiLogLabel IPC_LOG_LABEL = {LOG_CORE, 0, "ipcipc"}; +#define __IPC_LOG_(fmt, ...) \ + OHOS::HiviewDFX::HiLog::Info(IPC_LOG_LABEL, "%{public}s<%{public}d>" fmt, __func__, __LINE__, ##__VA_ARGS__) +static inline std::string to_utf8(std::u16string str16) +{ + return std::wstring_convert< std::codecvt_utf8_utf16, char16_t >{}.to_bytes(str16); +} + namespace OHOS { template class BrokerCreator { public: @@ -88,6 +100,7 @@ template BrokerDelegator::BrokerDelegator() { const std::u16string descriptor = T::GetDescriptor(); BrokerRegistration ®istration = BrokerRegistration::Get(); + __IPC_LOG_("%{public}s", to_utf8(descriptor).c_str()); registration.Register(descriptor, BrokerCreator()); } @@ -101,6 +114,7 @@ template BrokerDelegator::~BrokerDelegator() template inline sptr iface_cast(const sptr &object) { const std::u16string descriptor = INTERFACE::GetDescriptor(); + __IPC_LOG_("%{public}s", to_utf8(descriptor).c_str()); BrokerRegistration ®istration = BrokerRegistration::Get(); sptr broker = registration.NewInstance(descriptor, object); return static_cast(broker.GetRefPtr()); diff --git a/ipc/native/src/core/source/iremote_broker.cpp b/ipc/native/src/core/source/iremote_broker.cpp index 9a917fbb..fdeb32c0 100755 --- a/ipc/native/src/core/source/iremote_broker.cpp +++ b/ipc/native/src/core/source/iremote_broker.cpp @@ -69,6 +69,7 @@ sptr BrokerRegistration::NewInstance(const std::u16string &descri auto it = creators_.find(descriptor); if (it != creators_.end()) { broker = it->second(object); + __IPC_LOG_("%{public}s found %{public}p", to_utf8(descriptor).c_str(), broker.GetRefPtr()); } } else { broker = object->AsInterface().GetRefPtr(); -- Gitee