diff options
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
| -rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 90 | 
1 files changed, 44 insertions, 46 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 0ed47e7da2c9..681f8e9f44a0 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,  |