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

Commit a001114e authored by Aurélien Pomini's avatar Aurélien Pomini
Browse files

Don't change anything if multi_crop is false.

The legacy WallpaperDataParser (without multi-crop) was inadvertently
loading new attributes ("totalCropLeft, totalCropRight, ...") instead of
old ones ("cropLeft, cropRight, ...") even when the flag was false.

Flag: NA, fixes an issue outside flag
Bug: 329259443
Test: manually spotted the issue
Change-Id: Idb45decc64ad90da72a837a3fd7f19b3d2c182b2
parent 8ff0d0dc
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -314,6 +314,11 @@ public class WallpaperDataParser {
            wallpaper.wallpaperId = makeWallpaperIdLocked();
        }

        Rect legacyCropHint = new Rect(
                getAttributeInt(parser, "cropLeft", 0),
                getAttributeInt(parser, "cropTop", 0),
                getAttributeInt(parser, "cropRight", 0),
                getAttributeInt(parser, "cropBottom", 0));
        Rect totalCropHint = new Rect(
                getAttributeInt(parser, "totalCropLeft", 0),
                getAttributeInt(parser, "totalCropTop", 0),
@@ -332,18 +337,19 @@ public class WallpaperDataParser {
                        parser.getAttributeInt(null, "cropBottom" + pair.second, 0));
                if (!cropHint.isEmpty()) wallpaper.mCropHints.put(pair.first, cropHint);
            }
            if (wallpaper.mCropHints.size() == 0) {
            if (wallpaper.mCropHints.size() == 0 && totalCropHint.isEmpty()) {
                // migration case: the crops per screen orientation are not specified.
                // use the old attributes to find the crop for one screen orientation.
                Integer orientation = totalCropHint.width() < totalCropHint.height()
                int orientation = legacyCropHint.width() < legacyCropHint.height()
                        ? WallpaperManager.PORTRAIT : WallpaperManager.LANDSCAPE;
                if (!totalCropHint.isEmpty()) wallpaper.mCropHints.put(orientation, totalCropHint);
                if (!legacyCropHint.isEmpty()) {
                    wallpaper.mCropHints.put(orientation, legacyCropHint);
                }
            } else {
                wallpaper.cropHint.set(totalCropHint);
            }
            wallpaper.mSampleSize = parser.getAttributeFloat(null, "sampleSize", 1f);
        } else {
            wallpaper.cropHint.set(totalCropHint);
            wallpaper.cropHint.set(legacyCropHint);
        }
        final DisplayData wpData = mWallpaperDisplayHelper
                .getDisplayDataOrCreate(DEFAULT_DISPLAY);