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

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

Get rid of the field WallpaperData.mSupportsMultCrop

There are no short term plans to crop live wallpapers on the window
levels. Let's not keep confusing and unnecessary logic. If one day we
decide to use multi-crop for a live wallpaper, we'll rewrite something
similar.

Flag: ACONFIG com.android.window.flags.multi_crop TEAMFOOD
Bug: 330518320
Test: atest WallpaperManagerTest
Change-Id: I46e8469593303a77012e28e6019c6d789041cfd1
parent 10d37891
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -422,12 +422,11 @@ public class WallpaperCropper {
        } else {
            boolean needCrop = false;
            boolean needScale;
            boolean multiCrop = multiCrop() && wallpaper.mSupportsMultiCrop;

            Point bitmapSize = new Point(options.outWidth, options.outHeight);

            final Rect cropHint;
            if (multiCrop) {
            if (multiCrop()) {
                SparseArray<Rect> defaultDisplayCrops =
                        getDefaultCrops(wallpaper.mCropHints, bitmapSize);
                // adapt the entries in wallpaper.mCropHints for the actual display
@@ -485,7 +484,7 @@ public class WallpaperCropper {
                    || cropHint.width() > GLHelper.getMaxTextureSize();

            //make sure screen aspect ratio is preserved if width is scaled under screen size
            if (needScale && !multiCrop) {
            if (needScale && !multiCrop()) {
                final float scaleByHeight = (float) wpData.mHeight / (float) cropHint.height();
                final int newWidth = (int) (cropHint.width() * scaleByHeight);
                if (newWidth < displayInfo.logicalWidth) {
@@ -543,7 +542,7 @@ public class WallpaperCropper {
                    final Rect estimateCrop = new Rect(cropHint);
                    estimateCrop.scale(1f / options.inSampleSize);
                    float hRatio = (float) wpData.mHeight / estimateCrop.height();
                    if (multiCrop) {
                    if (multiCrop()) {
                        // make sure the crop height is at most the display largest dimension
                        hRatio = (float) mWallpaperDisplayHelper.getDefaultDisplayLargestDimension()
                                / estimateCrop.height();
@@ -557,7 +556,7 @@ public class WallpaperCropper {
                        if (DEBUG) {
                            Slog.w(TAG, "Invalid crop dimensions, trying to adjust.");
                        }
                        if (multiCrop) {
                        if (multiCrop()) {
                            // clear custom crop guidelines, fallback to system default
                            wallpaper.mCropHints.clear();
                            generateCropInternal(wallpaper);
@@ -618,7 +617,7 @@ public class WallpaperCropper {
                        final Bitmap finalCrop = Bitmap.createScaledBitmap(cropped,
                                safeWidth, safeHeight, true);

                        if (multiCrop) {
                        if (multiCrop()) {
                            wallpaper.mSampleSize =
                                    ((float) cropHint.height()) / finalCrop.getHeight();
                        }
+0 −6
Original line number Diff line number Diff line
@@ -171,11 +171,6 @@ class WallpaperData {
     */
    SparseArray<Rect> mCropHints = new SparseArray<>();

    /**
     * cropHints will be ignored if this flag is false
     */
    boolean mSupportsMultiCrop;

    /**
     * The phone orientation when the wallpaper was set. Only relevant for image wallpapers
     */
@@ -204,7 +199,6 @@ class WallpaperData {
        if (source.mCropHints != null) {
            this.mCropHints = source.mCropHints.clone();
        }
        this.mSupportsMultiCrop = source.mSupportsMultiCrop;
        this.allowBackup = source.allowBackup;
        this.primaryColors = source.primaryColors;
        this.mWallpaperDimAmount = source.mWallpaperDimAmount;
+3 −8
Original line number Diff line number Diff line
@@ -324,10 +324,7 @@ public class WallpaperDataParser {
                getAttributeInt(parser, "totalCropTop", 0),
                getAttributeInt(parser, "totalCropRight", 0),
                getAttributeInt(parser, "totalCropBottom", 0));
        wallpaper.mSupportsMultiCrop = multiCrop() && (
                parser.getAttributeBoolean(null, "supportsMultiCrop", false)
                || mImageWallpaper.equals(wallpaper.wallpaperComponent));
        if (wallpaper.mSupportsMultiCrop) {
        if (multiCrop() && mImageWallpaper.equals(wallpaper.nextWallpaperComponent)) {
            wallpaper.mCropHints = new SparseArray<>();
            for (Pair<Integer, String> pair: screenDimensionPairs()) {
                Rect cropHint = new Rect(
@@ -351,7 +348,7 @@ public class WallpaperDataParser {
                wallpaper.cropHint.set(totalCropHint);
            }
            wallpaper.mSampleSize = parser.getAttributeFloat(null, "sampleSize", 1f);
        } else {
        } else if (!multiCrop()) {
            wallpaper.cropHint.set(legacyCropHint);
        }
        final DisplayData wpData = mWallpaperDisplayHelper
@@ -467,9 +464,7 @@ public class WallpaperDataParser {
        out.startTag(null, tag);
        out.attributeInt(null, "id", wallpaper.wallpaperId);

        out.attributeBoolean(null, "supportsMultiCrop", wallpaper.mSupportsMultiCrop);

        if (multiCrop() && wallpaper.mSupportsMultiCrop) {
        if (multiCrop() && mImageWallpaper.equals(wallpaper.wallpaperComponent)) {
            if (wallpaper.mCropHints == null) {
                Slog.e(TAG, "cropHints should not be null when saved");
                wallpaper.mCropHints = new SparseArray<>();
+4 −5
Original line number Diff line number Diff line
@@ -803,7 +803,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    null /* options */);
            mWindowManagerInternal.setWallpaperShowWhenLocked(
                    mToken, (wallpaper.mWhich & FLAG_LOCK) != 0);
            if (multiCrop() && wallpaper.mSupportsMultiCrop) {
            if (multiCrop() && mImageWallpaper.equals(wallpaper.wallpaperComponent)) {
                mWindowManagerInternal.setWallpaperCropHints(mToken,
                        mWallpaperCropper.getRelativeCropHints(wallpaper));
            } else {
@@ -2225,7 +2225,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            checkPermission(READ_WALLPAPER_INTERNAL);
            WallpaperData wallpaper = (which == FLAG_LOCK) ? mLockWallpaperMap.get(userId)
                    : mWallpaperMap.get(userId);
            if (wallpaper == null || !wallpaper.mSupportsMultiCrop) return null;
            if (wallpaper == null || !mImageWallpaper.equals(wallpaper.wallpaperComponent)) {
                return null;
            }
            SparseArray<Rect> relativeSuggestedCrops =
                    mWallpaperCropper.getRelativeCropHints(wallpaper);
            Point croppedBitmapSize = new Point(
@@ -2913,7 +2915,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    wallpaper.fromForegroundApp = multiCrop() ? fromForegroundApp
                            : isFromForegroundApp(callingPackage);
                    if (!multiCrop()) wallpaper.cropHint.set(cropHint);
                    if (multiCrop()) wallpaper.mSupportsMultiCrop = true;
                    if (multiCrop()) wallpaper.mCropHints = cropMap;
                    wallpaper.allowBackup = allowBackup;
                    wallpaper.mWallpaperDimAmount = getWallpaperDimAmount();
@@ -2975,7 +2976,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        WallpaperData lockWP = new WallpaperData(userId, FLAG_LOCK);
        lockWP.wallpaperId = sysWP.wallpaperId;
        lockWP.cropHint.set(sysWP.cropHint);
        lockWP.mSupportsMultiCrop = sysWP.mSupportsMultiCrop;
        if (sysWP.mCropHints != null) {
            lockWP.mCropHints = sysWP.mCropHints.clone();
        }
@@ -3096,7 +3096,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            final long ident = Binder.clearCallingIdentity();

            try {
                newWallpaper.mSupportsMultiCrop = mImageWallpaper.equals(name);
                newWallpaper.imageWallpaperPending = false;
                newWallpaper.mWhich = which;
                newWallpaper.mSystemWasBoth = systemIsBoth;