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 Merged-In: Ia61809a4dc53317139446d099cfa262c095d2aea
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user