1/* 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 17syntax = "proto3"; 18 19import "frameworks/base/tools/aapt2/Configuration.proto"; 20 21package aapt.pb; 22 23option java_package = "com.android.aapt"; 24 25// A string pool that wraps the binary form of the C++ class android::ResStringPool. 26message StringPool { 27 bytes data = 1; 28} 29 30// The position of a declared entity within a file. 31message SourcePosition { 32 uint32 line_number = 1; 33 uint32 column_number = 2; 34} 35 36// Developer friendly source file information for an entity in the resource table. 37message Source { 38 // The index of the string path within the source string pool of a ResourceTable. 39 uint32 path_idx = 1; 40 SourcePosition position = 2; 41} 42 43// The name and version fingerprint of a build tool. 44message ToolFingerprint { 45 string tool = 1; 46 string version = 2; 47} 48 49// Top level message representing a resource table. 50message ResourceTable { 51 // The string pool containing source paths referenced throughout the resource table. This does 52 // not end up in the final binary ARSC file. 53 StringPool source_pool = 1; 54 55 // Resource definitions corresponding to an Android package. 56 repeated Package package = 2; 57 58 // The <overlayable> declarations within the resource table. 59 repeated Overlayable overlayable = 3; 60 61 // The version fingerprints of the tools that built the resource table. 62 repeated ToolFingerprint tool_fingerprint = 4; 63} 64 65// A package ID in the range [0x00, 0xff]. 66message PackageId { 67 uint32 id = 1; 68} 69 70// Defines resources for an Android package. 71message Package { 72 // The package ID of this package, in the range [0x00, 0xff]. 73 // - 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; 80 81 // The Java compatible Android package name of the app. 82 string package_name = 2; 83 84 // The series of types defined by the package. 85 repeated Type type = 3; 86} 87 88// A type ID in the range [0x01, 0xff]. 89message TypeId { 90 uint32 id = 1; 91} 92 93// 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 { 96 // The ID of the type. This may not be set if no ID was assigned. 97 TypeId type_id = 1; 98 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. 101 string name = 2; 102 103 // The entries defined for this type. 104 repeated Entry entry = 3; 105} 106 107// The Visibility of a symbol/entry (public, private, undefined). 108message Visibility { 109 // The visibility of the resource outside of its package. 110 enum Level { 111 // 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. 115 UNKNOWN = 0; 116 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. 121 PRIVATE = 1; 122 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. 125 PUBLIC = 2; 126 } 127 128 Level level = 1; 129 130 // The path at which this entry's visibility was defined (eg. public.xml). 131 Source source = 2; 132 133 // The comment associated with the <public> tag. 134 string comment = 3; 135} 136 137// Whether a resource comes from a compile-time overlay and is explicitly allowed to not overlay an 138// existing resource. 139message AllowNew { 140 // Where this was defined in source. 141 Source source = 1; 142 143 // Any comment associated with the declaration. 144 string comment = 2; 145} 146 147// Represents a set of overlayable resources. 148message Overlayable { 149 // The name of the <overlayable>. 150 string name = 1; 151 152 // The location of the <overlayable> declaration in the source. 153 Source source = 2; 154 155 // The component responsible for enabling and disabling overlays targeting this <overlayable>. 156 string actor = 3; 157} 158 159// Represents an overlayable <item> declaration within an <overlayable> tag. 160message OverlayableItem { 161 enum Policy { 162 NONE = 0; 163 PUBLIC = 1; 164 SYSTEM = 2; 165 VENDOR = 3; 166 PRODUCT = 4; 167 SIGNATURE = 5; 168 ODM = 6; 169 OEM = 7; 170 ACTOR = 8; 171 } 172 173 // The location of the <item> declaration in source. 174 Source source = 1; 175 176 // Any comment associated with the declaration. 177 string comment = 2; 178 179 // The policy defined by the enclosing <policy> tag of this <item>. 180 repeated Policy policy = 3; 181 182 // The index into overlayable list that points to the <overlayable> tag that contains 183 // this <item>. 184 uint32 overlayable_idx = 4; 185} 186 187// An entry ID in the range [0x0000, 0xffff]. 188message EntryId { 189 uint32 id = 1; 190} 191 192// An entry declaration. An entry has a full resource ID that is the combination of package ID, 193// type ID, and its own entry ID. An entry on its own has no value, but values are defined for 194// various configurations/variants. 195message Entry { 196 // The ID of this entry. Together with the package ID and type ID, this forms a full resource ID 197 // of the form 0xPPTTEEEE, where PP is the package ID, TT is the type ID, and EEEE is the entry 198 // ID. 199 // This may not be set if no ID was assigned. 200 EntryId entry_id = 1; 201 202 // The name of this entry. This corresponds to the 'entry' part of a full resource name of the 203 // form package:type/entry. 204 string name = 2; 205 206 // The visibility of this entry (public, private, undefined). 207 Visibility visibility = 3; 208 209 // Whether this resource, when originating from a compile-time overlay, is allowed to NOT overlay 210 // any existing resources. 211 AllowNew allow_new = 4; 212 213 // Whether this resource can be overlaid by a runtime resource overlay (RRO). 214 OverlayableItem overlayable_item = 5; 215 216 // The set of values defined for this entry, each corresponding to a different 217 // configuration/variant. 218 repeated ConfigValue config_value = 6; 219} 220 221// A Configuration/Value pair. 222message ConfigValue { 223 Configuration config = 1; 224 Value value = 2; 225} 226 227// The generic meta-data for every value in a resource table. 228message Value { 229 // Where the value was defined. 230 Source source = 1; 231 232 // Any comment associated with the value. 233 string comment = 2; 234 235 // Whether the value can be overridden. 236 bool weak = 3; 237 238 // The value is either an Item or a CompoundValue. 239 oneof value { 240 Item item = 4; 241 CompoundValue compound_value = 5; 242 } 243} 244 245// An Item is an abstract type. It represents a value that can appear inline in many places, such 246// as XML attribute values or on the right hand side of style attribute definitions. The concrete 247// type is one of the types below. Only one can be set. 248message Item { 249 oneof value { 250 Reference ref = 1; 251 String str = 2; 252 RawString raw_str = 3; 253 StyledString styled_str = 4; 254 FileReference file = 5; 255 Id id = 6; 256 Primitive prim = 7; 257 } 258} 259 260// A CompoundValue is an abstract type. It represents a value that is a made of other values. 261// These can only usually appear as top-level resources. The concrete type is one of the types 262// below. Only one can be set. 263message CompoundValue { 264 oneof value { 265 Attribute attr = 1; 266 Style style = 2; 267 Styleable styleable = 3; 268 Array array = 4; 269 Plural plural = 5; 270 } 271} 272 273// Message holding a boolean, so it can be optionally encoded. 274message Boolean { 275 bool value = 1; 276} 277 278// A value that is a reference to another resource. This reference can be by name or resource ID. 279message Reference { 280 enum Type { 281 // A plain reference (@package:type/entry). 282 REFERENCE = 0; 283 284 // A reference to a theme attribute (?package:type/entry). 285 ATTRIBUTE = 1; 286 } 287 288 Type type = 1; 289 290 // The resource ID (0xPPTTEEEE) of the resource being referred. This is optional. 291 uint32 id = 2; 292 293 // The name of the resource being referred. This is optional if the resource ID is set. 294 string name = 3; 295 296 // Whether this reference is referencing a private resource (@*package:type/entry). 297 bool private = 4; 298 299 // Whether this reference is dynamic. 300 Boolean is_dynamic = 5; 301} 302 303// A value that represents an ID. This is just a placeholder, as ID values are used to occupy a 304// resource ID (0xPPTTEEEE) as a unique identifier. Their value is unimportant. 305message Id { 306} 307 308// A value that is a string. 309message String { 310 string value = 1; 311} 312 313// A value that is a raw string, which is unescaped/uninterpreted. This is typically used to 314// represent the value of a style attribute before the attribute is compiled and the set of 315// allowed values is known. 316message RawString { 317 string value = 1; 318} 319 320// A string with styling information, like html tags that specify boldness, italics, etc. 321message StyledString { 322 // The raw text of the string. 323 string value = 1; 324 325 // A Span marks a region of the string text that is styled. 326 message Span { 327 // The name of the tag, and its attributes, encoded as follows: 328 // tag_name;attr1=value1;attr2=value2;[...] 329 string tag = 1; 330 331 // The first character position this span applies to, in UTF-16 offset. 332 uint32 first_char = 2; 333 334 // The last character position this span applies to, in UTF-16 offset. 335 uint32 last_char = 3; 336 } 337 338 repeated Span span = 2; 339} 340 341// A value that is a reference to an external entity, like an XML file or a PNG. 342message FileReference { 343 enum Type { 344 UNKNOWN = 0; 345 PNG = 1; 346 BINARY_XML = 2; 347 PROTO_XML = 3; 348 } 349 350 // Path to a file within the APK (typically res/type-config/entry.ext). 351 string path = 1; 352 353 // The type of file this path points to. For UAM bundle, this cannot be 354 // BINARY_XML. 355 Type type = 2; 356} 357 358// A value that represents a primitive data type (float, int, boolean, etc.). 359// Refer to Res_value in ResourceTypes.h for info on types and formatting 360message Primitive { 361 message NullType { 362 } 363 message EmptyType { 364 } 365 oneof oneof_value { 366 NullType null_value = 1; 367 EmptyType empty_value = 2; 368 float float_value = 3; 369 uint32 dimension_value = 13; 370 uint32 fraction_value = 14; 371 int32 int_decimal_value = 6; 372 uint32 int_hexadecimal_value = 7; 373 bool boolean_value = 8; 374 uint32 color_argb8_value = 9; 375 uint32 color_rgb8_value = 10; 376 uint32 color_argb4_value = 11; 377 uint32 color_rgb4_value = 12; 378 float dimension_value_deprecated = 4 [deprecated=true]; 379 float fraction_value_deprecated = 5 [deprecated=true]; 380 } 381} 382 383// A value that represents an XML attribute and what values it accepts. 384message Attribute { 385 // A Symbol used to represent an enum or a flag. 386 message Symbol { 387 // Where the enum/flag item was defined. 388 Source source = 1; 389 390 // Any comments associated with the enum or flag. 391 string comment = 2; 392 393 // The name of the enum/flag as a reference. Enums/flag items are generated as ID resource 394 // values. 395 Reference name = 3; 396 397 // The value of the enum/flag. 398 uint32 value = 4; 399 400 // The data type of the enum/flag as defined in android::Res_value. 401 uint32 type = 5; 402 } 403 404 // Bitmask of formats allowed for an attribute. 405 enum FormatFlags { 406 NONE = 0x0; // Proto3 requires a default of 0. 407 ANY = 0x0000ffff; // Allows any type except ENUM and FLAGS. 408 REFERENCE = 0x01; // Allows Reference values. 409 STRING = 0x02; // Allows String/StyledString values. 410 INTEGER = 0x04; // Allows any integer BinaryPrimitive values. 411 BOOLEAN = 0x08; // Allows any boolean BinaryPrimitive values. 412 COLOR = 0x010; // Allows any color BinaryPrimitive values. 413 FLOAT = 0x020; // Allows any float BinaryPrimitive values. 414 DIMENSION = 0x040; // Allows any dimension BinaryPrimitive values. 415 FRACTION = 0x080; // Allows any fraction BinaryPrimitive values. 416 ENUM = 0x00010000; // Allows enums that are defined in the Attribute's symbols. 417 // ENUM and FLAGS cannot BOTH be set. 418 FLAGS = 0x00020000; // Allows flags that are defined in the Attribute's symbols. 419 // ENUM and FLAGS cannot BOTH be set. 420 } 421 422 // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the 423 // enum FormatFlags. 424 uint32 format_flags = 1; 425 426 // The smallest integer allowed for this XML attribute. Only makes sense if the format includes 427 // FormatFlags::INTEGER. 428 int32 min_int = 2; 429 430 // The largest integer allowed for this XML attribute. Only makes sense if the format includes 431 // FormatFlags::INTEGER. 432 int32 max_int = 3; 433 434 // The set of enums/flags defined in this attribute. Only makes sense if the format includes 435 // either FormatFlags::ENUM or FormatFlags::FLAGS. Having both is an error. 436 repeated Symbol symbol = 4; 437} 438 439// A value that represents a style. 440message Style { 441 // An XML attribute/value pair defined in the style. 442 message Entry { 443 // Where the entry was defined. 444 Source source = 1; 445 446 // Any comments associated with the entry. 447 string comment = 2; 448 449 // A reference to the XML attribute. 450 Reference key = 3; 451 452 // The Item defined for this XML attribute. 453 Item item = 4; 454 } 455 456 // The optinal style from which this style inherits attributes. 457 Reference parent = 1; 458 459 // The source file information of the parent inheritance declaration. 460 Source parent_source = 2; 461 462 // The set of XML attribute/value pairs for this style. 463 repeated Entry entry = 3; 464} 465 466// A value that represents a <declare-styleable> XML resource. These are not real resources and 467// only end up as Java fields in the generated R.java. They do not end up in the binary ARSC file. 468message Styleable { 469 // An attribute defined for this styleable. 470 message Entry { 471 // Where the attribute was defined within the <declare-styleable> block. 472 Source source = 1; 473 474 // Any comments associated with the declaration. 475 string comment = 2; 476 477 // The reference to the attribute. 478 Reference attr = 3; 479 } 480 481 // The set of attribute declarations. 482 repeated Entry entry = 1; 483} 484 485// A value that represents an array of resource values. 486message Array { 487 // A single element of the array. 488 message Element { 489 // Where the element was defined. 490 Source source = 1; 491 492 // Any comments associated with the element. 493 string comment = 2; 494 495 // The value assigned to this element. 496 Item item = 3; 497 } 498 499 // The list of array elements. 500 repeated Element element = 1; 501} 502 503// A value that represents a string and its many variations based on plurality. 504message Plural { 505 // The arity of the plural. 506 enum Arity { 507 ZERO = 0; 508 ONE = 1; 509 TWO = 2; 510 FEW = 3; 511 MANY = 4; 512 OTHER = 5; 513 } 514 515 // The plural value for a given arity. 516 message Entry { 517 // Where the plural was defined. 518 Source source = 1; 519 520 // Any comments associated with the plural. 521 string comment = 2; 522 523 // The arity of the plural. 524 Arity arity = 3; 525 526 // The value assigned to this plural. 527 Item item = 4; 528 } 529 530 // The set of arity/plural mappings. 531 repeated Entry entry = 1; 532} 533 534// Defines an abstract XmlNode that must be either an XmlElement, or 535// a text node represented by a string. 536message XmlNode { 537 oneof node { 538 XmlElement element = 1; 539 string text = 2; 540 } 541 542 // Source line and column info. 543 SourcePosition source = 3; 544} 545 546// An <element> in an XML document. 547message XmlElement { 548 // Namespaces defined on this element. 549 repeated XmlNamespace namespace_declaration = 1; 550 551 // The namespace URI of this element. 552 string namespace_uri = 2; 553 554 // The name of this element. 555 string name = 3; 556 557 // The attributes of this element. 558 repeated XmlAttribute attribute = 4; 559 560 // The children of this element. 561 repeated XmlNode child = 5; 562} 563 564// A namespace declaration on an XmlElement (xmlns:android="http://..."). 565message XmlNamespace { 566 string prefix = 1; 567 string uri = 2; 568 569 // Source line and column info. 570 SourcePosition source = 3; 571} 572 573// An attribute defined on an XmlElement (android:text="..."). 574message XmlAttribute { 575 string namespace_uri = 1; 576 string name = 2; 577 string value = 3; 578 579 // Source line and column info. 580 SourcePosition source = 4; 581 582 // The optional resource ID (0xPPTTEEEE) of the attribute. 583 uint32 resource_id = 5; 584 585 // The optional interpreted/compiled version of the `value` string. 586 Item compiled_item = 6; 587} 588