From 1681aa2eeb486e105341a5af09bf5af9263ed884 Mon Sep 17 00:00:00 2001 From: joehsu Date: Wed, 12 May 2021 14:15:06 +0800 Subject: [PATCH] Check FontFamily null before adding it. Missing ttf files under /product/fonts will cause NullPointerException. This CL fixes it. Bug: 187901462 Test: Flash Sabrina to Android S. Boot to check if there's still an error. Change-Id: I9d39c2a6e4730563f35f43176f630ac0439767b3 --- .../android/graphics/fonts/FontCustomizationParser.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphics/java/android/graphics/fonts/FontCustomizationParser.java b/graphics/java/android/graphics/fonts/FontCustomizationParser.java index 9c01a4be381f5..df47f73eb04a7 100644 --- a/graphics/java/android/graphics/fonts/FontCustomizationParser.java +++ b/graphics/java/android/graphics/fonts/FontCustomizationParser.java @@ -134,7 +134,11 @@ public class FontCustomizationParser { throw new IllegalArgumentException("customizationType must be specified"); } if (customizationType.equals("new-named-family")) { - out.add(FontListParser.readFamily(parser, fontDir, updatableFontMap, false)); + FontFamily fontFamily = FontListParser.readFamily( + parser, fontDir, updatableFontMap, false); + if (fontFamily != null) { + out.add(fontFamily); + } } else { throw new IllegalArgumentException("Unknown customizationType=" + customizationType); }