Merge "Restricted Context layout font loading in TextView" into oc-dev
am: 7f90a9fdb0
Change-Id: I32a8e9e627e0b78b22c87b11483e744486e16944
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index eee70e0..629216e 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -912,10 +912,13 @@
break;
case com.android.internal.R.styleable.TextAppearance_fontFamily:
- try {
- fontTypeface = appearance.getFont(attr);
- } catch (UnsupportedOperationException | Resources.NotFoundException e) {
- // Expected if it is not a font resource.
+ if (!context.isRestricted()) {
+ try {
+ fontTypeface = appearance.getFont(attr);
+ } catch (UnsupportedOperationException
+ | Resources.NotFoundException e) {
+ // Expected if it is not a font resource.
+ }
}
if (fontTypeface == null) {
fontFamily = appearance.getString(attr);
@@ -1229,11 +1232,13 @@
break;
case com.android.internal.R.styleable.TextView_fontFamily:
- try {
- fontTypeface = a.getFont(attr);
- } catch (UnsupportedOperationException | Resources.NotFoundException e) {
- // Expected if it is not a resource reference or if it is a reference to
- // another resource type.
+ if (!context.isRestricted()) {
+ try {
+ fontTypeface = a.getFont(attr);
+ } catch (UnsupportedOperationException | Resources.NotFoundException e) {
+ // Expected if it is not a resource reference or if it is a reference to
+ // another resource type.
+ }
}
if (fontTypeface == null) {
fontFamily = a.getString(attr);
@@ -3380,10 +3385,12 @@
Typeface fontTypeface = null;
String fontFamily = null;
- try {
- fontTypeface = ta.getFont(R.styleable.TextAppearance_fontFamily);
- } catch (UnsupportedOperationException | Resources.NotFoundException e) {
- // Expected if it is not a font resource.
+ if (!context.isRestricted()) {
+ try {
+ fontTypeface = ta.getFont(R.styleable.TextAppearance_fontFamily);
+ } catch (UnsupportedOperationException | Resources.NotFoundException e) {
+ // Expected if it is not a font resource.
+ }
}
if (fontTypeface == null) {
fontFamily = ta.getString(R.styleable.TextAppearance_fontFamily);