Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28a13545 authored by Steven Ng's avatar Steven Ng
Browse files

Fix pixelated wallpaper image shown on external display

Root clause: the wallpaper image is downscaled during the bitmap decoding process because the default bitmap density is non-zero for external display.

Also, relax the max display to wallpaper image ratio back to 1.5 as we identified the root clause of the image quality problem.

Flag: android.app.enable_connected_displays_wallpaper
Test: connect to an external display to check if the wallpaper has good quality on the external display.
Bug: 403277285
Change-Id: I04672881d13c7910aaa496ea0177d08f9cdfba39
parent 79e6e3d4
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.Manifest.permission.MANAGE_EXTERNAL_STORAGE;
import static android.Manifest.permission.READ_WALLPAPER_INTERNAL;
import static android.Manifest.permission.SET_WALLPAPER_DIM_AMOUNT;
import static android.app.Flags.FLAG_LIVE_WALLPAPER_CONTENT_HANDLING;
import static android.app.Flags.enableConnectedDisplaysWallpaper;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.ParcelFileDescriptor.MODE_READ_ONLY;

@@ -874,7 +875,13 @@ public class WallpaperManager {
                    return null;
                }
                try (InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) {
                    ImageDecoder.Source src = ImageDecoder.createSource(context.getResources(), is);
                    ImageDecoder.Source src;
                    if (enableConnectedDisplaysWallpaper()) {
                        src = ImageDecoder.createSource(context.getResources(), is,
                                /* density= */ 0);
                    } else {
                        src = ImageDecoder.createSource(context.getResources(), is);
                    }
                    return ImageDecoder.decodeBitmap(src, ((decoder, info, source) -> {
                        // Mutable and hardware config can't be set at the same time.
                        decoder.setMutableRequired(!hardware);
+1 −1
Original line number Diff line number Diff line
@@ -863,7 +863,7 @@ public class WallpaperCropper {

        double maxDisplayToImageRatio = Math.max((double) displaySize.x / croppedImageBound.width(),
                (double) displaySize.y / croppedImageBound.height());
        if (maxDisplayToImageRatio > 1.3) {
        if (maxDisplayToImageRatio > 1.5) {
            return false;
        }