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

Commit 7ea91ec1 authored by John Spurlock's avatar John Spurlock
Browse files

Ensure wallpaper hint is at least the display's max size.

Bug:11332853
Change-Id: Ied13ffab77395f64642f7fb536f36d9cd8367e74
parent 3e7495b2
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -648,6 +648,10 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
            if (width <= 0 || height <= 0) {
                throw new IllegalArgumentException("width and height must be > 0");
            }
            // Make sure it is at least as large as the display's maximum size.
            int maxSizeDimension = getMaximumSizeDimension();
            width = Math.max(width, maxSizeDimension);
            height = Math.max(height, maxSizeDimension);

            if (width != wallpaper.width || height != wallpaper.height) {
                wallpaper.width = width;
@@ -1146,9 +1150,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
        }

        // We always want to have some reasonable width hint.
        WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
        Display d = wm.getDefaultDisplay();
        int baseSize = d.getMaximumSizeDimension();
        int baseSize = getMaximumSizeDimension();
        if (wallpaper.width < baseSize) {
            wallpaper.width = baseSize;
        }
@@ -1157,6 +1159,12 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
        }
    }

    private int getMaximumSizeDimension() {
        WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
        Display d = wm.getDefaultDisplay();
        return d.getMaximumSizeDimension();
    }

    // Called by SystemBackupAgent after files are restored to disk.
    void settingsRestored() {
        // TODO: If necessary, make it work for secondary users as well. This currently assumes