SF: Cleanup creating / destroying virtual display APIs
Follow-up CL for cleanup requested by SF owner in http://ag/27202517.
Misc:
- Fix type conversion warnings for print format.
- Return status destroying virtual display in SF and add appropriate
checks in UT.
- Use static constexpr / const for compile-time effciciency.
Bug: 339525838
Bug: 137375833
Bug: 194863377
Test: atest libsurfaceflinger_unittest
Test: atest SurfaceFlinger_test
Flag: EXEMPT refactor
Change-Id: I7859720989c9244b26f8764c3323a8495064c888
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index c0e7965..b0db396 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -1186,9 +1186,8 @@
MultiDisplayTests() : InputSurfacesTest() { ProcessState::self()->startThreadPool(); }
void TearDown() override {
- for (auto& token : mVirtualDisplays) {
- SurfaceComposerClient::destroyDisplay(token);
- }
+ std::for_each(mVirtualDisplays.begin(), mVirtualDisplays.end(),
+ SurfaceComposerClient::destroyVirtualDisplay);
InputSurfacesTest::TearDown();
}
@@ -1203,7 +1202,7 @@
std::string name = "VirtualDisplay";
name += std::to_string(mVirtualDisplays.size());
- sp<IBinder> token = SurfaceComposerClient::createDisplay(String8(name.c_str()), isSecure);
+ sp<IBinder> token = SurfaceComposerClient::createVirtualDisplay(name, isSecure);
SurfaceComposerClient::Transaction t;
t.setDisplaySurface(token, producer);
t.setDisplayFlags(token, receivesInput ? 0x01 /* DisplayDevice::eReceivesInput */ : 0);
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index eee4fb9..6c6a849 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -673,13 +673,14 @@
return binder::Status::ok();
}
- binder::Status createDisplay(const std::string& /*displayName*/, bool /*isSecure*/,
- const std::string& /*uniqueId*/, float /*requestedRefreshRate*/,
- sp<IBinder>* /*outDisplay*/) override {
+ binder::Status createVirtualDisplay(const std::string& /*displayName*/, bool /*isSecure*/,
+ const std::string& /*uniqueId*/,
+ float /*requestedRefreshRate*/,
+ sp<IBinder>* /*outDisplay*/) override {
return binder::Status::ok();
}
- binder::Status destroyDisplay(const sp<IBinder>& /*display*/) override {
+ binder::Status destroyVirtualDisplay(const sp<IBinder>& /*displayToken*/) override {
return binder::Status::ok();
}