diff options
| author | 2021-03-12 01:38:16 +0000 | |
|---|---|---|
| committer | 2021-03-12 01:38:16 +0000 | |
| commit | 5774fa63b28e08b15857f5fb50e8f3873a4074fc (patch) | |
| tree | ce02cbeddd6fbb5b757c7859be12b6ce9efc4ebf /graphics/java | |
| parent | 755678b31a9526096082d9162a160dd6b8469a05 (diff) | |
| parent | 991f134df3bca4d436d2da24761f915c486f5b4a (diff) | |
Merge "Expose shared memory related APIs for testing purpose" into sc-dev
Diffstat (limited to 'graphics/java')
| -rw-r--r-- | graphics/java/android/graphics/Typeface.java | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java index c80788269c24..2a6bbf36ef76 100644 --- a/graphics/java/android/graphics/Typeface.java +++ b/graphics/java/android/graphics/Typeface.java @@ -25,6 +25,7 @@ import android.annotation.IntDef; import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.TestApi; import android.annotation.UiThread; import android.compat.annotation.UnsupportedAppUsage; import android.content.res.AssetManager; @@ -169,6 +170,21 @@ public class Typeface { Collections.emptyMap(); /** + * Returns the shared memory that used for creating Typefaces. + * + * @return A SharedMemory used for creating Typeface. Maybe null if the lazy initialization is + * disabled or inside SystemServer or Zygote. + * @hide + */ + @TestApi + public static @Nullable SharedMemory getSystemFontMapSharedMemory() { + if (ENABLE_LAZY_TYPEFACE_INITIALIZATION) { + Objects.requireNonNull(sSystemFontMapSharedMemory); + } + return sSystemFontMapSharedMemory; + } + + /** * @hide */ @UnsupportedAppUsage @@ -1196,8 +1212,13 @@ public class Typeface { } } - /** @hide */ - public static SharedMemory serializeFontMap(Map<String, Typeface> fontMap) + /** + * Create a serialized system font mappings. + * + * @hide + */ + @TestApi + public static @NonNull SharedMemory serializeFontMap(@NonNull Map<String, Typeface> fontMap) throws IOException, ErrnoException { long[] nativePtrs = new long[fontMap.size()]; // The name table will not be large, so let's create a byte array in memory. @@ -1229,9 +1250,14 @@ public class Typeface { } // buffer's byte order should be BIG_ENDIAN. - /** @hide */ - @VisibleForTesting - public static Map<String, Typeface> deserializeFontMap(ByteBuffer buffer) throws IOException { + /** + * Deserialize the font mapping from the serialized byte buffer. + * + * @hide + */ + @TestApi + public static @NonNull Map<String, Typeface> deserializeFontMap(@NonNull ByteBuffer buffer) + throws IOException { Map<String, Typeface> fontMap = new ArrayMap<>(); int typefacesBytesCount = buffer.getInt(); long[] nativePtrs = nativeReadTypefaces(buffer.slice()); |