summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ui/DisplayIdentification.cpp11
-rw-r--r--libs/ui/include/ui/DisplayIdentification.h1
-rw-r--r--libs/ui/tests/DisplayIdentification_test.cpp7
3 files changed, 16 insertions, 3 deletions
diff --git a/libs/ui/DisplayIdentification.cpp b/libs/ui/DisplayIdentification.cpp
index 5cdaa71627..8d6f74b605 100644
--- a/libs/ui/DisplayIdentification.cpp
+++ b/libs/ui/DisplayIdentification.cpp
@@ -249,7 +249,8 @@ std::optional<Edid> parseEdid(const DisplayIdentificationData& edid) {
view = view.subspan(kDescriptorOffset);
std::string_view displayName;
- std::string_view serialNumber;
+ std::string_view descriptorBlockSerialNumber;
+ std::optional<uint64_t> hashedDescriptorBlockSNOpt = std::nullopt;
std::string_view asciiText;
ui::Size preferredDTDPixelSize;
ui::Size preferredDTDPhysicalSize;
@@ -274,7 +275,10 @@ std::optional<Edid> parseEdid(const DisplayIdentificationData& edid) {
asciiText = parseEdidText(descriptor);
break;
case 0xff:
- serialNumber = parseEdidText(descriptor);
+ descriptorBlockSerialNumber = parseEdidText(descriptor);
+ hashedDescriptorBlockSNOpt = descriptorBlockSerialNumber.empty()
+ ? std::nullopt
+ : ftl::stable_hash(descriptorBlockSerialNumber);
break;
}
} else if (isDetailedTimingDescriptor(view)) {
@@ -315,7 +319,7 @@ std::optional<Edid> parseEdid(const DisplayIdentificationData& edid) {
if (modelString.empty()) {
ALOGW("Invalid EDID: falling back to serial number due to missing display name.");
- modelString = serialNumber;
+ modelString = descriptorBlockSerialNumber;
}
if (modelString.empty()) {
ALOGW("Invalid EDID: falling back to ASCII text due to missing serial number.");
@@ -369,6 +373,7 @@ std::optional<Edid> parseEdid(const DisplayIdentificationData& edid) {
.manufacturerId = manufacturerId,
.productId = productId,
.hashedBlockZeroSerialNumberOpt = hashedBlockZeroSNOpt,
+ .hashedDescriptorBlockSerialNumberOpt = hashedDescriptorBlockSNOpt,
.pnpId = *pnpId,
.modelHash = modelHash,
.displayName = displayName,
diff --git a/libs/ui/include/ui/DisplayIdentification.h b/libs/ui/include/ui/DisplayIdentification.h
index 85e5cee490..cf67d7bf93 100644
--- a/libs/ui/include/ui/DisplayIdentification.h
+++ b/libs/ui/include/ui/DisplayIdentification.h
@@ -70,6 +70,7 @@ struct Edid {
uint16_t manufacturerId;
uint16_t productId;
std::optional<uint64_t> hashedBlockZeroSerialNumberOpt;
+ std::optional<uint64_t> hashedDescriptorBlockSerialNumberOpt;
PnpId pnpId;
uint32_t modelHash;
std::string_view displayName;
diff --git a/libs/ui/tests/DisplayIdentification_test.cpp b/libs/ui/tests/DisplayIdentification_test.cpp
index fbbe719be8..d1699e79b6 100644
--- a/libs/ui/tests/DisplayIdentification_test.cpp
+++ b/libs/ui/tests/DisplayIdentification_test.cpp
@@ -193,6 +193,7 @@ TEST(DisplayIdentificationTest, parseEdid) {
EXPECT_EQ(12610, edid->productId);
EXPECT_TRUE(edid->hashedBlockZeroSerialNumberOpt.has_value());
EXPECT_EQ(ftl::stable_hash("12345678"), edid->hashedBlockZeroSerialNumberOpt.value());
+ EXPECT_FALSE(edid->hashedDescriptorBlockSerialNumberOpt.has_value());
EXPECT_EQ(21, edid->manufactureOrModelYear);
EXPECT_EQ(0, edid->manufactureWeek);
EXPECT_EQ(26, edid->physicalSizeInCm.width);
@@ -213,6 +214,8 @@ TEST(DisplayIdentificationTest, parseEdid) {
EXPECT_EQ(10348, edid->productId);
EXPECT_TRUE(edid->hashedBlockZeroSerialNumberOpt.has_value());
EXPECT_EQ(ftl::stable_hash("16843009"), edid->hashedBlockZeroSerialNumberOpt.value());
+ EXPECT_TRUE(edid->hashedDescriptorBlockSerialNumberOpt.has_value());
+ EXPECT_EQ(ftl::stable_hash("CN4202137Q"), edid->hashedDescriptorBlockSerialNumberOpt.value());
EXPECT_EQ(22, edid->manufactureOrModelYear);
EXPECT_EQ(2, edid->manufactureWeek);
EXPECT_EQ(64, edid->physicalSizeInCm.width);
@@ -233,6 +236,7 @@ TEST(DisplayIdentificationTest, parseEdid) {
EXPECT_EQ(2302, edid->productId);
EXPECT_TRUE(edid->hashedBlockZeroSerialNumberOpt.has_value());
EXPECT_EQ(ftl::stable_hash("87654321"), edid->hashedBlockZeroSerialNumberOpt.value());
+ EXPECT_FALSE(edid->hashedDescriptorBlockSerialNumberOpt.has_value());
EXPECT_EQ(21, edid->manufactureOrModelYear);
EXPECT_EQ(41, edid->manufactureWeek);
EXPECT_EQ(16, edid->physicalSizeInCm.width);
@@ -259,6 +263,7 @@ TEST(DisplayIdentificationTest, parseEdid) {
EXPECT_EQ(41622, edid->productId);
EXPECT_TRUE(edid->hashedBlockZeroSerialNumberOpt.has_value());
EXPECT_EQ(ftl::stable_hash("16843009"), edid->hashedBlockZeroSerialNumberOpt.value());
+ EXPECT_FALSE(edid->hashedDescriptorBlockSerialNumberOpt.has_value());
EXPECT_EQ(29, edid->manufactureOrModelYear);
EXPECT_EQ(0, edid->manufactureWeek);
EXPECT_EQ(128, edid->physicalSizeInCm.width);
@@ -284,6 +289,7 @@ TEST(DisplayIdentificationTest, parseEdid) {
EXPECT_EQ("Hisense", edid->displayName);
EXPECT_EQ(0, edid->productId);
EXPECT_FALSE(edid->hashedBlockZeroSerialNumberOpt.has_value());
+ EXPECT_FALSE(edid->hashedDescriptorBlockSerialNumberOpt.has_value());
EXPECT_EQ(29, edid->manufactureOrModelYear);
EXPECT_EQ(18, edid->manufactureWeek);
EXPECT_EQ(0, edid->physicalSizeInCm.width);
@@ -310,6 +316,7 @@ TEST(DisplayIdentificationTest, parseEdid) {
EXPECT_EQ(9373, edid->productId);
EXPECT_TRUE(edid->hashedBlockZeroSerialNumberOpt.has_value());
EXPECT_EQ(ftl::stable_hash("11223344"), edid->hashedBlockZeroSerialNumberOpt.value());
+ EXPECT_FALSE(edid->hashedDescriptorBlockSerialNumberOpt.has_value());
EXPECT_EQ(23, edid->manufactureOrModelYear);
EXPECT_EQ(0xff, edid->manufactureWeek);
EXPECT_EQ(52, edid->physicalSizeInCm.width);