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

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

Merge "Cleanup flag fix_image_wallpaper_crash_surface_already_released" into main

parents f55b2b0e 70259cbb
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -555,16 +555,6 @@ flag {
   bug: "335828150"
}

flag {
  name: "fix_image_wallpaper_crash_surface_already_released"
  namespace: "systemui"
  description: "Make sure ImageWallpaper doesn't return from OnSurfaceDestroyed until any drawing is finished"
  bug: "337287154"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
   name: "activity_transition_use_largest_window"
   namespace: "systemui"
+10 −38
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.app.WallpaperManager.FLAG_LOCK;
import static android.app.WallpaperManager.FLAG_SYSTEM;
import static android.app.WallpaperManager.SetWallpaperFlags;

import static com.android.systemui.Flags.fixImageWallpaperCrashSurfaceAlreadyReleased;
import static com.android.window.flags.Flags.multiCrop;
import static com.android.window.flags.Flags.offloadColorExtraction;

@@ -240,19 +239,9 @@ public class ImageWallpaper extends WallpaperService {
            if (DEBUG) {
                Log.i(TAG, "onSurfaceDestroyed");
            }
            if (fixImageWallpaperCrashSurfaceAlreadyReleased()) {
            synchronized (mSurfaceLock) {
                mSurfaceHolder = null;
            }
                return;
            }
            mLongExecutor.execute(this::onSurfaceDestroyedSynchronized);
        }

        private void onSurfaceDestroyedSynchronized() {
            synchronized (mLock) {
                mSurfaceHolder = null;
            }
        }

        @Override
@@ -282,16 +271,10 @@ public class ImageWallpaper extends WallpaperService {
        }

        private void drawFrameInternal() {
            if (mSurfaceHolder == null && !fixImageWallpaperCrashSurfaceAlreadyReleased()) {
                Log.i(TAG, "attempt to draw a frame without a valid surface");
                return;
            }

            // load the wallpaper if not already done
            if (!isBitmapLoaded()) {
                loadWallpaperAndDrawFrameInternal();
            } else {
                if (fixImageWallpaperCrashSurfaceAlreadyReleased()) {
                synchronized (mSurfaceLock) {
                    if (mSurfaceHolder == null) {
                        Log.i(TAG, "Surface released before the image could be drawn");
@@ -301,14 +284,8 @@ public class ImageWallpaper extends WallpaperService {
                    drawFrameOnCanvas(mBitmap);
                    reportEngineShown(false);
                    unloadBitmapIfNotUsedInternal();
                        return;
                }
            }
                mBitmapUsages++;
                drawFrameOnCanvas(mBitmap);
                reportEngineShown(false);
                unloadBitmapIfNotUsedInternal();
            }
        }

        @VisibleForTesting
@@ -364,14 +341,9 @@ public class ImageWallpaper extends WallpaperService {
                mBitmap.recycle();
            }
            mBitmap = null;
            if (fixImageWallpaperCrashSurfaceAlreadyReleased()) {
            synchronized (mSurfaceLock) {
                if (mSurfaceHolder != null) mSurfaceHolder.getSurface().hwuiDestroy();
            }
            } else {
                final Surface surface = getSurfaceHolder().getSurface();
                surface.hwuiDestroy();
            }
            mWallpaperManager.forgetLoadedWallpaper();
            Trace.endSection();
        }