Merge "Update signature of FontManager#updateFontFile()." into sc-dev
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 536d3b6..f330a93 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -2852,7 +2852,8 @@
   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 2a9b318..86fe8c3 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -838,7 +838,8 @@
   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 f087dd0..e512cf1 100644
--- a/core/java/android/graphics/fonts/FontManager.java
+++ b/core/java/android/graphics/fonts/FontManager.java
@@ -208,42 +208,40 @@
     }
 
     /**
-     * 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.
+     * <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 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.
+     * @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 @@
      * @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