Prepare aapt2 for multiple ids per type
For the SDK finalization changes, aapt2 must be able to handle resources of the same type having different type ids. The ResourceTable data structure currently stores package ids and type ids on ResourceTablePackage and ResourceTableType respectively. This prevents resource entries of the same type from having different type ids without having to create another ResourceTableType structure. JavaClassGenerator assumes each type only appears once in the ResourceTable and it would need to dedupe the types to ensure one class containing all the resource types ids is generated. TableFlattener on the other hand needs a separate ResourceTableType for each type/id combination so that the types are flattened into separate ResTable_types. This change simplifies aapt2's ResourceTable data structure: - Resource ids are stored exclusively on ResourceEntry structures meaning multiple entries can have different type ids while being stored in the same ResourceTableType. Classes like JavaClassGenerator can simply iterate over a type to see all the resources of the type regardless of what their type id is. - ResourceTable::GetPartitionedView() retrieves a list of resources sorted and partitioned by package id, type id, and entry id. Classes like TableFlattener can use this view to get separate ResourceTavleTypes for each different type id that a type has. These changes will also make it easy to have a resource span multiple type ids if it exhausts all of the entry ids in one type id. The new NewResourcesBuilder replaces the numerous setter methods on ResourceTable. Bug: 183102797 Test: aapt2_tests Change-Id: I60dbcb24143bb958333899cafa7d41faa226d203
Loading
Please register or sign in to comment