Skip to content

Commit

Permalink
[android] Fixed getting product id and product name
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 committed Jul 1, 2022
1 parent 6c6dca3 commit 262567f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/platform/android/DeviceInstanceInfoProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,30 @@ 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 = 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 = 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 262567f

Please sign in to comment.