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

Commit ff2099c9 authored by Kohsuke Yatoh's avatar Kohsuke Yatoh
Browse files

Update signature of FontManager#updateFontFile().

Bug: 179103383
Test: atest CtsGraphicsTestCases:FontManagerTest
Change-Id: If8aa02cd6264902058871ef9f0395c2233651650
parent c2008e8a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2844,7 +2844,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
+2 −1
Original line number Diff line number Diff line
@@ -837,7 +837,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
+40 −30
Original line number Diff line number Diff line
@@ -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,17 +256,29 @@ 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.
     *