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

Commit be1d460a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revive the old behavior of unsupported filed in public APIs"

parents 67122808 7d3d2aa2
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ 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;
@@ -652,17 +651,12 @@ 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 (IllegalArgumentException e) {
                // To be a compatible behavior with API28 or before, catch IllegalArgumentExcetpion
                // thrown by native code and returns null.
                return null;
            } catch (IOException e) {
                continue;
            }
+5 −12
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.graphics.fonts.FontStyle;
import android.graphics.fonts.FontVariationAxis;
import android.graphics.fonts.SystemFonts;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.ParcelFileDescriptor;
import android.provider.FontRequest;
import android.provider.FontsContract;
@@ -48,7 +47,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;

import dalvik.annotation.optimization.CriticalNative;
import dalvik.system.VMRuntime;

import libcore.util.NativeAllocationRegistry;

@@ -266,16 +264,7 @@ public class Typeface {
                if (familyBuilder == null) {
                    familyBuilder = new FontFamily.Builder(fontBuilder.build());
                } else {
                    try {
                    familyBuilder.addFont(fontBuilder.build());
                    } catch (IllegalArgumentException e) {
                        if (VMRuntime.getRuntime().getTargetSdkVersion() <= VERSION_CODES.P) {
                            // Surpress the IllegalArgumentException for keeping the backward
                            // compatibility.
                            continue;
                        }
                        throw e;
                    }
                }
            }
            if (familyBuilder == null) {
@@ -297,6 +286,10 @@ public class Typeface {
            typeface = new Typeface.CustomFallbackBuilder(family)
                    .setStyle(bestFont.getStyle())
                    .build();
        } catch (IllegalArgumentException e) {
            // To be a compatible behavior with API28 or before, catch IllegalArgumentExcetpion
            // thrown by native code and returns null.
            return null;
        } catch (IOException e) {
            typeface = Typeface.DEFAULT;
        }