blob: 00f7a42f10e470cffeb425f9f974e084d1ec4222 [file] [log] [blame]
Adam Lesinski4452e132016-10-12 07:47:28 -07001/*
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 Lesinski7a37b742016-10-12 14:05:55 -070017#include "AttributeFinder.h"
18
Adam Lesinski4452e132016-10-12 07:47:28 -070019#include "androidfw/AttributeResolution.h"
20#include "androidfw/ResourceTypes.h"
21
22#include <android/log.h>
23#include <cstdint>
24
25constexpr bool kDebugStyles = false;
26
27namespace android {
28
Adam Lesinski4452e132016-10-12 07:47:28 -070029class XmlAttributeFinder : public BackTrackingAttributeFinder<XmlAttributeFinder, size_t> {
Adam Lesinski7a37b742016-10-12 14:05:55 -070030 public:
31 explicit XmlAttributeFinder(const ResXMLParser* parser)
32 : BackTrackingAttributeFinder(0, parser != NULL ? parser->getAttributeCount() : 0),
33 parser_(parser) {}
Adam Lesinski4452e132016-10-12 07:47:28 -070034
Adam Lesinski7a37b742016-10-12 14:05:55 -070035 inline uint32_t GetAttribute(size_t index) const { return parser_->getAttributeNameResID(index); }
Adam Lesinski4452e132016-10-12 07:47:28 -070036
Adam Lesinski7a37b742016-10-12 14:05:55 -070037 private:
38 const ResXMLParser* parser_;
Adam Lesinski4452e132016-10-12 07:47:28 -070039};
40
Adam Lesinski7a37b742016-10-12 14:05:55 -070041class BagAttributeFinder
42 : public BackTrackingAttributeFinder<BagAttributeFinder, const ResTable::bag_entry*> {
43 public:
44 BagAttributeFinder(const ResTable::bag_entry* start, const ResTable::bag_entry* end)
45 : BackTrackingAttributeFinder(start, end) {}
Adam Lesinski4452e132016-10-12 07:47:28 -070046
Adam Lesinski7a37b742016-10-12 14:05:55 -070047 inline uint32_t GetAttribute(const ResTable::bag_entry* entry) const {
48 return entry->map.name.ident;
49 }
Adam Lesinski4452e132016-10-12 07:47:28 -070050};
51
Adam Lesinski7a37b742016-10-12 14:05:55 -070052bool ResolveAttrs(ResTable::Theme* theme, uint32_t def_style_attr, uint32_t def_style_res,
53 uint32_t* src_values, size_t src_values_length, uint32_t* attrs,
54 size_t attrs_length, uint32_t* out_values, uint32_t* out_indices) {
55 if (kDebugStyles) {
56 ALOGI("APPLY STYLE: theme=0x%p defStyleAttr=0x%x defStyleRes=0x%x", theme, def_style_attr,
57 def_style_res);
58 }
59
60 const ResTable& res = theme->getResTable();
61 ResTable_config config;
62 Res_value value;
63
64 int indices_idx = 0;
65
66 // Load default style from attribute, if specified...
67 uint32_t def_style_bag_type_set_flags = 0;
68 if (def_style_attr != 0) {
69 Res_value value;
70 if (theme->getAttribute(def_style_attr, &value, &def_style_bag_type_set_flags) >= 0) {
71 if (value.dataType == Res_value::TYPE_REFERENCE) {
72 def_style_res = value.data;
73 }
74 }
75 }
76
77 // Now lock down the resource object and start pulling stuff from it.
78 res.lock();
79
80 // Retrieve the default style bag, if requested.
81 const ResTable::bag_entry* def_style_start = NULL;
82 uint32_t def_style_type_set_flags = 0;
83 ssize_t bag_off =
84 def_style_res != 0
85 ? res.getBagLocked(def_style_res, &def_style_start, &def_style_type_set_flags)
86 : -1;
87 def_style_type_set_flags |= def_style_bag_type_set_flags;
88 const ResTable::bag_entry* const def_style_end = def_style_start + (bag_off >= 0 ? bag_off : 0);
89 BagAttributeFinder def_style_attr_finder(def_style_start, def_style_end);
90
91 // Now iterate through all of the attributes that the client has requested,
92 // filling in each with whatever data we can find.
93 for (size_t ii = 0; ii < attrs_length; ii++) {
94 const uint32_t cur_ident = attrs[ii];
95
Adam Lesinski4452e132016-10-12 07:47:28 -070096 if (kDebugStyles) {
Adam Lesinski7a37b742016-10-12 14:05:55 -070097 ALOGI("RETRIEVING ATTR 0x%08x...", cur_ident);
Adam Lesinski4452e132016-10-12 07:47:28 -070098 }
99
Adam Lesinski7a37b742016-10-12 14:05:55 -0700100 ssize_t block = -1;
101 uint32_t type_set_flags = 0;
Adam Lesinski4452e132016-10-12 07:47:28 -0700102
Adam Lesinski7a37b742016-10-12 14:05:55 -0700103 value.dataType = Res_value::TYPE_NULL;
104 value.data = Res_value::DATA_NULL_UNDEFINED;
105 config.density = 0;
Adam Lesinski4452e132016-10-12 07:47:28 -0700106
Adam Lesinski7a37b742016-10-12 14:05:55 -0700107 // Try to find a value for this attribute... we prioritize values
108 // coming from, first XML attributes, then XML style, then default
109 // style, and finally the theme.
110
111 // Retrieve the current input value if available.
112 if (src_values_length > 0 && src_values[ii] != 0) {
113 value.dataType = Res_value::TYPE_ATTRIBUTE;
114 value.data = src_values[ii];
115 if (kDebugStyles) {
116 ALOGI("-> From values: type=0x%x, data=0x%08x", value.dataType, value.data);
117 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700118 }
119
Adam Lesinski7a37b742016-10-12 14:05:55 -0700120 if (value.dataType == Res_value::TYPE_NULL) {
121 const ResTable::bag_entry* const def_style_entry = def_style_attr_finder.Find(cur_ident);
122 if (def_style_entry != def_style_end) {
123 block = def_style_entry->stringBlock;
124 type_set_flags = def_style_type_set_flags;
125 value = def_style_entry->map.value;
Adam Lesinski4452e132016-10-12 07:47:28 -0700126 if (kDebugStyles) {
Adam Lesinski7a37b742016-10-12 14:05:55 -0700127 ALOGI("-> From def style: type=0x%x, data=0x%08x", value.dataType, value.data);
Adam Lesinski4452e132016-10-12 07:47:28 -0700128 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700129 }
130 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700131
Adam Lesinski7a37b742016-10-12 14:05:55 -0700132 uint32_t resid = 0;
133 if (value.dataType != Res_value::TYPE_NULL) {
134 // Take care of resolving the found resource to its final value.
135 ssize_t new_block =
136 theme->resolveAttributeReference(&value, block, &resid, &type_set_flags, &config);
137 if (new_block >= 0) block = new_block;
138 if (kDebugStyles) {
139 ALOGI("-> Resolved attr: type=0x%x, data=0x%08x", value.dataType, value.data);
140 }
141 } else {
142 // If we still don't have a value for this attribute, try to find
143 // it in the theme!
144 ssize_t new_block = theme->getAttribute(cur_ident, &value, &type_set_flags);
145 if (new_block >= 0) {
Adam Lesinski4452e132016-10-12 07:47:28 -0700146 if (kDebugStyles) {
Adam Lesinski7a37b742016-10-12 14:05:55 -0700147 ALOGI("-> From theme: type=0x%x, data=0x%08x", value.dataType, value.data);
Adam Lesinski4452e132016-10-12 07:47:28 -0700148 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700149 new_block = res.resolveReference(&value, new_block, &resid, &type_set_flags, &config);
150 if (new_block >= 0) block = new_block;
151 if (kDebugStyles) {
152 ALOGI("-> Resolved theme: type=0x%x, data=0x%08x", value.dataType, value.data);
Adam Lesinski4452e132016-10-12 07:47:28 -0700153 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700154 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700155 }
156
Adam Lesinski7a37b742016-10-12 14:05:55 -0700157 // Deal with the special @null value -- it turns back to TYPE_NULL.
158 if (value.dataType == Res_value::TYPE_REFERENCE && value.data == 0) {
159 if (kDebugStyles) {
160 ALOGI("-> Setting to @null!");
161 }
162 value.dataType = Res_value::TYPE_NULL;
163 value.data = Res_value::DATA_NULL_UNDEFINED;
164 block = -1;
Adam Lesinski4452e132016-10-12 07:47:28 -0700165 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700166
Adam Lesinski4452e132016-10-12 07:47:28 -0700167 if (kDebugStyles) {
Adam Lesinski7a37b742016-10-12 14:05:55 -0700168 ALOGI("Attribute 0x%08x: type=0x%x, data=0x%08x", cur_ident, value.dataType, value.data);
Adam Lesinski4452e132016-10-12 07:47:28 -0700169 }
170
Adam Lesinski7a37b742016-10-12 14:05:55 -0700171 // Write the final value back to Java.
172 out_values[STYLE_TYPE] = value.dataType;
173 out_values[STYLE_DATA] = value.data;
174 out_values[STYLE_ASSET_COOKIE] =
175 block != -1 ? static_cast<uint32_t>(res.getTableCookie(block)) : static_cast<uint32_t>(-1);
176 out_values[STYLE_RESOURCE_ID] = resid;
177 out_values[STYLE_CHANGING_CONFIGURATIONS] = type_set_flags;
178 out_values[STYLE_DENSITY] = config.density;
179
180 if (out_indices != NULL && value.dataType != Res_value::TYPE_NULL) {
181 indices_idx++;
182 out_indices[indices_idx] = ii;
183 }
184
185 out_values += STYLE_NUM_ENTRIES;
186 }
187
188 res.unlock();
189
190 if (out_indices != NULL) {
191 out_indices[0] = indices_idx;
192 }
193 return true;
194}
195
196bool ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr,
197 uint32_t def_style_res, uint32_t* attrs, size_t attrs_length, uint32_t* out_values,
198 uint32_t* out_indices) {
199 if (kDebugStyles) {
200 ALOGI("APPLY STYLE: theme=0x%p defStyleAttr=0x%x defStyleRes=0x%x xml=0x%p", theme,
201 def_style_attr, def_style_res, xml_parser);
202 }
203
204 const ResTable& res = theme->getResTable();
205 ResTable_config config;
206 Res_value value;
207
208 int indices_idx = 0;
209
210 // Load default style from attribute, if specified...
211 uint32_t def_style_bag_type_set_flags = 0;
212 if (def_style_attr != 0) {
Adam Lesinski4452e132016-10-12 07:47:28 -0700213 Res_value value;
Adam Lesinski7a37b742016-10-12 14:05:55 -0700214 if (theme->getAttribute(def_style_attr, &value, &def_style_bag_type_set_flags) >= 0) {
215 if (value.dataType == Res_value::TYPE_REFERENCE) {
216 def_style_res = value.data;
217 }
218 }
219 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700220
Adam Lesinski7a37b742016-10-12 14:05:55 -0700221 // Retrieve the style class associated with the current XML tag.
222 int style = 0;
223 uint32_t style_bag_type_set_flags = 0;
224 if (xml_parser != NULL) {
225 ssize_t idx = xml_parser->indexOfStyle();
226 if (idx >= 0 && xml_parser->getAttributeValue(idx, &value) >= 0) {
227 if (value.dataType == value.TYPE_ATTRIBUTE) {
228 if (theme->getAttribute(value.data, &value, &style_bag_type_set_flags) < 0) {
229 value.dataType = Res_value::TYPE_NULL;
Adam Lesinski4452e132016-10-12 07:47:28 -0700230 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700231 }
232 if (value.dataType == value.TYPE_REFERENCE) {
233 style = value.data;
234 }
235 }
236 }
237
238 // Now lock down the resource object and start pulling stuff from it.
239 res.lock();
240
241 // Retrieve the default style bag, if requested.
242 const ResTable::bag_entry* def_style_attr_start = NULL;
243 uint32_t def_style_type_set_flags = 0;
244 ssize_t bag_off =
245 def_style_res != 0
246 ? res.getBagLocked(def_style_res, &def_style_attr_start, &def_style_type_set_flags)
247 : -1;
248 def_style_type_set_flags |= def_style_bag_type_set_flags;
249 const ResTable::bag_entry* const def_style_attr_end =
250 def_style_attr_start + (bag_off >= 0 ? bag_off : 0);
251 BagAttributeFinder def_style_attr_finder(def_style_attr_start, def_style_attr_end);
252
253 // Retrieve the style class bag, if requested.
254 const ResTable::bag_entry* style_attr_start = NULL;
255 uint32_t style_type_set_flags = 0;
256 bag_off = style != 0 ? res.getBagLocked(style, &style_attr_start, &style_type_set_flags) : -1;
257 style_type_set_flags |= style_bag_type_set_flags;
258 const ResTable::bag_entry* const style_attr_end = style_attr_start + (bag_off >= 0 ? bag_off : 0);
259 BagAttributeFinder style_attr_finder(style_attr_start, style_attr_end);
260
261 // Retrieve the XML attributes, if requested.
262 static const ssize_t kXmlBlock = 0x10000000;
263 XmlAttributeFinder xml_attr_finder(xml_parser);
264 const size_t xml_attr_end = xml_parser != NULL ? xml_parser->getAttributeCount() : 0;
265
266 // Now iterate through all of the attributes that the client has requested,
267 // filling in each with whatever data we can find.
268 for (size_t ii = 0; ii < attrs_length; ii++) {
269 const uint32_t cur_ident = attrs[ii];
270
271 if (kDebugStyles) {
272 ALOGI("RETRIEVING ATTR 0x%08x...", cur_ident);
Adam Lesinski4452e132016-10-12 07:47:28 -0700273 }
274
Adam Lesinski7a37b742016-10-12 14:05:55 -0700275 ssize_t block = kXmlBlock;
276 uint32_t type_set_flags = 0;
277
278 value.dataType = Res_value::TYPE_NULL;
279 value.data = Res_value::DATA_NULL_UNDEFINED;
280 config.density = 0;
281
282 // Try to find a value for this attribute... we prioritize values
283 // coming from, first XML attributes, then XML style, then default
284 // style, and finally the theme.
285
286 // Walk through the xml attributes looking for the requested attribute.
287 const size_t xml_attr_idx = xml_attr_finder.Find(cur_ident);
288 if (xml_attr_idx != xml_attr_end) {
289 // We found the attribute we were looking for.
290 xml_parser->getAttributeValue(xml_attr_idx, &value);
291 if (kDebugStyles) {
292 ALOGI("-> From XML: type=0x%x, data=0x%08x", value.dataType, value.data);
293 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700294 }
295
Adam Lesinski7a37b742016-10-12 14:05:55 -0700296 if (value.dataType == Res_value::TYPE_NULL) {
297 // Walk through the style class values looking for the requested attribute.
298 const ResTable::bag_entry* const style_attr_entry = style_attr_finder.Find(cur_ident);
299 if (style_attr_entry != style_attr_end) {
300 // We found the attribute we were looking for.
301 block = style_attr_entry->stringBlock;
302 type_set_flags = style_type_set_flags;
303 value = style_attr_entry->map.value;
Adam Lesinski4452e132016-10-12 07:47:28 -0700304 if (kDebugStyles) {
Adam Lesinski7a37b742016-10-12 14:05:55 -0700305 ALOGI("-> From style: type=0x%x, data=0x%08x", value.dataType, value.data);
Adam Lesinski4452e132016-10-12 07:47:28 -0700306 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700307 }
308 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700309
Adam Lesinski7a37b742016-10-12 14:05:55 -0700310 if (value.dataType == Res_value::TYPE_NULL) {
311 // Walk through the default style values looking for the requested attribute.
312 const ResTable::bag_entry* const def_style_attr_entry = def_style_attr_finder.Find(cur_ident);
313 if (def_style_attr_entry != def_style_attr_end) {
314 // We found the attribute we were looking for.
315 block = def_style_attr_entry->stringBlock;
316 type_set_flags = style_type_set_flags;
317 value = def_style_attr_entry->map.value;
318 if (kDebugStyles) {
319 ALOGI("-> From def style: type=0x%x, data=0x%08x", value.dataType, value.data);
Adam Lesinski4452e132016-10-12 07:47:28 -0700320 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700321 }
322 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700323
Adam Lesinski7a37b742016-10-12 14:05:55 -0700324 uint32_t resid = 0;
325 if (value.dataType != Res_value::TYPE_NULL) {
326 // Take care of resolving the found resource to its final value.
327 ssize_t new_block =
328 theme->resolveAttributeReference(&value, block, &resid, &type_set_flags, &config);
329 if (new_block >= 0) {
330 block = new_block;
331 }
332
333 if (kDebugStyles) {
334 ALOGI("-> Resolved attr: type=0x%x, data=0x%08x", value.dataType, value.data);
335 }
336 } else {
337 // If we still don't have a value for this attribute, try to find
338 // it in the theme!
339 ssize_t new_block = theme->getAttribute(cur_ident, &value, &type_set_flags);
340 if (new_block >= 0) {
341 if (kDebugStyles) {
342 ALOGI("-> From theme: type=0x%x, data=0x%08x", value.dataType, value.data);
Adam Lesinski4452e132016-10-12 07:47:28 -0700343 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700344 new_block = res.resolveReference(&value, new_block, &resid, &type_set_flags, &config);
345 if (new_block >= 0) {
346 block = new_block;
Adam Lesinski4452e132016-10-12 07:47:28 -0700347 }
348
349 if (kDebugStyles) {
Adam Lesinski7a37b742016-10-12 14:05:55 -0700350 ALOGI("-> Resolved theme: type=0x%x, data=0x%08x", value.dataType, value.data);
Adam Lesinski4452e132016-10-12 07:47:28 -0700351 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700352 }
Adam Lesinski4452e132016-10-12 07:47:28 -0700353 }
354
Adam Lesinski7a37b742016-10-12 14:05:55 -0700355 // Deal with the special @null value -- it turns back to TYPE_NULL.
356 if (value.dataType == Res_value::TYPE_REFERENCE && value.data == 0) {
357 if (kDebugStyles) {
358 ALOGI("-> Setting to @null!");
359 }
360 value.dataType = Res_value::TYPE_NULL;
361 value.data = Res_value::DATA_NULL_UNDEFINED;
362 block = kXmlBlock;
Adam Lesinski4452e132016-10-12 07:47:28 -0700363 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700364
365 if (kDebugStyles) {
366 ALOGI("Attribute 0x%08x: type=0x%x, data=0x%08x", cur_ident, value.dataType, value.data);
367 }
368
369 // Write the final value back to Java.
370 out_values[STYLE_TYPE] = value.dataType;
371 out_values[STYLE_DATA] = value.data;
372 out_values[STYLE_ASSET_COOKIE] = block != kXmlBlock
373 ? static_cast<uint32_t>(res.getTableCookie(block))
374 : static_cast<uint32_t>(-1);
375 out_values[STYLE_RESOURCE_ID] = resid;
376 out_values[STYLE_CHANGING_CONFIGURATIONS] = type_set_flags;
377 out_values[STYLE_DENSITY] = config.density;
378
379 if (out_indices != NULL && value.dataType != Res_value::TYPE_NULL) {
380 indices_idx++;
381 out_indices[indices_idx] = ii;
382 }
383
384 out_values += STYLE_NUM_ENTRIES;
385 }
386
387 res.unlock();
388
389 if (out_indices != NULL) {
390 out_indices[0] = indices_idx;
391 }
392 return true;
Adam Lesinski4452e132016-10-12 07:47:28 -0700393}
394
Adam Lesinski7a37b742016-10-12 14:05:55 -0700395bool RetrieveAttributes(const ResTable* res, ResXMLParser* xml_parser, uint32_t* attrs,
396 size_t attrs_length, uint32_t* out_values, uint32_t* out_indices) {
397 ResTable_config config;
398 Res_value value;
Adam Lesinski4452e132016-10-12 07:47:28 -0700399
Adam Lesinski7a37b742016-10-12 14:05:55 -0700400 int indices_idx = 0;
Adam Lesinski4452e132016-10-12 07:47:28 -0700401
Adam Lesinski7a37b742016-10-12 14:05:55 -0700402 // Now lock down the resource object and start pulling stuff from it.
403 res->lock();
Adam Lesinski4452e132016-10-12 07:47:28 -0700404
Adam Lesinski7a37b742016-10-12 14:05:55 -0700405 // Retrieve the XML attributes, if requested.
406 const size_t xml_attr_count = xml_parser->getAttributeCount();
407 size_t ix = 0;
408 uint32_t cur_xml_attr = xml_parser->getAttributeNameResID(ix);
Adam Lesinski4452e132016-10-12 07:47:28 -0700409
Adam Lesinski7a37b742016-10-12 14:05:55 -0700410 static const ssize_t kXmlBlock = 0x10000000;
Adam Lesinski4452e132016-10-12 07:47:28 -0700411
Adam Lesinski7a37b742016-10-12 14:05:55 -0700412 // Now iterate through all of the attributes that the client has requested,
413 // filling in each with whatever data we can find.
414 for (size_t ii = 0; ii < attrs_length; ii++) {
415 const uint32_t cur_ident = attrs[ii];
416 ssize_t block = kXmlBlock;
417 uint32_t type_set_flags = 0;
Adam Lesinski4452e132016-10-12 07:47:28 -0700418
Adam Lesinski7a37b742016-10-12 14:05:55 -0700419 value.dataType = Res_value::TYPE_NULL;
420 value.data = Res_value::DATA_NULL_UNDEFINED;
421 config.density = 0;
Adam Lesinski4452e132016-10-12 07:47:28 -0700422
Adam Lesinski7a37b742016-10-12 14:05:55 -0700423 // Try to find a value for this attribute...
424 // Skip through XML attributes until the end or the next possible match.
425 while (ix < xml_attr_count && cur_ident > cur_xml_attr) {
426 ix++;
427 cur_xml_attr = xml_parser->getAttributeNameResID(ix);
428 }
429 // Retrieve the current XML attribute if it matches, and step to next.
430 if (ix < xml_attr_count && cur_ident == cur_xml_attr) {
431 xml_parser->getAttributeValue(ix, &value);
432 ix++;
433 cur_xml_attr = xml_parser->getAttributeNameResID(ix);
Adam Lesinski4452e132016-10-12 07:47:28 -0700434 }
435
Adam Lesinski7a37b742016-10-12 14:05:55 -0700436 uint32_t resid = 0;
437 if (value.dataType != Res_value::TYPE_NULL) {
438 // Take care of resolving the found resource to its final value.
439 // printf("Resolving attribute reference\n");
440 ssize_t new_block = res->resolveReference(&value, block, &resid, &type_set_flags, &config);
441 if (new_block >= 0) block = new_block;
Adam Lesinski4452e132016-10-12 07:47:28 -0700442 }
Adam Lesinski7a37b742016-10-12 14:05:55 -0700443
444 // Deal with the special @null value -- it turns back to TYPE_NULL.
445 if (value.dataType == Res_value::TYPE_REFERENCE && value.data == 0) {
446 value.dataType = Res_value::TYPE_NULL;
447 value.data = Res_value::DATA_NULL_UNDEFINED;
448 block = kXmlBlock;
449 }
450
451 // Write the final value back to Java.
452 out_values[STYLE_TYPE] = value.dataType;
453 out_values[STYLE_DATA] = value.data;
454 out_values[STYLE_ASSET_COOKIE] = block != kXmlBlock
455 ? static_cast<uint32_t>(res->getTableCookie(block))
456 : static_cast<uint32_t>(-1);
457 out_values[STYLE_RESOURCE_ID] = resid;
458 out_values[STYLE_CHANGING_CONFIGURATIONS] = type_set_flags;
459 out_values[STYLE_DENSITY] = config.density;
460
461 if (out_indices != NULL && value.dataType != Res_value::TYPE_NULL) {
462 indices_idx++;
463 out_indices[indices_idx] = ii;
464 }
465
466 out_values += STYLE_NUM_ENTRIES;
467 }
468
469 res->unlock();
470
471 if (out_indices != NULL) {
472 out_indices[0] = indices_idx;
473 }
474 return true;
Adam Lesinski4452e132016-10-12 07:47:28 -0700475}
476
Adam Lesinski7a37b742016-10-12 14:05:55 -0700477} // namespace android