summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2021-01-26 00:52:39 -0800
committerSeigo Nonaka <nona@google.com>2021-01-27 22:59:06 +0000
commit9387e7f4cda0f24eb88231254c1929b400df8935 (patch)
tree05ecbe98262512a3163e65cdd1a67e47ae4e27b0 /core/java/android
parent9ce7fe21528450722379660cd8f7b1a4aca67672 (diff)
Add more shell command for font
Bug: 173619554 Test: atest UpdatableFontDirTest PersistentSystemFontConfigTest FontManagerTest Change-Id: I25917fa9e8c42742f74222f25c5ba68d96a2c2fd
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/graphics/fonts/FontManager.java113
-rw-r--r--core/java/android/text/FontConfig.java33
2 files changed, 144 insertions, 2 deletions
diff --git a/core/java/android/graphics/fonts/FontManager.java b/core/java/android/graphics/fonts/FontManager.java
index ea6cf2f44be9..eca56b375dd4 100644
--- a/core/java/android/graphics/fonts/FontManager.java
+++ b/core/java/android/graphics/fonts/FontManager.java
@@ -16,6 +16,7 @@
package android.graphics.fonts;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
@@ -28,6 +29,8 @@ import android.util.Log;
import com.android.internal.graphics.fonts.IFontManager;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
/**
@@ -41,6 +44,116 @@ public class FontManager {
private static final String TAG = "FontManager";
private final @NonNull IFontManager mIFontManager;
+ /** @hide */
+ @IntDef(prefix = "ERROR_CODE_",
+ value = { ERROR_CODE_OK, ERROR_CODE_FAILED_TO_WRITE_FONT_FILE,
+ ERROR_CODE_VERIFICATION_FAILURE, ERROR_CODE_FONT_NAME_MISMATCH,
+ ERROR_CODE_INVALID_FONT_FILE, ERROR_CODE_MISSING_POST_SCRIPT_NAME,
+ ERROR_CODE_DOWNGRADING, ERROR_CODE_FAILED_TO_CREATE_CONFIG_FILE,
+ ERROR_CODE_FONT_UPDATER_DISABLED })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ErrorCode {}
+
+ /**
+ * Indicates an operation has processed successfully.
+ * @hide
+ */
+ public static final int ERROR_CODE_OK = 0;
+
+ /**
+ * Indicates a failure of writing font files.
+ * @hide
+ */
+ public static final int ERROR_CODE_FAILED_TO_WRITE_FONT_FILE = -1;
+
+ /**
+ * Indicates a failure of fs-verity setup.
+ * @hide
+ */
+ public static final int ERROR_CODE_VERIFICATION_FAILURE = -2;
+
+ /**
+ * Indicates a failure of verifying the font name with PostScript name.
+ * @hide
+ */
+ public static final int ERROR_CODE_FONT_NAME_MISMATCH = -3;
+
+ /**
+ * Indicates a failure of placing fonts due to unexpected font contents.
+ * @hide
+ */
+ public static final int ERROR_CODE_INVALID_FONT_FILE = -4;
+
+ /**
+ * Indicates a failure due to missing PostScript name in name table.
+ * @hide
+ */
+ public static final int ERROR_CODE_MISSING_POST_SCRIPT_NAME = -5;
+
+ /**
+ * Indicates a failure of placing fonts due to downgrading.
+ * @hide
+ */
+ public static final int ERROR_CODE_DOWNGRADING = -6;
+
+ /**
+ * Indicates a failure of writing system font configuration XML file.
+ * @hide
+ */
+ public static final int ERROR_CODE_FAILED_TO_CREATE_CONFIG_FILE = -7;
+
+ /**
+ * Indicates a failure due to disabled font updater.
+ * @hide
+ */
+ public static final int ERROR_CODE_FONT_UPDATER_DISABLED = -8;
+
+ /**
+ * Indicates a failure of opening font file.
+ *
+ * This error code is only used with the shell command interaction.
+ *
+ * @hide
+ */
+ public static final int ERROR_CODE_FAILED_TO_OPEN_FONT_FILE = -10001;
+
+ /**
+ * Indicates a failure of opening signature file.
+ *
+ * This error code is only used with the shell command interaction.
+ *
+ * @hide
+ */
+ public static final int ERROR_CODE_FAILED_TO_OPEN_SIGNATURE_FILE = -10002;
+
+ /**
+ * Indicates a failure of invalid shell command arguments.
+ *
+ * This error code is only used with the shell command interaction.
+ *
+ * @hide
+ */
+ public static final int ERROR_CODE_INVALID_SHELL_ARGUMENT = -10003;
+
+ /**
+ * Indicates a failure of reading signature file.
+ *
+ * This error code is only used with the shell command interaction.
+ *
+ * @hide
+ */
+ public static final int ERROR_CODE_INVALID_SIGNATURE_FILE = -10004;
+
+ /**
+ * Indicates a failure due to exceeding allowed signature file size (8kb).
+ *
+ * This error code is only used with the shell command interaction.
+ *
+ * @hide
+ */
+ public static final int ERROR_CODE_SIGNATURE_TOO_LARGE = -10005;
+
+
private FontManager(@NonNull IFontManager iFontManager) {
mIFontManager = iFontManager;
}
diff --git a/core/java/android/text/FontConfig.java b/core/java/android/text/FontConfig.java
index 82d7399c86e0..53fe1ba9c4b4 100644
--- a/core/java/android/text/FontConfig.java
+++ b/core/java/android/text/FontConfig.java
@@ -53,6 +53,8 @@ import java.util.List;
public final class FontConfig implements Parcelable {
private final @NonNull List<FontFamily> mFamilies;
private final @NonNull List<Alias> mAliases;
+ private final long mLastModifiedDate;
+ private final int mConfigVersion;
/**
* Construct a FontConfig instance.
@@ -62,9 +64,12 @@ public final class FontConfig implements Parcelable {
*
* @hide Only system server can create this instance and passed via IPC.
*/
- public FontConfig(@NonNull List<FontFamily> families, @NonNull List<Alias> aliases) {
+ public FontConfig(@NonNull List<FontFamily> families, @NonNull List<Alias> aliases,
+ long lastModifiedDate, @IntRange(from = 0) int configVersion) {
mFamilies = families;
mAliases = aliases;
+ mLastModifiedDate = lastModifiedDate;
+ mConfigVersion = configVersion;
}
/**
@@ -88,6 +93,26 @@ public final class FontConfig implements Parcelable {
}
/**
+ * Returns the last modified date as Java epoch seconds.
+ *
+ * If there is no update, this return 0.
+ * @hide
+ */
+ public long getLastModifiedDate() {
+ return mLastModifiedDate;
+ }
+
+ /**
+ * Returns the monotonically increasing config version value.
+ *
+ * The config version is reset to 0 when the system is restarted.
+ * @hide
+ */
+ public @IntRange(from = 0) int getConfigVersion() {
+ return mConfigVersion;
+ }
+
+ /**
* Returns the ordered list of families included in the system fonts.
* @deprecated Use getFontFamilies instead.
* @hide
@@ -107,6 +132,8 @@ public final class FontConfig implements Parcelable {
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeParcelableList(mFamilies, flags);
dest.writeParcelableList(mAliases, flags);
+ dest.writeLong(mLastModifiedDate);
+ dest.writeInt(mConfigVersion);
}
public static final @NonNull Creator<FontConfig> CREATOR = new Creator<FontConfig>() {
@@ -116,7 +143,9 @@ public final class FontConfig implements Parcelable {
FontFamily.class.getClassLoader());
List<Alias> aliases = source.readParcelableList(new ArrayList<>(),
Alias.class.getClassLoader());
- return new FontConfig(families, aliases);
+ long lastModifiedDate = source.readLong();
+ int configVersion = source.readInt();
+ return new FontConfig(families, aliases, lastModifiedDate, configVersion);
}
@Override