Debian Codegraph @

core/java/android/provider/FontRequest.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package android.provider;
17
18 import android.annotation.NonNull;
19 import android.util.Base64;
20
21 import com.android.internal.util.Preconditions;
22
23 import java.util.Collections;
24 import java.util.List;
25
26 /**
27 * Information about a font request that may be sent to a Font Provider.
28 * @deprecated Use the {@link androidx.core.provider.FontRequest}
29 */
30 @Deprecated
31 public final class FontRequest {
32 private final String mProviderAuthority;
33 private final String mProviderPackage;
34 private final String mQuery;
35 private final List<List<byte[]>> mCertificates;
36
37 // Used for key of the cache.
38 private final String mIdentifier;
39
40 /**
41 * @param providerAuthority The authority of the Font Provider to be used for the request. This
42 * should be a system installed app.
43 * @param providerPackage The package for the Font Provider to be used for the request. This is
44 * used to verify the identity of the provider.
45 * @param query The query to be sent over to the provider. Refer to your font provider's
46 * documentation on the format of this string.
47 */
48 public FontRequest(@NonNull String providerAuthority, @NonNull String providerPackage,
49 @NonNull String query) {
50 mProviderAuthority = Preconditions.checkNotNull(providerAuthority);
51 mQuery = Preconditions.checkNotNull(query);
52 mProviderPackage = Preconditions.checkNotNull(providerPackage);
53 mCertificates = Collections.emptyList();
54 mIdentifier = new StringBuilder(mProviderAuthority).append("-").append(mProviderPackage)
55 .append("-").append(mQuery).toString();
56 }
57
58 /**
59 * @param providerAuthority The authority of the Font Provider to be used for the request.
60 * @param query The query to be sent over to the provider. Refer to your font provider's
61 * documentation on the format of this string.
62 * @param providerPackage The package for the Font Provider to be used for the request. This is
63 * used to verify the identity of the provider.
64 * @param certificates The list of sets of hashes for the certificates the provider should be
65 * signed with. This is used to verify the identity of the provider. Each set in the
66 * list represents one collection of signature hashes. Refer to your font provider's
67 * documentation for these values.
68 */
69 public FontRequest(@NonNull String providerAuthority, @NonNull String providerPackage,
70 @NonNull String query, @NonNull List<List<byte[]>> certificates) {
71 mProviderAuthority = Preconditions.checkNotNull(providerAuthority);
72 mProviderPackage = Preconditions.checkNotNull(providerPackage);
73 mQuery = Preconditions.checkNotNull(query);
74 mCertificates = Preconditions.checkNotNull(certificates);
75 mIdentifier = new StringBuilder(mProviderAuthority).append("-").append(mProviderPackage)
76 .append("-").append(mQuery).toString();
77 }
78
79 /**
80 * Returns the selected font provider's authority. This tells the system what font provider
81 * it should request the font from.
82 */
83 public String getProviderAuthority() {
84 return mProviderAuthority;
85 }
86
87 /**
88 * Returns the selected font provider's package. This helps the system verify that the provider
89 * identified by the given authority is the one requested.
90 */
91 public String getProviderPackage() {
92 return mProviderPackage;
93 }
94
95 /**
96 * Returns the query string. Refer to your font provider's documentation on the format of this
97 * string.
98 */
99 public String getQuery() {
100 return mQuery;
101 }
102
103 /**
104 * Returns the list of certificate sets given for this provider. This helps the system verify
105 * that the provider identified by the given authority is the one requested.
106 */
107 public List<List<byte[]>> getCertificates() {
108 return mCertificates;
109 }
110
111 /** @hide */
112 public String getIdentifier() {
113 return mIdentifier;
114 }
115
116 @Override
117 public String toString() {
118 StringBuilder builder = new StringBuilder();
119 builder.append("FontRequest {"
120 + "mProviderAuthority: " + mProviderAuthority
121 + ", mProviderPackage: " + mProviderPackage
122 + ", mQuery: " + mQuery
123 + ", mCertificates:");
124 for (int i = 0; i < mCertificates.size(); i++) {
125 builder.append(" [");
126 List<byte[]> set = mCertificates.get(i);
127 for (int j = 0; j < set.size(); j++) {
128 builder.append(" \"");
129 byte[] array = set.get(j);
130 builder.append(Base64.encodeToString(array, Base64.DEFAULT));
131 builder.append("\"");
132 }
133 builder.append(" ]");
134 }
135 builder.append("}");
136 return builder.toString();
137 }
138 }