blob: b45c0401d19a6889f05db21d406df4621198e14f [file] [log] [blame]
Adam Lesinski59e04c62016-02-04 15:59:23 -08001/*
2 * Copyright (C) 2016 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
Adam Lesinski5bd44232017-09-07 09:39:07 -070017syntax = "proto3";
18
Adam Lesinskib58c3ef2017-09-12 17:39:52 -070019import "frameworks/base/tools/aapt2/Configuration.proto";
20
Adam Lesinski5bd44232017-09-07 09:39:07 -070021package aapt.pb;
Adam Lesinski59e04c62016-02-04 15:59:23 -080022
Adam Lesinski4ffea042017-08-10 15:37:28 -070023option java_package = "com.android.aapt";
Adam Lesinski59e04c62016-02-04 15:59:23 -080024
Adam Lesinski0c808952017-07-10 05:40:39 -070025// A string pool that wraps the binary form of the C++ class android::ResStringPool.
Adam Lesinski59e04c62016-02-04 15:59:23 -080026message StringPool {
Adam Lesinski5bd44232017-09-07 09:39:07 -070027 bytes data = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -080028}
29
Adam Lesinski4ffea042017-08-10 15:37:28 -070030// The position of a declared entity within a file.
31message SourcePosition {
Adam Lesinski5bd44232017-09-07 09:39:07 -070032 uint32 line_number = 1;
33 uint32 column_number = 2;
Adam Lesinski4ffea042017-08-10 15:37:28 -070034}
35
Adam Lesinski0c808952017-07-10 05:40:39 -070036// Developer friendly source file information for an entity in the resource table.
Adam Lesinski59e04c62016-02-04 15:59:23 -080037message Source {
Adam Lesinski0c808952017-07-10 05:40:39 -070038 // The index of the string path within the source string pool of a ResourceTable.
Adam Lesinski5bd44232017-09-07 09:39:07 -070039 uint32 path_idx = 1;
40 SourcePosition position = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -070041}
42
Ryan Mitchell34039b22019-03-18 08:57:47 -070043// The name and version fingerprint of a build tool.
44message ToolFingerprint {
45 string tool = 1;
46 string version = 2;
47}
48
Adam Lesinski0c808952017-07-10 05:40:39 -070049// Top level message representing a resource table.
50message ResourceTable {
Adam Lesinski0c808952017-07-10 05:40:39 -070051 // The string pool containing source paths referenced throughout the resource table. This does
52 // not end up in the final binary ARSC file.
Adam Lesinski5bd44232017-09-07 09:39:07 -070053 StringPool source_pool = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -070054
55 // Resource definitions corresponding to an Android package.
Adam Lesinski4ffea042017-08-10 15:37:28 -070056 repeated Package package = 2;
Ryan Mitchell54237ff2018-12-13 15:44:29 -080057
58 // The <overlayable> declarations within the resource table.
59 repeated Overlayable overlayable = 3;
Ryan Mitchell34039b22019-03-18 08:57:47 -070060
61 // The version fingerprints of the tools that built the resource table.
62 repeated ToolFingerprint tool_fingerprint = 4;
Adam Lesinski0c808952017-07-10 05:40:39 -070063}
64
Adam Lesinski5bd44232017-09-07 09:39:07 -070065// A package ID in the range [0x00, 0xff].
66message PackageId {
67 uint32 id = 1;
68}
69
Adam Lesinski0c808952017-07-10 05:40:39 -070070// Defines resources for an Android package.
71message Package {
72 // The package ID of this package, in the range [0x00, 0xff].
Adam Lesinski5bd44232017-09-07 09:39:07 -070073 // - ID 0x00 is reserved for shared libraries, or when the ID is assigned at run-time.
74 // - ID 0x01 is reserved for the 'android' package (framework).
75 // - ID range [0x02, 0x7f) is reserved for auto-assignment to shared libraries at run-time.
76 // - ID 0x7f is reserved for the application package.
77 // - IDs > 0x7f are reserved for the application as well and are treated as feature splits.
78 // This may not be set if no ID was assigned.
79 PackageId package_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -070080
81 // The Java compatible Android package name of the app.
Adam Lesinski5bd44232017-09-07 09:39:07 -070082 string package_name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -070083
84 // The series of types defined by the package.
Adam Lesinski4ffea042017-08-10 15:37:28 -070085 repeated Type type = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -070086}
87
Adam Lesinski5bd44232017-09-07 09:39:07 -070088// A type ID in the range [0x01, 0xff].
89message TypeId {
90 uint32 id = 1;
91}
92
Adam Lesinski0c808952017-07-10 05:40:39 -070093// A set of resources grouped under a common type. Such types include string, layout, xml, dimen,
94// attr, etc. This maps to the second part of a resource identifier in Java (R.type.entry).
95message Type {
Adam Lesinski5bd44232017-09-07 09:39:07 -070096 // The ID of the type. This may not be set if no ID was assigned.
97 TypeId type_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -070098
99 // The name of the type. This corresponds to the 'type' part of a full resource name of the form
100 // package:type/entry. The set of legal type names is listed in Resource.cpp.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700101 string name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700102
103 // The entries defined for this type.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700104 repeated Entry entry = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700105}
106
Adam Lesinski71be7052017-12-12 16:48:07 -0800107// The Visibility of a symbol/entry (public, private, undefined).
108message Visibility {
Adam Lesinski0c808952017-07-10 05:40:39 -0700109 // The visibility of the resource outside of its package.
Adam Lesinski71be7052017-12-12 16:48:07 -0800110 enum Level {
Adam Lesinski0c808952017-07-10 05:40:39 -0700111 // No visibility was explicitly specified. This is typically treated as private.
112 // The distinction is important when two separate R.java files are generated: a public and
113 // private one. An unknown visibility, in this case, would cause the resource to be omitted
114 // from either R.java.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700115 UNKNOWN = 0;
Adam Lesinski0c808952017-07-10 05:40:39 -0700116
117 // A resource was explicitly marked as private. This means the resource can not be accessed
118 // outside of its package unless the @*package:type/entry notation is used (the asterisk being
119 // the private accessor). If two R.java files are generated (private + public), the resource
120 // will only be emitted to the private R.java file.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700121 PRIVATE = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700122
123 // A resource was explicitly marked as public. This means the resource can be accessed
124 // from any package, and is emitted into all R.java files, public and private.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700125 PUBLIC = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700126 }
127
Adam Lesinski71be7052017-12-12 16:48:07 -0800128 Level level = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700129
130 // The path at which this entry's visibility was defined (eg. public.xml).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700131 Source source = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700132
133 // The comment associated with the <public> tag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700134 string comment = 3;
Ryan Mitchell2e9bec12021-03-22 09:31:00 -0700135
136 // Indicates that the resource id may change across builds and that the public R.java identifier
137 // for this resource should not be final. This is set to `true` for resources in `staging-group`
138 // tags.
139 bool staged_api = 4;
Adam Lesinski71be7052017-12-12 16:48:07 -0800140}
Adam Lesinski0c808952017-07-10 05:40:39 -0700141
Adam Lesinski71be7052017-12-12 16:48:07 -0800142// Whether a resource comes from a compile-time overlay and is explicitly allowed to not overlay an
143// existing resource.
144message AllowNew {
145 // Where this was defined in source.
146 Source source = 1;
147
148 // Any comment associated with the declaration.
149 string comment = 2;
150}
151
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800152// Represents a set of overlayable resources.
Adam Lesinski71be7052017-12-12 16:48:07 -0800153message Overlayable {
Winsonb2d7f532019-02-04 16:32:43 -0800154 // The name of the <overlayable>.
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800155 string name = 1;
156
Winsonb2d7f532019-02-04 16:32:43 -0800157 // The location of the <overlayable> declaration in the source.
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800158 Source source = 2;
159
160 // The component responsible for enabling and disabling overlays targeting this <overlayable>.
161 string actor = 3;
162}
163
164// Represents an overlayable <item> declaration within an <overlayable> tag.
165message OverlayableItem {
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700166 enum Policy {
Winson6bee4252019-02-13 07:57:24 -0800167 NONE = 0;
168 PUBLIC = 1;
169 SYSTEM = 2;
170 VENDOR = 3;
171 PRODUCT = 4;
172 SIGNATURE = 5;
Ryan Mitchell939df092019-04-09 17:13:50 -0700173 ODM = 6;
174 OEM = 7;
Winsonf56ade32019-12-04 11:32:41 -0800175 ACTOR = 8;
Zoran Jovanovic9336d9e2020-06-09 18:51:57 +0200176 CONFIG_SIGNATURE = 9;
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700177 }
178
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800179 // The location of the <item> declaration in source.
Adam Lesinski71be7052017-12-12 16:48:07 -0800180 Source source = 1;
181
182 // Any comment associated with the declaration.
183 string comment = 2;
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700184
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800185 // The policy defined by the enclosing <policy> tag of this <item>.
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800186 repeated Policy policy = 3;
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800187
188 // The index into overlayable list that points to the <overlayable> tag that contains
189 // this <item>.
190 uint32 overlayable_idx = 4;
Adam Lesinski5bd44232017-09-07 09:39:07 -0700191}
192
193// An entry ID in the range [0x0000, 0xffff].
194message EntryId {
195 uint32 id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700196}
197
198// An entry declaration. An entry has a full resource ID that is the combination of package ID,
199// type ID, and its own entry ID. An entry on its own has no value, but values are defined for
200// various configurations/variants.
201message Entry {
202 // The ID of this entry. Together with the package ID and type ID, this forms a full resource ID
203 // of the form 0xPPTTEEEE, where PP is the package ID, TT is the type ID, and EEEE is the entry
204 // ID.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700205 // This may not be set if no ID was assigned.
206 EntryId entry_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700207
208 // The name of this entry. This corresponds to the 'entry' part of a full resource name of the
209 // form package:type/entry.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700210 string name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700211
Adam Lesinski71be7052017-12-12 16:48:07 -0800212 // The visibility of this entry (public, private, undefined).
213 Visibility visibility = 3;
214
215 // Whether this resource, when originating from a compile-time overlay, is allowed to NOT overlay
216 // any existing resources.
217 AllowNew allow_new = 4;
218
219 // Whether this resource can be overlaid by a runtime resource overlay (RRO).
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800220 OverlayableItem overlayable_item = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -0700221
222 // The set of values defined for this entry, each corresponding to a different
223 // configuration/variant.
Adam Lesinski71be7052017-12-12 16:48:07 -0800224 repeated ConfigValue config_value = 6;
Adam Lesinski0c808952017-07-10 05:40:39 -0700225}
226
227// A Configuration/Value pair.
228message ConfigValue {
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700229 Configuration config = 1;
Adam Lesinski5bd44232017-09-07 09:39:07 -0700230 Value value = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700231}
232
233// The generic meta-data for every value in a resource table.
234message Value {
235 // Where the value was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700236 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700237
238 // Any comment associated with the value.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700239 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700240
241 // Whether the value can be overridden.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700242 bool weak = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700243
Adam Lesinski5bd44232017-09-07 09:39:07 -0700244 // The value is either an Item or a CompoundValue.
245 oneof value {
246 Item item = 4;
247 CompoundValue compound_value = 5;
248 }
Adam Lesinski0c808952017-07-10 05:40:39 -0700249}
250
251// An Item is an abstract type. It represents a value that can appear inline in many places, such
252// as XML attribute values or on the right hand side of style attribute definitions. The concrete
253// type is one of the types below. Only one can be set.
254message Item {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700255 oneof value {
256 Reference ref = 1;
257 String str = 2;
258 RawString raw_str = 3;
259 StyledString styled_str = 4;
260 FileReference file = 5;
261 Id id = 6;
262 Primitive prim = 7;
263 }
Adam Lesinski0c808952017-07-10 05:40:39 -0700264}
265
266// A CompoundValue is an abstract type. It represents a value that is a made of other values.
267// These can only usually appear as top-level resources. The concrete type is one of the types
268// below. Only one can be set.
269message CompoundValue {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700270 oneof value {
271 Attribute attr = 1;
272 Style style = 2;
273 Styleable styleable = 3;
274 Array array = 4;
275 Plural plural = 5;
Ryan Mitchell326e35ff2021-04-12 07:50:42 -0700276 MacroBody macro = 6;
Adam Lesinski5bd44232017-09-07 09:39:07 -0700277 }
Adam Lesinski0c808952017-07-10 05:40:39 -0700278}
279
Clark DuValle9fedbe2020-01-09 11:52:52 -0800280// Message holding a boolean, so it can be optionally encoded.
281message Boolean {
282 bool value = 1;
283}
284
Adam Lesinski0c808952017-07-10 05:40:39 -0700285// A value that is a reference to another resource. This reference can be by name or resource ID.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800286message Reference {
Adam Lesinski0c808952017-07-10 05:40:39 -0700287 enum Type {
288 // A plain reference (@package:type/entry).
Adam Lesinski4ffea042017-08-10 15:37:28 -0700289 REFERENCE = 0;
Adam Lesinski0c808952017-07-10 05:40:39 -0700290
291 // A reference to a theme attribute (?package:type/entry).
Adam Lesinski4ffea042017-08-10 15:37:28 -0700292 ATTRIBUTE = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700293 }
294
Adam Lesinski5bd44232017-09-07 09:39:07 -0700295 Type type = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700296
Adam Lesinski5bd44232017-09-07 09:39:07 -0700297 // The resource ID (0xPPTTEEEE) of the resource being referred. This is optional.
298 uint32 id = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700299
Adam Lesinski5bd44232017-09-07 09:39:07 -0700300 // The name of the resource being referred. This is optional if the resource ID is set.
301 string name = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700302
303 // Whether this reference is referencing a private resource (@*package:type/entry).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700304 bool private = 4;
Clark DuValle9fedbe2020-01-09 11:52:52 -0800305
306 // Whether this reference is dynamic.
307 Boolean is_dynamic = 5;
Ryan Mitchell326e35ff2021-04-12 07:50:42 -0700308
309 // The type flags used when compiling the reference. Used for substituting the contents of macros.
310 uint32 type_flags = 6;
311
312 // Whether raw string values would have been accepted in place of this reference definition. Used
313 // for substituting the contents of macros.
314 bool allow_raw = 7;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800315}
316
Adam Lesinski0c808952017-07-10 05:40:39 -0700317// A value that represents an ID. This is just a placeholder, as ID values are used to occupy a
318// resource ID (0xPPTTEEEE) as a unique identifier. Their value is unimportant.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800319message Id {
320}
321
Adam Lesinski0c808952017-07-10 05:40:39 -0700322// A value that is a string.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800323message String {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700324 string value = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800325}
326
Adam Lesinski0c808952017-07-10 05:40:39 -0700327// A value that is a raw string, which is unescaped/uninterpreted. This is typically used to
328// represent the value of a style attribute before the attribute is compiled and the set of
329// allowed values is known.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800330message RawString {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700331 string value = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700332}
333
334// A string with styling information, like html tags that specify boldness, italics, etc.
335message StyledString {
336 // The raw text of the string.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700337 string value = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700338
339 // A Span marks a region of the string text that is styled.
340 message Span {
341 // The name of the tag, and its attributes, encoded as follows:
342 // tag_name;attr1=value1;attr2=value2;[...]
Adam Lesinski5bd44232017-09-07 09:39:07 -0700343 string tag = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700344
345 // The first character position this span applies to, in UTF-16 offset.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700346 uint32 first_char = 2;
Adam Lesinski08535002017-08-04 16:15:17 -0700347
348 // The last character position this span applies to, in UTF-16 offset.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700349 uint32 last_char = 3;
Adam Lesinski08535002017-08-04 16:15:17 -0700350 }
351
352 repeated Span span = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800353}
354
Adam Lesinski0c808952017-07-10 05:40:39 -0700355// A value that is a reference to an external entity, like an XML file or a PNG.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800356message FileReference {
Adam Lesinskie59f0d82017-10-13 09:36:53 -0700357 enum Type {
358 UNKNOWN = 0;
359 PNG = 1;
360 BINARY_XML = 2;
361 PROTO_XML = 3;
362 }
363
Adam Lesinski08535002017-08-04 16:15:17 -0700364 // Path to a file within the APK (typically res/type-config/entry.ext).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700365 string path = 1;
Adam Lesinskie59f0d82017-10-13 09:36:53 -0700366
367 // The type of file this path points to. For UAM bundle, this cannot be
368 // BINARY_XML.
369 Type type = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800370}
371
Adam Lesinski0c808952017-07-10 05:40:39 -0700372// A value that represents a primitive data type (float, int, boolean, etc.).
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700373// Refer to Res_value in ResourceTypes.h for info on types and formatting
Adam Lesinski59e04c62016-02-04 15:59:23 -0800374message Primitive {
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800375 message NullType {
376 }
377 message EmptyType {
378 }
379 oneof oneof_value {
380 NullType null_value = 1;
381 EmptyType empty_value = 2;
382 float float_value = 3;
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700383 uint32 dimension_value = 13;
384 uint32 fraction_value = 14;
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800385 int32 int_decimal_value = 6;
Dave Ingram22ed4122018-01-30 16:11:52 -0800386 uint32 int_hexadecimal_value = 7;
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800387 bool boolean_value = 8;
388 uint32 color_argb8_value = 9;
389 uint32 color_rgb8_value = 10;
390 uint32 color_argb4_value = 11;
391 uint32 color_rgb4_value = 12;
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700392 float dimension_value_deprecated = 4 [deprecated=true];
393 float fraction_value_deprecated = 5 [deprecated=true];
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800394 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800395}
396
Adam Lesinski0c808952017-07-10 05:40:39 -0700397// A value that represents an XML attribute and what values it accepts.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800398message Attribute {
Adam Lesinski0c808952017-07-10 05:40:39 -0700399 // A Symbol used to represent an enum or a flag.
400 message Symbol {
401 // Where the enum/flag item was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700402 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700403
404 // Any comments associated with the enum or flag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700405 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700406
407 // The name of the enum/flag as a reference. Enums/flag items are generated as ID resource
408 // values.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700409 Reference name = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700410
411 // The value of the enum/flag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700412 uint32 value = 4;
Ryan Mitchellc1676802019-05-20 16:47:08 -0700413
414 // The data type of the enum/flag as defined in android::Res_value.
415 uint32 type = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -0700416 }
417
Adam Lesinski4ffea042017-08-10 15:37:28 -0700418 // Bitmask of formats allowed for an attribute.
419 enum FormatFlags {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700420 NONE = 0x0; // Proto3 requires a default of 0.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700421 ANY = 0x0000ffff; // Allows any type except ENUM and FLAGS.
422 REFERENCE = 0x01; // Allows Reference values.
423 STRING = 0x02; // Allows String/StyledString values.
424 INTEGER = 0x04; // Allows any integer BinaryPrimitive values.
425 BOOLEAN = 0x08; // Allows any boolean BinaryPrimitive values.
426 COLOR = 0x010; // Allows any color BinaryPrimitive values.
427 FLOAT = 0x020; // Allows any float BinaryPrimitive values.
428 DIMENSION = 0x040; // Allows any dimension BinaryPrimitive values.
429 FRACTION = 0x080; // Allows any fraction BinaryPrimitive values.
430 ENUM = 0x00010000; // Allows enums that are defined in the Attribute's symbols.
431 // ENUM and FLAGS cannot BOTH be set.
432 FLAGS = 0x00020000; // Allows flags that are defined in the Attribute's symbols.
433 // ENUM and FLAGS cannot BOTH be set.
434 }
435
436 // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the
437 // enum FormatFlags.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700438 uint32 format_flags = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700439
440 // The smallest integer allowed for this XML attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700441 // FormatFlags::INTEGER.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700442 int32 min_int = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700443
444 // The largest integer allowed for this XML attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700445 // FormatFlags::INTEGER.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700446 int32 max_int = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700447
448 // The set of enums/flags defined in this attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700449 // either FormatFlags::ENUM or FormatFlags::FLAGS. Having both is an error.
450 repeated Symbol symbol = 4;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800451}
452
Adam Lesinski0c808952017-07-10 05:40:39 -0700453// A value that represents a style.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800454message Style {
Adam Lesinski0c808952017-07-10 05:40:39 -0700455 // An XML attribute/value pair defined in the style.
456 message Entry {
457 // Where the entry was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700458 Source source = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800459
Adam Lesinski0c808952017-07-10 05:40:39 -0700460 // Any comments associated with the entry.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700461 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700462
463 // A reference to the XML attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700464 Reference key = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700465
466 // The Item defined for this XML attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700467 Item item = 4;
Adam Lesinski0c808952017-07-10 05:40:39 -0700468 }
469
470 // The optinal style from which this style inherits attributes.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700471 Reference parent = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700472
473 // The source file information of the parent inheritance declaration.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700474 Source parent_source = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700475
476 // The set of XML attribute/value pairs for this style.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700477 repeated Entry entry = 3;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800478}
479
Adam Lesinski0c808952017-07-10 05:40:39 -0700480// A value that represents a <declare-styleable> XML resource. These are not real resources and
481// only end up as Java fields in the generated R.java. They do not end up in the binary ARSC file.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800482message Styleable {
Adam Lesinski0c808952017-07-10 05:40:39 -0700483 // An attribute defined for this styleable.
484 message Entry {
485 // Where the attribute was defined within the <declare-styleable> block.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700486 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700487
488 // Any comments associated with the declaration.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700489 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700490
491 // The reference to the attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700492 Reference attr = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700493 }
494
495 // The set of attribute declarations.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700496 repeated Entry entry = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800497}
498
Adam Lesinski0c808952017-07-10 05:40:39 -0700499// A value that represents an array of resource values.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800500message Array {
Adam Lesinski0c808952017-07-10 05:40:39 -0700501 // A single element of the array.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700502 message Element {
Adam Lesinski0c808952017-07-10 05:40:39 -0700503 // Where the element was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700504 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700505
506 // Any comments associated with the element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700507 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700508
509 // The value assigned to this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700510 Item item = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700511 }
512
513 // The list of array elements.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700514 repeated Element element = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800515}
516
Adam Lesinski0c808952017-07-10 05:40:39 -0700517// A value that represents a string and its many variations based on plurality.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800518message Plural {
Adam Lesinski0c808952017-07-10 05:40:39 -0700519 // The arity of the plural.
520 enum Arity {
Adam Lesinski4ffea042017-08-10 15:37:28 -0700521 ZERO = 0;
522 ONE = 1;
523 TWO = 2;
524 FEW = 3;
525 MANY = 4;
526 OTHER = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -0700527 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800528
Adam Lesinski0c808952017-07-10 05:40:39 -0700529 // The plural value for a given arity.
530 message Entry {
531 // Where the plural was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700532 Source source = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800533
Adam Lesinski0c808952017-07-10 05:40:39 -0700534 // Any comments associated with the plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700535 string comment = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800536
Adam Lesinski0c808952017-07-10 05:40:39 -0700537 // The arity of the plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700538 Arity arity = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700539
540 // The value assigned to this plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700541 Item item = 4;
Adam Lesinski0c808952017-07-10 05:40:39 -0700542 }
543
544 // The set of arity/plural mappings.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700545 repeated Entry entry = 1;
546}
547
548// Defines an abstract XmlNode that must be either an XmlElement, or
549// a text node represented by a string.
550message XmlNode {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700551 oneof node {
552 XmlElement element = 1;
553 string text = 2;
554 }
Adam Lesinski4ffea042017-08-10 15:37:28 -0700555
556 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700557 SourcePosition source = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700558}
559
560// An <element> in an XML document.
561message XmlElement {
562 // Namespaces defined on this element.
563 repeated XmlNamespace namespace_declaration = 1;
564
565 // The namespace URI of this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700566 string namespace_uri = 2;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700567
568 // The name of this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700569 string name = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700570
571 // The attributes of this element.
572 repeated XmlAttribute attribute = 4;
573
574 // The children of this element.
575 repeated XmlNode child = 5;
576}
577
578// A namespace declaration on an XmlElement (xmlns:android="http://...").
579message XmlNamespace {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700580 string prefix = 1;
581 string uri = 2;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700582
583 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700584 SourcePosition source = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700585}
586
587// An attribute defined on an XmlElement (android:text="...").
588message XmlAttribute {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700589 string namespace_uri = 1;
590 string name = 2;
591 string value = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700592
593 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700594 SourcePosition source = 4;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700595
Adam Lesinski5bd44232017-09-07 09:39:07 -0700596 // The optional resource ID (0xPPTTEEEE) of the attribute.
597 uint32 resource_id = 5;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700598
Adam Lesinski5bd44232017-09-07 09:39:07 -0700599 // The optional interpreted/compiled version of the `value` string.
600 Item compiled_item = 6;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800601}
Ryan Mitchell326e35ff2021-04-12 07:50:42 -0700602
603message MacroBody {
604 string raw_string = 1;
605 StyleString style_string = 2;
606 repeated UntranslatableSection untranslatable_sections = 3;
607 repeated NamespaceAlias namespace_stack = 4;
608 SourcePosition source = 5;
609}
610
611message NamespaceAlias {
612 string prefix = 1;
613 string package_name = 2;
614 bool is_private = 3;
615}
616
617message StyleString {
618 message Span {
619 string name = 1;
620 uint32 start_index = 2;
621 uint32 end_index = 3;
622 }
623 string str = 1;
624 repeated Span spans = 2;
625}
626
627message UntranslatableSection {
628 uint64 start_index = 1;
629 uint64 end_index = 2;
630}