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

Commit e852d199 authored by Diego Perez's avatar Diego Perez
Browse files

Fix NPE when using "view" tag without class attribute

Bug: http://b.android.com/209830
Change-Id: I0c2a10501ae82588623bfba049155f4956f9907f
(cherry picked from commit 9ab38b560cc781536c1d0863cfa7fa8f7ec74cae)
parent 4a1bd499
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -144,9 +144,26 @@ public final class BridgeInflater extends LayoutInflater {
    @Override
    public View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
            boolean ignoreThemeAttr) {
        View view;
        View view = null;
        if (name.equals("view")) {
            // This is usually done by the superclass but this allows us catching the error and
            // reporting something useful.
            name = attrs.getAttributeValue(null, "class");

            if (name == null) {
                Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Unable to inflate view tag without " +
                  "class attribute", null);
                // We weren't able to resolve the view so we just pass a mock View to be able to
                // continue rendering.
                view = new MockView(context, attrs);
                ((MockView) view).setText("view");
            }
        }

        try {
            if (view == null) {
                view = super.createViewFromTag(parent, name, context, attrs, ignoreThemeAttr);
            }
        } catch (InflateException e) {
            // Creation of ContextThemeWrapper code is same as in the super method.
            // Apply a theme wrapper, if allowed and one is specified.
@@ -240,6 +257,9 @@ public final class BridgeInflater extends LayoutInflater {
            // first get the classname in case it's not the node name
            if (name.equals("view")) {
                name = attrs.getAttributeValue(null, "class");
                if (name == null) {
                    return null;
                }
            }

            mConstructorArgs[1] = attrs;