Remove internal display related methods
Sync with changes made in SurfaceFlinger and SurfaceComposerClient.
Use the system property, persist.boot.animation.displays, to determine
the displays to show the boot animation. If the system property is not
present, the first display from the display list is used.
Bug: 241285477
Test: manual, run bootanim command to verify
Change-Id: If29ecb12a68fc075daef2b8f674995d0f11cbc09
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 814800b..8be8cda 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -492,28 +492,13 @@
status_t BootAnimation::readyToRun() {
mAssets.addDefaultAssets();
- mDisplayToken = SurfaceComposerClient::getInternalDisplayToken();
- if (mDisplayToken == nullptr)
+ const std::vector<PhysicalDisplayId> ids = SurfaceComposerClient::getPhysicalDisplayIds();
+ if (ids.empty()) {
+ SLOGE("Failed to get ID for any displays\n");
return NAME_NOT_FOUND;
+ }
- DisplayMode displayMode;
- const status_t error =
- SurfaceComposerClient::getActiveDisplayMode(mDisplayToken, &displayMode);
- if (error != NO_ERROR)
- return error;
-
- mMaxWidth = android::base::GetIntProperty("ro.surface_flinger.max_graphics_width", 0);
- mMaxHeight = android::base::GetIntProperty("ro.surface_flinger.max_graphics_height", 0);
- ui::Size resolution = displayMode.resolution;
- resolution = limitSurfaceSize(resolution.width, resolution.height);
- // create the native surface
- sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
- resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGB_565,
- ISurfaceComposerClient::eOpaque);
-
- SurfaceComposerClient::Transaction t;
-
- // this guest property specifies multi-display IDs to show the boot animation
+ // this system property specifies multi-display IDs to show the boot animation
// multiple ids can be set with comma (,) as separator, for example:
// setprop persist.boot.animation.displays 19260422155234049,19261083906282754
Vector<PhysicalDisplayId> physicalDisplayIds;
@@ -540,9 +525,44 @@
stream.ignore();
}
+ // the first specified display id is used to retrieve mDisplayToken
+ for (const auto id : physicalDisplayIds) {
+ if (std::find(ids.begin(), ids.end(), id) != ids.end()) {
+ if (const auto token = SurfaceComposerClient::getPhysicalDisplayToken(id)) {
+ mDisplayToken = token;
+ break;
+ }
+ }
+ }
+ }
+
+ // If the system property is not present or invalid, display 0 is used
+ if (mDisplayToken == nullptr) {
+ mDisplayToken = SurfaceComposerClient::getPhysicalDisplayToken(ids.front());
+ if (mDisplayToken == nullptr) {
+ return NAME_NOT_FOUND;
+ }
+ }
+
+ DisplayMode displayMode;
+ const status_t error =
+ SurfaceComposerClient::getActiveDisplayMode(mDisplayToken, &displayMode);
+ if (error != NO_ERROR) {
+ return error;
+ }
+
+ mMaxWidth = android::base::GetIntProperty("ro.surface_flinger.max_graphics_width", 0);
+ mMaxHeight = android::base::GetIntProperty("ro.surface_flinger.max_graphics_height", 0);
+ ui::Size resolution = displayMode.resolution;
+ resolution = limitSurfaceSize(resolution.width, resolution.height);
+ // create the native surface
+ sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
+ resolution.getWidth(), resolution.getHeight(), PIXEL_FORMAT_RGB_565,
+ ISurfaceComposerClient::eOpaque);
+
+ SurfaceComposerClient::Transaction t;
+ if (isValid) {
// In the case of multi-display, boot animation shows on the specified displays
- // in addition to the primary display
- const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
for (const auto id : physicalDisplayIds) {
if (std::find(ids.begin(), ids.end(), id) != ids.end()) {
if (const auto token = SurfaceComposerClient::getPhysicalDisplayToken(id)) {
@@ -570,8 +590,9 @@
eglQuerySurface(display, surface, EGL_WIDTH, &w);
eglQuerySurface(display, surface, EGL_HEIGHT, &h);
- if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE)
+ if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
return NO_INIT;
+ }
mDisplay = display;
mContext = context;