Cache the Typeface based on the FontRequest.

Bug: 37471729
Test: FontsContractE2ETest
Change-Id: Ifb1bd2b50077471404f5f1dffc01e7697d7042e6
This commit is contained in:
Seigo Nonaka
2017-04-19 12:16:39 -07:00
parent ab7a2879eb
commit daa8dfc690
7 changed files with 595 additions and 1 deletions

View File

@@ -35,6 +35,9 @@ public final class FontRequest implements Parcelable {
private final String mQuery;
private final List<List<byte[]>> mCertificates;
// Used for key of the cache.
private final String mIdentifier;
/**
* @param providerAuthority The authority of the Font Provider to be used for the request. This
* should be a system installed app.
@@ -49,6 +52,8 @@ public final class FontRequest implements Parcelable {
mQuery = Preconditions.checkNotNull(query);
mProviderPackage = Preconditions.checkNotNull(providerPackage);
mCertificates = Collections.emptyList();
mIdentifier = new StringBuilder(mProviderAuthority).append("-").append(mProviderPackage)
.append("-").append(mQuery).toString();
}
/**
@@ -68,6 +73,8 @@ public final class FontRequest implements Parcelable {
mProviderPackage = Preconditions.checkNotNull(providerPackage);
mQuery = Preconditions.checkNotNull(query);
mCertificates = Preconditions.checkNotNull(certificates);
mIdentifier = new StringBuilder(mProviderAuthority).append("-").append(mProviderPackage)
.append("-").append(mQuery).toString();
}
/**
@@ -102,6 +109,11 @@ public final class FontRequest implements Parcelable {
return mCertificates;
}
/** @hide */
public String getIdentifier() {
return mIdentifier;
}
@Override
public int describeContents() {
return 0;
@@ -121,6 +133,8 @@ public final class FontRequest implements Parcelable {
mQuery = in.readString();
mCertificates = new ArrayList<>();
in.readList(mCertificates, null);
mIdentifier = new StringBuilder(mProviderAuthority).append("-").append(mProviderPackage)
.append("-").append(mQuery).toString();
}
public static final Parcelable.Creator<FontRequest> CREATOR =