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

Commit 5be32a1c authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Tweaking workaround to use fallback with null buffer" into rvc-dev

parents 997a3c73 69aebfc9
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.app.ActivityManager.TaskSnapshot;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.GraphicBuffer;
import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.HardwareBuffer;
import android.util.Log;
@@ -63,10 +64,12 @@ public class ThumbnailData {

    public ThumbnailData(TaskSnapshot snapshot) {
        final GraphicBuffer buffer = snapshot.getSnapshot();
        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());