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

Commit 2a424a7b authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Suppress IllegalArgumentException on API 28 or before

Bug: 119432246
Test: N/A
Change-Id: I7fba3e4d21fc895dfee4300db7d7e3000095ff92
parent 5af6efd9
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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 {
                    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;