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

Commit 80f4ac22 authored by Aurélien Pomini's avatar Aurélien Pomini Committed by Android (Google) Code Review
Browse files

Merge "Fix getBitmapCrops" into main

parents 84f78524 5e0c9b41
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1603,8 +1603,18 @@ public class WallpaperManager {
            @SetWallpaperFlags int which, boolean originalBitmap) {
        checkExactlyOneWallpaperFlagSet(which);
        try {
            return sGlobals.mService.getBitmapCrops(displaySizes, which, originalBitmap,
                    mContext.getUserId());
            List<Rect> result = sGlobals.mService.getBitmapCrops(
                    displaySizes, which, originalBitmap, mContext.getUserId());
            if (result != null) return result;
            // mService.getBitmapCrops returns null if the requested wallpaper is an ImageWallpaper,
            // but there are no crop hints and the bitmap size is unknown to the service (this
            // mostly happens for the default wallpaper). In that case, fetch the bitmap dimensions
            // and use the other getBitmapCrops API with no cropHints to figure out the crops.
            Rect bitmapDimensions = peekBitmapDimensions(which, true);
            if (bitmapDimensions == null) return List.of();
            Point bitmapSize = new Point(bitmapDimensions.width(), bitmapDimensions.height());
            return getBitmapCrops(bitmapSize, displaySizes, null);

        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+6 −0
Original line number Diff line number Diff line
@@ -2269,6 +2269,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            Point croppedBitmapSize = new Point(
                    (int) (0.5f + wallpaper.cropHint.width() / wallpaper.mSampleSize),
                    (int) (0.5f + wallpaper.cropHint.height() / wallpaper.mSampleSize));
            if (croppedBitmapSize.equals(0, 0)) {
                // There is an ImageWallpaper, but there are no crop hints and the bitmap size is
                // unknown (e.g. the default wallpaper). Return a special "null" value that will be
                // handled by WallpaperManager, which will fetch the dimensions of the wallpaper.
                return null;
            }
            SparseArray<Rect> relativeDefaultCrops =
                    mWallpaperCropper.getDefaultCrops(relativeSuggestedCrops, croppedBitmapSize);
            SparseArray<Rect> adjustedRelativeSuggestedCrops = new SparseArray<>();