diff options
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/provider/FontsContract.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/provider/FontsContract.java b/core/java/android/provider/FontsContract.java index e9ef770212c8..b410cbdbc7f1 100644 --- a/core/java/android/provider/FontsContract.java +++ b/core/java/android/provider/FontsContract.java @@ -283,6 +283,12 @@ public class FontsContract { */ public static final int STATUS_UNEXPECTED_DATA_PROVIDED = 2; + /** + * Constant represents that the fetching font data was rejected by system. This happens if + * the passed context is restricted. + */ + public static final int STATUS_REJECTED = 3; + /** @hide */ @IntDef({STATUS_OK, STATUS_WRONG_CERTIFICATES, STATUS_UNEXPECTED_DATA_PROVIDED}) @Retention(RetentionPolicy.SOURCE) @@ -555,6 +561,10 @@ public class FontsContract { public static @NonNull FontFamilyResult fetchFonts( @NonNull Context context, @Nullable CancellationSignal cancellationSignal, @NonNull FontRequest request) throws NameNotFoundException { + if (context.isRestricted()) { + // TODO: Should we allow if the peer process is system or myself? + return new FontFamilyResult(FontFamilyResult.STATUS_REJECTED, null); + } ProviderInfo providerInfo = getProvider(context.getPackageManager(), request); if (providerInfo == null) { return new FontFamilyResult(FontFamilyResult.STATUS_WRONG_CERTIFICATES, null); @@ -590,6 +600,10 @@ public class FontsContract { public static Typeface buildTypeface(@NonNull Context context, @Nullable CancellationSignal cancellationSignal, @NonNull FontInfo[] fonts, int weight, boolean italic, @Nullable String fallbackFontName) { + if (context.isRestricted()) { + // TODO: Should we allow if the peer process is system or myself? + return null; + } final Map<Uri, ByteBuffer> uriBuffer = prepareFontData(context, fonts, cancellationSignal); return new Typeface.Builder(fonts, uriBuffer) @@ -613,6 +627,10 @@ public class FontsContract { */ public static Typeface buildTypeface(@NonNull Context context, @Nullable CancellationSignal cancellationSignal, @NonNull FontInfo[] fonts) { + if (context.isRestricted()) { + // TODO: Should we allow if the peer process is system or myself? + return null; + } final Map<Uri, ByteBuffer> uriBuffer = prepareFontData(context, fonts, cancellationSignal); return new Typeface.Builder(fonts, uriBuffer).build(); |
