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

Commit e18aa866 authored by Winson Chung's avatar Winson Chung
Browse files

Tweaking workaround to use fallback with null buffer

- This case still shouldn't ever happen, but we're still
  getting crashes. It looks like the call to wrapHardwareBuffer
  will always create a hw buffer even if the graphic buffer
  is null, and the internal call to wrap the hw buffer may
  not have the flags if a null buffer is provided.

Bug: 157562905
Test: Haven't been able to reproduce
Change-Id: Ia61809a4dc53317139446d099cfa262c095d2aea
parent 8694c4b8
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_
import android.app.ActivityManager.TaskSnapshot;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.HardwareBuffer;
import android.util.Log;
@@ -62,10 +63,12 @@ public class ThumbnailData {

    public ThumbnailData(TaskSnapshot snapshot) {
        final HardwareBuffer buffer = snapshot.getHardwareBuffer();
        if (buffer != null && (buffer.getUsage() & HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE) == 0) {
        if (buffer == null || (buffer.getUsage() & HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE) == 0) {
            // TODO(b/157562905): Workaround for a crash when we get a snapshot without this state
            Log.e("ThumbnailData", "Unexpected snapshot without USAGE_GPU_SAMPLED_IMAGE");
            thumbnail = Bitmap.createBitmap(buffer.getWidth(), buffer.getHeight(), ARGB_8888);
            Log.e("ThumbnailData", "Unexpected snapshot without USAGE_GPU_SAMPLED_IMAGE: "
                    + buffer);
            Point taskSize = snapshot.getTaskSize();
            thumbnail = Bitmap.createBitmap(taskSize.x, taskSize.y, ARGB_8888);
            thumbnail.eraseColor(Color.BLACK);
        } else {
            thumbnail = Bitmap.wrapHardwareBuffer(buffer, snapshot.getColorSpace());