summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Huihong Luo <huisinro@google.com> 2022-08-15 20:38:10 -0700
committer Huihong Luo <huisinro@google.com> 2022-09-26 21:07:46 +0000
commit31b5ac21e84a0fde6483dc8487af664582dcc5ee (patch)
tree79150a8c2b31fbfbc7fa48ffb313833073fb6a1c
parent5a0d7d494aaf7a6bbf280e41564f2e79b2860cb6 (diff)
Remove internal display related methods
SurfaceFlinger and SurfaceComposerClient simply return the first connected display as internal display, which is not really correct. In particular,in the case of dual display for foldable devices, both displays are marked as Internal determined by calling into HWC2 IComposerClient::getDisplayConnectionType(). Therefore, the concept of internal/external/primary displays is removed from SurfaceFlinger, and the display manager is the better place to handle the logics. flatland is modified to take an extra argument to specify display id, and error occurs if no display is specified in case of multi-display. Bug: 241285477 Bug: 242763577 Bug: 74619554 Test: atest libgui_test libsurfaceflinger_unittest SurfaceFlinger_test Change-Id: Ib6c7e502ef3269c2c60a4e5388e5ac75275f87ed
-rw-r--r--cmds/flatland/GLHelper.cpp13
-rw-r--r--cmds/flatland/GLHelper.h4
-rw-r--r--cmds/flatland/Main.cpp64
-rw-r--r--libs/gui/Surface.cpp37
-rw-r--r--libs/gui/SurfaceComposerClient.cpp10
-rw-r--r--libs/gui/include/gui/Surface.h4
-rw-r--r--libs/gui/include/gui/SurfaceComposerClient.h2
-rw-r--r--libs/gui/include/private/gui/ComposerServiceAIDL.h22
-rw-r--r--libs/gui/tests/BLASTBufferQueue_test.cpp5
-rw-r--r--libs/gui/tests/DisplayedContentSampling_test.cpp5
-rw-r--r--libs/gui/tests/EndToEndNativeInputTest.cpp6
-rw-r--r--libs/gui/tests/Surface_test.cpp5
-rw-r--r--libs/nativedisplay/ADisplay.cpp9
-rw-r--r--libs/nativewindow/include/system/window.h35
-rw-r--r--libs/renderengine/benchmark/RenderEngineBench.cpp28
-rw-r--r--opengl/tests/lib/WindowSurface.cpp9
-rw-r--r--services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp2
-rw-r--r--services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h12
-rw-r--r--services/surfaceflinger/tests/BootDisplayMode_test.cpp9
-rw-r--r--services/surfaceflinger/tests/Credentials_test.cpp33
-rw-r--r--services/surfaceflinger/tests/DisplayConfigs_test.cpp6
-rw-r--r--services/surfaceflinger/tests/EffectLayer_test.cpp8
-rw-r--r--services/surfaceflinger/tests/IPC_test.cpp4
-rw-r--r--services/surfaceflinger/tests/LayerBorder_test.cpp4
-rw-r--r--services/surfaceflinger/tests/LayerTransactionTest.h4
-rw-r--r--services/surfaceflinger/tests/LayerUpdate_test.cpp4
-rw-r--r--services/surfaceflinger/tests/MirrorLayer_test.cpp13
-rw-r--r--services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp4
-rw-r--r--services/surfaceflinger/tests/RelativeZ_test.cpp4
-rw-r--r--services/surfaceflinger/tests/ScreenCapture_test.cpp4
-rw-r--r--services/surfaceflinger/tests/SurfaceInterceptor_test.cpp4
-rw-r--r--services/surfaceflinger/tests/TransactionTestHarnesses.h5
-rw-r--r--services/surfaceflinger/tests/utils/ScreenshotUtils.h6
33 files changed, 244 insertions, 140 deletions
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp
index 01f7d30a42..c163095c50 100644
--- a/cmds/flatland/GLHelper.cpp
+++ b/cmds/flatland/GLHelper.cpp
@@ -35,9 +35,12 @@ GLHelper::GLHelper() :
GLHelper::~GLHelper() {
}
-bool GLHelper::setUp(const ShaderDesc* shaderDescs, size_t numShaders) {
+bool GLHelper::setUp(const sp<IBinder>& displayToken, const ShaderDesc* shaderDescs,
+ size_t numShaders) {
bool result;
+ mDisplayToken = displayToken;
+
mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (mDisplay == EGL_NO_DISPLAY) {
fprintf(stderr, "eglGetDisplay error: %#x\n", eglGetError());
@@ -221,14 +224,8 @@ bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
}
bool GLHelper::computeWindowScale(uint32_t w, uint32_t h, float* scale) {
- const sp<IBinder> dpy = mSurfaceComposerClient->getInternalDisplayToken();
- if (dpy == nullptr) {
- fprintf(stderr, "SurfaceComposer::getInternalDisplayToken failed.\n");
- return false;
- }
-
ui::DisplayMode mode;
- status_t err = mSurfaceComposerClient->getActiveDisplayMode(dpy, &mode);
+ status_t err = mSurfaceComposerClient->getActiveDisplayMode(mDisplayToken, &mode);
if (err != NO_ERROR) {
fprintf(stderr, "SurfaceComposer::getActiveDisplayMode failed: %#x\n", err);
return false;
diff --git a/cmds/flatland/GLHelper.h b/cmds/flatland/GLHelper.h
index d09463a9b8..5194f5084f 100644
--- a/cmds/flatland/GLHelper.h
+++ b/cmds/flatland/GLHelper.h
@@ -44,7 +44,7 @@ public:
~GLHelper();
- bool setUp(const ShaderDesc* shaderDescs, size_t numShaders);
+ bool setUp(const sp<IBinder>& displayToken, const ShaderDesc* shaderDescs, size_t numShaders);
void tearDown();
@@ -87,6 +87,8 @@ private:
size_t mNumShaders;
GLuint mDitherTexture;
+
+ sp<IBinder> mDisplayToken;
};
} // namespace android
diff --git a/cmds/flatland/Main.cpp b/cmds/flatland/Main.cpp
index 7ceb397032..6d14d568a4 100644
--- a/cmds/flatland/Main.cpp
+++ b/cmds/flatland/Main.cpp
@@ -20,6 +20,7 @@
#include <gui/SurfaceControl.h>
#include <gui/GLConsumer.h>
#include <gui/Surface.h>
+#include <gui/SurfaceComposerClient.h>
#include <ui/Fence.h>
#include <utils/Trace.h>
@@ -34,9 +35,10 @@
using namespace ::android;
-static uint32_t g_SleepBetweenSamplesMs = 0;
-static bool g_PresentToWindow = false;
-static size_t g_BenchmarkNameLen = 0;
+static uint32_t g_SleepBetweenSamplesMs = 0;
+static bool g_PresentToWindow = false;
+static size_t g_BenchmarkNameLen = 0;
+static sp<IBinder> g_DisplayToken = nullptr;
struct BenchmarkDesc {
// The name of the test.
@@ -393,7 +395,7 @@ public:
uint32_t h = mDesc.runHeights[mInstance];
mGLHelper = new GLHelper();
- result = mGLHelper->setUp(shaders, NELEMS(shaders));
+ result = mGLHelper->setUp(g_DisplayToken, shaders, NELEMS(shaders));
if (!result) {
return false;
}
@@ -718,13 +720,17 @@ static size_t maxBenchmarkNameLen() {
}
// Print the command usage help to stderr.
-static void showHelp(const char *cmd) {
- fprintf(stderr, "usage: %s [options]\n", cmd);
- fprintf(stderr, "options include:\n"
- " -s N sleep for N ms between samples\n"
- " -d display the test frame to a window\n"
- " --help print this helpful message and exit\n"
- );
+static void showHelp(const char* cmd) {
+ fprintf(stderr, "usage: %s [options]\n", cmd);
+ fprintf(
+ stderr,
+ "options include:\n"
+ " -s N sleep for N ms between samples\n"
+ " -d display the test frame to a window\n"
+ " -i display-id specify a display ID to use for multi-display device\n"
+ " see \"dumpsys SurfaceFlinger --display-id\" for valid "
+ "display IDs\n"
+ " --help print this helpful message and exit\n");
}
int main(int argc, char** argv) {
@@ -733,6 +739,14 @@ int main(int argc, char** argv) {
exit(0);
}
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ if (ids.empty()) {
+ fprintf(stderr, "Failed to get ID for any displays.\n");
+ exit(3);
+ }
+
+ std::optional<PhysicalDisplayId> displayId;
+
for (;;) {
int ret;
int option_index = 0;
@@ -741,7 +755,7 @@ int main(int argc, char** argv) {
{ 0, 0, 0, 0 }
};
- ret = getopt_long(argc, argv, "ds:",
+ ret = getopt_long(argc, argv, "ds:i:",
long_options, &option_index);
if (ret < 0) {
@@ -757,6 +771,14 @@ int main(int argc, char** argv) {
g_SleepBetweenSamplesMs = atoi(optarg);
break;
+ case 'i':
+ displayId = DisplayId::fromValue<PhysicalDisplayId>(atoll(optarg));
+ if (!displayId) {
+ fprintf(stderr, "Invalid display ID: %s.\n", optarg);
+ exit(4);
+ }
+ break;
+
case 0:
if (strcmp(long_options[option_index].name, "help")) {
showHelp(argv[0]);
@@ -770,6 +792,22 @@ int main(int argc, char** argv) {
}
}
+ if (!displayId) { // no display id is specified
+ if (ids.size() == 1) {
+ displayId = ids.front();
+ } else {
+ fprintf(stderr, "Please specify a display ID for multi-display device.\n");
+ showHelp(argv[0]);
+ exit(5);
+ }
+ }
+
+ g_DisplayToken = SurfaceComposerClient::getPhysicalDisplayToken(*displayId);
+ if (g_DisplayToken == nullptr) {
+ fprintf(stderr, "SurfaceComposer::getPhysicalDisplayToken failed.\n");
+ exit(6);
+ }
+
g_BenchmarkNameLen = maxBenchmarkNameLen();
printf(" cmdline:");
@@ -782,4 +820,6 @@ int main(int argc, char** argv) {
fprintf(stderr, "exiting due to error.\n");
return 1;
}
+
+ return 0;
}
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 4b4d46a92e..c4fb1cf408 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -56,6 +56,12 @@ using ui::Dataspace;
namespace {
+enum {
+ // moved from nativewindow/include/system/window.h, to be removed
+ NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT = 28,
+ NATIVE_WINDOW_GET_HDR_SUPPORT = 29,
+};
+
bool isInterceptorRegistrationOp(int op) {
return op == NATIVE_WINDOW_SET_CANCEL_INTERCEPTOR ||
op == NATIVE_WINDOW_SET_DEQUEUE_INTERCEPTOR ||
@@ -348,34 +354,25 @@ status_t Surface::getFrameTimestamps(uint64_t frameNumber,
return NO_ERROR;
}
+// Deprecated(b/242763577): to be removed, this method should not be used
+// The reason this method still exists here is to support compiled vndk
+// Surface support should not be tied to the display
+// Return true since most displays should have this support
status_t Surface::getWideColorSupport(bool* supported) {
ATRACE_CALL();
- const sp<IBinder> display = ComposerServiceAIDL::getInstance().getInternalDisplayToken();
- if (display == nullptr) {
- return NAME_NOT_FOUND;
- }
-
- *supported = false;
- binder::Status status = composerServiceAIDL()->isWideColorDisplay(display, supported);
- return statusTFromBinderStatus(status);
+ *supported = true;
+ return NO_ERROR;
}
+// Deprecated(b/242763577): to be removed, this method should not be used
+// The reason this method still exists here is to support compiled vndk
+// Surface support should not be tied to the display
+// Return true since most displays should have this support
status_t Surface::getHdrSupport(bool* supported) {
ATRACE_CALL();
- const sp<IBinder> display = ComposerServiceAIDL::getInstance().getInternalDisplayToken();
- if (display == nullptr) {
- return NAME_NOT_FOUND;
- }
-
- gui::DynamicDisplayInfo info;
- if (binder::Status status = composerServiceAIDL()->getDynamicDisplayInfo(display, &info);
- !status.isOk()) {
- return statusTFromBinderStatus(status);
- }
-
- *supported = !info.hdrCapabilities.supportedHdrTypes.empty();
+ *supported = true;
return NO_ERROR;
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 751721e2a8..18366ab083 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1091,11 +1091,6 @@ std::vector<PhysicalDisplayId> SurfaceComposerClient::getPhysicalDisplayIds() {
return physicalDisplayIds;
}
-std::optional<PhysicalDisplayId> SurfaceComposerClient::getInternalDisplayId() {
- ComposerServiceAIDL& instance = ComposerServiceAIDL::getInstance();
- return instance.getInternalDisplayId();
-}
-
sp<IBinder> SurfaceComposerClient::getPhysicalDisplayToken(PhysicalDisplayId displayId) {
sp<IBinder> display = nullptr;
binder::Status status =
@@ -1104,11 +1099,6 @@ sp<IBinder> SurfaceComposerClient::getPhysicalDisplayToken(PhysicalDisplayId dis
return status.isOk() ? display : nullptr;
}
-sp<IBinder> SurfaceComposerClient::getInternalDisplayToken() {
- ComposerServiceAIDL& instance = ComposerServiceAIDL::getInstance();
- return instance.getInternalDisplayToken();
-}
-
void SurfaceComposerClient::Transaction::setAnimationTransaction() {
mAnimation = true;
}
diff --git a/libs/gui/include/gui/Surface.h b/libs/gui/include/gui/Surface.h
index 634acb68b9..1f19f4e1da 100644
--- a/libs/gui/include/gui/Surface.h
+++ b/libs/gui/include/gui/Surface.h
@@ -187,8 +187,8 @@ public:
nsecs_t* outDisplayPresentTime, nsecs_t* outDequeueReadyTime,
nsecs_t* outReleaseTime);
- status_t getWideColorSupport(bool* supported);
- status_t getHdrSupport(bool* supported);
+ status_t getWideColorSupport(bool* supported) __attribute__((__deprecated__));
+ status_t getHdrSupport(bool* supported) __attribute__((__deprecated__));
status_t getUniqueId(uint64_t* outId) const;
status_t getConsumerUsage(uint64_t* outUsage) const;
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 8c47ebc3b8..a688a52495 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -351,11 +351,9 @@ public:
//! Get stable IDs for connected physical displays
static std::vector<PhysicalDisplayId> getPhysicalDisplayIds();
- static std::optional<PhysicalDisplayId> getInternalDisplayId();
//! Get token for a physical display given its stable ID
static sp<IBinder> getPhysicalDisplayToken(PhysicalDisplayId displayId);
- static sp<IBinder> getInternalDisplayToken();
static status_t enableVSyncInjections(bool enable);
diff --git a/libs/gui/include/private/gui/ComposerServiceAIDL.h b/libs/gui/include/private/gui/ComposerServiceAIDL.h
index 296358329b..6352a5851c 100644
--- a/libs/gui/include/private/gui/ComposerServiceAIDL.h
+++ b/libs/gui/include/private/gui/ComposerServiceAIDL.h
@@ -51,28 +51,6 @@ public:
// Get a connection to the Composer Service. This will block until
// a connection is established. Returns null if permission is denied.
static sp<gui::ISurfaceComposer> getComposerService();
-
- // the following two methods are moved from ISurfaceComposer.h
- // TODO(b/74619554): Remove this stopgap once the framework is display-agnostic.
- std::optional<PhysicalDisplayId> getInternalDisplayId() const {
- std::vector<int64_t> displayIds;
- binder::Status status = mComposerService->getPhysicalDisplayIds(&displayIds);
- return (!status.isOk() || displayIds.empty())
- ? std::nullopt
- : DisplayId::fromValue<PhysicalDisplayId>(
- static_cast<uint64_t>(displayIds.front()));
- }
-
- // TODO(b/74619554): Remove this stopgap once the framework is display-agnostic.
- sp<IBinder> getInternalDisplayToken() const {
- const auto displayId = getInternalDisplayId();
- if (!displayId) return nullptr;
- sp<IBinder> display;
- binder::Status status =
- mComposerService->getPhysicalDisplayToken(static_cast<int64_t>(displayId->value),
- &display);
- return status.isOk() ? display : nullptr;
- }
};
// ---------------------------------------------------------------------------
diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp
index c4c2fa5b85..cf2593dc81 100644
--- a/libs/gui/tests/BLASTBufferQueue_test.cpp
+++ b/libs/gui/tests/BLASTBufferQueue_test.cpp
@@ -188,7 +188,10 @@ protected:
void SetUp() {
mComposer = ComposerService::getComposerService();
mClient = new SurfaceComposerClient();
- mDisplayToken = mClient->getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ // display 0 is picked as this test is not much display depedent
+ mDisplayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_NE(nullptr, mDisplayToken.get());
Transaction t;
t.setDisplayLayerStack(mDisplayToken, ui::DEFAULT_LAYER_STACK);
diff --git a/libs/gui/tests/DisplayedContentSampling_test.cpp b/libs/gui/tests/DisplayedContentSampling_test.cpp
index b647aaba8f..0a2750a4dd 100644
--- a/libs/gui/tests/DisplayedContentSampling_test.cpp
+++ b/libs/gui/tests/DisplayedContentSampling_test.cpp
@@ -32,7 +32,10 @@ protected:
void SetUp() {
mComposerClient = new SurfaceComposerClient;
ASSERT_EQ(OK, mComposerClient->initCheck());
- mDisplayToken = mComposerClient->getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ // display 0 is picked for now, can extend to support all displays if needed
+ mDisplayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_TRUE(mDisplayToken);
}
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index 2637f59b5e..3344e0b690 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -360,8 +360,10 @@ public:
void SetUp() {
mComposerClient = new SurfaceComposerClient;
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
-
- const auto display = mComposerClient->getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ // display 0 is picked for now, can extend to support all displays if needed
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_NE(display, nullptr);
ui::DisplayMode mode;
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index b9358e7717..c078378118 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -263,7 +263,10 @@ TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersDontSucceed) {
sp<ANativeWindow> anw(mSurface);
// Verify the screenshot works with no protected buffers.
- const sp<IBinder> display = ComposerServiceAIDL::getInstance().getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ // display 0 is picked for now, can extend to support all displays if needed
+ const sp<IBinder> display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(display == nullptr);
DisplayCaptureArgs captureArgs;
diff --git a/libs/nativedisplay/ADisplay.cpp b/libs/nativedisplay/ADisplay.cpp
index 76b85d6002..60328e48a6 100644
--- a/libs/nativedisplay/ADisplay.cpp
+++ b/libs/nativedisplay/ADisplay.cpp
@@ -136,6 +136,7 @@ int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays) {
}
std::vector<DisplayConfigImpl> modesPerDisplay[size];
+ ui::DisplayConnectionType displayConnectionTypes[size];
int numModes = 0;
for (int i = 0; i < size; ++i) {
const sp<IBinder> token = SurfaceComposerClient::getPhysicalDisplayToken(ids[i]);
@@ -145,6 +146,7 @@ int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays) {
status != OK) {
return status;
}
+ displayConnectionTypes[i] = staticInfo.connectionType;
ui::DynamicDisplayInfo dynamicInfo;
if (const status_t status =
@@ -168,8 +170,6 @@ int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays) {
}
}
- const std::optional<PhysicalDisplayId> internalId =
- SurfaceComposerClient::getInternalDisplayId();
ui::Dataspace defaultDataspace;
ui::PixelFormat defaultPixelFormat;
ui::Dataspace wcgDataspace;
@@ -201,8 +201,9 @@ int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays) {
for (size_t i = 0; i < size; ++i) {
const PhysicalDisplayId id = ids[i];
- const ADisplayType type = (internalId == id) ? ADisplayType::DISPLAY_TYPE_INTERNAL
- : ADisplayType::DISPLAY_TYPE_EXTERNAL;
+ const ADisplayType type = (displayConnectionTypes[i] == ui::DisplayConnectionType::Internal)
+ ? ADisplayType::DISPLAY_TYPE_INTERNAL
+ : ADisplayType::DISPLAY_TYPE_EXTERNAL;
const std::vector<DisplayConfigImpl>& configs = modesPerDisplay[i];
memcpy(configData, configs.data(), sizeof(DisplayConfigImpl) * configs.size());
diff --git a/libs/nativewindow/include/system/window.h b/libs/nativewindow/include/system/window.h
index 79f49e1786..c7745e6672 100644
--- a/libs/nativewindow/include/system/window.h
+++ b/libs/nativewindow/include/system/window.h
@@ -235,8 +235,8 @@ enum {
NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS = 25,
NATIVE_WINDOW_GET_COMPOSITOR_TIMING = 26,
NATIVE_WINDOW_GET_FRAME_TIMESTAMPS = 27,
- NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT = 28,
- NATIVE_WINDOW_GET_HDR_SUPPORT = 29,
+ /* 28, removed: NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT */
+ /* 29, removed: NATIVE_WINDOW_GET_HDR_SUPPORT */
NATIVE_WINDOW_SET_USAGE64 = ANATIVEWINDOW_PERFORM_SET_USAGE64,
NATIVE_WINDOW_GET_CONSUMER_USAGE64 = 31,
NATIVE_WINDOW_SET_BUFFERS_SMPTE2086_METADATA = 32,
@@ -988,15 +988,34 @@ static inline int native_window_get_frame_timestamps(
outDequeueReadyTime, outReleaseTime);
}
-static inline int native_window_get_wide_color_support(
- struct ANativeWindow* window, bool* outSupport) {
- return window->perform(window, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT,
- outSupport);
+/* deprecated. Always returns 0 and outSupport holds true. Don't call. */
+static inline int native_window_get_wide_color_support (
+ struct ANativeWindow* window __UNUSED, bool* outSupport) __deprecated;
+
+/*
+ Deprecated(b/242763577): to be removed, this method should not be used
+ Surface support should not be tied to the display
+ Return true since most displays should have this support
+*/
+static inline int native_window_get_wide_color_support (
+ struct ANativeWindow* window __UNUSED, bool* outSupport) {
+ *outSupport = true;
+ return 0;
}
-static inline int native_window_get_hdr_support(struct ANativeWindow* window,
+/* deprecated. Always returns 0 and outSupport holds true. Don't call. */
+static inline int native_window_get_hdr_support(struct ANativeWindow* window __UNUSED,
+ bool* outSupport) __deprecated;
+
+/*
+ Deprecated(b/242763577): to be removed, this method should not be used
+ Surface support should not be tied to the display
+ Return true since most displays should have this support
+*/
+static inline int native_window_get_hdr_support(struct ANativeWindow* window __UNUSED,
bool* outSupport) {
- return window->perform(window, NATIVE_WINDOW_GET_HDR_SUPPORT, outSupport);
+ *outSupport = true;
+ return 0;
}
static inline int native_window_get_consumer_usage(struct ANativeWindow* window,
diff --git a/libs/renderengine/benchmark/RenderEngineBench.cpp b/libs/renderengine/benchmark/RenderEngineBench.cpp
index 739f3fa327..d44eb463f7 100644
--- a/libs/renderengine/benchmark/RenderEngineBench.cpp
+++ b/libs/renderengine/benchmark/RenderEngineBench.cpp
@@ -80,16 +80,26 @@ std::pair<uint32_t, uint32_t> getDisplaySize() {
std::once_flag once;
std::call_once(once, []() {
auto surfaceComposerClient = SurfaceComposerClient::getDefault();
- auto displayToken = surfaceComposerClient->getInternalDisplayToken();
- ui::DisplayMode displayMode;
- if (surfaceComposerClient->getActiveDisplayMode(displayToken, &displayMode) < 0) {
- LOG_ALWAYS_FATAL("Failed to get active display mode!");
+ auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ LOG_ALWAYS_FATAL_IF(ids.empty(), "Failed to get any display!");
+ ui::Size resolution = ui::kEmptySize;
+ // find the largest display resolution
+ for (auto id : ids) {
+ auto displayToken = surfaceComposerClient->getPhysicalDisplayToken(id);
+ ui::DisplayMode displayMode;
+ if (surfaceComposerClient->getActiveDisplayMode(displayToken, &displayMode) < 0) {
+ LOG_ALWAYS_FATAL("Failed to get active display mode!");
+ }
+ auto tw = displayMode.resolution.width;
+ auto th = displayMode.resolution.height;
+ LOG_ALWAYS_FATAL_IF(tw <= 0 || th <= 0, "Invalid display size!");
+ if (resolution.width * resolution.height <
+ displayMode.resolution.width * displayMode.resolution.height) {
+ resolution = displayMode.resolution;
+ }
}
- auto w = displayMode.resolution.width;
- auto h = displayMode.resolution.height;
- LOG_ALWAYS_FATAL_IF(w <= 0 || h <= 0, "Invalid display size!");
- width = static_cast<uint32_t>(w);
- height = static_cast<uint32_t>(h);
+ width = static_cast<uint32_t>(resolution.width);
+ height = static_cast<uint32_t>(resolution.height);
});
return std::pair<uint32_t, uint32_t>(width, height);
}
diff --git a/opengl/tests/lib/WindowSurface.cpp b/opengl/tests/lib/WindowSurface.cpp
index fd4522e757..e94b565f11 100644
--- a/opengl/tests/lib/WindowSurface.cpp
+++ b/opengl/tests/lib/WindowSurface.cpp
@@ -36,7 +36,14 @@ WindowSurface::WindowSurface() {
return;
}
- const auto displayToken = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ if (ids.empty()) {
+ fprintf(stderr, "Failed to get ID for any displays.\n");
+ return;
+ }
+
+ // display 0 is picked for now, can extend to support all displays if needed
+ const auto displayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
if (displayToken == nullptr) {
fprintf(stderr, "ERROR: no display\n");
return;
diff --git a/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp b/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp
index fae916542a..f8fc6f5a40 100644
--- a/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp
+++ b/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp
@@ -116,7 +116,7 @@ static constexpr hal::HWConfigId kActiveConfig = 0;
class DisplayHardwareFuzzer {
public:
DisplayHardwareFuzzer(const uint8_t* data, size_t size) : mFdp(data, size) {
- mPhysicalDisplayId = SurfaceComposerClient::getInternalDisplayId().value_or(
+ mPhysicalDisplayId = TestableSurfaceFlinger::getFirstDisplayId().value_or(
PhysicalDisplayId::fromPort(mFdp.ConsumeIntegral<uint8_t>()));
};
void process();
diff --git a/services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h b/services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h
index 22976186f2..72148f4341 100644
--- a/services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h
+++ b/services/surfaceflinger/fuzzer/surfaceflinger_fuzzers_utils.h
@@ -529,6 +529,13 @@ public:
mFlinger->setVsyncConfig(vsyncConfig, fdp->ConsumeIntegral<nsecs_t>());
}
+ // TODO(b/248317436): extend to cover all displays for multi-display devices
+ static std::optional<PhysicalDisplayId> getFirstDisplayId() {
+ std::vector<PhysicalDisplayId> ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ if (ids.empty()) return {};
+ return ids.front();
+ }
+
sp<IBinder> fuzzBoot(FuzzedDataProvider *fdp) {
mFlinger->callingThreadHasUnscopedSurfaceFlingerAccess(fdp->ConsumeBool());
const sp<Client> client = sp<Client>::make(mFlinger);
@@ -540,9 +547,8 @@ public:
ui::PixelFormat pixelFormat{};
mFlinger->getHwComposer().allocateVirtualDisplay(halVirtualDisplayId, uiSize, &pixelFormat);
- PhysicalDisplayId physicalDisplayId =
- SurfaceComposerClient::getInternalDisplayId().value_or(
- PhysicalDisplayId::fromPort(fdp->ConsumeIntegral<uint8_t>()));
+ PhysicalDisplayId physicalDisplayId = getFirstDisplayId().value_or(
+ PhysicalDisplayId::fromPort(fdp->ConsumeIntegral<uint8_t>()));
mFlinger->getHwComposer().allocatePhysicalDisplay(kHwDisplayId, physicalDisplayId);
sp<IBinder> display =
diff --git a/services/surfaceflinger/tests/BootDisplayMode_test.cpp b/services/surfaceflinger/tests/BootDisplayMode_test.cpp
index 432e227cae..f2874ae0e1 100644
--- a/services/surfaceflinger/tests/BootDisplayMode_test.cpp
+++ b/services/surfaceflinger/tests/BootDisplayMode_test.cpp
@@ -30,7 +30,10 @@ using gui::aidl_utils::statusTFromBinderStatus;
TEST(BootDisplayModeTest, setBootDisplayMode) {
sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
- auto displayToken = SurfaceComposerClient::getInternalDisplayToken();
+
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ auto displayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
bool bootModeSupport = false;
binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport);
ASSERT_NO_FATAL_FAILURE(statusTFromBinderStatus(status));
@@ -42,7 +45,9 @@ TEST(BootDisplayModeTest, setBootDisplayMode) {
TEST(BootDisplayModeTest, clearBootDisplayMode) {
sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
- auto displayToken = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ auto displayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
bool bootModeSupport = false;
binder::Status status = sf->getBootDisplayModeSupport(&bootModeSupport);
ASSERT_NO_FATAL_FAILURE(statusTFromBinderStatus(status));
diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp
index 775de4a8fe..4f04934d34 100644
--- a/services/surfaceflinger/tests/Credentials_test.cpp
+++ b/services/surfaceflinger/tests/Credentials_test.cpp
@@ -74,8 +74,17 @@ protected:
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
}
+ static sp<IBinder> getFirstDisplayToken() {
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ if (ids.empty()) {
+ return nullptr;
+ }
+
+ return SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
+ }
+
void setupBackgroundSurface() {
- mDisplay = SurfaceComposerClient::getInternalDisplayToken();
+ mDisplay = getFirstDisplayToken();
ASSERT_FALSE(mDisplay == nullptr);
ui::DisplayMode mode;
@@ -158,9 +167,7 @@ TEST_F(CredentialsTest, ClientInitTest) {
}
TEST_F(CredentialsTest, GetBuiltInDisplayAccessTest) {
- std::function<bool()> condition = [] {
- return SurfaceComposerClient::getInternalDisplayToken() != nullptr;
- };
+ std::function<bool()> condition = [] { return getFirstDisplayToken() != nullptr; };
// Anyone can access display information.
ASSERT_NO_FATAL_FAILURE(checkWithPrivileges(condition, true, true));
}
@@ -169,7 +176,7 @@ TEST_F(CredentialsTest, AllowedGetterMethodsTest) {
// The following methods are tested with a UID that is not root, graphics,
// or system, to show that anyone can access them.
UIDFaker f(AID_BIN);
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
ASSERT_TRUE(display != nullptr);
ui::DisplayMode mode;
@@ -181,7 +188,7 @@ TEST_F(CredentialsTest, AllowedGetterMethodsTest) {
}
TEST_F(CredentialsTest, GetDynamicDisplayInfoTest) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
std::function<status_t()> condition = [=]() {
ui::DynamicDisplayInfo info;
return SurfaceComposerClient::getDynamicDisplayInfo(display, &info);
@@ -190,7 +197,7 @@ TEST_F(CredentialsTest, GetDynamicDisplayInfoTest) {
}
TEST_F(CredentialsTest, GetDisplayNativePrimariesTest) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
std::function<status_t()> condition = [=]() {
ui::DisplayPrimaries primaries;
return SurfaceComposerClient::getDisplayNativePrimaries(display, primaries);
@@ -199,7 +206,7 @@ TEST_F(CredentialsTest, GetDisplayNativePrimariesTest) {
}
TEST_F(CredentialsTest, SetDesiredDisplayConfigsTest) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
ui::DisplayModeId defaultMode;
bool allowGroupSwitching;
float primaryFpsMin;
@@ -222,7 +229,7 @@ TEST_F(CredentialsTest, SetDesiredDisplayConfigsTest) {
}
TEST_F(CredentialsTest, SetActiveColorModeTest) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
std::function<status_t()> condition = [=]() {
return SurfaceComposerClient::setActiveColorMode(display, ui::ColorMode::NATIVE);
};
@@ -274,7 +281,7 @@ TEST_F(CredentialsTest, CreateDisplayTest) {
}
TEST_F(CredentialsTest, CaptureTest) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
std::function<status_t()> condition = [=]() {
sp<GraphicBuffer> outBuffer;
DisplayCaptureArgs captureArgs;
@@ -333,7 +340,7 @@ TEST_F(CredentialsTest, GetLayerDebugInfo) {
}
TEST_F(CredentialsTest, IsWideColorDisplayBasicCorrectness) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
ASSERT_FALSE(display == nullptr);
bool result = false;
status_t error = SurfaceComposerClient::isWideColorDisplay(display, &result);
@@ -357,7 +364,7 @@ TEST_F(CredentialsTest, IsWideColorDisplayBasicCorrectness) {
}
TEST_F(CredentialsTest, IsWideColorDisplayWithPrivileges) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
ASSERT_FALSE(display == nullptr);
std::function<status_t()> condition = [=]() {
bool result = false;
@@ -367,7 +374,7 @@ TEST_F(CredentialsTest, IsWideColorDisplayWithPrivileges) {
}
TEST_F(CredentialsTest, GetActiveColorModeBasicCorrectness) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = getFirstDisplayToken();
ASSERT_FALSE(display == nullptr);
ui::DynamicDisplayInfo info;
SurfaceComposerClient::getDynamicDisplayInfo(display, &info);
diff --git a/services/surfaceflinger/tests/DisplayConfigs_test.cpp b/services/surfaceflinger/tests/DisplayConfigs_test.cpp
index 2dc96b8511..02c934e576 100644
--- a/services/surfaceflinger/tests/DisplayConfigs_test.cpp
+++ b/services/surfaceflinger/tests/DisplayConfigs_test.cpp
@@ -48,7 +48,9 @@ private:
protected:
void SetUp() override {
- mDisplayToken = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ mDisplayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
status_t res =
SurfaceComposerClient::getDesiredDisplayModeSpecs(mDisplayToken,
&initialDefaultMode,
@@ -149,4 +151,4 @@ TEST_F(RefreshRateRangeTest, setAllowGroupSwitching) {
} // namespace android
// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic pop // ignored "-Wextra" \ No newline at end of file
+#pragma clang diagnostic pop // ignored "-Wextra"
diff --git a/services/surfaceflinger/tests/EffectLayer_test.cpp b/services/surfaceflinger/tests/EffectLayer_test.cpp
index 9fa0452915..52aa502743 100644
--- a/services/surfaceflinger/tests/EffectLayer_test.cpp
+++ b/services/surfaceflinger/tests/EffectLayer_test.cpp
@@ -28,7 +28,9 @@ protected:
LayerTransactionTest::SetUp();
ASSERT_EQ(NO_ERROR, mClient->initCheck());
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(display == nullptr);
mParentLayer = createColorLayer("Parent layer", Color::RED);
@@ -177,7 +179,9 @@ TEST_F(EffectLayerTest, BlurEffectLayerIsVisible) {
}
TEST_F(EffectLayerTest, EffectLayerWithColorNoCrop) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ui::DisplayMode mode;
ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode));
const ui::Size& resolution = mode.resolution;
diff --git a/services/surfaceflinger/tests/IPC_test.cpp b/services/surfaceflinger/tests/IPC_test.cpp
index c63d251c31..40a5d5757d 100644
--- a/services/surfaceflinger/tests/IPC_test.cpp
+++ b/services/surfaceflinger/tests/IPC_test.cpp
@@ -224,7 +224,9 @@ public:
mClient = sp<SurfaceComposerClient>::make();
ASSERT_EQ(NO_ERROR, mClient->initCheck());
- mPrimaryDisplay = mClient->getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ mPrimaryDisplay = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ui::DisplayMode mode;
mClient->getActiveDisplayMode(mPrimaryDisplay, &mode);
mDisplayWidth = mode.resolution.getWidth();
diff --git a/services/surfaceflinger/tests/LayerBorder_test.cpp b/services/surfaceflinger/tests/LayerBorder_test.cpp
index 0d55ec1dcf..a907d9d3b4 100644
--- a/services/surfaceflinger/tests/LayerBorder_test.cpp
+++ b/services/surfaceflinger/tests/LayerBorder_test.cpp
@@ -34,7 +34,9 @@ protected:
toHalf3 = ColorTransformHelper::toHalf3;
toHalf4 = ColorTransformHelper::toHalf4;
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(display == nullptr);
mColorOrange = toHalf4({255, 140, 0, 255});
mParentLayer = createColorLayer("Parent layer", Color::RED);
diff --git a/services/surfaceflinger/tests/LayerTransactionTest.h b/services/surfaceflinger/tests/LayerTransactionTest.h
index 0e8f3dd1d4..9ed951b6d1 100644
--- a/services/surfaceflinger/tests/LayerTransactionTest.h
+++ b/services/surfaceflinger/tests/LayerTransactionTest.h
@@ -289,7 +289,9 @@ protected:
private:
void SetUpDisplay() {
- mDisplay = mClient->getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ mDisplay = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(mDisplay == nullptr) << "failed to get display";
ui::DisplayMode mode;
diff --git a/services/surfaceflinger/tests/LayerUpdate_test.cpp b/services/surfaceflinger/tests/LayerUpdate_test.cpp
index e1a7ecc03b..867eddbc44 100644
--- a/services/surfaceflinger/tests/LayerUpdate_test.cpp
+++ b/services/surfaceflinger/tests/LayerUpdate_test.cpp
@@ -33,7 +33,9 @@ protected:
LayerTransactionTest::SetUp();
ASSERT_EQ(NO_ERROR, mClient->initCheck());
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(display == nullptr);
ui::DisplayMode mode;
diff --git a/services/surfaceflinger/tests/MirrorLayer_test.cpp b/services/surfaceflinger/tests/MirrorLayer_test.cpp
index a921aa810e..e3f2f02b0a 100644
--- a/services/surfaceflinger/tests/MirrorLayer_test.cpp
+++ b/services/surfaceflinger/tests/MirrorLayer_test.cpp
@@ -29,8 +29,10 @@ protected:
virtual void SetUp() {
LayerTransactionTest::SetUp();
ASSERT_EQ(NO_ERROR, mClient->initCheck());
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(display == nullptr);
mParentLayer = createColorLayer("Parent layer", Color::RED);
@@ -231,7 +233,10 @@ TEST_F(MirrorLayerTest, MirrorBufferLayer) {
// Test that the mirror layer is initially offscreen.
TEST_F(MirrorLayerTest, InitialMirrorState) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ui::DisplayMode mode;
SurfaceComposerClient::getActiveDisplayMode(display, &mode);
const ui::Size& size = mode.resolution;
@@ -275,7 +280,9 @@ TEST_F(MirrorLayerTest, InitialMirrorState) {
// Test that a mirror layer can be screenshot when offscreen
TEST_F(MirrorLayerTest, OffscreenMirrorScreenshot) {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ui::DisplayMode mode;
SurfaceComposerClient::getActiveDisplayMode(display, &mode);
const ui::Size& size = mode.resolution;
diff --git a/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp b/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp
index 1ed6c65afb..15ff696412 100644
--- a/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp
+++ b/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp
@@ -35,7 +35,9 @@ protected:
LayerTransactionTest::SetUp();
ASSERT_EQ(NO_ERROR, mClient->initCheck());
- mMainDisplay = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ mMainDisplay = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
SurfaceComposerClient::getDisplayState(mMainDisplay, &mMainDisplayState);
SurfaceComposerClient::getActiveDisplayMode(mMainDisplay, &mMainDisplayMode);
diff --git a/services/surfaceflinger/tests/RelativeZ_test.cpp b/services/surfaceflinger/tests/RelativeZ_test.cpp
index 50a4092ddb..9cebf11b9c 100644
--- a/services/surfaceflinger/tests/RelativeZ_test.cpp
+++ b/services/surfaceflinger/tests/RelativeZ_test.cpp
@@ -33,7 +33,9 @@ protected:
LayerTransactionTest::SetUp();
ASSERT_EQ(NO_ERROR, mClient->initCheck());
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(display == nullptr);
// Back layer
diff --git a/services/surfaceflinger/tests/ScreenCapture_test.cpp b/services/surfaceflinger/tests/ScreenCapture_test.cpp
index d78c8a9ee0..34503755e3 100644
--- a/services/surfaceflinger/tests/ScreenCapture_test.cpp
+++ b/services/surfaceflinger/tests/ScreenCapture_test.cpp
@@ -30,7 +30,9 @@ protected:
LayerTransactionTest::SetUp();
ASSERT_EQ(NO_ERROR, mClient->initCheck());
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(display == nullptr);
ui::DisplayMode mode;
diff --git a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp
index d79e59211b..7166d413f1 100644
--- a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp
+++ b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp
@@ -264,7 +264,9 @@ void SurfaceInterceptorTest::capture(TestAction action, Trace* outTrace) {
}
void SurfaceInterceptorTest::setupBackgroundSurface() {
- const auto display = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ ASSERT_FALSE(ids.empty());
+ const auto display = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ASSERT_FALSE(display == nullptr);
ui::DisplayMode mode;
diff --git a/services/surfaceflinger/tests/TransactionTestHarnesses.h b/services/surfaceflinger/tests/TransactionTestHarnesses.h
index ad03ed3073..797a64c7d7 100644
--- a/services/surfaceflinger/tests/TransactionTestHarnesses.h
+++ b/services/surfaceflinger/tests/TransactionTestHarnesses.h
@@ -35,7 +35,10 @@ public:
return mDelegate->screenshot();
case RenderPath::VIRTUAL_DISPLAY:
- const auto displayToken = SurfaceComposerClient::getInternalDisplayToken();
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ const auto displayToken = ids.empty()
+ ? nullptr
+ : SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
ui::DisplayState displayState;
SurfaceComposerClient::getDisplayState(displayToken, &displayState);
diff --git a/services/surfaceflinger/tests/utils/ScreenshotUtils.h b/services/surfaceflinger/tests/utils/ScreenshotUtils.h
index 224868c014..f297da5511 100644
--- a/services/surfaceflinger/tests/utils/ScreenshotUtils.h
+++ b/services/surfaceflinger/tests/utils/ScreenshotUtils.h
@@ -51,7 +51,11 @@ public:
}
static void captureScreen(std::unique_ptr<ScreenCapture>* sc) {
- captureScreen(sc, SurfaceComposerClient::getInternalDisplayToken());
+ const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ // TODO(b/248317436): extend to cover all displays for multi-display devices
+ const auto display =
+ ids.empty() ? nullptr : SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
+ captureScreen(sc, display);
}
static void captureScreen(std::unique_ptr<ScreenCapture>* sc, sp<IBinder> displayToken) {