Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 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 | |
| 17 | syntax = "proto2"; |
| 18 | |
| 19 | option optimize_for = LITE_RUNTIME; |
| 20 | |
| 21 | package aapt.pb; |
| 22 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 23 | // A configuration description that wraps the binary form of the C++ class |
| 24 | // aapt::ConfigDescription, with an added product definition. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 25 | message ConfigDescription { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 26 | optional bytes data = 1; |
| 27 | optional string product = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 28 | } |
| 29 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 30 | // A string pool that wraps the binary form of the C++ class android::ResStringPool. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 31 | message StringPool { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 32 | optional bytes data = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 33 | } |
| 34 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 35 | // Developer friendly source file information for an entity in the resource table. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 36 | message Source { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 37 | // The index of the string path within the source string pool of a ResourceTable. |
| 38 | optional uint32 path_idx = 1; |
| 39 | |
| 40 | optional uint32 line_no = 2; |
| 41 | optional uint32 col_no = 3; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 42 | } |
| 43 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 44 | // The top level message representing an external resource file (layout XML, PNG, etc). |
| 45 | message CompiledFile { |
| 46 | message Symbol { |
| 47 | // The name of the symbol (in the form package:type/name). |
| 48 | optional string resource_name = 1; |
| 49 | |
| 50 | // Line number in the file at which this symbol is defined. For debug use. |
| 51 | optional uint32 line_no = 2; |
| 52 | } |
| 53 | |
| 54 | // The name of the resource (in the form package:type/name). |
| 55 | optional string resource_name = 1; |
| 56 | |
| 57 | // The configuration for which the resource is defined. |
| 58 | optional ConfigDescription config = 2; |
| 59 | |
| 60 | // The filesystem path to where the source file originated. |
| 61 | // Mainly used to display helpful error messages. |
| 62 | optional string source_path = 3; |
| 63 | |
| 64 | // Any symbols this file auto-generates/exports (eg. @+id/foo in an XML file). |
| 65 | repeated Symbol exported_symbols = 4; |
| 66 | } |
| 67 | |
| 68 | // Top level message representing a resource table. |
| 69 | message ResourceTable { |
| 70 | // The string pool containing string values (strings that actually end up in the binary ARSC |
| 71 | // file) referenced throughout the resource table. |
| 72 | optional StringPool string_pool = 1; |
| 73 | |
| 74 | // The string pool containing source paths referenced throughout the resource table. This does |
| 75 | // not end up in the final binary ARSC file. |
| 76 | optional StringPool source_pool = 2; |
| 77 | |
| 78 | // The string pool containing the names of unresolved symbols. This does not end up in the final |
| 79 | // binary ARSC file. Unresolved symbols are just resource names that haven't had a resource ID |
| 80 | // assigned to them, therefore can't be referenced by resource ID. |
| 81 | optional StringPool symbol_pool = 3; |
| 82 | |
| 83 | // Resource definitions corresponding to an Android package. |
| 84 | repeated Package packages = 4; |
| 85 | } |
| 86 | |
| 87 | // Defines resources for an Android package. |
| 88 | message Package { |
| 89 | // The package ID of this package, in the range [0x00, 0xff]. |
| 90 | // The ID 0x00 is reserved for shared libraries, or when the ID is assigned at run-time. |
| 91 | // The ID 0x01 is reserved for the 'android' package (framework). |
| 92 | // The ID range [0x02, 0x7f) is reserved for auto-assignment to shared libraries at run-time. |
| 93 | // The ID 0x7f is reserved for the application package. |
| 94 | // IDs > 0x7f are reserved for the application as well and are treated as feature splits. |
| 95 | optional uint32 package_id = 1; |
| 96 | |
| 97 | // The Java compatible Android package name of the app. |
| 98 | optional string package_name = 2; |
| 99 | |
| 100 | // The series of types defined by the package. |
| 101 | repeated Type types = 3; |
| 102 | } |
| 103 | |
| 104 | // A set of resources grouped under a common type. Such types include string, layout, xml, dimen, |
| 105 | // attr, etc. This maps to the second part of a resource identifier in Java (R.type.entry). |
| 106 | message Type { |
| 107 | // The ID of the type. This may be 0, which indicates no ID is set. |
| 108 | optional uint32 id = 1; |
| 109 | |
| 110 | // The name of the type. This corresponds to the 'type' part of a full resource name of the form |
| 111 | // package:type/entry. The set of legal type names is listed in Resource.cpp. |
| 112 | optional string name = 2; |
| 113 | |
| 114 | // The entries defined for this type. |
| 115 | repeated Entry entries = 3; |
| 116 | } |
| 117 | |
| 118 | // The status of a symbol/entry. This contains information like visibility (public/private), |
| 119 | // comments, and whether the entry can be overridden. |
| 120 | message SymbolStatus { |
| 121 | // The visibility of the resource outside of its package. |
| 122 | enum Visibility { |
| 123 | // No visibility was explicitly specified. This is typically treated as private. |
| 124 | // The distinction is important when two separate R.java files are generated: a public and |
| 125 | // private one. An unknown visibility, in this case, would cause the resource to be omitted |
| 126 | // from either R.java. |
| 127 | Unknown = 0; |
| 128 | |
| 129 | // A resource was explicitly marked as private. This means the resource can not be accessed |
| 130 | // outside of its package unless the @*package:type/entry notation is used (the asterisk being |
| 131 | // the private accessor). If two R.java files are generated (private + public), the resource |
| 132 | // will only be emitted to the private R.java file. |
| 133 | Private = 1; |
| 134 | |
| 135 | // A resource was explicitly marked as public. This means the resource can be accessed |
| 136 | // from any package, and is emitted into all R.java files, public and private. |
| 137 | Public = 2; |
| 138 | } |
| 139 | |
| 140 | optional Visibility visibility = 1; |
| 141 | |
| 142 | // The path at which this entry's visibility was defined (eg. public.xml). |
| 143 | optional Source source = 2; |
| 144 | |
| 145 | // The comment associated with the <public> tag. |
| 146 | optional string comment = 3; |
| 147 | |
| 148 | // Whether the symbol can be merged into another resource table without there being an existing |
| 149 | // definition to override. Used for overlays and set to true when <add-resource> is specified. |
| 150 | optional bool allow_new = 4; |
| 151 | } |
| 152 | |
| 153 | // An entry declaration. An entry has a full resource ID that is the combination of package ID, |
| 154 | // type ID, and its own entry ID. An entry on its own has no value, but values are defined for |
| 155 | // various configurations/variants. |
| 156 | message Entry { |
| 157 | // The ID of this entry. Together with the package ID and type ID, this forms a full resource ID |
| 158 | // of the form 0xPPTTEEEE, where PP is the package ID, TT is the type ID, and EEEE is the entry |
| 159 | // ID. |
| 160 | optional uint32 id = 1; |
| 161 | |
| 162 | // The name of this entry. This corresponds to the 'entry' part of a full resource name of the |
| 163 | // form package:type/entry. |
| 164 | optional string name = 2; |
| 165 | |
| 166 | // The symbol status of this entry, which includes visibility information. |
| 167 | optional SymbolStatus symbol_status = 3; |
| 168 | |
| 169 | // The set of values defined for this entry, each corresponding to a different |
| 170 | // configuration/variant. |
| 171 | repeated ConfigValue config_values = 4; |
| 172 | } |
| 173 | |
| 174 | // A Configuration/Value pair. |
| 175 | message ConfigValue { |
| 176 | optional ConfigDescription config = 1; |
| 177 | optional Value value = 2; |
| 178 | } |
| 179 | |
| 180 | // The generic meta-data for every value in a resource table. |
| 181 | message Value { |
| 182 | // Where the value was defined. |
| 183 | optional Source source = 1; |
| 184 | |
| 185 | // Any comment associated with the value. |
| 186 | optional string comment = 2; |
| 187 | |
| 188 | // Whether the value can be overridden. |
| 189 | optional bool weak = 3; |
| 190 | |
| 191 | // If the value is an Item, this is set. |
| 192 | optional Item item = 4; |
| 193 | |
| 194 | // If the value is a CompoundValue, this is set. |
| 195 | optional CompoundValue compound_value = 5; |
| 196 | } |
| 197 | |
| 198 | // An Item is an abstract type. It represents a value that can appear inline in many places, such |
| 199 | // as XML attribute values or on the right hand side of style attribute definitions. The concrete |
| 200 | // type is one of the types below. Only one can be set. |
| 201 | message Item { |
| 202 | optional Reference ref = 1; |
| 203 | optional String str = 2; |
| 204 | optional RawString raw_str = 3; |
| 205 | optional FileReference file = 4; |
| 206 | optional Id id = 5; |
| 207 | optional Primitive prim = 6; |
| 208 | } |
| 209 | |
| 210 | // A CompoundValue is an abstract type. It represents a value that is a made of other values. |
| 211 | // These can only usually appear as top-level resources. The concrete type is one of the types |
| 212 | // below. Only one can be set. |
| 213 | message CompoundValue { |
| 214 | optional Attribute attr = 1; |
| 215 | optional Style style = 2; |
| 216 | optional Styleable styleable = 3; |
| 217 | optional Array array = 4; |
| 218 | optional Plural plural = 5; |
| 219 | } |
| 220 | |
| 221 | // A value that is a reference to another resource. This reference can be by name or resource ID. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 222 | message Reference { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 223 | enum Type { |
| 224 | // A plain reference (@package:type/entry). |
| 225 | Ref = 0; |
| 226 | |
| 227 | // A reference to a theme attribute (?package:type/entry). |
| 228 | Attr = 1; |
| 229 | } |
| 230 | |
| 231 | optional Type type = 1; |
| 232 | |
| 233 | // The resource ID (0xPPTTEEEE) of the resource being referred. |
| 234 | optional uint32 id = 2; |
| 235 | |
| 236 | // If the resource ID is not resolved, the index into the symbol string pool where the name of |
| 237 | // the reference is stored. The symbol string pool is located at the top level ResourceTable |
| 238 | // message. |
| 239 | optional uint32 symbol_idx = 3; |
| 240 | |
| 241 | // Whether this reference is referencing a private resource (@*package:type/entry). |
| 242 | optional bool private = 4; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 243 | } |
| 244 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 245 | // A value that represents an ID. This is just a placeholder, as ID values are used to occupy a |
| 246 | // resource ID (0xPPTTEEEE) as a unique identifier. Their value is unimportant. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 247 | message Id { |
| 248 | } |
| 249 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 250 | // A value that is a string. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 251 | message String { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 252 | // The index into the values string pool, located at the top level ResourceTable message. |
| 253 | optional uint32 idx = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 254 | } |
| 255 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 256 | // A value that is a raw string, which is unescaped/uninterpreted. This is typically used to |
| 257 | // represent the value of a style attribute before the attribute is compiled and the set of |
| 258 | // allowed values is known. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 259 | message RawString { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 260 | // The index into the values string pool, located at the top level ResourceTable message. |
| 261 | optional uint32 idx = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 264 | // A value that is a reference to an external entity, like an XML file or a PNG. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 265 | message FileReference { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 266 | // The index into the values string pool, located at the top level ResourceTable message. This |
| 267 | // represents the path to the file within an APK (typically res/type-config/entry.ext). |
| 268 | optional uint32 path_idx = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 269 | } |
| 270 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 271 | // A value that represents a primitive data type (float, int, boolean, etc.). |
| 272 | // Corresponds to the fields (type/data) of the C struct android::Res_value. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 273 | message Primitive { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 274 | optional uint32 type = 1; |
| 275 | optional uint32 data = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 276 | } |
| 277 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 278 | // A value that represents an XML attribute and what values it accepts. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 279 | message Attribute { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 280 | // A Symbol used to represent an enum or a flag. |
| 281 | message Symbol { |
| 282 | // Where the enum/flag item was defined. |
| 283 | optional Source source = 1; |
| 284 | |
| 285 | // Any comments associated with the enum or flag. |
| 286 | optional string comment = 2; |
| 287 | |
| 288 | // The name of the enum/flag as a reference. Enums/flag items are generated as ID resource |
| 289 | // values. |
| 290 | optional Reference name = 3; |
| 291 | |
| 292 | // The value of the enum/flag. |
| 293 | optional uint32 value = 4; |
| 294 | } |
| 295 | |
| 296 | // A bitmask of types that this XML attribute accepts. Corresponds to the flags in the C struct |
| 297 | // android::ResTable_map. |
| 298 | optional uint32 format_flags = 1; |
| 299 | |
| 300 | // The smallest integer allowed for this XML attribute. Only makes sense if the format includes |
| 301 | // TYPE_INTEGER. |
| 302 | optional int32 min_int = 2; |
| 303 | |
| 304 | // The largest integer allowed for this XML attribute. Only makes sense if the format includes |
| 305 | // TYPE_INTEGER. |
| 306 | optional int32 max_int = 3; |
| 307 | |
| 308 | // The set of enums/flags defined in this attribute. Only makes sense if the format includes |
| 309 | // either TYPE_ENUM or TYPE_FLAGS. Having both is an error. |
| 310 | repeated Symbol symbols = 4; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 311 | } |
| 312 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 313 | // A value that represents a style. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 314 | message Style { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 315 | // An XML attribute/value pair defined in the style. |
| 316 | message Entry { |
| 317 | // Where the entry was defined. |
| 318 | optional Source source = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 319 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 320 | // Any comments associated with the entry. |
| 321 | optional string comment = 2; |
| 322 | |
| 323 | // A reference to the XML attribute. |
| 324 | optional Reference key = 3; |
| 325 | |
| 326 | // The Item defined for this XML attribute. |
| 327 | optional Item item = 4; |
| 328 | } |
| 329 | |
| 330 | // The optinal style from which this style inherits attributes. |
| 331 | optional Reference parent = 1; |
| 332 | |
| 333 | // The source file information of the parent inheritance declaration. |
| 334 | optional Source parent_source = 2; |
| 335 | |
| 336 | // The set of XML attribute/value pairs for this style. |
| 337 | repeated Entry entries = 3; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 338 | } |
| 339 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 340 | // A value that represents a <declare-styleable> XML resource. These are not real resources and |
| 341 | // only end up as Java fields in the generated R.java. They do not end up in the binary ARSC file. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 342 | message Styleable { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 343 | // An attribute defined for this styleable. |
| 344 | message Entry { |
| 345 | // Where the attribute was defined within the <declare-styleable> block. |
| 346 | optional Source source = 1; |
| 347 | |
| 348 | // Any comments associated with the declaration. |
| 349 | optional string comment = 2; |
| 350 | |
| 351 | // The reference to the attribute. |
| 352 | optional Reference attr = 3; |
| 353 | } |
| 354 | |
| 355 | // The set of attribute declarations. |
| 356 | repeated Entry entries = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 357 | } |
| 358 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 359 | // A value that represents an array of resource values. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 360 | message Array { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 361 | // A single element of the array. |
| 362 | message Entry { |
| 363 | // Where the element was defined. |
| 364 | optional Source source = 1; |
| 365 | |
| 366 | // Any comments associated with the element. |
| 367 | optional string comment = 2; |
| 368 | |
| 369 | // The value assigned to this element. |
| 370 | optional Item item = 3; |
| 371 | } |
| 372 | |
| 373 | // The list of array elements. |
| 374 | repeated Entry entries = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 375 | } |
| 376 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 377 | // A value that represents a string and its many variations based on plurality. |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 378 | message Plural { |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 379 | // The arity of the plural. |
| 380 | enum Arity { |
| 381 | Zero = 0; |
| 382 | One = 1; |
| 383 | Two = 2; |
| 384 | Few = 3; |
| 385 | Many = 4; |
| 386 | Other = 5; |
| 387 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 388 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 389 | // The plural value for a given arity. |
| 390 | message Entry { |
| 391 | // Where the plural was defined. |
| 392 | optional Source source = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 393 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 394 | // Any comments associated with the plural. |
| 395 | optional string comment = 2; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 396 | |
Adam Lesinski | 0c80895 | 2017-07-10 05:40:39 -0700 | [diff] [blame] | 397 | // The arity of the plural. |
| 398 | optional Arity arity = 3; |
| 399 | |
| 400 | // The value assigned to this plural. |
| 401 | optional Item item = 4; |
| 402 | } |
| 403 | |
| 404 | // The set of arity/plural mappings. |
| 405 | repeated Entry entries = 1; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 406 | } |