diff --git a/ext/profile/include/device_profile_adapter.h b/ext/profile/include/device_profile_adapter.h index 3703a619a921ae9e90f787451a5e20fa93bcfef9..242ed02ecebfe2652dcc6f7e2075e96280b34d8c 100644 --- a/ext/profile/include/device_profile_adapter.h +++ b/ext/profile/include/device_profile_adapter.h @@ -24,7 +24,8 @@ namespace OHOS { namespace DistributedHardware { -class DeviceProfileAdapter : public IProfileAdapter, public IProfileConnectorCallback { +class DeviceProfileAdapter : public IProfileAdapter, public IProfileConnectorCallback, + public std::enable_shared_from_this { public: DeviceProfileAdapter(); ~DeviceProfileAdapter(); diff --git a/ext/profile/src/device_profile_adapter.cpp b/ext/profile/src/device_profile_adapter.cpp index 5d6165a01ba16b33944f5f71870e1a43e5119fe4..b036406eb1dd7b37359d33985787050d295f224d 100644 --- a/ext/profile/src/device_profile_adapter.cpp +++ b/ext/profile/src/device_profile_adapter.cpp @@ -36,13 +36,13 @@ int32_t DeviceProfileAdapter::RegisterProfileListener(const std::string &pkgName { LOGI("DeviceProfileAdapter::RegisterProfileListener"); deviceProfileAdapterCallback_ = callback; - profileConnector_->RegisterProfileCallback(pkgName, deviceId, std::shared_ptr(this)); + profileConnector_->RegisterProfileCallback(pkgName, deviceId, shared_from_this()); return DM_OK; } int32_t DeviceProfileAdapter::UnRegisterProfileListener(const std::string &pkgName) { - LOGI("DeviceProfileAdapter::RegisterProfileListener"); + LOGI("DeviceProfileAdapter::UnRegisterProfileListener"); deviceProfileAdapterCallback_ = nullptr; profileConnector_->UnRegisterProfileCallback(pkgName); return DM_OK;