diff options
-rw-r--r-- | core/api/system-current.txt | 3 | ||||
-rw-r--r-- | core/api/test-current.txt | 3 | ||||
-rw-r--r-- | core/java/android/graphics/fonts/FontManager.java | 70 |
3 files changed, 44 insertions, 32 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 536d3b6599cc..f330a9355cfb 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -2852,7 +2852,8 @@ package android.graphics.fonts { public class FontManager { method @Nullable public android.text.FontConfig getFontConfig(); method @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFamily(@NonNull android.graphics.fonts.FontFamilyUpdateRequest, @IntRange(from=0) int); - method @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFile(@NonNull android.os.ParcelFileDescriptor, @NonNull byte[], @IntRange(from=0) int); + method @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFile(@NonNull android.graphics.fonts.FontFileUpdateRequest, @IntRange(from=0) int); + method @Deprecated @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFile(@NonNull android.os.ParcelFileDescriptor, @NonNull byte[], @IntRange(from=0) int); field public static final int RESULT_ERROR_DOWNGRADING = -5; // 0xfffffffb field public static final int RESULT_ERROR_FAILED_TO_WRITE_FONT_FILE = -1; // 0xffffffff field public static final int RESULT_ERROR_FAILED_UPDATE_CONFIG = -6; // 0xfffffffa diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 2a9b31833087..86fe8c30ca22 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -838,7 +838,8 @@ package android.graphics.fonts { public class FontManager { method @Nullable public android.text.FontConfig getFontConfig(); method @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFamily(@NonNull android.graphics.fonts.FontFamilyUpdateRequest, @IntRange(from=0) int); - method @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFile(@NonNull android.os.ParcelFileDescriptor, @NonNull byte[], @IntRange(from=0) int); + method @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFile(@NonNull android.graphics.fonts.FontFileUpdateRequest, @IntRange(from=0) int); + method @Deprecated @RequiresPermission(android.Manifest.permission.UPDATE_FONTS) public int updateFontFile(@NonNull android.os.ParcelFileDescriptor, @NonNull byte[], @IntRange(from=0) int); field public static final int RESULT_ERROR_DOWNGRADING = -5; // 0xfffffffb field public static final int RESULT_ERROR_FAILED_TO_WRITE_FONT_FILE = -1; // 0xffffffff field public static final int RESULT_ERROR_FAILED_UPDATE_CONFIG = -6; // 0xfffffffa diff --git a/core/java/android/graphics/fonts/FontManager.java b/core/java/android/graphics/fonts/FontManager.java index f087dd075816..e512cf1bbb1f 100644 --- a/core/java/android/graphics/fonts/FontManager.java +++ b/core/java/android/graphics/fonts/FontManager.java @@ -208,42 +208,40 @@ public class FontManager { } /** - * Update system installed font file. + * Update a system installed font file. * * <p> - * To protect devices, system font updater relies on the Linux Kernel feature called fs-verity. - * If the device is not ready for fs-verity, {@link #RESULT_ERROR_FONT_UPDATER_DISABLED} will be + * To protect devices, system font updater relies on a Linux Kernel feature called fs-verity. + * If the device does not support fs-verity, {@link #RESULT_ERROR_FONT_UPDATER_DISABLED} will be * returned. * - * Android only accepts OpenType compliant font files. If other font files are provided, + * <p>Android only accepts OpenType compliant font files. If other font files are provided, * {@link #RESULT_ERROR_INVALID_FONT_FILE} will be returned. * - * The font file to be updated is identified by PostScript name stored in name table. If the - * font file doesn't have PostScript name entry, {@link #RESULT_ERROR_INVALID_FONT_NAME} will be - * returned. + * <p>The font file to be updated is identified by PostScript name stored in the name table. If + * the font file doesn't have PostScript name entry, {@link #RESULT_ERROR_INVALID_FONT_NAME} + * will be returned. * - * The entire font file is verified with the given signature for the system installed - * certificate. If the system cannot verify the font contents, + * <p>The entire font file is verified with the given signature using system installed + * certificates. If the system cannot verify the font file contents, * {@link #RESULT_ERROR_VERIFICATION_FAILURE} will be returned. * - * The font file must have newer or equal revision number in the head table. In other words, the - * downgrading font file is not allowed. If the older font file is provided, + * <p>The font file must have a newer revision number in the head table. In other words, it is + * not allowed to downgrade a font file. If an older font file is provided, * {@link #RESULT_ERROR_DOWNGRADING} will be returned. * - * The caller must specify the base config version for keeping consist system configuration. If - * the system configuration is updated for some reason between you get config with - * {@link #getFontConfig()} and calling this method, {@link #RESULT_ERROR_VERSION_MISMATCH} will - * be returned. Get the latest font configuration by calling {@link #getFontConfig()} again and - * try with the latest config version again. - * - * @param pfd A file descriptor of the font file. - * @param signature A PKCS#7 detached signature for verifying entire font files. - * @param baseVersion A base config version to be updated. You can get latest config version by - * {@link FontConfig#getConfigVersion()} via {@link #getFontConfig()}. If the - * system has newer config version, the update will fail with - * {@link #RESULT_ERROR_VERSION_MISMATCH}. Try to get the latest config and - * try update again. - * @return result code. + * <p>The caller must specify the base config version for keeping the font configuration + * consistent. If the font configuration is updated for some reason between the time you get + * a configuration with {@link #getFontConfig()} and the time when you call this method, + * {@link #RESULT_ERROR_VERSION_MISMATCH} will be returned. Get the latest font configuration by + * calling {@link #getFontConfig()} and call this method again with the latest config version. + * + * @param request A {@link FontFileUpdateRequest} to execute. + * @param baseVersion A base config version to be updated. You can get the latest config version + * by {@link FontConfig#getConfigVersion()} via {@link #getFontConfig()}. If + * the system has a newer config version, the update will fail with + * {@link #RESULT_ERROR_VERSION_MISMATCH}. + * @return A result code. * * @see FontConfig#getConfigVersion() * @see #getFontConfig() @@ -258,18 +256,30 @@ public class FontManager { * @see #RESULT_ERROR_FONT_UPDATER_DISABLED */ @RequiresPermission(Manifest.permission.UPDATE_FONTS) public @ResultCode int updateFontFile( - @NonNull ParcelFileDescriptor pfd, - @NonNull byte[] signature, - @IntRange(from = 0) int baseVersion - ) { + @NonNull FontFileUpdateRequest request, @IntRange(from = 0) int baseVersion) { try { - return mIFontManager.updateFontFile(new FontUpdateRequest(pfd, signature), baseVersion); + return mIFontManager.updateFontFile(new FontUpdateRequest( + request.getParcelFileDescriptor(), request.getSignature()), baseVersion); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** + * @deprecated Use {@link #updateFontFile(FontFileUpdateRequest, int)} + */ + // TODO: Remove this API before Developer Preview 3. + @Deprecated + @RequiresPermission(Manifest.permission.UPDATE_FONTS) public @ResultCode int updateFontFile( + @NonNull ParcelFileDescriptor pfd, + @NonNull byte[] signature, + @IntRange(from = 0) int baseVersion + ) { + return updateFontFile(new FontFileUpdateRequest(pfd, signature), baseVersion); + } + + + /** * Update or add system wide font families. * * <p>This method will update existing font families or add new font families. The updated |