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

Commit cafdea61 authored by Romain Guy's avatar Romain Guy
Browse files

Fixes #1914574. An NPE could be causes in lists by ViewGroup.dispatchDraw().

ViewGroup was trying to access the AttachInfo without checking whether the
info object is null. The object can be null at varioous times in the lifecycle
of a list.
parent 763a5723
Loading
Loading
Loading
Loading
+70 −69
Original line number Diff line number Diff line
@@ -229,9 +229,10 @@ public final class MotionEvent implements Parcelable {
                float[] history = mHistory;
                int length = history.length;
                for (int i = 0; i < length; i += 4) {
                    history[i] *= scale;
                    history[i + 2] *= scale;
                    history[i + 3] *= scale;
                    history[i] *= scale;        // X
                                                // history[i + 2] == pressure
                    history[i + 1] *= scale;    // Y
                    history[i + 3] *= scale;    // Size, TODO: square this?
                }
            }
        }
+2 −1
Original line number Diff line number Diff line
@@ -1449,7 +1449,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        if ((flags & FLAG_CHILDREN_DRAWN_WITH_CACHE) == FLAG_CHILDREN_DRAWN_WITH_CACHE ||
                (flags & FLAG_ALWAYS_DRAWN_WITH_CACHE) == FLAG_ALWAYS_DRAWN_WITH_CACHE) {
            cache = child.getDrawingCache();
            scalingRequired = mAttachInfo.mScalingRequired;
            if (mAttachInfo != null) scalingRequired = mAttachInfo.mScalingRequired;
        }

        final boolean hasNoCache = cache == null;
@@ -1460,6 +1460,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        } else {
            canvas.translate(cl, ct);
            if (scalingRequired) {
                // mAttachInfo cannot be null, otherwise scalingRequired == false
                final float scale = 1.0f / mAttachInfo.mApplicationScale;
                canvas.scale(scale, scale);
            }