From 0ca051107834f5a0a5eef7bbffba58ca6cec9c33 Mon Sep 17 00:00:00 2001 From: Arkadiusz Balys Date: Wed, 13 Jul 2022 14:27:28 +0200 Subject: [PATCH] Set DeviceInstanceInfoProvider to the platform implementation. In the #19514 there was a mistake made. Within some platforms, the DeviceInstanceInfoProvider was set to a generic one instead of the platform implementation. To resolve this issue, the DeviceInstanceInfoProvider has been set to the proper one in PlatformManager implementation for Android, Darwin, Linux, Tizen, and WebOS. --- src/platform/Darwin/DeviceInstanceInfoProviderImpl.h | 10 ++++++---- src/platform/Darwin/PlatformManagerImpl.cpp | 3 +++ src/platform/Linux/DeviceInstanceInfoProviderImpl.h | 10 ++++++---- src/platform/Linux/PlatformManagerImpl.cpp | 3 +++ src/platform/Tizen/DeviceInstanceInfoProviderImpl.h | 10 ++++++---- src/platform/Tizen/PlatformManagerImpl.cpp | 3 +++ src/platform/android/DeviceInstanceInfoProviderImpl.h | 11 ++++++----- src/platform/android/PlatformManagerImpl.cpp | 3 +++ src/platform/webos/DeviceInstanceInfoProviderImpl.h | 10 ++++++---- src/platform/webos/PlatformManagerImpl.cpp | 3 +++ 10 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/platform/Darwin/DeviceInstanceInfoProviderImpl.h b/src/platform/Darwin/DeviceInstanceInfoProviderImpl.h index 0fd05e46dc5160..630fdbe24c8a12 100644 --- a/src/platform/Darwin/DeviceInstanceInfoProviderImpl.h +++ b/src/platform/Darwin/DeviceInstanceInfoProviderImpl.h @@ -18,6 +18,7 @@ #pragma once +#include #include namespace chip { @@ -29,14 +30,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf CHIP_ERROR GetVendorId(uint16_t & vendorId) override; CHIP_ERROR GetProductId(uint16_t & productId) override; -private: - friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl(); - static DeviceInstanceInfoProviderImpl sInstance; + DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : + Internal::GenericDeviceInstanceInfoProvider(configManager) + {} }; inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl() { - return DeviceInstanceInfoProviderImpl::sInstance; + static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance()); + return sInstance; } } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Darwin/PlatformManagerImpl.cpp b/src/platform/Darwin/PlatformManagerImpl.cpp index 1a80645a0192c1..00e63fb88c6d22 100644 --- a/src/platform/Darwin/PlatformManagerImpl.cpp +++ b/src/platform/Darwin/PlatformManagerImpl.cpp @@ -24,7 +24,9 @@ #include +#include #include +#include #include // Include the non-inline definitions for the GenericPlatformManagerImpl<> template, @@ -48,6 +50,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() #endif // CHIP_DISABLE_PLATFORM_KVS SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); mRunLoopSem = dispatch_semaphore_create(0); diff --git a/src/platform/Linux/DeviceInstanceInfoProviderImpl.h b/src/platform/Linux/DeviceInstanceInfoProviderImpl.h index 0fd05e46dc5160..7c1135b28d0123 100644 --- a/src/platform/Linux/DeviceInstanceInfoProviderImpl.h +++ b/src/platform/Linux/DeviceInstanceInfoProviderImpl.h @@ -18,6 +18,7 @@ #pragma once +#include #include namespace chip { @@ -29,14 +30,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf CHIP_ERROR GetVendorId(uint16_t & vendorId) override; CHIP_ERROR GetProductId(uint16_t & productId) override; -private: - friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl(); - static DeviceInstanceInfoProviderImpl sInstance; + DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : + Internal::GenericDeviceInstanceInfoProvider(configManager) + {} }; inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl() { - return DeviceInstanceInfoProviderImpl::sInstance; + static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance()); + return sInstance; } } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Linux/PlatformManagerImpl.cpp b/src/platform/Linux/PlatformManagerImpl.cpp index 2aa464bb07c2f6..1bd7de58e2db2d 100644 --- a/src/platform/Linux/PlatformManagerImpl.cpp +++ b/src/platform/Linux/PlatformManagerImpl.cpp @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include #include @@ -175,6 +177,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() ReturnErrorOnFailure(Internal::PosixConfig::Init()); SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); // Call _InitChipStack() on the generic implementation base class // to finish the initialization process. diff --git a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h index 0fd05e46dc5160..630fdbe24c8a12 100644 --- a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h +++ b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h @@ -18,6 +18,7 @@ #pragma once +#include #include namespace chip { @@ -29,14 +30,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf CHIP_ERROR GetVendorId(uint16_t & vendorId) override; CHIP_ERROR GetProductId(uint16_t & productId) override; -private: - friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl(); - static DeviceInstanceInfoProviderImpl sInstance; + DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : + Internal::GenericDeviceInstanceInfoProvider(configManager) + {} }; inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl() { - return DeviceInstanceInfoProviderImpl::sInstance; + static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance()); + return sInstance; } } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Tizen/PlatformManagerImpl.cpp b/src/platform/Tizen/PlatformManagerImpl.cpp index 87b9a36201bad4..78ee755146680c 100644 --- a/src/platform/Tizen/PlatformManagerImpl.cpp +++ b/src/platform/Tizen/PlatformManagerImpl.cpp @@ -25,7 +25,9 @@ #include +#include #include +#include #include #include @@ -39,6 +41,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) ReturnErrorOnFailure(Internal::PosixConfig::Init()); SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); return Internal::GenericPlatformManagerImpl_POSIX::_InitChipStack(); } diff --git a/src/platform/android/DeviceInstanceInfoProviderImpl.h b/src/platform/android/DeviceInstanceInfoProviderImpl.h index 4fa49245d20882..05cb232fd1f98c 100644 --- a/src/platform/android/DeviceInstanceInfoProviderImpl.h +++ b/src/platform/android/DeviceInstanceInfoProviderImpl.h @@ -18,6 +18,7 @@ #pragma once +#include #include namespace chip { @@ -30,15 +31,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf CHIP_ERROR GetProductId(uint16_t & productId) override; CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override; -private: - friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl(); - static DeviceInstanceInfoProviderImpl sInstance; + DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : + Internal::GenericDeviceInstanceInfoProvider(configManager) + {} }; inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl() { - return DeviceInstanceInfoProviderImpl::sInstance; + static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance()); + return sInstance; } - } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/android/PlatformManagerImpl.cpp b/src/platform/android/PlatformManagerImpl.cpp index 44ebf7af8594ee..a6bc9ddf86c58b 100644 --- a/src/platform/android/PlatformManagerImpl.cpp +++ b/src/platform/android/PlatformManagerImpl.cpp @@ -26,7 +26,9 @@ #include #include +#include #include +#include #include #include @@ -46,6 +48,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() SuccessOrExit(err); SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); // Call _InitChipStack() on the generic implementation base class // to finish the initialization process. diff --git a/src/platform/webos/DeviceInstanceInfoProviderImpl.h b/src/platform/webos/DeviceInstanceInfoProviderImpl.h index 0fd05e46dc5160..d4986c7ace84fb 100644 --- a/src/platform/webos/DeviceInstanceInfoProviderImpl.h +++ b/src/platform/webos/DeviceInstanceInfoProviderImpl.h @@ -18,6 +18,7 @@ #pragma once +#include #include namespace chip { @@ -29,14 +30,15 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf CHIP_ERROR GetVendorId(uint16_t & vendorId) override; CHIP_ERROR GetProductId(uint16_t & productId) override; -private: - friend DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl(); - static DeviceInstanceInfoProviderImpl sInstance; + DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : + Internal::GenericDeviceInstanceInfoProvider(configManager) + {} }; inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl() { - return DeviceInstanceInfoProviderImpl::sInstance; + static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance()); + return sInstance; } } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/webos/PlatformManagerImpl.cpp b/src/platform/webos/PlatformManagerImpl.cpp index 92be732d7ec4eb..c2e6845368aeb9 100644 --- a/src/platform/webos/PlatformManagerImpl.cpp +++ b/src/platform/webos/PlatformManagerImpl.cpp @@ -29,9 +29,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -166,6 +168,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); SetDeviceInfoProvider(&DeviceInfoProviderImpl::GetDefaultInstance()); + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); // Call _InitChipStack() on the generic implementation base class // to finish the initialization process.