OSDN Git Service

am 35e87811: am 033dc46b: Merge "Switch from FingerprintService to FingerprintManager...
[android-x86/frameworks-base.git] / tools / aapt2 / ResourceTypeExtensions.h
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     /**
34      * A chunk that holds the string pool
35      * for source entries (path/to/source:line).
36      */
37     RES_TABLE_SOURCE_POOL_TYPE = 0x000e,
38
39     /**
40      * A chunk holding names of externally
41      * defined symbols and offsets to where
42      * they are referenced in the table.
43      */
44     RES_TABLE_SYMBOL_TABLE_TYPE = 0x000f,
45 };
46
47 /**
48  * New resource types that are meant to only be used
49  * by AAPT and will not end up on the device.
50  */
51 struct ExtendedTypes {
52     enum {
53         /**
54          * A sentinel value used when a resource is defined as
55          * public but it has no defined value yet. If we don't
56          * flatten it with some value, we will lose its name.
57          */
58         TYPE_SENTINEL = 0xff,
59
60         /**
61          * A raw string value that hasn't had its escape sequences
62          * processed nor whitespace removed.
63          */
64         TYPE_RAW_STRING = 0xfe
65     };
66 };
67
68 /**
69  * A chunk with type RES_TABLE_SYMBOL_TABLE_TYPE.
70  * Following the header are count number of SymbolTable_entry
71  * structures, followed by an android::ResStringPool_header.
72  */
73 struct SymbolTable_header {
74     android::ResChunk_header header;
75
76     /**
77      * Number of SymbolTable_entry structures following
78      * this header.
79      */
80     uint32_t count;
81 };
82
83 struct SymbolTable_entry {
84     /**
85      * Offset from the beginning of the resource table
86      * where the symbol entry is referenced.
87      */
88     uint32_t offset;
89
90     /**
91      * The index into the string pool where the name of this
92      * symbol exists.
93      */
94     uint32_t stringIndex;
95 };
96
97 /**
98  * A structure representing the source of a resourc entry.
99  * Appears after an android::ResTable_entry or android::ResTable_map_entry.
100  *
101  * TODO(adamlesinski): This causes some issues when runtime code checks
102  * the size of an android::ResTable_entry. It assumes it is an
103  * android::ResTable_map_entry if the size is bigger than an android::ResTable_entry
104  * which may not be true if this structure is present.
105  */
106 struct ResTable_entry_source {
107     /**
108      * Index into the source string pool.
109      */
110     uint32_t pathIndex;
111
112     /**
113      * Line number this resource was defined on.
114      */
115     uint32_t line;
116 };
117
118 } // namespace aapt
119
120 #endif // AAPT_RESOURCE_TYPE_EXTENSIONS_H