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

Commit 50b5b6da authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Fix crash in TaskSnapshot#toString

The toString of TaskSnapshot is reading the width and height of
mSnapshot without checking if it wasn't closed. This can lead to
exceptions when printing out this object.

Flag: EXEMPT bugfix
Test: n/a
Bug: 281029564
Change-Id: Ia9ba5e8aa3aa442a6d1f1ceaf0bdd712a070e6de
parent bfe2c0c9
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -327,13 +327,20 @@ public class TaskSnapshot implements Parcelable {


    @Override
    @Override
    public String toString() {
    public String toString() {
        final int width = mSnapshot != null ? mSnapshot.getWidth() : 0;
        final String snapshotString;
        final int height = mSnapshot != null ? mSnapshot.getHeight() : 0;
        if (mSnapshot == null) {
            snapshotString = "null";
        } else if (mSnapshot.isClosed()) {
            snapshotString = "closed";
        } else {
            snapshotString = mSnapshot + " (" + mSnapshot.getWidth() + "x" + mSnapshot.getHeight()
                    + ")";
        }
        return "TaskSnapshot{"
        return "TaskSnapshot{"
                + " mId=" + mId
                + " mId=" + mId
                + " mCaptureTime=" + mCaptureTime
                + " mCaptureTime=" + mCaptureTime
                + " mTopActivityComponent=" + mTopActivityComponent.flattenToShortString()
                + " mTopActivityComponent=" + mTopActivityComponent.flattenToShortString()
                + " mSnapshot=" + mSnapshot + " (" + width + "x" + height + ")"
                + " mSnapshot=" + snapshotString
                + " mColorSpace=" + mColorSpace.toString()
                + " mColorSpace=" + mColorSpace.toString()
                + " mOrientation=" + mOrientation
                + " mOrientation=" + mOrientation
                + " mRotation=" + mRotation
                + " mRotation=" + mRotation