• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef ANDROIDFW_ASSETMANAGER2_H_
18 #define ANDROIDFW_ASSETMANAGER2_H_
19 
20 #include <utils/RefBase.h>
21 
22 #include <array>
23 #include <limits>
24 #include <set>
25 #include <span>
26 #include <unordered_map>
27 
28 #include "android-base/function_ref.h"
29 #include "android-base/macros.h"
30 #include "androidfw/ApkAssets.h"
31 #include "androidfw/Asset.h"
32 #include "androidfw/AssetManager.h"
33 #include "androidfw/ResourceTypes.h"
34 #include "androidfw/Util.h"
35 
36 namespace android {
37 
38 class Theme;
39 
40 using ApkAssetsCookie = int32_t;
41 
42 enum : ApkAssetsCookie {
43   kInvalidCookie = -1,
44 };
45 
46 // Holds a bag that has been merged with its parent, if one exists.
47 struct ResolvedBag {
48   // A single key-value entry in a bag.
49   struct Entry {
50     // The key, as described in ResTable_map::name.
51     uint32_t key;
52 
53     Res_value value;
54 
55     // The resource ID of the origin style associated with the given entry.
56     uint32_t style;
57 
58     // Which ApkAssets this entry came from.
59     ApkAssetsCookie cookie;
60 
61     ResStringPool* key_pool;
62     ResStringPool* type_pool;
63   };
64 
65   // Denotes the configuration axis that this bag varies with.
66   // If a configuration changes with respect to one of these axis,
67   // the bag should be reloaded.
68   uint32_t type_spec_flags;
69 
70   // The number of entries in this bag. Access them by indexing into `entries`.
71   uint32_t entry_count;
72 
73   // The array of entries for this bag. An empty array is a neat trick to force alignment
74   // of the Entry structs that follow this structure and avoids a bunch of casts.
75   Entry entries[0];
76 };
77 
78 struct FindEntryResult;
79 
80 // AssetManager2 is the main entry point for accessing assets and resources.
81 // AssetManager2 provides caching of resources retrieved via the underlying ApkAssets.
82 class AssetManager2 {
83   friend Theme;
84 
85  public:
86   struct ResourceName {
87     const char* package = nullptr;
88     size_t package_len = 0u;
89 
90     const char* type = nullptr;
91     const char16_t* type16 = nullptr;
92     size_t type_len = 0u;
93 
94     const char* entry = nullptr;
95     const char16_t* entry16 = nullptr;
96     size_t entry_len = 0u;
97   };
98 
99   using ApkAssetsPtr = sp<const ApkAssets>;
100   using ApkAssetsWPtr = wp<const ApkAssets>;
101   using ApkAssetsList = std::span<const ApkAssetsPtr>;
102 
103   AssetManager2() = default;
104   explicit AssetManager2(AssetManager2&& other) = default;
105   AssetManager2(ApkAssetsList apk_assets, const ResTable_config& configuration);
106 
107   struct ScopedOperation {
108     DISALLOW_COPY_AND_ASSIGN(ScopedOperation);
109     friend AssetManager2;
110     const AssetManager2& am_;
111     ScopedOperation(const AssetManager2& am);
112 
113    public:
114     ~ScopedOperation();
115   };
116 
117   [[nodiscard]] ScopedOperation StartOperation() const;
118 
119   // Sets/resets the underlying ApkAssets for this AssetManager. The ApkAssets
120   // are not owned by the AssetManager, and must have a longer lifetime.
121   //
122   // Only pass invalidate_caches=false when it is known that the structure
123   // change in ApkAssets is due to a safe addition of resources with completely
124   // new resource IDs.
125   bool SetApkAssets(ApkAssetsList apk_assets, bool invalidate_caches = true);
126   bool SetApkAssets(std::initializer_list<ApkAssetsPtr> apk_assets, bool invalidate_caches = true);
127 
128   const ApkAssetsPtr& GetApkAssets(ApkAssetsCookie cookie) const;
GetApkAssetsCount()129   int GetApkAssetsCount() const {
130     return int(apk_assets_.size());
131   }
132 
133   // Returns the string pool for the given asset cookie.
134   // Use the string pool returned here with a valid Res_value object of type Res_value::TYPE_STRING.
135   const ResStringPool* GetStringPoolForCookie(ApkAssetsCookie cookie) const;
136 
137   // Returns the DynamicRefTable for the given package ID.
138   // This may be nullptr if the APK represented by `cookie` has no resource table.
139   const DynamicRefTable* GetDynamicRefTableForPackage(uint32_t package_id) const;
140 
141   // Returns the DynamicRefTable for the ApkAssets represented by the cookie.
142   // This may be nullptr if the APK represented by `cookie` has no resource table.
143   std::shared_ptr<const DynamicRefTable> GetDynamicRefTableForCookie(ApkAssetsCookie cookie) const;
144 
145   // Retrieve the assigned package id of the package if loaded into this AssetManager
146   uint8_t GetAssignedPackageId(const LoadedPackage* package) const;
147 
148   // Returns a string representation of the overlayable API of a package.
149   bool GetOverlayablesToString(android::StringPiece package_name, std::string* out) const;
150 
151   const std::unordered_map<std::string, std::string>* GetOverlayableMapForPackage(
152       uint32_t package_id) const;
153 
154   // Returns whether the resources.arsc of any loaded apk assets is allocated in RAM (not mmapped).
155   bool ContainsAllocatedTable() const;
156 
157   // Sets/resets the configuration for this AssetManager. This will cause all
158   // caches that are related to the configuration change to be invalidated.
159   void SetConfiguration(const ResTable_config& configuration);
160 
GetConfiguration()161   inline const ResTable_config& GetConfiguration() const {
162     return configuration_;
163   }
164 
165   // Returns all configurations for which there are resources defined, or an I/O error if reading
166   // resource data failed.
167   //
168   // This includes resource configurations in all the ApkAssets set for this AssetManager.
169   // If `exclude_system` is set to true, resource configurations from system APKs
170   // ('android' package, other libraries) will be excluded from the list.
171   // If `exclude_mipmap` is set to true, resource configurations defined for resource type 'mipmap'
172   // will be excluded from the list.
173   base::expected<std::set<ResTable_config>, IOError> GetResourceConfigurations(
174       bool exclude_system = false, bool exclude_mipmap = false) const;
175 
176   // Returns all the locales for which there are resources defined. This includes resource
177   // locales in all the ApkAssets set for this AssetManager.
178   // If `exclude_system` is set to true, resource locales from system APKs
179   // ('android' package, other libraries) will be excluded from the list.
180   // If `merge_equivalent_languages` is set to true, resource locales will be canonicalized
181   // and de-duped in the resulting list.
182   std::set<std::string> GetResourceLocales(bool exclude_system = false,
183                                            bool merge_equivalent_languages = false) const;
184 
185   // Searches the set of APKs loaded by this AssetManager and opens the first one found located
186   // in the assets/ directory.
187   // `mode` controls how the file is opened.
188   //
189   // NOTE: The loaded APKs are searched in reverse order.
190   std::unique_ptr<Asset> Open(const std::string& filename, Asset::AccessMode mode) const;
191 
192   // Opens a file within the assets/ directory of the APK specified by `cookie`.
193   // `mode` controls how the file is opened.
194   std::unique_ptr<Asset> Open(const std::string& filename, ApkAssetsCookie cookie,
195                               Asset::AccessMode mode) const;
196 
197   // Opens the directory specified by `dirname`. The result is an AssetDir that is the combination
198   // of all directories matching `dirname` under the assets/ directory of every ApkAssets loaded.
199   // The entries are sorted by their ASCII name.
200   std::unique_ptr<AssetDir> OpenDir(const std::string& dirname) const;
201 
202   // Searches the set of APKs loaded by this AssetManager and opens the first one found.
203   // `mode` controls how the file is opened.
204   // `out_cookie` is populated with the cookie of the APK this file was found in.
205   //
206   // NOTE: The loaded APKs are searched in reverse order.
207   std::unique_ptr<Asset> OpenNonAsset(const std::string& filename, Asset::AccessMode mode,
208                                       ApkAssetsCookie* out_cookie = nullptr) const;
209 
210   // Opens a file in the APK specified by `cookie`. `mode` controls how the file is opened.
211   // This is typically used to open a specific AndroidManifest.xml, or a binary XML file
212   // referenced by a resource lookup with GetResource().
213   std::unique_ptr<Asset> OpenNonAsset(const std::string& filename, ApkAssetsCookie cookie,
214                                       Asset::AccessMode mode) const;
215 
216   // Returns the resource id of parent style of the specified theme.
217   //
218   // Returns a null error if the name is missing/corrupt, or an I/O error if reading resource data
219   // failed.
220   base::expected<uint32_t, NullOrIOError> GetParentThemeResourceId(uint32_t resid) const;
221 
222   // Returns the resource name of the specified resource ID.
223   //
224   // Utf8 strings are preferred, and only if they are unavailable are the Utf16 variants populated.
225   //
226   // Returns a null error if the name is missing/corrupt, or an I/O error if reading resource data
227   // failed.
228   base::expected<ResourceName, NullOrIOError> GetResourceName(uint32_t resid) const;
229 
230   // Finds the resource ID assigned to `resource_name`.
231   //
232   // `resource_name` must be of the form '[package:][type/]entry'.
233   // If no package is specified in `resource_name`, then `fallback_package` is used as the package.
234   // If no type is specified in `resource_name`, then `fallback_type` is used as the type.
235   //
236   // Returns a null error if no resource by that name was found, or an I/O error if reading resource
237   // data failed.
238   base::expected<uint32_t, NullOrIOError> GetResourceId(
239       const std::string& resource_name, const std::string& fallback_type = {},
240       const std::string& fallback_package = {}) const;
241 
242   struct SelectedValue {
243     friend AssetManager2;
244     friend Theme;
245     SelectedValue() = default;
SelectedValueSelectedValue246     SelectedValue(const ResolvedBag* bag, const ResolvedBag::Entry& entry) :
247         cookie(entry.cookie), data(entry.value.data), type(entry.value.dataType),
248         flags(bag->type_spec_flags), resid(0U), config({}) {};
249 
250     // The cookie representing the ApkAssets in which the value resides.
251     ApkAssetsCookie cookie = kInvalidCookie;
252 
253     // The data for this value, as interpreted according to `type`.
254     Res_value::data_type data;
255 
256     // Type of the data value.
257     uint8_t type;
258 
259     // The bitmask of configuration axis that this resource varies with.
260     // See ResTable_config::CONFIG_*.
261     uint32_t flags;
262 
263     // The resource ID from which this value was resolved.
264     uint32_t resid;
265 
266     // The configuration for which the resolved value was defined.
267     ResTable_config config;
268 
269    private:
SelectedValueSelectedValue270     SelectedValue(uint8_t value_type, Res_value::data_type value_data, ApkAssetsCookie cookie,
271                   uint32_t type_flags, uint32_t resid, const ResTable_config& config) :
272                   cookie(cookie), data(value_data), type(value_type), flags(type_flags),
273                   resid(resid), config(config) {};
274   };
275 
276   // Retrieves the best matching resource value with ID `resid`.
277   //
278   // If `may_be_bag` is false, this function logs if the resource was a map/bag type and returns a
279   // null result. If `density_override` is non-zero, the configuration to match against is
280   // overridden with that density.
281   //
282   // Returns a null error if a best match could not be found, or an I/O error if reading resource
283   // data failed.
284   base::expected<SelectedValue, NullOrIOError> GetResource(uint32_t resid, bool may_be_bag = false,
285                                                            uint16_t density_override = 0U) const;
286 
287   // Resolves the resource referenced in `value` if the type is Res_value::TYPE_REFERENCE.
288   //
289   // If the data type is not Res_value::TYPE_REFERENCE, no work is done. Configuration flags of the
290   // values pointed to by the reference are OR'd into `value.flags`. If `cache_value` is true, then
291   // the resolved value will be cached and used when attempting to resolve the resource id specified
292   // in `value`.
293   //
294   // Returns a null error if the resource could not be resolved, or an I/O error if reading
295   // resource data failed.
296   base::expected<std::monostate, NullOrIOError> ResolveReference(SelectedValue& value,
297                                                                  bool cache_value = false) const;
298 
299   // Retrieves the best matching bag/map resource with ID `resid`.
300   //
301   // This method will resolve all parent references for this bag and merge keys with the child.
302   // To iterate over the keys, use the following idiom:
303   //
304   //  base::expected<const ResolvedBag*, NullOrIOError> bag = asset_manager->GetBag(id);
305   //  if (bag.has_value()) {
306   //    for (auto iter = begin(*bag); iter != end(*bag); ++iter) {
307   //      ...
308   //    }
309   //  }
310   //
311   // Returns a null error if a best match could not be found, or an I/O error if reading resource
312   // data failed.
313   base::expected<const ResolvedBag*, NullOrIOError> GetBag(uint32_t resid) const;
314 
315   // Retrieves the best matching bag/map resource of the resource referenced in `value`.
316   //
317   // If `value.type` is not Res_value::TYPE_REFERENCE, a null result is returned.
318   // Configuration flags of the bag pointed to by the reference are OR'd into `value.flags`.
319   //
320   // Returns a null error if a best match could not be found, or an I/O error if reading resource
321   // data failed.
322   base::expected<const ResolvedBag*, NullOrIOError> ResolveBag(SelectedValue& value) const;
323 
324   // Returns the android::ResTable_typeSpec flags of the resource ID.
325   //
326   // Returns a null error if the resource could not be resolved, or an I/O error if reading
327   // resource data failed.
328   base::expected<uint32_t, NullOrIOError> GetResourceTypeSpecFlags(uint32_t resid) const;
329 
330   const std::vector<uint32_t> GetBagResIdStack(uint32_t resid) const;
331 
332   // Resets the resource resolution structures in preparation for the next resource retrieval.
333   void ResetResourceResolution() const;
334 
335   // Enables or disables resource resolution logging. Clears stored steps when disabled.
336   void SetResourceResolutionLoggingEnabled(bool enabled);
337 
338   // Returns formatted log of last resource resolution path, or empty if no resource has been
339   // resolved yet.
340   std::string GetLastResourceResolution() const;
341 
342   // Creates a new Theme from this AssetManager.
343   std::unique_ptr<Theme> NewTheme();
344 
345   void ForEachPackage(base::function_ref<bool(const std::string&, uint8_t)> func,
346                       package_property_t excluded_property_flags = 0U) const;
347 
348   void DumpToLog() const;
349 
350  private:
351   DISALLOW_COPY_AND_ASSIGN(AssetManager2);
352 
353   // A collection of configurations and their associated ResTable_type that match the current
354   // AssetManager configuration.
355   struct FilteredConfigGroup {
356       std::vector<const TypeSpec::TypeEntry*> type_entries;
357   };
358 
359   // Represents an single package.
360   struct ConfiguredPackage {
361       // A pointer to the immutable, loaded package info.
362       const LoadedPackage* loaded_package_;
363 
364       // A mutable AssetManager-specific list of configurations that match the AssetManager's
365       // current configuration. This is used as an optimization to avoid checking every single
366       // candidate configuration when looking up resources.
367       ByteBucketArray<FilteredConfigGroup> filtered_configs_;
368   };
369 
370   // Represents a Runtime Resource Overlay that overlays resources in the logical package.
371   struct ConfiguredOverlay {
372       // The set of package groups that overlay this package group.
373       IdmapResMap overlay_res_maps_;
374 
375       // The cookie of the overlay assets.
376       ApkAssetsCookie cookie;
377   };
378 
379   // Represents a logical package, which can be made up of many individual packages. Each package
380   // in a PackageGroup shares the same package name and package ID.
381   struct PackageGroup {
382       // The set of packages that make-up this group.
383       std::vector<ConfiguredPackage> packages_;
384 
385       // The cookies associated with each package in the group. They share the same order as
386       // packages_.
387       std::vector<ApkAssetsCookie> cookies_;
388 
389       // Runtime Resource Overlays that overlay resources in this package group.
390       std::vector<ConfiguredOverlay> overlays_;
391 
392       // A library reference table that contains build-package ID to runtime-package ID mappings.
393       std::shared_ptr<DynamicRefTable> dynamic_ref_table = std::make_shared<DynamicRefTable>();
394   };
395 
396   // Finds the best entry for `resid` from the set of ApkAssets. The entry can be a simple
397   // Res_value, or a complex map/bag type. Returns a null result if a best entry cannot be found.
398   //
399   // `density_override` overrides the density of the current configuration when doing a search.
400   //
401   // When `stop_at_first_match` is true, the first match found is selected and the search
402   // terminates. This is useful for methods that just look up the name of a resource and don't
403   // care about the value. In this case, the value of `FindEntryResult::type_flags` is incomplete
404   // and should not be used.
405   //
406   // When `ignore_configuration` is true, FindEntry will return always select the first entry in
407   // for the type seen regardless of its configuration.
408   //
409   // NOTE: FindEntry takes care of ensuring that structs within FindEntryResult have been properly
410   // bounds-checked. Callers of FindEntry are free to trust the data if this method succeeds.
411   base::expected<FindEntryResult, NullOrIOError> FindEntry(uint32_t resid,
412                                                            uint16_t density_override,
413                                                            bool stop_at_first_match,
414                                                            bool ignore_configuration) const;
415 
416   base::expected<FindEntryResult, NullOrIOError> FindEntryInternal(
417       const PackageGroup& package_group, uint8_t type_idx, uint16_t entry_idx,
418       const ResTable_config& desired_config, bool stop_at_first_match,
419       bool ignore_configuration) const;
420 
421   // Assigns package IDs to all shared library ApkAssets.
422   // Should be called whenever the ApkAssets are changed.
423   void BuildDynamicRefTable(ApkAssetsList assets);
424 
425   // Purge all resources that are cached and vary by the configuration axis denoted by the
426   // bitmask `diff`.
427   void InvalidateCaches(uint32_t diff);
428 
429   // Triggers the re-construction of lists of types that match the set configuration.
430   // This should always be called when mutating the AssetManager's configuration or ApkAssets set.
431   void RebuildFilterList();
432 
433   // Retrieves the APK paths of overlays that overlay non-system packages.
434   std::set<ApkAssetsPtr> GetNonSystemOverlays() const;
435 
436   // AssetManager2::GetBag(resid) wraps this function to track which resource ids have already
437   // been seen while traversing bag parents.
438   base::expected<const ResolvedBag*, NullOrIOError> GetBag(
439       uint32_t resid, std::vector<uint32_t>& child_resids) const;
440 
441   // Finish an operation that was running with the current asset manager, and clean up the
442   // promoted apk assets when the last operation ends.
443   void FinishOperation() const;
444 
445   // The ordered list of ApkAssets to search. These are not owned by the AssetManager, and must
446   // have a longer lifetime.
447   // The second pair element is the promoted version of the assets, that is held for the duration
448   // of the currently running operation. FinishOperation() clears all promoted assets to make sure
449   // they can be released when the system needs that.
450   mutable std::vector<std::pair<ApkAssetsWPtr, ApkAssetsPtr>> apk_assets_;
451 
452   // DynamicRefTables for shared library package resolution.
453   // These are ordered according to apk_assets_. The mappings may change depending on what is
454   // in apk_assets_, therefore they must be stored in the AssetManager and not in the
455   // immutable ApkAssets class.
456   std::vector<PackageGroup> package_groups_;
457 
458   // An array mapping package ID to index into package_groups. This keeps the lookup fast
459   // without taking too much memory.
460   std::array<uint8_t, std::numeric_limits<uint8_t>::max() + 1> package_ids_;
461 
462   // The current configuration set for this AssetManager. When this changes, cached resources
463   // may need to be purged.
464   ResTable_config configuration_ = {};
465 
466   // Cached set of bags. These are cached because they can inherit keys from parent bags,
467   // which involves some calculation.
468   mutable std::unordered_map<uint32_t, util::unique_cptr<ResolvedBag>> cached_bags_;
469 
470   // Cached set of bag resid stacks for each bag. These are cached because they might be requested
471   // a number of times for each view during View inspection.
472   mutable std::unordered_map<uint32_t, std::vector<uint32_t>> cached_bag_resid_stacks_;
473 
474   // Cached set of resolved resource values.
475   mutable std::unordered_map<uint32_t, SelectedValue> cached_resolved_values_;
476 
477   // Tracking the number of the started operations running with the current AssetManager.
478   // Finishing the last one clears all promoted apk assets.
479   mutable int number_of_running_scoped_operations_ = 0;
480 
481   // Whether or not to save resource resolution steps
482   bool resource_resolution_logging_enabled_ = false;
483 
484   struct Resolution {
485     struct Step {
486       enum class Type {
487         INITIAL,
488         BETTER_MATCH,
489         OVERLAID,
490         OVERLAID_INLINE,
491         SKIPPED,
492         NO_ENTRY,
493       };
494 
495       // Marks what kind of override this step was.
496       Type type;
497 
498       // Built name of configuration for this step.
499       String8 config_name;
500 
501       ApkAssetsCookie cookie = kInvalidCookie;
502     };
503 
504     // Last resolved resource ID.
505     uint32_t resid;
506 
507     // Last resolved resource result cookie.
508     ApkAssetsCookie cookie = kInvalidCookie;
509 
510     // Last resolved resource type.
511     StringPoolRef type_string_ref;
512 
513     // Last resolved resource entry.
514     StringPoolRef entry_string_ref;
515 
516     // Steps taken to resolve last resource.
517     std::vector<Step> steps;
518 
519     // The configuration name of the best resource found.
520     String8 best_config_name;
521 
522     // The package name of the best resource found.
523     String8 best_package_name;
524   };
525 
526   // Record of the last resolved resource's resolution path.
527   mutable Resolution last_resolution_;
528 };
529 
530 class Theme {
531   friend class AssetManager2;
532 
533  public:
534   ~Theme();
535 
536   // Applies the style identified by `resid` to this theme.
537   //
538   // This can be called multiple times with different styles. By default, any theme attributes that
539   // are already defined before this call are not overridden. If `force` is set to true, this
540   // behavior is changed and all theme attributes from the style at `resid` are applied.
541   //
542   // Returns a null error if the style could not be applied, or an I/O error if reading resource
543   // data failed.
544   base::expected<std::monostate, NullOrIOError> ApplyStyle(uint32_t resid, bool force = false);
545 
546   // Clears the existing theme, sets the new asset manager to use for this theme, and applies the
547   // styles in `style_ids` through repeated invocations of `ApplyStyle`.
548   void Rebase(AssetManager2* am, const uint32_t* style_ids, const uint8_t* force,
549               size_t style_count);
550 
551   // Sets this Theme to be a copy of `source` if `source` has the same AssetManager as this Theme.
552   //
553   // If `source` does not have the same AssetManager as this theme, only attributes from ApkAssets
554   // loaded into both AssetManagers will be copied to this theme.
555   //
556   // Returns an I/O error if reading resource data failed.
557   base::expected<std::monostate, IOError> SetTo(const Theme& source);
558 
559   void Clear();
560 
561   // Retrieves the value of attribute ID `resid` in the theme.
562   //
563   // NOTE: This function does not do reference traversal. If you want to follow references to other
564   // resources to get the "real" value to use, you need to call ResolveReference() after this
565   // function.
566   std::optional<AssetManager2::SelectedValue> GetAttribute(uint32_t resid) const;
567 
568   // This is like AssetManager2::ResolveReference(), but also takes care of resolving attribute
569   // references to the theme.
570   base::expected<std::monostate, NullOrIOError> ResolveAttributeReference(
571       AssetManager2::SelectedValue& value) const;
572 
GetAssetManager()573   AssetManager2* GetAssetManager() {
574     return asset_manager_;
575   }
576 
GetAssetManager()577   const AssetManager2* GetAssetManager() const {
578     return asset_manager_;
579   }
580 
581   // Returns a bit mask of configuration changes that will impact this
582   // theme (and thus require completely reloading it).
GetChangingConfigurations()583   uint32_t GetChangingConfigurations() const {
584     return type_spec_flags_;
585   }
586 
587   void Dump() const;
588 
589   struct Entry;
590  private:
591   DISALLOW_COPY_AND_ASSIGN(Theme);
592 
593   explicit Theme(AssetManager2* asset_manager);
594 
595   AssetManager2* asset_manager_ = nullptr;
596   uint32_t type_spec_flags_ = 0u;
597 
598   std::vector<uint32_t> keys_;
599   std::vector<Entry> entries_;
600 };
601 
begin(const ResolvedBag * bag)602 inline const ResolvedBag::Entry* begin(const ResolvedBag* bag) {
603   return bag->entries;
604 }
605 
end(const ResolvedBag * bag)606 inline const ResolvedBag::Entry* end(const ResolvedBag* bag) {
607   return bag->entries + bag->entry_count;
608 }
609 
610 }  // namespace android
611 
612 #endif /* ANDROIDFW_ASSETMANAGER2_H_ */
613