[users] Read product from the device tree on DT platforms
Non-DMI platforms may have a device tree instead (e.g. many embedded devices, Apple Silicon Macs). If we find a model string in the DT, use that as a fallback when DMI is not available. Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
parent
f53b064296
commit
17e1027ea2
@ -339,15 +339,30 @@ guessProductName()
|
||||
if ( !tried )
|
||||
{
|
||||
QFile dmiFile( QStringLiteral( "/sys/devices/virtual/dmi/id/product_name" ) );
|
||||
QFile modelFile( QStringLiteral( "/proc/device-tree/model" ) );
|
||||
|
||||
if ( dmiFile.exists() && dmiFile.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
dmiProduct = cleanupForHostname( QString::fromLocal8Bit( dmiFile.readAll().simplified().data() ) );
|
||||
if ( !dmiProduct.isEmpty() )
|
||||
{
|
||||
tried = true;
|
||||
return dmiProduct;
|
||||
}
|
||||
}
|
||||
if ( dmiProduct.isEmpty() )
|
||||
|
||||
if ( modelFile.exists() && modelFile.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
dmiProduct = QStringLiteral( "pc" );
|
||||
dmiProduct
|
||||
= cleanupForHostname( QString::fromLocal8Bit( modelFile.readAll().chopped( 1 ).simplified().data() ) );
|
||||
if ( !dmiProduct.isEmpty() )
|
||||
{
|
||||
tried = true;
|
||||
return dmiProduct;
|
||||
}
|
||||
}
|
||||
|
||||
dmiProduct = QStringLiteral( "pc" );
|
||||
tried = true;
|
||||
}
|
||||
return dmiProduct;
|
||||
|
Loading…
Reference in New Issue
Block a user