Remove getPrimaryPhysicalDisplayId
SurfaceFlinger marks the first connected display as primary, which is
not really useful, and surfaceflinger should not care about this.
The display manager can decide whether a display is primary when needed.
Bug: 240703637
Test: atest surfaceflinger_test
Change-Id: Ia5368a137c689989fcac7b355d1c6dddf3a8cf26
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index d365851..ad9130b 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1085,16 +1085,6 @@
return physicalDisplayIds;
}
-status_t SurfaceComposerClient::getPrimaryPhysicalDisplayId(PhysicalDisplayId* id) {
- int64_t displayId;
- binder::Status status =
- ComposerServiceAIDL::getComposerService()->getPrimaryPhysicalDisplayId(&displayId);
- if (status.isOk()) {
- *id = *DisplayId::fromValue<PhysicalDisplayId>(static_cast<uint64_t>(displayId));
- }
- return statusTFromBinderStatus(status);
-}
-
std::optional<PhysicalDisplayId> SurfaceComposerClient::getInternalDisplayId() {
ComposerServiceAIDL& instance = ComposerServiceAIDL::getInstance();
return instance.getInternalDisplayId();
diff --git a/libs/gui/aidl/android/gui/ISurfaceComposer.aidl b/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
index 730d758..3c220fc 100644
--- a/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
+++ b/libs/gui/aidl/android/gui/ISurfaceComposer.aidl
@@ -94,8 +94,6 @@
*/
long[] getPhysicalDisplayIds();
- long getPrimaryPhysicalDisplayId();
-
/**
* Get token for a physical display given its stable ID obtained via getPhysicalDisplayIds or
* a DisplayEventReceiver hotplug event.
diff --git a/libs/gui/fuzzer/libgui_fuzzer_utils.h b/libs/gui/fuzzer/libgui_fuzzer_utils.h
index 98e2ea3..d17ce4a 100644
--- a/libs/gui/fuzzer/libgui_fuzzer_utils.h
+++ b/libs/gui/fuzzer/libgui_fuzzer_utils.h
@@ -71,7 +71,6 @@
(override));
MOCK_METHOD(binder::Status, destroyDisplay, (const sp<IBinder>&), (override));
MOCK_METHOD(binder::Status, getPhysicalDisplayIds, (std::vector<int64_t>*), (override));
- MOCK_METHOD(binder::Status, getPrimaryPhysicalDisplayId, (int64_t*), (override));
MOCK_METHOD(binder::Status, getPhysicalDisplayToken, (int64_t, sp<IBinder>*), (override));
MOCK_METHOD(binder::Status, setPowerMode, (const sp<IBinder>&, int), (override));
MOCK_METHOD(binder::Status, getSupportedFrameTimestamps, (std::vector<FrameEvent>*),
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index d5f4414..27a44a4 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -349,7 +349,6 @@
//! Get stable IDs for connected physical displays
static std::vector<PhysicalDisplayId> getPhysicalDisplayIds();
- static status_t getPrimaryPhysicalDisplayId(PhysicalDisplayId*);
static std::optional<PhysicalDisplayId> getInternalDisplayId();
//! Get token for a physical display given its stable ID
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 391a0aa..71f2ad4 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -745,10 +745,6 @@
return binder::Status::ok();
}
- binder::Status getPrimaryPhysicalDisplayId(int64_t* /*outDisplayId*/) override {
- return binder::Status::ok();
- }
-
binder::Status getPhysicalDisplayToken(int64_t /*displayId*/,
sp<IBinder>* /*outDisplay*/) override {
return binder::Status::ok();
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 215f083..24aed17 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -607,12 +607,6 @@
return displayIds;
}
-status_t SurfaceFlinger::getPrimaryPhysicalDisplayId(PhysicalDisplayId* id) const {
- Mutex::Autolock lock(mStateLock);
- *id = getPrimaryDisplayIdLocked();
- return NO_ERROR;
-}
-
sp<IBinder> SurfaceFlinger::getPhysicalDisplayToken(PhysicalDisplayId displayId) const {
Mutex::Autolock lock(mStateLock);
return getPhysicalDisplayTokenLocked(displayId);
@@ -7230,20 +7224,6 @@
return binder::Status::ok();
}
-binder::Status SurfaceComposerAIDL::getPrimaryPhysicalDisplayId(int64_t* outDisplayId) {
- status_t status = checkAccessPermission();
- if (status != OK) {
- return binderStatusFromStatusT(status);
- }
-
- PhysicalDisplayId id;
- status = mFlinger->getPrimaryPhysicalDisplayId(&id);
- if (status == NO_ERROR) {
- *outDisplayId = id.value;
- }
- return binderStatusFromStatusT(status);
-}
-
binder::Status SurfaceComposerAIDL::getPhysicalDisplayToken(int64_t displayId,
sp<IBinder>* outDisplay) {
const auto id = DisplayId::fromValue<PhysicalDisplayId>(static_cast<uint64_t>(displayId));
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 46d941f..39277aa 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -524,7 +524,6 @@
Mutex::Autolock lock(mStateLock);
return getPhysicalDisplayIdsLocked();
}
- status_t getPrimaryPhysicalDisplayId(PhysicalDisplayId*) const EXCLUDES(mStateLock);
sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId) const;
status_t setTransactionState(const FrameTimelineInfo& frameTimelineInfo,
@@ -1420,7 +1419,6 @@
sp<IBinder>* outDisplay) override;
binder::Status destroyDisplay(const sp<IBinder>& display) override;
binder::Status getPhysicalDisplayIds(std::vector<int64_t>* outDisplayIds) override;
- binder::Status getPrimaryPhysicalDisplayId(int64_t* outDisplayId) override;
binder::Status getPhysicalDisplayToken(int64_t displayId, sp<IBinder>* outDisplay) override;
binder::Status setPowerMode(const sp<IBinder>& display, int mode) override;
binder::Status getSupportedFrameTimestamps(std::vector<FrameEvent>* outSupported) override;