summaryrefslogtreecommitdiff
path: root/cmds/bootanimation/BootAnimation.cpp
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2023-08-25 12:59:08 -0700
committer Xin Li <delphij@google.com> 2023-08-25 12:59:08 -0700
commit7d3ffbae618e9e728644a96647ed709bf39ae759 (patch)
treeab369a30c6a0e17a69c8f80c6353be4de3692e10 /cmds/bootanimation/BootAnimation.cpp
parenta8a87bbca9162af7add830139198c4ee899fa123 (diff)
parent8a809c6e46007521f75ac035ad4b1dcc1d00d9cf (diff)
Merge Android U (ab/10368041)
Bug: 291102124 Merged-In: I3c9e9d15786fbead1b874636b46844f6c24bccc2 Change-Id: Id6cf6cc13baef4e67486c6271a1510146204affa
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
-rw-r--r--cmds/bootanimation/BootAnimation.cpp90
1 files changed, 44 insertions, 46 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 74ca41d0f9b4..fd79a04814fd 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -72,8 +72,6 @@ static const char PRODUCT_BOOTANIMATION_DARK_FILE[] = "/product/media/bootanimat
static const char PRODUCT_BOOTANIMATION_FILE[] = "/product/media/bootanimation.zip";
static const char SYSTEM_BOOTANIMATION_FILE[] = "/system/media/bootanimation.zip";
static const char APEX_BOOTANIMATION_FILE[] = "/apex/com.android.bootanimation/etc/bootanimation.zip";
-static const char PRODUCT_ENCRYPTED_BOOTANIMATION_FILE[] = "/product/media/bootanimation-encrypted.zip";
-static const char SYSTEM_ENCRYPTED_BOOTANIMATION_FILE[] = "/system/media/bootanimation-encrypted.zip";
static const char OEM_SHUTDOWNANIMATION_FILE[] = "/oem/media/shutdownanimation.zip";
static const char PRODUCT_SHUTDOWNANIMATION_FILE[] = "/product/media/shutdownanimation.zip";
static const char SYSTEM_SHUTDOWNANIMATION_FILE[] = "/system/media/shutdownanimation.zip";
@@ -497,28 +495,13 @@ ui::Size BootAnimation::limitSurfaceSize(int width, int height) const {
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;
@@ -545,9 +528,44 @@ status_t BootAnimation::readyToRun() {
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)) {
@@ -575,8 +593,9 @@ status_t BootAnimation::readyToRun() {
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;
@@ -673,10 +692,6 @@ void BootAnimation::resizeSurface(int newWidth, int newHeight) {
mWidth = limitedSize.width;
mHeight = limitedSize.height;
- SurfaceComposerClient::Transaction t;
- t.setSize(mFlingerSurfaceControl, mWidth, mHeight);
- t.apply();
-
EGLConfig config = getEglConfig(mDisplay);
EGLSurface surface = eglCreateWindowSurface(mDisplay, config, mFlingerSurface.get(), nullptr);
if (eglMakeCurrent(mDisplay, surface, surface, mContext) == EGL_FALSE) {
@@ -710,23 +725,6 @@ bool BootAnimation::findBootAnimationFileInternal(const std::vector<std::string>
}
void BootAnimation::findBootAnimationFile() {
- // If the device has encryption turned on or is in process
- // of being encrypted we show the encrypted boot animation.
- char decrypt[PROPERTY_VALUE_MAX];
- property_get("vold.decrypt", decrypt, "");
-
- bool encryptedAnimation = atoi(decrypt) != 0 ||
- !strcmp("trigger_restart_min_framework", decrypt);
-
- if (!mShuttingDown && encryptedAnimation) {
- static const std::vector<std::string> encryptedBootFiles = {
- PRODUCT_ENCRYPTED_BOOTANIMATION_FILE, SYSTEM_ENCRYPTED_BOOTANIMATION_FILE,
- };
- if (findBootAnimationFileInternal(encryptedBootFiles)) {
- return;
- }
- }
-
const bool playDarkAnim = android::base::GetIntProperty("ro.boot.theme", 0) == 1;
static const std::vector<std::string> bootFiles = {
APEX_BOOTANIMATION_FILE, playDarkAnim ? PRODUCT_BOOTANIMATION_DARK_FILE : PRODUCT_BOOTANIMATION_FILE,