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

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

Adding additional check for zero-sized snapshot.

Bug: 62727429
Test: Not reproducible, just adding check
Change-Id: I1fd5aa43ffb6f211881d5c198c10ee1451666970
parent f69d450b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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),