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

Commit e1f569ea authored by Rasheed Lewis's avatar Rasheed Lewis Committed by Automerger Merge Worker
Browse files

Merge "Revert "Refresh layout parameter for bounds change from relayout"" into...

Merge "Revert "Refresh layout parameter for bounds change from relayout"" into udc-dev am: 9474fd78

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22622577



Change-Id: Ic04de2940a5db7d92f889ad2fb8497bc7eb69f12
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents fba99803 9474fd78
Loading
Loading
Loading
Loading
+10 −56
Original line number Original line Diff line number Diff line
@@ -112,7 +112,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
import java.util.function.Supplier;


/**
/**
@@ -432,7 +431,6 @@ public abstract class WallpaperService extends Service {
                Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
                Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
                        reportDraw ? 1 : 0,
                        reportDraw ? 1 : 0,
                        mergedConfiguration);
                        mergedConfiguration);
                mIWallpaperEngine.mPendingResizeCount.incrementAndGet();
                mCaller.sendMessage(msg);
                mCaller.sendMessage(msg);
            }
            }


@@ -512,7 +510,6 @@ public abstract class WallpaperService extends Service {
        public Engine(Supplier<Long> clockFunction, Handler handler) {
        public Engine(Supplier<Long> clockFunction, Handler handler) {
            mClockFunction = clockFunction;
            mClockFunction = clockFunction;
            mHandler = handler;
            mHandler = handler;
            mMergedConfiguration.setOverrideConfiguration(getResources().getConfiguration());
        }
        }


        /**
        /**
@@ -1054,10 +1051,6 @@ public abstract class WallpaperService extends Service {
            out.print(prefix); out.print("mZoom="); out.println(mZoom);
            out.print(prefix); out.print("mZoom="); out.println(mZoom);
            out.print(prefix); out.print("mPreviewSurfacePosition=");
            out.print(prefix); out.print("mPreviewSurfacePosition=");
                    out.println(mPreviewSurfacePosition);
                    out.println(mPreviewSurfacePosition);
            final int pendingCount = mIWallpaperEngine.mPendingResizeCount.get();
            if (pendingCount != 0) {
                out.print(prefix); out.print("mPendingResizeCount="); out.println(pendingCount);
            }
            synchronized (mLock) {
            synchronized (mLock) {
                out.print(prefix); out.print("mPendingXOffset="); out.print(mPendingXOffset);
                out.print(prefix); out.print("mPendingXOffset="); out.print(mPendingXOffset);
                        out.print(" mPendingXOffset="); out.println(mPendingXOffset);
                        out.print(" mPendingXOffset="); out.println(mPendingXOffset);
@@ -1120,6 +1113,10 @@ public abstract class WallpaperService extends Service {
            }
            }
        }
        }


        private void updateConfiguration(MergedConfiguration mergedConfiguration) {
            mMergedConfiguration.setTo(mergedConfiguration);
        }

        void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNeeded) {
        void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNeeded) {
            if (mDestroyed) {
            if (mDestroyed) {
                Log.w(TAG, "Ignoring updateSurface due to destroyed");
                Log.w(TAG, "Ignoring updateSurface due to destroyed");
@@ -1168,7 +1165,7 @@ public abstract class WallpaperService extends Service {
                            | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
                            | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;


                    final Configuration config = mMergedConfiguration.getMergedConfiguration();
                    final Configuration config = mMergedConfiguration.getMergedConfiguration();
                    final Rect maxBounds = new Rect(config.windowConfiguration.getMaxBounds());
                    final Rect maxBounds = config.windowConfiguration.getMaxBounds();
                    if (myWidth == ViewGroup.LayoutParams.MATCH_PARENT
                    if (myWidth == ViewGroup.LayoutParams.MATCH_PARENT
                            && myHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
                            && myHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
                        mLayout.width = myWidth;
                        mLayout.width = myWidth;
@@ -1224,17 +1221,6 @@ public abstract class WallpaperService extends Service {
                    final int relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                    final int relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, 0, 0, mWinFrames, mMergedConfiguration,
                            View.VISIBLE, 0, 0, 0, mWinFrames, mMergedConfiguration,
                            mSurfaceControl, mInsetsState, mTempControls, mSyncSeqIdBundle);
                            mSurfaceControl, mInsetsState, mTempControls, mSyncSeqIdBundle);
                    final Rect outMaxBounds = mMergedConfiguration.getMergedConfiguration()
                            .windowConfiguration.getMaxBounds();
                    if (!outMaxBounds.equals(maxBounds)) {
                        Log.i(TAG, "Retry updateSurface because bounds changed from relayout: "
                                + maxBounds + " -> " + outMaxBounds);
                        mSurfaceHolder.mSurfaceLock.unlock();
                        mDrawingAllowed = false;
                        mCaller.sendMessage(mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
                                redrawNeeded ? 1 : 0));
                        return;
                    }


                    final int transformHint = SurfaceControl.rotationToBufferTransform(
                    final int transformHint = SurfaceControl.rotationToBufferTransform(
                            (mDisplay.getInstallOrientation() + mDisplay.getRotation()) % 4);
                            (mDisplay.getInstallOrientation() + mDisplay.getRotation()) % 4);
@@ -2338,8 +2324,6 @@ public abstract class WallpaperService extends Service {
        final IBinder mWindowToken;
        final IBinder mWindowToken;
        final int mWindowType;
        final int mWindowType;
        final boolean mIsPreview;
        final boolean mIsPreview;
        final AtomicInteger mPendingResizeCount = new AtomicInteger();
        boolean mReportDraw;
        boolean mShownReported;
        boolean mShownReported;
        int mReqWidth;
        int mReqWidth;
        int mReqHeight;
        int mReqHeight;
@@ -2595,7 +2579,11 @@ public abstract class WallpaperService extends Service {
                    mEngine.doCommand(cmd);
                    mEngine.doCommand(cmd);
                } break;
                } break;
                case MSG_WINDOW_RESIZED: {
                case MSG_WINDOW_RESIZED: {
                    handleResized((MergedConfiguration) message.obj, message.arg1 != 0);
                    final boolean reportDraw = message.arg1 != 0;
                    mEngine.updateConfiguration(((MergedConfiguration) message.obj));
                    mEngine.updateSurface(true, false, reportDraw);
                    mEngine.doOffsetsChanged(true);
                    mEngine.scaleAndCropScreenshot();
                } break;
                } break;
                case MSG_WINDOW_MOVED: {
                case MSG_WINDOW_MOVED: {
                    // Do nothing. What does it mean for a Wallpaper to move?
                    // Do nothing. What does it mean for a Wallpaper to move?
@@ -2643,40 +2631,6 @@ public abstract class WallpaperService extends Service {
                    Log.w(TAG, "Unknown message type " + message.what);
                    Log.w(TAG, "Unknown message type " + message.what);
            }
            }
        }
        }

        /**
         * In general this performs relayout for IWindow#resized. If there are several pending
         * (in the message queue) MSG_WINDOW_RESIZED from server side, only the last one will be
         * handled (ignore intermediate states). Note that this procedure cannot be skipped if the
         * configuration is not changed because this is also used to dispatch insets changes.
         */
        private void handleResized(MergedConfiguration config, boolean reportDraw) {
            // The config can be null when retrying for a changed config from relayout, otherwise
            // it is from IWindow#resized which always sends non-null config.
            final int pendingCount = config != null ? mPendingResizeCount.decrementAndGet() : -1;
            if (reportDraw) {
                mReportDraw = true;
            }
            if (pendingCount > 0) {
                if (DEBUG) {
                    Log.d(TAG, "Skip outdated resize, bounds="
                            + config.getMergedConfiguration().windowConfiguration.getMaxBounds()
                            + " pendingCount=" + pendingCount);
                }
                return;
            }
            if (config != null) {
                if (DEBUG) {
                    Log.d(TAG, "Update config from resized, bounds="
                            + config.getMergedConfiguration().windowConfiguration.getMaxBounds());
                }
                mEngine.mMergedConfiguration.setTo(config);
            }
            mEngine.updateSurface(true /* forceRelayout */, false /* forceReport */, mReportDraw);
            mReportDraw = false;
            mEngine.doOffsetsChanged(true);
            mEngine.scaleAndCropScreenshot();
        }
    }
    }


    /**
    /**