From 262567f29e173f68510013450fa215d0bd95b3ff Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk Date: Fri, 1 Jul 2022 10:28:57 +0200 Subject: [PATCH] [android] Fixed getting product id and product name In the #19514 there was a mistake done, as Android methods were meant to only be moved to other module not change their implementation. Restored the previous implementation/ --- .../DeviceInstanceInfoProviderImpl.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/platform/android/DeviceInstanceInfoProviderImpl.cpp b/src/platform/android/DeviceInstanceInfoProviderImpl.cpp index 6d7b1bf4408350..3be54251db8884 100644 --- a/src/platform/android/DeviceInstanceInfoProviderImpl.cpp +++ b/src/platform/android/DeviceInstanceInfoProviderImpl.cpp @@ -43,15 +43,30 @@ CHIP_ERROR DeviceInstanceInfoProviderImpl::GetHardwareVersionString(char * buf, CHIP_ERROR DeviceInstanceInfoProviderImpl::GetProductId(uint16_t & productId) { - productId = static_cast(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID); + CHIP_ERROR err; + uint32_t u32ProductId = 0; + err = ReadConfigValue(Internal::AndroidConfig::kConfigKey_ProductId, u32ProductId); + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + productId = static_cast(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID); + } + else + { + productId = static_cast(u32ProductId); + } return CHIP_NO_ERROR; } CHIP_ERROR DeviceInstanceInfoProviderImpl::GetProductName(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME); - + CHIP_ERROR err; + size_t productNameSize = 0; // without counting null-terminator + err = ReadConfigValueStr(Internal::AndroidConfig::kConfigKey_ProductName, buf, bufSize, productNameSize); + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); + strcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME); + } return CHIP_NO_ERROR; }