SF: Fix two display identification bugs
1) getDisplayIdentificationData() was called on hotplug disconnect and
not just on hotplug connect. The DisplayTransactionTest had a
warning, and I've fixed the issue and made the test explicitly expect
zero calls so it will fail instead.
2) One of the tests in DisplayIdentificationTest had a use after free,
detected by enabling the address sanitizer on the unit test executable.
Bug: None
Test: Test passes with no errors or warnings
Change-Id: Iceda0d499d692991adfcbf5c772da736bd4a843f
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 2c94a0e..d963ab6 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -160,11 +160,13 @@
std::optional<DisplayId> displayId;
- uint8_t port;
- DisplayIdentificationData data;
- if (getDisplayIdentificationData(hwcDisplayId, &port, &data)) {
- displayId = generateDisplayId(port, data);
- ALOGE_IF(!displayId, "Failed to generate stable ID for display %" PRIu64, hwcDisplayId);
+ if (connection == HWC2::Connection::Connected) {
+ uint8_t port;
+ DisplayIdentificationData data;
+ if (getDisplayIdentificationData(hwcDisplayId, &port, &data)) {
+ displayId = generateDisplayId(port, data);
+ ALOGE_IF(!displayId, "Failed to generate stable ID for display %" PRIu64, hwcDisplayId);
+ }
}
// Disconnect is handled through HWComposer::disconnectDisplay via