diff options
| author | 2020-10-20 18:32:23 -0400 | |
|---|---|---|
| committer | 2020-10-20 18:32:23 -0400 | |
| commit | bee5abf146e13d42dbc2eae9ea957e7daeaae73d (patch) | |
| tree | 75f4eb47a3a89db4d2b796a64b096f0eabef0379 | |
| parent | 56d8e713e90f4f9a5602a969e86b2c66a4c5c696 (diff) | |
Catch IAE on wrapHardwareBuffer
Bug: 157562905
Test: speculative
Change-Id: Ia07e6f64e4426855fd09e3eda9c58c214bbf0b4e
| -rw-r--r-- | packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java index 9d3620f34186..3de0b4b78e06 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/ThumbnailData.java @@ -61,18 +61,28 @@ public class ThumbnailData { snapshotId = 0; } - public ThumbnailData(TaskSnapshot snapshot) { + private static Bitmap makeThumbnail(TaskSnapshot snapshot) { final HardwareBuffer buffer = snapshot.getHardwareBuffer(); - if (buffer == null || (buffer.getUsage() & HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE) == 0) { + Bitmap thumbnail = null; + try { + if (buffer != null) { + thumbnail = Bitmap.wrapHardwareBuffer(buffer, snapshot.getColorSpace()); + } + } catch (IllegalArgumentException ex) { // 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: " - + buffer); + + buffer, ex); + } + if (thumbnail == null) { Point taskSize = snapshot.getTaskSize(); thumbnail = Bitmap.createBitmap(taskSize.x, taskSize.y, ARGB_8888); thumbnail.eraseColor(Color.BLACK); - } else { - thumbnail = Bitmap.wrapHardwareBuffer(buffer, snapshot.getColorSpace()); } + return thumbnail; + } + + public ThumbnailData(TaskSnapshot snapshot) { + thumbnail = makeThumbnail(snapshot); insets = new Rect(snapshot.getContentInsets()); orientation = snapshot.getOrientation(); rotation = snapshot.getRotation(); |