blob: fe9b4a8843ca03d5cff5261f2f9bf5b4a6f10c02 [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
Rico Winde70bbb12022-11-11 09:37:54 +010049// References to non local resources
50message DynamicRefTable {
51 PackageId package_id = 1;
52 string package_name = 2;
53}
54
55
Adam Lesinski0c808952017-07-10 05:40:39 -070056// Top level message representing a resource table.
57message ResourceTable {
Adam Lesinski0c808952017-07-10 05:40:39 -070058 // The string pool containing source paths referenced throughout the resource table. This does
59 // not end up in the final binary ARSC file.
Adam Lesinski5bd44232017-09-07 09:39:07 -070060 StringPool source_pool = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -070061
62 // Resource definitions corresponding to an Android package.
Adam Lesinski4ffea042017-08-10 15:37:28 -070063 repeated Package package = 2;
Ryan Mitchell54237ff2018-12-13 15:44:29 -080064
65 // The <overlayable> declarations within the resource table.
66 repeated Overlayable overlayable = 3;
Ryan Mitchell34039b22019-03-18 08:57:47 -070067
68 // The version fingerprints of the tools that built the resource table.
69 repeated ToolFingerprint tool_fingerprint = 4;
Rico Winde70bbb12022-11-11 09:37:54 +010070
71 repeated DynamicRefTable dynamic_ref_table = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -070072}
73
Adam Lesinski5bd44232017-09-07 09:39:07 -070074// A package ID in the range [0x00, 0xff].
75message PackageId {
76 uint32 id = 1;
77}
78
Adam Lesinski0c808952017-07-10 05:40:39 -070079// Defines resources for an Android package.
80message Package {
81 // The package ID of this package, in the range [0x00, 0xff].
Adam Lesinski5bd44232017-09-07 09:39:07 -070082 // - ID 0x00 is reserved for shared libraries, or when the ID is assigned at run-time.
83 // - ID 0x01 is reserved for the 'android' package (framework).
84 // - ID range [0x02, 0x7f) is reserved for auto-assignment to shared libraries at run-time.
85 // - ID 0x7f is reserved for the application package.
86 // - IDs > 0x7f are reserved for the application as well and are treated as feature splits.
87 // This may not be set if no ID was assigned.
88 PackageId package_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -070089
90 // The Java compatible Android package name of the app.
Adam Lesinski5bd44232017-09-07 09:39:07 -070091 string package_name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -070092
93 // The series of types defined by the package.
Adam Lesinski4ffea042017-08-10 15:37:28 -070094 repeated Type type = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -070095}
96
Adam Lesinski5bd44232017-09-07 09:39:07 -070097// A type ID in the range [0x01, 0xff].
98message TypeId {
99 uint32 id = 1;
100}
101
Adam Lesinski0c808952017-07-10 05:40:39 -0700102// A set of resources grouped under a common type. Such types include string, layout, xml, dimen,
103// attr, etc. This maps to the second part of a resource identifier in Java (R.type.entry).
104message Type {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700105 // The ID of the type. This may not be set if no ID was assigned.
106 TypeId type_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700107
108 // The name of the type. This corresponds to the 'type' part of a full resource name of the form
109 // package:type/entry. The set of legal type names is listed in Resource.cpp.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700110 string name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700111
112 // The entries defined for this type.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700113 repeated Entry entry = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700114}
115
Adam Lesinski71be7052017-12-12 16:48:07 -0800116// The Visibility of a symbol/entry (public, private, undefined).
117message Visibility {
Adam Lesinski0c808952017-07-10 05:40:39 -0700118 // The visibility of the resource outside of its package.
Adam Lesinski71be7052017-12-12 16:48:07 -0800119 enum Level {
Adam Lesinski0c808952017-07-10 05:40:39 -0700120 // No visibility was explicitly specified. This is typically treated as private.
121 // The distinction is important when two separate R.java files are generated: a public and
122 // private one. An unknown visibility, in this case, would cause the resource to be omitted
123 // from either R.java.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700124 UNKNOWN = 0;
Adam Lesinski0c808952017-07-10 05:40:39 -0700125
126 // A resource was explicitly marked as private. This means the resource can not be accessed
127 // outside of its package unless the @*package:type/entry notation is used (the asterisk being
128 // the private accessor). If two R.java files are generated (private + public), the resource
129 // will only be emitted to the private R.java file.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700130 PRIVATE = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700131
132 // A resource was explicitly marked as public. This means the resource can be accessed
133 // from any package, and is emitted into all R.java files, public and private.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700134 PUBLIC = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700135 }
136
Adam Lesinski71be7052017-12-12 16:48:07 -0800137 Level level = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700138
139 // The path at which this entry's visibility was defined (eg. public.xml).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700140 Source source = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700141
142 // The comment associated with the <public> tag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700143 string comment = 3;
Ryan Mitchell2e9bec12021-03-22 09:31:00 -0700144
145 // Indicates that the resource id may change across builds and that the public R.java identifier
146 // for this resource should not be final. This is set to `true` for resources in `staging-group`
147 // tags.
148 bool staged_api = 4;
Adam Lesinski71be7052017-12-12 16:48:07 -0800149}
Adam Lesinski0c808952017-07-10 05:40:39 -0700150
Adam Lesinski71be7052017-12-12 16:48:07 -0800151// Whether a resource comes from a compile-time overlay and is explicitly allowed to not overlay an
152// existing resource.
153message AllowNew {
154 // Where this was defined in source.
155 Source source = 1;
156
157 // Any comment associated with the declaration.
158 string comment = 2;
159}
160
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800161// Represents a set of overlayable resources.
Adam Lesinski71be7052017-12-12 16:48:07 -0800162message Overlayable {
Winsonb2d7f532019-02-04 16:32:43 -0800163 // The name of the <overlayable>.
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800164 string name = 1;
165
Winsonb2d7f532019-02-04 16:32:43 -0800166 // The location of the <overlayable> declaration in the source.
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800167 Source source = 2;
168
169 // The component responsible for enabling and disabling overlays targeting this <overlayable>.
170 string actor = 3;
171}
172
173// Represents an overlayable <item> declaration within an <overlayable> tag.
174message OverlayableItem {
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700175 enum Policy {
Winson6bee4252019-02-13 07:57:24 -0800176 NONE = 0;
177 PUBLIC = 1;
178 SYSTEM = 2;
179 VENDOR = 3;
180 PRODUCT = 4;
181 SIGNATURE = 5;
Ryan Mitchell939df092019-04-09 17:13:50 -0700182 ODM = 6;
183 OEM = 7;
Winsonf56ade32019-12-04 11:32:41 -0800184 ACTOR = 8;
Zoran Jovanovic9336d9e2020-06-09 18:51:57 +0200185 CONFIG_SIGNATURE = 9;
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700186 }
187
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800188 // The location of the <item> declaration in source.
Adam Lesinski71be7052017-12-12 16:48:07 -0800189 Source source = 1;
190
191 // Any comment associated with the declaration.
192 string comment = 2;
Ryan Mitchelle4e989c2018-10-29 02:21:50 -0700193
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800194 // The policy defined by the enclosing <policy> tag of this <item>.
Ryan Mitchell1bb1fe02018-11-16 11:21:41 -0800195 repeated Policy policy = 3;
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800196
197 // The index into overlayable list that points to the <overlayable> tag that contains
198 // this <item>.
199 uint32 overlayable_idx = 4;
Adam Lesinski5bd44232017-09-07 09:39:07 -0700200}
201
Ryan Mitchell2fedba92021-04-23 07:47:38 -0700202// The staged resource ID definition of a finalized resource.
203message StagedId {
204 Source source = 1;
205 uint32 staged_id = 2;
206}
207
Adam Lesinski5bd44232017-09-07 09:39:07 -0700208// An entry ID in the range [0x0000, 0xffff].
209message EntryId {
210 uint32 id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700211}
212
213// An entry declaration. An entry has a full resource ID that is the combination of package ID,
214// type ID, and its own entry ID. An entry on its own has no value, but values are defined for
215// various configurations/variants.
216message Entry {
217 // The ID of this entry. Together with the package ID and type ID, this forms a full resource ID
218 // of the form 0xPPTTEEEE, where PP is the package ID, TT is the type ID, and EEEE is the entry
219 // ID.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700220 // This may not be set if no ID was assigned.
221 EntryId entry_id = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700222
223 // The name of this entry. This corresponds to the 'entry' part of a full resource name of the
224 // form package:type/entry.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700225 string name = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700226
Adam Lesinski71be7052017-12-12 16:48:07 -0800227 // The visibility of this entry (public, private, undefined).
228 Visibility visibility = 3;
229
230 // Whether this resource, when originating from a compile-time overlay, is allowed to NOT overlay
231 // any existing resources.
232 AllowNew allow_new = 4;
233
234 // Whether this resource can be overlaid by a runtime resource overlay (RRO).
Ryan Mitchell54237ff2018-12-13 15:44:29 -0800235 OverlayableItem overlayable_item = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -0700236
237 // The set of values defined for this entry, each corresponding to a different
238 // configuration/variant.
Adam Lesinski71be7052017-12-12 16:48:07 -0800239 repeated ConfigValue config_value = 6;
Ryan Mitchell2fedba92021-04-23 07:47:38 -0700240
241 // The staged resource ID of this finalized resource.
242 StagedId staged_id = 7;
Jeremy Meyer3d8d4a12024-08-23 17:29:03 -0700243
244 // The set of values defined for this entry which are behind disabled flags
245 repeated ConfigValue flag_disabled_config_value = 8;
Adam Lesinski0c808952017-07-10 05:40:39 -0700246}
247
248// A Configuration/Value pair.
249message ConfigValue {
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700250 Configuration config = 1;
Adam Lesinski5bd44232017-09-07 09:39:07 -0700251 Value value = 2;
Jeremy Meyerd52bd682024-08-14 11:16:58 -0700252 reserved 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700253}
254
255// The generic meta-data for every value in a resource table.
256message Value {
257 // Where the value was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700258 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700259
260 // Any comment associated with the value.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700261 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700262
263 // Whether the value can be overridden.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700264 bool weak = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700265
Adam Lesinski5bd44232017-09-07 09:39:07 -0700266 // The value is either an Item or a CompoundValue.
267 oneof value {
268 Item item = 4;
269 CompoundValue compound_value = 5;
270 }
Adam Lesinski0c808952017-07-10 05:40:39 -0700271}
272
273// An Item is an abstract type. It represents a value that can appear inline in many places, such
274// as XML attribute values or on the right hand side of style attribute definitions. The concrete
275// type is one of the types below. Only one can be set.
276message Item {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700277 oneof value {
278 Reference ref = 1;
279 String str = 2;
280 RawString raw_str = 3;
281 StyledString styled_str = 4;
282 FileReference file = 5;
283 Id id = 6;
284 Primitive prim = 7;
285 }
Jeremy Meyerd52bd682024-08-14 11:16:58 -0700286
287 // The status of the flag the value is behind if any
288 uint32 flag_status = 8;
Jeremy Meyer3d8d4a12024-08-23 17:29:03 -0700289 bool flag_negated = 9;
290 string flag_name = 10;
Adam Lesinski0c808952017-07-10 05:40:39 -0700291}
292
293// A CompoundValue is an abstract type. It represents a value that is a made of other values.
294// These can only usually appear as top-level resources. The concrete type is one of the types
295// below. Only one can be set.
296message CompoundValue {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700297 oneof value {
298 Attribute attr = 1;
299 Style style = 2;
300 Styleable styleable = 3;
301 Array array = 4;
302 Plural plural = 5;
Ryan Mitchell326e35ff2021-04-12 07:50:42 -0700303 MacroBody macro = 6;
Adam Lesinski5bd44232017-09-07 09:39:07 -0700304 }
Jeremy Meyerf53a0272024-09-19 09:47:47 -0700305
306 // The status of the flag the value is behind if any
307 uint32 flag_status = 7;
308 bool flag_negated = 8;
309 string flag_name = 9;
Adam Lesinski0c808952017-07-10 05:40:39 -0700310}
311
Clark DuValle9fedbe2020-01-09 11:52:52 -0800312// Message holding a boolean, so it can be optionally encoded.
313message Boolean {
314 bool value = 1;
315}
316
Adam Lesinski0c808952017-07-10 05:40:39 -0700317// 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 -0800318message Reference {
Adam Lesinski0c808952017-07-10 05:40:39 -0700319 enum Type {
320 // A plain reference (@package:type/entry).
Adam Lesinski4ffea042017-08-10 15:37:28 -0700321 REFERENCE = 0;
Adam Lesinski0c808952017-07-10 05:40:39 -0700322
323 // A reference to a theme attribute (?package:type/entry).
Adam Lesinski4ffea042017-08-10 15:37:28 -0700324 ATTRIBUTE = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700325 }
326
Adam Lesinski5bd44232017-09-07 09:39:07 -0700327 Type type = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700328
Adam Lesinski5bd44232017-09-07 09:39:07 -0700329 // The resource ID (0xPPTTEEEE) of the resource being referred. This is optional.
330 uint32 id = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700331
Adam Lesinski5bd44232017-09-07 09:39:07 -0700332 // The name of the resource being referred. This is optional if the resource ID is set.
333 string name = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700334
335 // Whether this reference is referencing a private resource (@*package:type/entry).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700336 bool private = 4;
Clark DuValle9fedbe2020-01-09 11:52:52 -0800337
338 // Whether this reference is dynamic.
339 Boolean is_dynamic = 5;
Ryan Mitchell326e35ff2021-04-12 07:50:42 -0700340
341 // The type flags used when compiling the reference. Used for substituting the contents of macros.
342 uint32 type_flags = 6;
343
344 // Whether raw string values would have been accepted in place of this reference definition. Used
345 // for substituting the contents of macros.
346 bool allow_raw = 7;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800347}
348
Adam Lesinski0c808952017-07-10 05:40:39 -0700349// A value that represents an ID. This is just a placeholder, as ID values are used to occupy a
350// resource ID (0xPPTTEEEE) as a unique identifier. Their value is unimportant.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800351message Id {
352}
353
Adam Lesinski0c808952017-07-10 05:40:39 -0700354// A value that is a string.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800355message String {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700356 string value = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800357}
358
Adam Lesinski0c808952017-07-10 05:40:39 -0700359// A value that is a raw string, which is unescaped/uninterpreted. This is typically used to
360// represent the value of a style attribute before the attribute is compiled and the set of
361// allowed values is known.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800362message RawString {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700363 string value = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700364}
365
366// A string with styling information, like html tags that specify boldness, italics, etc.
367message StyledString {
368 // The raw text of the string.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700369 string value = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700370
371 // A Span marks a region of the string text that is styled.
372 message Span {
373 // The name of the tag, and its attributes, encoded as follows:
374 // tag_name;attr1=value1;attr2=value2;[...]
Adam Lesinski5bd44232017-09-07 09:39:07 -0700375 string tag = 1;
Adam Lesinski08535002017-08-04 16:15:17 -0700376
377 // The first character position this span applies to, in UTF-16 offset.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700378 uint32 first_char = 2;
Adam Lesinski08535002017-08-04 16:15:17 -0700379
380 // The last character position this span applies to, in UTF-16 offset.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700381 uint32 last_char = 3;
Adam Lesinski08535002017-08-04 16:15:17 -0700382 }
383
384 repeated Span span = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800385}
386
Adam Lesinski0c808952017-07-10 05:40:39 -0700387// A value that is a reference to an external entity, like an XML file or a PNG.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800388message FileReference {
Adam Lesinskie59f0d82017-10-13 09:36:53 -0700389 enum Type {
390 UNKNOWN = 0;
391 PNG = 1;
392 BINARY_XML = 2;
393 PROTO_XML = 3;
394 }
395
Adam Lesinski08535002017-08-04 16:15:17 -0700396 // Path to a file within the APK (typically res/type-config/entry.ext).
Adam Lesinski5bd44232017-09-07 09:39:07 -0700397 string path = 1;
Adam Lesinskie59f0d82017-10-13 09:36:53 -0700398
399 // The type of file this path points to. For UAM bundle, this cannot be
400 // BINARY_XML.
401 Type type = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800402}
403
Adam Lesinski0c808952017-07-10 05:40:39 -0700404// A value that represents a primitive data type (float, int, boolean, etc.).
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700405// Refer to Res_value in ResourceTypes.h for info on types and formatting
Adam Lesinski59e04c62016-02-04 15:59:23 -0800406message Primitive {
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800407 message NullType {
408 }
409 message EmptyType {
410 }
411 oneof oneof_value {
412 NullType null_value = 1;
413 EmptyType empty_value = 2;
414 float float_value = 3;
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700415 uint32 dimension_value = 13;
416 uint32 fraction_value = 14;
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800417 int32 int_decimal_value = 6;
Dave Ingram22ed4122018-01-30 16:11:52 -0800418 uint32 int_hexadecimal_value = 7;
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800419 bool boolean_value = 8;
420 uint32 color_argb8_value = 9;
421 uint32 color_rgb8_value = 10;
422 uint32 color_argb4_value = 11;
423 uint32 color_rgb4_value = 12;
Michael Wachenschwanz8b749272018-04-18 18:52:47 -0700424 float dimension_value_deprecated = 4 [deprecated=true];
425 float fraction_value_deprecated = 5 [deprecated=true];
Michael Wachenschwanzd06f1f32018-01-11 18:36:22 -0800426 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800427}
428
Adam Lesinski0c808952017-07-10 05:40:39 -0700429// A value that represents an XML attribute and what values it accepts.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800430message Attribute {
Adam Lesinski0c808952017-07-10 05:40:39 -0700431 // A Symbol used to represent an enum or a flag.
432 message Symbol {
433 // Where the enum/flag item was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700434 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700435
436 // Any comments associated with the enum or flag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700437 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700438
439 // The name of the enum/flag as a reference. Enums/flag items are generated as ID resource
440 // values.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700441 Reference name = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700442
443 // The value of the enum/flag.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700444 uint32 value = 4;
Ryan Mitchellc1676802019-05-20 16:47:08 -0700445
446 // The data type of the enum/flag as defined in android::Res_value.
447 uint32 type = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -0700448 }
449
Adam Lesinski4ffea042017-08-10 15:37:28 -0700450 // Bitmask of formats allowed for an attribute.
451 enum FormatFlags {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700452 NONE = 0x0; // Proto3 requires a default of 0.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700453 ANY = 0x0000ffff; // Allows any type except ENUM and FLAGS.
454 REFERENCE = 0x01; // Allows Reference values.
455 STRING = 0x02; // Allows String/StyledString values.
456 INTEGER = 0x04; // Allows any integer BinaryPrimitive values.
457 BOOLEAN = 0x08; // Allows any boolean BinaryPrimitive values.
458 COLOR = 0x010; // Allows any color BinaryPrimitive values.
459 FLOAT = 0x020; // Allows any float BinaryPrimitive values.
460 DIMENSION = 0x040; // Allows any dimension BinaryPrimitive values.
461 FRACTION = 0x080; // Allows any fraction BinaryPrimitive values.
462 ENUM = 0x00010000; // Allows enums that are defined in the Attribute's symbols.
463 // ENUM and FLAGS cannot BOTH be set.
464 FLAGS = 0x00020000; // Allows flags that are defined in the Attribute's symbols.
465 // ENUM and FLAGS cannot BOTH be set.
466 }
467
468 // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the
469 // enum FormatFlags.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700470 uint32 format_flags = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700471
472 // The smallest integer allowed for this XML attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700473 // FormatFlags::INTEGER.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700474 int32 min_int = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700475
476 // The largest integer allowed for this XML attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700477 // FormatFlags::INTEGER.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700478 int32 max_int = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700479
480 // The set of enums/flags defined in this attribute. Only makes sense if the format includes
Adam Lesinski4ffea042017-08-10 15:37:28 -0700481 // either FormatFlags::ENUM or FormatFlags::FLAGS. Having both is an error.
482 repeated Symbol symbol = 4;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800483}
484
Adam Lesinski0c808952017-07-10 05:40:39 -0700485// A value that represents a style.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800486message Style {
Adam Lesinski0c808952017-07-10 05:40:39 -0700487 // An XML attribute/value pair defined in the style.
488 message Entry {
489 // Where the entry was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700490 Source source = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800491
Adam Lesinski0c808952017-07-10 05:40:39 -0700492 // Any comments associated with the entry.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700493 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700494
495 // A reference to the XML attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700496 Reference key = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700497
498 // The Item defined for this XML attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700499 Item item = 4;
Adam Lesinski0c808952017-07-10 05:40:39 -0700500 }
501
502 // The optinal style from which this style inherits attributes.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700503 Reference parent = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700504
505 // The source file information of the parent inheritance declaration.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700506 Source parent_source = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700507
508 // The set of XML attribute/value pairs for this style.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700509 repeated Entry entry = 3;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800510}
511
Adam Lesinski0c808952017-07-10 05:40:39 -0700512// A value that represents a <declare-styleable> XML resource. These are not real resources and
513// 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 -0800514message Styleable {
Adam Lesinski0c808952017-07-10 05:40:39 -0700515 // An attribute defined for this styleable.
516 message Entry {
517 // Where the attribute was defined within the <declare-styleable> block.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700518 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700519
520 // Any comments associated with the declaration.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700521 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700522
523 // The reference to the attribute.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700524 Reference attr = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700525 }
526
527 // The set of attribute declarations.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700528 repeated Entry entry = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800529}
530
Adam Lesinski0c808952017-07-10 05:40:39 -0700531// A value that represents an array of resource values.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800532message Array {
Adam Lesinski0c808952017-07-10 05:40:39 -0700533 // A single element of the array.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700534 message Element {
Adam Lesinski0c808952017-07-10 05:40:39 -0700535 // Where the element was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700536 Source source = 1;
Adam Lesinski0c808952017-07-10 05:40:39 -0700537
538 // Any comments associated with the element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700539 string comment = 2;
Adam Lesinski0c808952017-07-10 05:40:39 -0700540
541 // The value assigned to this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700542 Item item = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700543 }
544
545 // The list of array elements.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700546 repeated Element element = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800547}
548
Adam Lesinski0c808952017-07-10 05:40:39 -0700549// A value that represents a string and its many variations based on plurality.
Adam Lesinski59e04c62016-02-04 15:59:23 -0800550message Plural {
Adam Lesinski0c808952017-07-10 05:40:39 -0700551 // The arity of the plural.
552 enum Arity {
Adam Lesinski4ffea042017-08-10 15:37:28 -0700553 ZERO = 0;
554 ONE = 1;
555 TWO = 2;
556 FEW = 3;
557 MANY = 4;
558 OTHER = 5;
Adam Lesinski0c808952017-07-10 05:40:39 -0700559 }
Adam Lesinski59e04c62016-02-04 15:59:23 -0800560
Adam Lesinski0c808952017-07-10 05:40:39 -0700561 // The plural value for a given arity.
562 message Entry {
563 // Where the plural was defined.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700564 Source source = 1;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800565
Adam Lesinski0c808952017-07-10 05:40:39 -0700566 // Any comments associated with the plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700567 string comment = 2;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800568
Adam Lesinski0c808952017-07-10 05:40:39 -0700569 // The arity of the plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700570 Arity arity = 3;
Adam Lesinski0c808952017-07-10 05:40:39 -0700571
572 // The value assigned to this plural.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700573 Item item = 4;
Adam Lesinski0c808952017-07-10 05:40:39 -0700574 }
575
576 // The set of arity/plural mappings.
Adam Lesinski4ffea042017-08-10 15:37:28 -0700577 repeated Entry entry = 1;
578}
579
580// Defines an abstract XmlNode that must be either an XmlElement, or
581// a text node represented by a string.
582message XmlNode {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700583 oneof node {
584 XmlElement element = 1;
585 string text = 2;
586 }
Adam Lesinski4ffea042017-08-10 15:37:28 -0700587
588 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700589 SourcePosition source = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700590}
591
592// An <element> in an XML document.
593message XmlElement {
594 // Namespaces defined on this element.
595 repeated XmlNamespace namespace_declaration = 1;
596
597 // The namespace URI of this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700598 string namespace_uri = 2;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700599
600 // The name of this element.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700601 string name = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700602
603 // The attributes of this element.
604 repeated XmlAttribute attribute = 4;
605
606 // The children of this element.
607 repeated XmlNode child = 5;
608}
609
610// A namespace declaration on an XmlElement (xmlns:android="http://...").
611message XmlNamespace {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700612 string prefix = 1;
613 string uri = 2;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700614
615 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700616 SourcePosition source = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700617}
618
619// An attribute defined on an XmlElement (android:text="...").
620message XmlAttribute {
Adam Lesinski5bd44232017-09-07 09:39:07 -0700621 string namespace_uri = 1;
622 string name = 2;
623 string value = 3;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700624
625 // Source line and column info.
Adam Lesinski5bd44232017-09-07 09:39:07 -0700626 SourcePosition source = 4;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700627
Adam Lesinski5bd44232017-09-07 09:39:07 -0700628 // The optional resource ID (0xPPTTEEEE) of the attribute.
629 uint32 resource_id = 5;
Adam Lesinski4ffea042017-08-10 15:37:28 -0700630
Adam Lesinski5bd44232017-09-07 09:39:07 -0700631 // The optional interpreted/compiled version of the `value` string.
632 Item compiled_item = 6;
Adam Lesinski59e04c62016-02-04 15:59:23 -0800633}
Ryan Mitchell326e35ff2021-04-12 07:50:42 -0700634
635message MacroBody {
636 string raw_string = 1;
637 StyleString style_string = 2;
638 repeated UntranslatableSection untranslatable_sections = 3;
639 repeated NamespaceAlias namespace_stack = 4;
640 SourcePosition source = 5;
641}
642
643message NamespaceAlias {
644 string prefix = 1;
645 string package_name = 2;
646 bool is_private = 3;
647}
648
649message StyleString {
650 message Span {
651 string name = 1;
652 uint32 start_index = 2;
653 uint32 end_index = 3;
654 }
655 string str = 1;
656 repeated Span spans = 2;
657}
658
659message UntranslatableSection {
660 uint64 start_index = 1;
661 uint64 end_index = 2;
Jeremy Meyer56f36e82022-05-20 20:35:42 +0000662}