diff options
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskSnapshotPersister.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java index 297e2880a455..b628869c54e5 100644 --- a/services/core/java/com/android/server/wm/TaskSnapshotPersister.java +++ b/services/core/java/com/android/server/wm/TaskSnapshotPersister.java @@ -25,6 +25,7 @@ import android.app.ActivityManager.TaskSnapshot; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.Bitmap.Config; +import android.graphics.GraphicBuffer; import android.os.Process; import android.os.SystemClock; import android.util.ArraySet; @@ -325,6 +326,15 @@ class TaskSnapshotPersister { final File file = getBitmapFile(mTaskId, mUserId); final File reducedFile = getReducedResolutionBitmapFile(mTaskId, mUserId); final Bitmap bitmap = Bitmap.createHardwareBitmap(mSnapshot.getSnapshot()); + if (bitmap == null) { + Slog.e(TAG, "Invalid task snapshot"); + return false; + } else if (bitmap.getWidth() == 0 || bitmap.getHeight() == 0) { + Slog.e(TAG, "Invalid task snapshot dimensions " + bitmap.getWidth() + "x" + + bitmap.getHeight()); + return false; + } + final Bitmap swBitmap = bitmap.copy(Config.ARGB_8888, false /* isMutable */); final Bitmap reduced = Bitmap.createScaledBitmap(swBitmap, (int) (bitmap.getWidth() * REDUCED_SCALE), |