SF: return the active display from getInternalDisplayId
So clients that uses SurfaceComposerClient::getInternalDisplayId
such as screenrecord would get the current active display
Test: screenrecord
Bug: 193821864
Bug: 199336728
Change-Id: Ief856c736c78ab9ddca3c4ffccd8e374c050b0bd
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index d70e2e9..34b5cdc 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -619,12 +619,18 @@
std::vector<PhysicalDisplayId> SurfaceFlinger::getPhysicalDisplayIdsLocked() const {
std::vector<PhysicalDisplayId> displayIds;
displayIds.reserve(mPhysicalDisplayTokens.size());
+ const auto defaultDisplayId = [this]() REQUIRES(mStateLock) {
+ if (const auto display = getDefaultDisplayDeviceLocked()) {
+ return display->getPhysicalId();
+ }
- const auto internalDisplayId = getInternalDisplayIdLocked();
- displayIds.push_back(internalDisplayId);
+ // fallback to the internal display id if the active display is unknown
+ return getInternalDisplayIdLocked();
+ }();
+ displayIds.push_back(defaultDisplayId);
for (const auto& [id, token] : mPhysicalDisplayTokens) {
- if (id != internalDisplayId) {
+ if (id != defaultDisplayId) {
displayIds.push_back(id);
}
}