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

Commit 8d43f766 authored by George Lin's avatar George Lin
Browse files

[framework] Modify scalePreview in WallpaperService

Modified the implementation of scalePreview to call setFixedSize instead

This function is used by the wallpaper picker to resolve the scaling
issue.

A TODO b/262750854 is created to later have a holistic fix.

Bug: 204844104
Bug: 240291366
Test: Manuel
Change-Id: Idd45eaac34db69d7e2bdd5450678b7d7e86d4629
parent ca906a1e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -42,7 +42,7 @@ interface IWallpaperEngine {
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    oneway void destroy();
    oneway void destroy();
    oneway void setZoomOut(float scale);
    oneway void setZoomOut(float scale);
    oneway void scalePreview(in Rect positionInWindow);
    oneway void resizePreview(in Rect positionInWindow);
    oneway void removeLocalColorsAreas(in List<RectF> regions);
    oneway void removeLocalColorsAreas(in List<RectF> regions);
    oneway void addLocalColorsAreas(in List<RectF> regions);
    oneway void addLocalColorsAreas(in List<RectF> regions);
    SurfaceControl mirrorSurfaceControl();
    SurfaceControl mirrorSurfaceControl();
+9 −16
Original line number Original line Diff line number Diff line
@@ -163,7 +163,7 @@ public abstract class WallpaperService extends Service {
    private static final int MSG_TOUCH_EVENT = 10040;
    private static final int MSG_TOUCH_EVENT = 10040;
    private static final int MSG_REQUEST_WALLPAPER_COLORS = 10050;
    private static final int MSG_REQUEST_WALLPAPER_COLORS = 10050;
    private static final int MSG_ZOOM = 10100;
    private static final int MSG_ZOOM = 10100;
    private static final int MSG_SCALE_PREVIEW = 10110;
    private static final int MSG_RESIZE_PREVIEW = 10110;
    private static final int MSG_REPORT_SHOWN = 10150;
    private static final int MSG_REPORT_SHOWN = 10150;
    private static final int MSG_UPDATE_DIMMING = 10200;
    private static final int MSG_UPDATE_DIMMING = 10200;
    private static final List<Float> PROHIBITED_STEPS = Arrays.asList(0f, Float.POSITIVE_INFINITY,
    private static final List<Float> PROHIBITED_STEPS = Arrays.asList(0f, Float.POSITIVE_INFINITY,
@@ -323,7 +323,7 @@ public abstract class WallpaperService extends Service {


            @Override
            @Override
            public void setFixedSize(int width, int height) {
            public void setFixedSize(int width, int height) {
                if (!mFixedSizeAllowed) {
                if (!mFixedSizeAllowed && !mIWallpaperEngine.mIsPreview) {
                    // Regular apps can't do this.  It can only work for
                    // Regular apps can't do this.  It can only work for
                    // certain designs of window animations, so you can't
                    // certain designs of window animations, so you can't
                    // rely on it.
                    // rely on it.
@@ -1372,16 +1372,9 @@ public abstract class WallpaperService extends Service {
            }
            }
        }
        }


        private void scalePreview(Rect position) {
        private void resizePreview(Rect position) {
            if (isPreview() && mPreviewSurfacePosition == null && position != null
            if (position != null) {
                    || mPreviewSurfacePosition != null
                mSurfaceHolder.setFixedSize(position.width(), position.height());
                    && !mPreviewSurfacePosition.equals(position)) {
                mPreviewSurfacePosition = position;
                if (mSurfaceControl.isValid()) {
                    reposition();
                } else {
                    updateSurface(false, false, false);
                }
            }
            }
        }
        }


@@ -2295,8 +2288,8 @@ public abstract class WallpaperService extends Service {
            mCaller.sendMessage(msg);
            mCaller.sendMessage(msg);
        }
        }


        public void scalePreview(Rect position) {
        public void resizePreview(Rect position) {
            Message msg = mCaller.obtainMessageO(MSG_SCALE_PREVIEW, position);
            Message msg = mCaller.obtainMessageO(MSG_RESIZE_PREVIEW, position);
            mCaller.sendMessage(msg);
            mCaller.sendMessage(msg);
        }
        }


@@ -2383,8 +2376,8 @@ public abstract class WallpaperService extends Service {
                case MSG_UPDATE_DIMMING:
                case MSG_UPDATE_DIMMING:
                    mEngine.updateWallpaperDimming(Float.intBitsToFloat(message.arg1));
                    mEngine.updateWallpaperDimming(Float.intBitsToFloat(message.arg1));
                    break;
                    break;
                case MSG_SCALE_PREVIEW:
                case MSG_RESIZE_PREVIEW:
                    mEngine.scalePreview((Rect) message.obj);
                    mEngine.resizePreview((Rect) message.obj);
                    break;
                    break;
                case MSG_VISIBILITY_CHANGED:
                case MSG_VISIBILITY_CHANGED:
                    if (DEBUG) Log.v(TAG, "Visibility change in " + mEngine
                    if (DEBUG) Log.v(TAG, "Visibility change in " + mEngine