blob: bf9fe49da2d662c51f64438215c801a9c50134f1 [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 -080024option optimize_for = LITE_RUNTIME;
25
Adam Lesinski0c808952017-07-10 05:40:39 -070026// A string pool that wraps the binary form of the C++ class android::ResStringPool.
Adam Lesinski59e04c62016-02-04 15:59:23 -080027message StringPool {
Adam Lesinski5bd44232017-09-07 09:39:07 -070028 bytes data = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -080029}
30
Adam Lesinski4ffea042017-08-10 15:37:28 -070031// The position of a declared entity within a file.
32message SourcePosition {
Adam Lesinski5bd44232017-09-07 09:39:07 -070033 uint32 line_number = 1;
34 uint32 column_number = 2;
Adam Lesinski4ffea042017-08-10 15:37:28 -070035}
36
Adam Lesinski0c808952017-07-10 05:40:39 -070037// Developer friendly source file information for an entity in the resource table.
Adam Lesinski59e04c62016-02-04 15:59:23 -080038message Source {
Adam Lesinski0c808952017-07-10 05:40:39 -070039 // The index of the string path within the source string pool of a ResourceTable.
Adam Lesinski5bd44232017-09-07 09:39:07 -070040 uint32 path_idx = 1;
41 SourcePosition position = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -070042}
43
44// Top level message representing a resource table.
45message ResourceTable {
Adam Lesinski0c808952017-07-10 05:40:39 -070046 // The string pool containing source paths referenced throughout the resource table. This does
47 // not end up in the final binary ARSC file.
Adam Lesinski5bd44232017-09-07 09:39:07 -070048 StringPool source_pool = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -070049
50 // Resource definitions corresponding to an Android package.
Adam Lesinski4ffea042017-08-10 15:37:28 -070051 repeated Package package = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -070052}
53
Adam Lesinski5bd44232017-09-07 09:39:07 -070054// A package ID in the range [0x00, 0xff].
55message PackageId {
56 uint32 id = 1;
57}
58
Adam Lesinski0c808952017-07-10 05:40:39 -070059// Defines resources for an Android package.
60message Package {
61 // The package ID of this package, in the range [0x00, 0xff].
Adam Lesinski5bd44232017-09-07 09:39:07 -070062 // - ID 0x00 is reserved for shared libraries, or when the ID is assigned at run-time.
63 // - ID 0x01 is reserved for the 'android' package (framework).
64 // - ID range [0x02, 0x7f) is reserved for auto-assignment to shared libraries at run-time.
65 // - ID 0x7f is reserved for the application package.
66 // - IDs > 0x7f are reserved for the application as well and are treated as feature splits.
67 // This may not be set if no ID was assigned.
68 PackageId package_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -070069
70 // The Java compatible Android package name of the app.
Adam Lesinski5bd44232017-09-07 09:39:07 -070071 string package_name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -070072
73 // The series of types defined by the package.
Adam Lesinski4ffea042017-08-10 15:37:28 -070074 repeated Type type = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -070075}
76
Adam Lesinski5bd44232017-09-07 09:39:07 -070077// A type ID in the range [0x01, 0xff].
78message TypeId {
79 uint32 id = 1;
80}
81
Adam Lesinski0c808952017-07-10 05:40:39 -070082// A set of resources grouped under a common type. Such types include string, layout, xml, dimen,
83// attr, etc. This maps to the second part of a resource identifier in Java (R.type.entry).
84message Type {
Adam Lesinski5bd44232017-09-07 09:39:07 -070085 // The ID of the type. This may not be set if no ID was assigned.
86 TypeId type_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -070087
88 // The name of the type. This corresponds to the 'type' part of a full resource name of the form
89 // package:type/entry. The set of legal type names is listed in Resource.cpp.
Adam Lesinski5bd44232017-09-07 09:39:07 -070090 string name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -070091
92 // The entries defined for this type.
Adam Lesinski4ffea042017-08-10 15:37:28 -070093 repeated Entry entry = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -070094}
95
Adam Lesinski71be7052017-12-12 16:48:07 -080096// The Visibility of a symbol/entry (public, private, undefined).
97message Visibility {
Adam Lesinski0c808952017-07-10 05:40:39 -070098 // The visibility of the resource outside of its package.
Adam Lesinski71be7052017-12-12 16:48:07 -080099 enum Level {
Adam Lesinski0c808952017-07-10 05:40:39 -0700100 // No visibility was explicitly specified. This is typically treated as private.
101 // The distinction is important when two separate R.java files are generated: a public and
102 // private one. An unknown visibility, in this case, would cause the resource to be omitted
103 // from either R.java.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700104 UNKNOWN = 0;
Adam Lesinski0c808952017-07-10 05:40:39 -0700105
106 // A resource was explicitly marked as private. This means the resource can not be accessed
107 // outside of its package unless the @*package:type/entry notation is used (the asterisk being
108 // the private accessor). If two R.java files are generated (private + public), the resource
109 // will only be emitted to the private R.java file.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700110 PRIVATE = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700111
112 // A resource was explicitly marked as public. This means the resource can be accessed
113 // from any package, and is emitted into all R.java files, public and private.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700114 PUBLIC = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700115 }
116
Adam Lesinski71be7052017-12-12 16:48:07 -0800117 Level level = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700118
119 // The path at which this entry's visibility was defined (eg. public.xml).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700120 Source source = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700121
122 // The comment associated with the <public> tag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700123 string comment = 3;
Adam Lesinski71be7052017-12-12 16:48:07 -0800124}
Adam Lesinski0c808952017-07-10 05:40:39 -0700125
Adam Lesinski71be7052017-12-12 16:48:07 -0800126// Whether a resource comes from a compile-time overlay and is explicitly allowed to not overlay an
127// existing resource.
128message AllowNew {
129 // Where this was defined in source.
130 Source source = 1;
131
132 // Any comment associated with the declaration.
133 string comment = 2;
134}
135
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700136// Represents a declaration that a resource is overayable at runtime.
Adam Lesinski71be7052017-12-12 16:48:07 -0800137message Overlayable {
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700138 enum Policy {
139 NONE = 0;
140 PUBLIC = 1;
141 SYSTEM = 2;
142 VENDOR = 3;
143 PRODUCT = 4;
144 PRODUCT_SERVICES = 5;
145 }
146
Adam Lesinski71be7052017-12-12 16:48:07 -0800147 // Where this declaration was defined in source.
148 Source source = 1;
149
150 // Any comment associated with the declaration.
151 string comment = 2;
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700152
153 // The policy of the overlayable declaration
154 Policy policy = 3;
Adam Lesinski5bd44232017-09-07 09:39:07 -0700155}
156
157// An entry ID in the range [0x0000, 0xffff].
158message EntryId {
159 uint32 id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700160}
161
162// An entry declaration. An entry has a full resource ID that is the combination of package ID,
163// type ID, and its own entry ID. An entry on its own has no value, but values are defined for
164// various configurations/variants.
165message Entry {
166 // The ID of this entry. Together with the package ID and type ID, this forms a full resource ID
167 // of the form 0xPPTTEEEE, where PP is the package ID, TT is the type ID, and EEEE is the entry
168 // ID.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700169 // This may not be set if no ID was assigned.
170 EntryId entry_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700171
172 // The name of this entry. This corresponds to the 'entry' part of a full resource name of the
173 // form package:type/entry.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700174 string name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700175
Adam Lesinski71be7052017-12-12 16:48:07 -0800176 // The visibility of this entry (public, private, undefined).
177 Visibility visibility = 3;
178
179 // Whether this resource, when originating from a compile-time overlay, is allowed to NOT overlay
180 // any existing resources.
181 AllowNew allow_new = 4;
182
183 // Whether this resource can be overlaid by a runtime resource overlay (RRO).
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700184 repeated Overlayable overlayable = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -0700185
186 // The set of values defined for this entry, each corresponding to a different
187 // configuration/variant.
Adam Lesinski71be7052017-12-12 16:48:07 -0800188 repeated ConfigValue config_value = 6;
Adam Lesinski0c808952017-07-10 05:40:39 -0700189}
190
191// A Configuration/Value pair.
192message ConfigValue {
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700193 Configuration config = 1;
Adam Lesinski5bd44232017-09-07 09:39:07 -0700194 Value value = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700195}
196
197// The generic meta-data for every value in a resource table.
198message Value {
199 // Where the value was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700200 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700201
202 // Any comment associated with the value.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700203 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700204
205 // Whether the value can be overridden.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700206 bool weak = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700207
Adam Lesinski5bd44232017-09-07 09:39:07 -0700208 // The value is either an Item or a CompoundValue.
209 oneof value {
210 Item item = 4;
211 CompoundValue compound_value = 5;
212 }
Adam Lesinski0c808952017-07-10 05:40:39 -0700213}
214
215// An Item is an abstract type. It represents a value that can appear inline in many places, such
216// as XML attribute values or on the right hand side of style attribute definitions. The concrete
217// type is one of the types below. Only one can be set.
218message Item {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700219 oneof value {
220 Reference ref = 1;
221 String str = 2;
222 RawString raw_str = 3;
223 StyledString styled_str = 4;
224 FileReference file = 5;
225 Id id = 6;
226 Primitive prim = 7;
227 }
Adam Lesinski0c808952017-07-10 05:40:39 -0700228}
229
230// A CompoundValue is an abstract type. It represents a value that is a made of other values.
231// These can only usually appear as top-level resources. The concrete type is one of the types
232// below. Only one can be set.
233message CompoundValue {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700234 oneof value {
235 Attribute attr = 1;
236 Style style = 2;
237 Styleable styleable = 3;
238 Array array = 4;
239 Plural plural = 5;
240 }
Adam Lesinski0c808952017-07-10 05:40:39 -0700241}
242
243// 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 -0800244message Reference {
Adam Lesinski0c808952017-07-10 05:40:39 -0700245 enum Type {
246 // A plain reference (@package:type/entry).
Adam Lesinski4ffea042017-08-10 15:37:28 -0700247 REFERENCE = 0;
Adam Lesinski0c808952017-07-10 05:40:39 -0700248
249 // A reference to a theme attribute (?package:type/entry).
Adam Lesinski4ffea042017-08-10 15:37:28 -0700250 ATTRIBUTE = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700251 }
252
Adam Lesinski5bd44232017-09-07 09:39:07 -0700253 Type type = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700254
Adam Lesinski5bd44232017-09-07 09:39:07 -0700255 // The resource ID (0xPPTTEEEE) of the resource being referred. This is optional.
256 uint32 id = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700257
Adam Lesinski5bd44232017-09-07 09:39:07 -0700258 // The name of the resource being referred. This is optional if the resource ID is set.
259 string name = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700260
261 // Whether this reference is referencing a private resource (@*package:type/entry).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700262 bool private = 4;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800263}
264
Adam Lesinski0c808952017-07-10 05:40:39 -0700265// A value that represents an ID. This is just a placeholder, as ID values are used to occupy a
266// resource ID (0xPPTTEEEE) as a unique identifier. Their value is unimportant.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800267message Id {
268}
269
Adam Lesinski0c808952017-07-10 05:40:39 -0700270// A value that is a string.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800271message String {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700272 string value = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800273}
274
Adam Lesinski0c808952017-07-10 05:40:39 -0700275// A value that is a raw string, which is unescaped/uninterpreted. This is typically used to
276// represent the value of a style attribute before the attribute is compiled and the set of
277// allowed values is known.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800278message RawString {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700279 string value = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700280}
281
282// A string with styling information, like html tags that specify boldness, italics, etc.
283message StyledString {
284 // The raw text of the string.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700285 string value = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700286
287 // A Span marks a region of the string text that is styled.
288 message Span {
289 // The name of the tag, and its attributes, encoded as follows:
290 // tag_name;attr1=value1;attr2=value2;[...]
Adam Lesinski5bd44232017-09-07 09:39:07 -0700291 string tag = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700292
293 // The first character position this span applies to, in UTF-16 offset.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700294 uint32 first_char = 2;
Adam Lesinski08535002017-08-04 16:15:17 -0700295
296 // The last character position this span applies to, in UTF-16 offset.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700297 uint32 last_char = 3;
Adam Lesinski08535002017-08-04 16:15:17 -0700298 }
299
300 repeated Span span = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800301}
302
Adam Lesinski0c808952017-07-10 05:40:39 -0700303// A value that is a reference to an external entity, like an XML file or a PNG.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800304message FileReference {
Adam Lesinskie59f0d82017-10-13 09:36:53 -0700305 enum Type {
306 UNKNOWN = 0;
307 PNG = 1;
308 BINARY_XML = 2;
309 PROTO_XML = 3;
310 }
311
Adam Lesinski08535002017-08-04 16:15:17 -0700312 // Path to a file within the APK (typically res/type-config/entry.ext).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700313 string path = 1;
Adam Lesinskie59f0d82017-10-13 09:36:53 -0700314
315 // The type of file this path points to. For UAM bundle, this cannot be
316 // BINARY_XML.
317 Type type = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800318}
319
Adam Lesinski0c808952017-07-10 05:40:39 -0700320// A value that represents a primitive data type (float, int, boolean, etc.).
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700321// Refer to Res_value in ResourceTypes.h for info on types and formatting
Adam Lesinski59e04c62016-02-04 15:59:23 -0800322message Primitive {
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800323 message NullType {
324 }
325 message EmptyType {
326 }
327 oneof oneof_value {
328 NullType null_value = 1;
329 EmptyType empty_value = 2;
330 float float_value = 3;
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700331 uint32 dimension_value = 13;
332 uint32 fraction_value = 14;
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800333 int32 int_decimal_value = 6;
Dave Ingram22ed4122018-01-30 16:11:52 -0800334 uint32 int_hexadecimal_value = 7;
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800335 bool boolean_value = 8;
336 uint32 color_argb8_value = 9;
337 uint32 color_rgb8_value = 10;
338 uint32 color_argb4_value = 11;
339 uint32 color_rgb4_value = 12;
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700340 float dimension_value_deprecated = 4 [deprecated=true];
341 float fraction_value_deprecated = 5 [deprecated=true];
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800342 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800343}
344
Adam Lesinski0c808952017-07-10 05:40:39 -0700345// A value that represents an XML attribute and what values it accepts.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800346message Attribute {
Adam Lesinski0c808952017-07-10 05:40:39 -0700347 // A Symbol used to represent an enum or a flag.
348 message Symbol {
349 // Where the enum/flag item was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700350 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700351
352 // Any comments associated with the enum or flag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700353 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700354
355 // The name of the enum/flag as a reference. Enums/flag items are generated as ID resource
356 // values.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700357 Reference name = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700358
359 // The value of the enum/flag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700360 uint32 value = 4;
Adam Lesinski0c808952017-07-10 05:40:39 -0700361 }
362
Adam Lesinski4ffea042017-08-10 15:37:28 -0700363 // Bitmask of formats allowed for an attribute.
364 enum FormatFlags {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700365 NONE = 0x0; // Proto3 requires a default of 0.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700366 ANY = 0x0000ffff; // Allows any type except ENUM and FLAGS.
367 REFERENCE = 0x01; // Allows Reference values.
368 STRING = 0x02; // Allows String/StyledString values.
369 INTEGER = 0x04; // Allows any integer BinaryPrimitive values.
370 BOOLEAN = 0x08; // Allows any boolean BinaryPrimitive values.
371 COLOR = 0x010; // Allows any color BinaryPrimitive values.
372 FLOAT = 0x020; // Allows any float BinaryPrimitive values.
373 DIMENSION = 0x040; // Allows any dimension BinaryPrimitive values.
374 FRACTION = 0x080; // Allows any fraction BinaryPrimitive values.
375 ENUM = 0x00010000; // Allows enums that are defined in the Attribute's symbols.
376 // ENUM and FLAGS cannot BOTH be set.
377 FLAGS = 0x00020000; // Allows flags that are defined in the Attribute's symbols.
378 // ENUM and FLAGS cannot BOTH be set.
379 }
380
381 // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the
382 // enum FormatFlags.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700383 uint32 format_flags = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700384
385 // The smallest integer allowed for this XML attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700386 // FormatFlags::INTEGER.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700387 int32 min_int = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700388
389 // The largest integer allowed for this XML attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700390 // FormatFlags::INTEGER.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700391 int32 max_int = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700392
393 // The set of enums/flags defined in this attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700394 // either FormatFlags::ENUM or FormatFlags::FLAGS. Having both is an error.
395 repeated Symbol symbol = 4;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800396}
397
Adam Lesinski0c808952017-07-10 05:40:39 -0700398// A value that represents a style.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800399message Style {
Adam Lesinski0c808952017-07-10 05:40:39 -0700400 // An XML attribute/value pair defined in the style.
401 message Entry {
402 // Where the entry was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700403 Source source = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800404
Adam Lesinski0c808952017-07-10 05:40:39 -0700405 // Any comments associated with the entry.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700406 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700407
408 // A reference to the XML attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700409 Reference key = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700410
411 // The Item defined for this XML attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700412 Item item = 4;
Adam Lesinski0c808952017-07-10 05:40:39 -0700413 }
414
415 // The optinal style from which this style inherits attributes.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700416 Reference parent = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700417
418 // The source file information of the parent inheritance declaration.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700419 Source parent_source = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700420
421 // The set of XML attribute/value pairs for this style.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700422 repeated Entry entry = 3;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800423}
424
Adam Lesinski0c808952017-07-10 05:40:39 -0700425// A value that represents a <declare-styleable> XML resource. These are not real resources and
426// 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 -0800427message Styleable {
Adam Lesinski0c808952017-07-10 05:40:39 -0700428 // An attribute defined for this styleable.
429 message Entry {
430 // Where the attribute was defined within the <declare-styleable> block.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700431 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700432
433 // Any comments associated with the declaration.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700434 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700435
436 // The reference to the attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700437 Reference attr = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700438 }
439
440 // The set of attribute declarations.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700441 repeated Entry entry = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800442}
443
Adam Lesinski0c808952017-07-10 05:40:39 -0700444// A value that represents an array of resource values.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800445message Array {
Adam Lesinski0c808952017-07-10 05:40:39 -0700446 // A single element of the array.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700447 message Element {
Adam Lesinski0c808952017-07-10 05:40:39 -0700448 // Where the element was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700449 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700450
451 // Any comments associated with the element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700452 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700453
454 // The value assigned to this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700455 Item item = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700456 }
457
458 // The list of array elements.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700459 repeated Element element = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800460}
461
Adam Lesinski0c808952017-07-10 05:40:39 -0700462// A value that represents a string and its many variations based on plurality.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800463message Plural {
Adam Lesinski0c808952017-07-10 05:40:39 -0700464 // The arity of the plural.
465 enum Arity {
Adam Lesinski4ffea042017-08-10 15:37:28 -0700466 ZERO = 0;
467 ONE = 1;
468 TWO = 2;
469 FEW = 3;
470 MANY = 4;
471 OTHER = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -0700472 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800473
Adam Lesinski0c808952017-07-10 05:40:39 -0700474 // The plural value for a given arity.
475 message Entry {
476 // Where the plural was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700477 Source source = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800478
Adam Lesinski0c808952017-07-10 05:40:39 -0700479 // Any comments associated with the plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700480 string comment = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800481
Adam Lesinski0c808952017-07-10 05:40:39 -0700482 // The arity of the plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700483 Arity arity = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700484
485 // The value assigned to this plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700486 Item item = 4;
Adam Lesinski0c808952017-07-10 05:40:39 -0700487 }
488
489 // The set of arity/plural mappings.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700490 repeated Entry entry = 1;
491}
492
493// Defines an abstract XmlNode that must be either an XmlElement, or
494// a text node represented by a string.
495message XmlNode {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700496 oneof node {
497 XmlElement element = 1;
498 string text = 2;
499 }
Adam Lesinski4ffea042017-08-10 15:37:28 -0700500
501 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700502 SourcePosition source = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700503}
504
505// An <element> in an XML document.
506message XmlElement {
507 // Namespaces defined on this element.
508 repeated XmlNamespace namespace_declaration = 1;
509
510 // The namespace URI of this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700511 string namespace_uri = 2;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700512
513 // The name of this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700514 string name = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700515
516 // The attributes of this element.
517 repeated XmlAttribute attribute = 4;
518
519 // The children of this element.
520 repeated XmlNode child = 5;
521}
522
523// A namespace declaration on an XmlElement (xmlns:android="http://...").
524message XmlNamespace {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700525 string prefix = 1;
526 string uri = 2;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700527
528 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700529 SourcePosition source = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700530}
531
532// An attribute defined on an XmlElement (android:text="...").
533message XmlAttribute {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700534 string namespace_uri = 1;
535 string name = 2;
536 string value = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700537
538 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700539 SourcePosition source = 4;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700540
Adam Lesinski5bd44232017-09-07 09:39:07 -0700541 // The optional resource ID (0xPPTTEEEE) of the attribute.
542 uint32 resource_id = 5;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700543
Adam Lesinski5bd44232017-09-07 09:39:07 -0700544 // The optional interpreted/compiled version of the `value` string.
545 Item compiled_item = 6;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800546}