Skip to content

Commit

Permalink
[android] Fixed getting product id and product name (#20208)
Browse files Browse the repository at this point in the history
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/
  • Loading branch information
kkasperczyk-no authored and pull[bot] committed Dec 14, 2023
1 parent fece8c1 commit b080087
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/platform/android/DeviceInstanceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,31 @@ CHIP_ERROR DeviceInstanceInfoProviderImpl::GetHardwareVersionString(char * buf,

CHIP_ERROR DeviceInstanceInfoProviderImpl::GetProductId(uint16_t & productId)
{
productId = static_cast<uint16_t>(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID);
CHIP_ERROR err;
uint32_t u32ProductId = 0;
err = Internal::AndroidConfig::ReadConfigValue(Internal::AndroidConfig::kConfigKey_ProductId, u32ProductId);
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{
productId = static_cast<uint16_t>(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID);
}
else
{
productId = static_cast<uint16_t>(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 =
Internal::AndroidConfig::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;
}

Expand Down

0 comments on commit b080087

Please sign in to comment.