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

Commit bf629ed0 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Fix boot loop issue on Android Wear.

The boot loop was seen after I65e220aca823fd815a52437b11c8e6dc952de8e2
but only on Android Wear. On Android Wear, some font files are missing
but are listed in fonts.xml. Before that patch, we created a Typeface
object with an empty FontFamily even if there was no valid font entry
in font-family tag. However, after that patch, FontFamily stopped
creating native objects and holds a null pointer instead. As the
result, SIGSEGV happens.

The right fix is skipping Typeface creation if native code failed to
create the font family object.

Since Typeface.init cannot be called twice, this is hard to test
automatically.

Bug: 37328609
Bug: 37326002
Test: Boot succeeded even after removing CutiveMono.ttf from system.

Change-Id: I125de07343252784986d728c3bbaa46b24ace601
parent 92fc8bdd
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1112,6 +1112,7 @@ public class Typeface {
            // Treat as system error since reaching here means that a system pre-installed font
            // can't be used by our font stack.
            Log.e(TAG, "Unable to load Family: " + family.getName() + ":" + family.getLanguage());
            return null;
        }
        return fontFamily;
    }
@@ -1137,7 +1138,10 @@ public class Typeface {
            for (int i = 0; i < fontConfig.getFamilies().length; i++) {
                FontConfig.Family f = fontConfig.getFamilies()[i];
                if (i == 0 || f.getName() == null) {
                    familyList.add(makeFamilyFromParsed(f, bufferForPath));
                    FontFamily family = makeFamilyFromParsed(f, bufferForPath);
                    if (family != null) {
                        familyList.add(family);
                    }
                }
            }
            sFallbackFonts = familyList.toArray(new FontFamily[familyList.size()]);
@@ -1154,6 +1158,9 @@ public class Typeface {
                        typeface = sDefaultTypeface;
                    } else {
                        FontFamily fontFamily = makeFamilyFromParsed(f, bufferForPath);
                        if (fontFamily == null) {
                            continue;
                        }
                        FontFamily[] families = { fontFamily };
                        typeface = Typeface.createFromFamiliesWithDefault(families);
                    }