diff options
| author | 2019-01-17 21:59:36 +0000 | |
|---|---|---|
| committer | 2019-01-17 21:59:36 +0000 | |
| commit | 68f90d0ecc76cb96114d205b9b6763ae1088ca62 (patch) | |
| tree | 93b11911be00359368834e34dd5cc90afdd98050 | |
| parent | 70cf6e8b23ef7232603a24cc1d24ba6470a9edab (diff) | |
| parent | 2a424a7be3473d5d6b1084a781f5f64840408d49 (diff) | |
Merge "Suppress IllegalArgumentException on API 28 or before"
| -rw-r--r-- | core/java/android/provider/FontsContract.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/core/java/android/provider/FontsContract.java b/core/java/android/provider/FontsContract.java index 8e37559001db..e931826d2455 100644 --- a/core/java/android/provider/FontsContract.java +++ b/core/java/android/provider/FontsContract.java @@ -34,6 +34,7 @@ import android.graphics.fonts.FontFamily; import android.graphics.fonts.FontStyle; import android.graphics.fonts.FontVariationAxis; import android.net.Uri; +import android.os.Build.VERSION_CODES; import android.os.CancellationSignal; import android.os.Handler; import android.os.HandlerThread; @@ -651,7 +652,16 @@ public class FontsContract { if (familyBuilder == null) { familyBuilder = new FontFamily.Builder(font); } else { - familyBuilder.addFont(font); + try { + familyBuilder.addFont(font); + } catch (IllegalArgumentException e) { + if (context.getApplicationInfo().targetSdkVersion <= VERSION_CODES.P) { + // Surpress the IllegalArgumentException for keeping the backward + // compatibility. + continue; + } + throw e; + } } } catch (IOException e) { continue; |