Skip to content

Commit

Permalink
Set DeviceInstanceInfoProvider to the platform implementation. (#20801)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ArekBalysNordic authored Jul 19, 2022
1 parent ea78432 commit fcd6594
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 35 deletions.
3 changes: 0 additions & 3 deletions src/platform/Darwin/DeviceInstanceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

#include "DeviceInstanceInfoProviderImpl.h"

#include <platform/CHIPDeviceConfig.h>
#include <platform/CHIPDeviceError.h>
#include <platform/Darwin/PosixConfig.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.ipp>

namespace chip {
namespace DeviceLayer {
Expand Down
10 changes: 6 additions & 4 deletions src/platform/Darwin/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/Darwin/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -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<Internal::PosixConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}
} // namespace DeviceLayer
} // namespace chip
6 changes: 6 additions & 0 deletions src/platform/Darwin/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

#include <platform/internal/CHIPDeviceLayerInternal.h>

#if !CHIP_DISABLE_PLATFORM_KVS
#include <platform/Darwin/DeviceInstanceInfoProviderImpl.h>
#include <platform/DeviceInstanceInfoProvider.h>
#endif

#include <platform/Darwin/DiagnosticDataProviderImpl.h>
#include <platform/PlatformManager.h>

Expand All @@ -45,6 +50,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
#if !CHIP_DISABLE_PLATFORM_KVS
err = Internal::PosixConfig::Init();
SuccessOrExit(err);
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());
#endif // CHIP_DISABLE_PLATFORM_KVS
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance());
Expand Down
3 changes: 0 additions & 3 deletions src/platform/Linux/DeviceInstanceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

#include "DeviceInstanceInfoProviderImpl.h"

#include <platform/CHIPDeviceConfig.h>
#include <platform/CHIPDeviceError.h>
#include <platform/Linux/PosixConfig.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.ipp>

namespace chip {
namespace DeviceLayer {
Expand Down
10 changes: 6 additions & 4 deletions src/platform/Linux/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/Linux/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -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<Internal::PosixConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}
} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <lib/support/CHIPMem.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceControlServer.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/Linux/DeviceInstanceInfoProviderImpl.h>
#include <platform/Linux/DiagnosticDataProviderImpl.h>
#include <platform/PlatformManager.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.ipp>
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

#include "DeviceInstanceInfoProviderImpl.h"

#include <platform/CHIPDeviceConfig.h>
#include <platform/CHIPDeviceError.h>
#include <platform/Tizen/PosixConfig.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.ipp>

namespace chip {
namespace DeviceLayer {
Expand Down
10 changes: 6 additions & 4 deletions src/platform/Tizen/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/Tizen/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -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<Internal::PosixConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}
} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/Tizen/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>
#include <platform/Tizen/DeviceInstanceInfoProviderImpl.h>
#include <platform/Tizen/DiagnosticDataProviderImpl.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.ipp>

Expand All @@ -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<PlatformManagerImpl>::_InitChipStack();
}
Expand Down
2 changes: 0 additions & 2 deletions src/platform/android/DeviceInstanceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#include "DeviceInstanceInfoProviderImpl.h"

#include <platform/CHIPDeviceConfig.h>
#include <platform/CHIPDeviceError.h>
#include <platform/android/AndroidConfig.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.ipp>

namespace chip {
namespace DeviceLayer {
Expand Down
11 changes: 6 additions & 5 deletions src/platform/android/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include <platform/android/ConfigurationManagerImpl.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.h>

namespace chip {
Expand All @@ -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<Internal::AndroidConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}

} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/android/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

#include <lib/support/CHIPMem.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>
#include <platform/android/DeviceInstanceInfoProviderImpl.h>
#include <platform/android/DiagnosticDataProviderImpl.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.ipp>

Expand All @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions src/platform/webos/DeviceInstanceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

#include "DeviceInstanceInfoProviderImpl.h"

#include <platform/CHIPDeviceConfig.h>
#include <platform/CHIPDeviceError.h>
#include <platform/internal/GenericDeviceInstanceInfoProvider.ipp>
#include <platform/webos/PosixConfig.h>

namespace chip {
Expand Down
10 changes: 6 additions & 4 deletions src/platform/webos/DeviceInstanceInfoProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <platform/internal/GenericDeviceInstanceInfoProvider.h>
#include <platform/webos/ConfigurationManagerImpl.h>

namespace chip {
namespace DeviceLayer {
Expand All @@ -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<Internal::PosixConfig>(configManager)
{}
};

inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl()
{
return DeviceInstanceInfoProviderImpl::sInstance;
static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance());
return sInstance;
}
} // namespace DeviceLayer
} // namespace chip
3 changes: 3 additions & 0 deletions src/platform/webos/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
#include <lib/support/CHIPMem.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceControlServer.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/PlatformManager.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.ipp>
#include <platform/webos/DeviceInfoProviderImpl.h>
#include <platform/webos/DeviceInstanceInfoProviderImpl.h>
#include <platform/webos/DiagnosticDataProviderImpl.h>

#include <thread>
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit fcd6594

Please sign in to comment.