Fix NPE with Roboletric by returning emptyArray
Previous change I69e21940eaec4427f62abe59ae003b4f60855f22
did not handle the case of missing /system/etc/fonts.xml
This happens on roboletric test and crash with NPE.
Bug: 112843740
Test: N/A
Change-Id: I6d183dab9af66abf777f2e5b1fa633ff979fea55
diff --git a/graphics/java/android/graphics/fonts/SystemFonts.java b/graphics/java/android/graphics/fonts/SystemFonts.java
index dae48f8..26b4ec5 100644
--- a/graphics/java/android/graphics/fonts/SystemFonts.java
+++ b/graphics/java/android/graphics/fonts/SystemFonts.java
@@ -24,6 +24,7 @@
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.ArrayUtils;
import org.xmlpull.v1.XmlPullParserException;
@@ -251,7 +252,7 @@
return fontConfig.getAliases();
} catch (IOException | XmlPullParserException e) {
Log.e(TAG, "Failed initialize system fallbacks.", e);
- return null;
+ return ArrayUtils.emptyArray(FontConfig.Alias.class);
}
}