1 /* 2 * Copyright (C) 2015 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 #ifndef AAPT_RESOURCE_TYPE_EXTENSIONS_H 18 #define AAPT_RESOURCE_TYPE_EXTENSIONS_H 19 20 #include <androidfw/ResourceTypes.h> 21 22 namespace aapt { 23 24 /** 25 * New android::ResChunk_header types defined 26 * for AAPT to use. 27 * 28 * TODO(adamlesinski): Consider reserving these 29 * enums in androidfw/ResourceTypes.h to avoid 30 * future collisions. 31 */ 32 enum { 33 RES_TABLE_PUBLIC_TYPE = 0x000d, 34 35 /** 36 * A chunk that holds the string pool 37 * for source entries (path/to/source:line). 38 */ 39 RES_TABLE_SOURCE_POOL_TYPE = 0x000e, 40 41 /** 42 * A chunk holding names of externally 43 * defined symbols and offsets to where 44 * they are referenced in the table. 45 */ 46 RES_TABLE_SYMBOL_TABLE_TYPE = 0x000f, 47 }; 48 49 /** 50 * New resource types that are meant to only be used 51 * by AAPT and will not end up on the device. 52 */ 53 struct ExtendedTypes { 54 enum { 55 /** 56 * A raw string value that hasn't had its escape sequences 57 * processed nor whitespace removed. 58 */ 59 TYPE_RAW_STRING = 0xfe 60 }; 61 }; 62 63 struct Public_header { 64 android::ResChunk_header header; 65 66 /** 67 * The ID of the type this structure refers to. 68 */ 69 uint8_t typeId; 70 71 /** 72 * Reserved. Must be 0. 73 */ 74 uint8_t res0; 75 76 /** 77 * Reserved. Must be 0. 78 */ 79 uint16_t res1; 80 81 /** 82 * Number of public entries. 83 */ 84 uint32_t count; 85 }; 86 87 struct Public_entry { 88 uint16_t entryId; 89 uint16_t res0; 90 android::ResStringPool_ref key; 91 android::ResStringPool_ref source; 92 uint32_t sourceLine; 93 }; 94 95 /** 96 * A chunk with type RES_TABLE_SYMBOL_TABLE_TYPE. 97 * Following the header are count number of SymbolTable_entry 98 * structures, followed by an android::ResStringPool_header. 99 */ 100 struct SymbolTable_header { 101 android::ResChunk_header header; 102 103 /** 104 * Number of SymbolTable_entry structures following 105 * this header. 106 */ 107 uint32_t count; 108 }; 109 110 struct SymbolTable_entry { 111 /** 112 * Offset from the beginning of the resource table 113 * where the symbol entry is referenced. 114 */ 115 uint32_t offset; 116 117 /** 118 * The index into the string pool where the name of this 119 * symbol exists. 120 */ 121 uint32_t stringIndex; 122 }; 123 124 /** 125 * A structure representing the source of a resourc entry. 126 * Appears after an android::ResTable_entry or android::ResTable_map_entry. 127 * 128 * TODO(adamlesinski): This causes some issues when runtime code checks 129 * the size of an android::ResTable_entry. It assumes it is an 130 * android::ResTable_map_entry if the size is bigger than an android::ResTable_entry 131 * which may not be true if this structure is present. 132 */ 133 struct ResTable_entry_source { 134 /** 135 * Index into the source string pool. 136 */ 137 uint32_t pathIndex; 138 139 /** 140 * Line number this resource was defined on. 141 */ 142 uint32_t line; 143 }; 144 145 } // namespace aapt 146 147 #endif // AAPT_RESOURCE_TYPE_EXTENSIONS_H 148