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

Commit eb8c2e81 authored by Aurélien Pomini's avatar Aurélien Pomini Committed by Android (Google) Code Review
Browse files

Merge "Fix wallpaper dim race condition" into main

parents da692d34 e2777eaf
Loading
Loading
Loading
Loading
+35 −28
Original line number Diff line number Diff line
@@ -325,6 +325,7 @@ public abstract class WallpaperService extends Service {
        IWindowSession mSession;

        final Object mLock = new Object();
        private final Object mSurfaceReleaseLock = new Object();
        boolean mOffsetMessageEnqueued;

        @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
@@ -1075,10 +1076,12 @@ public abstract class WallpaperService extends Service {
                animator.setDuration(DIMMING_ANIMATION_DURATION_MS);
                animator.addUpdateListener((ValueAnimator va) -> {
                    final float dimValue = (float) va.getAnimatedValue();
                    if (mBbqSurfaceControl != null) {
                    synchronized (mSurfaceReleaseLock) {
                        if (mBbqSurfaceControl != null && mBbqSurfaceControl.isValid()) {
                            surfaceControlTransaction
                                    .setAlpha(mBbqSurfaceControl, 1 - dimValue).apply();
                        }
                    }
                });
                animator.addListener(new AnimatorListenerAdapter() {
                    @Override
@@ -2356,10 +2359,13 @@ public abstract class WallpaperService extends Service {
            if (DEBUG) Log.v(TAG, "onDestroy(): " + this);
            onDestroy();

            synchronized (mSurfaceReleaseLock) {
                if (mCreated) {
                    try {
                    if (DEBUG) Log.v(TAG, "Removing window and destroying surface "
                        if (DEBUG) {
                            Log.v(TAG, "Removing window and destroying surface "
                                    + mSurfaceHolder.getSurface() + " of: " + this);
                        }

                        if (mInputEventReceiver != null) {
                            mInputEventReceiver.dispose();
@@ -2387,6 +2393,7 @@ public abstract class WallpaperService extends Service {
                    mRelayoutResult = null;
                }
            }
        }

        private final DisplayListener mDisplayListener =
                new DisplayListener() {