Loading core/api/current.txt +4 −4 Original line number Original line Diff line number Diff line Loading @@ -1298,7 +1298,7 @@ package android { field public static final int shortcutLongLabel = 16844074; // 0x101052a field public static final int shortcutLongLabel = 16844074; // 0x101052a field public static final int shortcutShortLabel = 16844073; // 0x1010529 field public static final int shortcutShortLabel = 16844073; // 0x1010529 field public static final int shouldDisableView = 16843246; // 0x10101ee field public static final int shouldDisableView = 16843246; // 0x10101ee field public static final int shouldUseDefaultUnfoldTransition; field public static final int shouldUseDefaultUnfoldTransition = 16844364; // 0x101064c field public static final int showAsAction = 16843481; // 0x10102d9 field public static final int showAsAction = 16843481; // 0x10102d9 field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDividers = 16843561; // 0x1010329 field public static final int showDividers = 16843561; // 0x1010329 Loading Loading @@ -2014,9 +2014,9 @@ package android { public static final class R.id { public static final class R.id { ctor public R.id(); ctor public R.id(); field public static final int accessibilityActionContextClick = 16908348; // 0x102003c field public static final int accessibilityActionContextClick = 16908348; // 0x102003c field public static final int accessibilityActionDragCancel; field public static final int accessibilityActionDragCancel = 16908375; // 0x1020057 field public static final int accessibilityActionDragDrop; field public static final int accessibilityActionDragDrop = 16908374; // 0x1020056 field public static final int accessibilityActionDragStart; field public static final int accessibilityActionDragStart = 16908373; // 0x1020055 field public static final int accessibilityActionHideTooltip = 16908357; // 0x1020045 field public static final int accessibilityActionHideTooltip = 16908357; // 0x1020045 field public static final int accessibilityActionImeEnter = 16908372; // 0x1020054 field public static final int accessibilityActionImeEnter = 16908372; // 0x1020054 field public static final int accessibilityActionMoveWindow = 16908354; // 0x1020042 field public static final int accessibilityActionMoveWindow = 16908354; // 0x1020042 core/res/res/values/public.xml +9 −76 Original line number Original line Diff line number Diff line Loading @@ -1235,7 +1235,6 @@ <public type="attr" name="author" id="0x010102b4" /> <public type="attr" name="author" id="0x010102b4" /> <public type="attr" name="autoStart" id="0x010102b5" /> <public type="attr" name="autoStart" id="0x010102b5" /> <!-- =============================================================== <!-- =============================================================== Resources added in version 8 of the platform (Eclair MR2). Resources added in version 8 of the platform (Eclair MR2). =============================================================== --> =============================================================== --> Loading Loading @@ -3202,89 +3201,23 @@ <!-- =============================================================== <!-- =============================================================== Resources added in version S-V2 of the platform Resources added in version S-V2 of the platform NOTE: add <public> elements within a <staging-public-group> like so: <staging-public-group type="attr" first-id="0x01ff0000"> <public name="exampleAttr1" /> <public name="exampleAttr2" /> </staging-public-group> To add a new <staging-public-group> block, find the id value for the last <staging-public-group> block defined for thie API level, and subtract 0x00010000 from it to get to the id of the new block. For example, if the block closest to the end of this file has an id of 0x01ee0000, the id of the new block should be 0x01ed0000 (0x01ee0000 - 0x00010000 = 0x01ed0000). =============================================================== --> =============================================================== --> <eat-comment /> <eat-comment /> <staging-public-group type="attr" first-id="0x01ff0000"> <staging-public-group-final type="attr" first-id="0x01ff0000"> <public name="shouldUseDefaultUnfoldTransition" /> <public name="shouldUseDefaultUnfoldTransition" /> </staging-public-group> </staging-public-group-final> <public type="attr" name="shouldUseDefaultUnfoldTransition" id="0x0101064c" /> <staging-public-group type="id" first-id="0x01fe0000"> <staging-public-group-final type="id" first-id="0x01fe0000"> <public name="accessibilityActionDragStart" /> <public name="accessibilityActionDragStart" /> <public name="accessibilityActionDragDrop" /> <public name="accessibilityActionDragDrop" /> <public name="accessibilityActionDragCancel" /> <public name="accessibilityActionDragCancel" /> </staging-public-group> </staging-public-group-final> <staging-public-group type="style" first-id="0x01fd0000"> </staging-public-group> <staging-public-group type="string" first-id="0x01fc0000"> </staging-public-group> <staging-public-group type="dimen" first-id="0x01fb0000"> </staging-public-group> <staging-public-group type="color" first-id="0x01fa0000"> </staging-public-group> <staging-public-group type="array" first-id="0x01f90000"> </staging-public-group> <staging-public-group type="drawable" first-id="0x01f80000"> </staging-public-group> <staging-public-group type="layout" first-id="0x01f70000"> </staging-public-group> <staging-public-group type="anim" first-id="0x01f60000"> <public type="id" name="accessibilityActionDragStart" id="0x01020055" /> </staging-public-group> <public type="id" name="accessibilityActionDragDrop" id="0x01020056" /> <public type="id" name="accessibilityActionDragCancel" id="0x01020057" /> <staging-public-group type="animator" first-id="0x01f50000"> </staging-public-group> <staging-public-group type="interpolator" first-id="0x01f40000"> </staging-public-group> <staging-public-group type="mipmap" first-id="0x01f30000"> </staging-public-group> <staging-public-group type="integer" first-id="0x01f20000"> </staging-public-group> <staging-public-group type="transition" first-id="0x01f10000"> </staging-public-group> <staging-public-group type="raw" first-id="0x01f00000"> </staging-public-group> <staging-public-group type="bool" first-id="0x01ef0000"> </staging-public-group> <staging-public-group type="fraction" first-id="0x01ee0000"> </staging-public-group> <!-- =============================================================== DO NOT ADD UN-GROUPED ITEMS HERE Any new items (attrs, styles, ids, etc.) *must* be added in a staging-public-group block, as the preceding comment explains. Items added outside of a group may have their value recalculated every time something new is added to this file. =============================================================== --> </resources> </resources> tools/aapt2/format/binary/BinaryResourceParser.cpp +15 −3 Original line number Original line Diff line number Diff line Loading @@ -120,6 +120,13 @@ bool BinaryResourceParser::Parse() { static_cast<int>(parser.chunk()->type))); static_cast<int>(parser.chunk()->type))); } } } } if (!staged_entries_to_remove_.empty()) { diag_->Error(DiagMessage(source_) << "didn't find " << staged_entries_to_remove_.size() << " original staged resources"); return false; } return true; return true; } } Loading Loading @@ -393,6 +400,12 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, return false; return false; } } if (const auto to_remove_it = staged_entries_to_remove_.find({name, res_id}); to_remove_it != staged_entries_to_remove_.end()) { staged_entries_to_remove_.erase(to_remove_it); continue; } NewResourceBuilder res_builder(name); NewResourceBuilder res_builder(name); res_builder.SetValue(std::move(resource_value), config) res_builder.SetValue(std::move(resource_value), config) .SetId(res_id, OnIdConflict::CREATE_ENTRY) .SetId(res_id, OnIdConflict::CREATE_ENTRY) Loading Loading @@ -533,9 +546,8 @@ bool BinaryResourceParser::ParseStagedAliases(const ResChunk_header* chunk) { // Since a the finalized resource entry is cloned and added to the resource table under the // Since a the finalized resource entry is cloned and added to the resource table under the // staged resource id, remove the cloned resource entry from the table. // staged resource id, remove the cloned resource entry from the table. if (!table_->RemoveResource(resource_name, staged_id)) { if (!table_->RemoveResource(resource_name, staged_id)) { diag_->Error(DiagMessage(source_) << "failed to find resource entry for staged " // If we haven't seen this resource yet let's add a record to skip it when parsing. << " resource ID " << staged_id); staged_entries_to_remove_.insert({resource_name, staged_id}); return false; } } } } return true; return true; Loading tools/aapt2/format/binary/BinaryResourceParser.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -119,6 +119,10 @@ class BinaryResourceParser { // A mapping of resource ID to type spec flags. // A mapping of resource ID to type spec flags. std::unordered_map<ResourceId, uint32_t> entry_type_spec_flags_; std::unordered_map<ResourceId, uint32_t> entry_type_spec_flags_; // A collection of staged resources that got finalized already and we're supposed to prune - // but the original staged resource record hasn't been parsed yet. std::set<std::pair<ResourceName, ResourceId>> staged_entries_to_remove_; }; }; } // namespace aapt } // namespace aapt Loading tools/finalize_res/finalize_res.py +29 −6 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ """ """ Finalize resource values in <staging-public-group> tags Finalize resource values in <staging-public-group> tags and convert those to <staging-public-group-final> Usage: finalize_res.py core/res/res/values/public.xml public_finalized.xml Usage: finalize_res.py core/res/res/values/public.xml public_finalized.xml """ """ Loading @@ -24,18 +25,40 @@ Usage: finalize_res.py core/res/res/values/public.xml public_finalized.xml import re, sys, codecs import re, sys, codecs def finalize_item(raw): def finalize_item(raw): global _type, _id global _type_ids, _type _id += 1 id = _type_ids[_type] return '<public type="%s" name="%s" id="%s" />' % (_type, raw.group(1), '0x{0:0{1}x}'.format(_id-1,8)) _type_ids[_type] += 1 name = raw.group(1) val = '<public type="%s" name="%s" id="%s" />' % (_type, name, '0x{0:0{1}x}'.format(id,8)) if re.match(r'_*removed.+', name): val = '<!-- ' + val.replace('<public', '< public') + ' -->' return val def finalize_group(raw): def finalize_group(raw): global _type, _id global _type_ids, _type _type = raw.group(1) _type = raw.group(1) _id = int(raw.group(2), 16) id = int(raw.group(2), 16) return re.sub(r'<public name="(.+?)" */>', finalize_item, raw.group(3)) _type_ids[_type] = _type_ids.get(_type, id) (res, count) = re.subn(r' {0,2}<public name="(.+?)" */>', finalize_item, raw.group(3)) if count > 0: res = raw.group(0).replace("staging-public-group", "staging-public-group-final") + '\n' + res return res def collect_ids(raw): global _type_ids for m in re.finditer(r'<public type="(.+?)" name=".+?" id="(.+?)" />', raw): type = m.group(1) id = int(m.group(2), 16) _type_ids[type] = max(id + 1, _type_ids.get(type, 0)) with open(sys.argv[1]) as f: with open(sys.argv[1]) as f: global _type_ids, _type _type_ids = {} raw = f.read() raw = f.read() collect_ids(raw) raw = re.sub(r'<staging-public-group type="(.+?)" first-id="(.+?)">(.+?)</staging-public-group>', finalize_group, raw, flags=re.DOTALL) raw = re.sub(r'<staging-public-group type="(.+?)" first-id="(.+?)">(.+?)</staging-public-group>', finalize_group, raw, flags=re.DOTALL) raw = re.sub(r' *\n', '\n', raw) raw = re.sub(r'\n{3,}', '\n\n', raw) with open(sys.argv[2], "w") as f: with open(sys.argv[2], "w") as f: f.write(raw) f.write(raw) Loading
core/api/current.txt +4 −4 Original line number Original line Diff line number Diff line Loading @@ -1298,7 +1298,7 @@ package android { field public static final int shortcutLongLabel = 16844074; // 0x101052a field public static final int shortcutLongLabel = 16844074; // 0x101052a field public static final int shortcutShortLabel = 16844073; // 0x1010529 field public static final int shortcutShortLabel = 16844073; // 0x1010529 field public static final int shouldDisableView = 16843246; // 0x10101ee field public static final int shouldDisableView = 16843246; // 0x10101ee field public static final int shouldUseDefaultUnfoldTransition; field public static final int shouldUseDefaultUnfoldTransition = 16844364; // 0x101064c field public static final int showAsAction = 16843481; // 0x10102d9 field public static final int showAsAction = 16843481; // 0x10102d9 field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDefault = 16843258; // 0x10101fa field public static final int showDividers = 16843561; // 0x1010329 field public static final int showDividers = 16843561; // 0x1010329 Loading Loading @@ -2014,9 +2014,9 @@ package android { public static final class R.id { public static final class R.id { ctor public R.id(); ctor public R.id(); field public static final int accessibilityActionContextClick = 16908348; // 0x102003c field public static final int accessibilityActionContextClick = 16908348; // 0x102003c field public static final int accessibilityActionDragCancel; field public static final int accessibilityActionDragCancel = 16908375; // 0x1020057 field public static final int accessibilityActionDragDrop; field public static final int accessibilityActionDragDrop = 16908374; // 0x1020056 field public static final int accessibilityActionDragStart; field public static final int accessibilityActionDragStart = 16908373; // 0x1020055 field public static final int accessibilityActionHideTooltip = 16908357; // 0x1020045 field public static final int accessibilityActionHideTooltip = 16908357; // 0x1020045 field public static final int accessibilityActionImeEnter = 16908372; // 0x1020054 field public static final int accessibilityActionImeEnter = 16908372; // 0x1020054 field public static final int accessibilityActionMoveWindow = 16908354; // 0x1020042 field public static final int accessibilityActionMoveWindow = 16908354; // 0x1020042
core/res/res/values/public.xml +9 −76 Original line number Original line Diff line number Diff line Loading @@ -1235,7 +1235,6 @@ <public type="attr" name="author" id="0x010102b4" /> <public type="attr" name="author" id="0x010102b4" /> <public type="attr" name="autoStart" id="0x010102b5" /> <public type="attr" name="autoStart" id="0x010102b5" /> <!-- =============================================================== <!-- =============================================================== Resources added in version 8 of the platform (Eclair MR2). Resources added in version 8 of the platform (Eclair MR2). =============================================================== --> =============================================================== --> Loading Loading @@ -3202,89 +3201,23 @@ <!-- =============================================================== <!-- =============================================================== Resources added in version S-V2 of the platform Resources added in version S-V2 of the platform NOTE: add <public> elements within a <staging-public-group> like so: <staging-public-group type="attr" first-id="0x01ff0000"> <public name="exampleAttr1" /> <public name="exampleAttr2" /> </staging-public-group> To add a new <staging-public-group> block, find the id value for the last <staging-public-group> block defined for thie API level, and subtract 0x00010000 from it to get to the id of the new block. For example, if the block closest to the end of this file has an id of 0x01ee0000, the id of the new block should be 0x01ed0000 (0x01ee0000 - 0x00010000 = 0x01ed0000). =============================================================== --> =============================================================== --> <eat-comment /> <eat-comment /> <staging-public-group type="attr" first-id="0x01ff0000"> <staging-public-group-final type="attr" first-id="0x01ff0000"> <public name="shouldUseDefaultUnfoldTransition" /> <public name="shouldUseDefaultUnfoldTransition" /> </staging-public-group> </staging-public-group-final> <public type="attr" name="shouldUseDefaultUnfoldTransition" id="0x0101064c" /> <staging-public-group type="id" first-id="0x01fe0000"> <staging-public-group-final type="id" first-id="0x01fe0000"> <public name="accessibilityActionDragStart" /> <public name="accessibilityActionDragStart" /> <public name="accessibilityActionDragDrop" /> <public name="accessibilityActionDragDrop" /> <public name="accessibilityActionDragCancel" /> <public name="accessibilityActionDragCancel" /> </staging-public-group> </staging-public-group-final> <staging-public-group type="style" first-id="0x01fd0000"> </staging-public-group> <staging-public-group type="string" first-id="0x01fc0000"> </staging-public-group> <staging-public-group type="dimen" first-id="0x01fb0000"> </staging-public-group> <staging-public-group type="color" first-id="0x01fa0000"> </staging-public-group> <staging-public-group type="array" first-id="0x01f90000"> </staging-public-group> <staging-public-group type="drawable" first-id="0x01f80000"> </staging-public-group> <staging-public-group type="layout" first-id="0x01f70000"> </staging-public-group> <staging-public-group type="anim" first-id="0x01f60000"> <public type="id" name="accessibilityActionDragStart" id="0x01020055" /> </staging-public-group> <public type="id" name="accessibilityActionDragDrop" id="0x01020056" /> <public type="id" name="accessibilityActionDragCancel" id="0x01020057" /> <staging-public-group type="animator" first-id="0x01f50000"> </staging-public-group> <staging-public-group type="interpolator" first-id="0x01f40000"> </staging-public-group> <staging-public-group type="mipmap" first-id="0x01f30000"> </staging-public-group> <staging-public-group type="integer" first-id="0x01f20000"> </staging-public-group> <staging-public-group type="transition" first-id="0x01f10000"> </staging-public-group> <staging-public-group type="raw" first-id="0x01f00000"> </staging-public-group> <staging-public-group type="bool" first-id="0x01ef0000"> </staging-public-group> <staging-public-group type="fraction" first-id="0x01ee0000"> </staging-public-group> <!-- =============================================================== DO NOT ADD UN-GROUPED ITEMS HERE Any new items (attrs, styles, ids, etc.) *must* be added in a staging-public-group block, as the preceding comment explains. Items added outside of a group may have their value recalculated every time something new is added to this file. =============================================================== --> </resources> </resources>
tools/aapt2/format/binary/BinaryResourceParser.cpp +15 −3 Original line number Original line Diff line number Diff line Loading @@ -120,6 +120,13 @@ bool BinaryResourceParser::Parse() { static_cast<int>(parser.chunk()->type))); static_cast<int>(parser.chunk()->type))); } } } } if (!staged_entries_to_remove_.empty()) { diag_->Error(DiagMessage(source_) << "didn't find " << staged_entries_to_remove_.size() << " original staged resources"); return false; } return true; return true; } } Loading Loading @@ -393,6 +400,12 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, return false; return false; } } if (const auto to_remove_it = staged_entries_to_remove_.find({name, res_id}); to_remove_it != staged_entries_to_remove_.end()) { staged_entries_to_remove_.erase(to_remove_it); continue; } NewResourceBuilder res_builder(name); NewResourceBuilder res_builder(name); res_builder.SetValue(std::move(resource_value), config) res_builder.SetValue(std::move(resource_value), config) .SetId(res_id, OnIdConflict::CREATE_ENTRY) .SetId(res_id, OnIdConflict::CREATE_ENTRY) Loading Loading @@ -533,9 +546,8 @@ bool BinaryResourceParser::ParseStagedAliases(const ResChunk_header* chunk) { // Since a the finalized resource entry is cloned and added to the resource table under the // Since a the finalized resource entry is cloned and added to the resource table under the // staged resource id, remove the cloned resource entry from the table. // staged resource id, remove the cloned resource entry from the table. if (!table_->RemoveResource(resource_name, staged_id)) { if (!table_->RemoveResource(resource_name, staged_id)) { diag_->Error(DiagMessage(source_) << "failed to find resource entry for staged " // If we haven't seen this resource yet let's add a record to skip it when parsing. << " resource ID " << staged_id); staged_entries_to_remove_.insert({resource_name, staged_id}); return false; } } } } return true; return true; Loading
tools/aapt2/format/binary/BinaryResourceParser.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -119,6 +119,10 @@ class BinaryResourceParser { // A mapping of resource ID to type spec flags. // A mapping of resource ID to type spec flags. std::unordered_map<ResourceId, uint32_t> entry_type_spec_flags_; std::unordered_map<ResourceId, uint32_t> entry_type_spec_flags_; // A collection of staged resources that got finalized already and we're supposed to prune - // but the original staged resource record hasn't been parsed yet. std::set<std::pair<ResourceName, ResourceId>> staged_entries_to_remove_; }; }; } // namespace aapt } // namespace aapt Loading
tools/finalize_res/finalize_res.py +29 −6 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ """ """ Finalize resource values in <staging-public-group> tags Finalize resource values in <staging-public-group> tags and convert those to <staging-public-group-final> Usage: finalize_res.py core/res/res/values/public.xml public_finalized.xml Usage: finalize_res.py core/res/res/values/public.xml public_finalized.xml """ """ Loading @@ -24,18 +25,40 @@ Usage: finalize_res.py core/res/res/values/public.xml public_finalized.xml import re, sys, codecs import re, sys, codecs def finalize_item(raw): def finalize_item(raw): global _type, _id global _type_ids, _type _id += 1 id = _type_ids[_type] return '<public type="%s" name="%s" id="%s" />' % (_type, raw.group(1), '0x{0:0{1}x}'.format(_id-1,8)) _type_ids[_type] += 1 name = raw.group(1) val = '<public type="%s" name="%s" id="%s" />' % (_type, name, '0x{0:0{1}x}'.format(id,8)) if re.match(r'_*removed.+', name): val = '<!-- ' + val.replace('<public', '< public') + ' -->' return val def finalize_group(raw): def finalize_group(raw): global _type, _id global _type_ids, _type _type = raw.group(1) _type = raw.group(1) _id = int(raw.group(2), 16) id = int(raw.group(2), 16) return re.sub(r'<public name="(.+?)" */>', finalize_item, raw.group(3)) _type_ids[_type] = _type_ids.get(_type, id) (res, count) = re.subn(r' {0,2}<public name="(.+?)" */>', finalize_item, raw.group(3)) if count > 0: res = raw.group(0).replace("staging-public-group", "staging-public-group-final") + '\n' + res return res def collect_ids(raw): global _type_ids for m in re.finditer(r'<public type="(.+?)" name=".+?" id="(.+?)" />', raw): type = m.group(1) id = int(m.group(2), 16) _type_ids[type] = max(id + 1, _type_ids.get(type, 0)) with open(sys.argv[1]) as f: with open(sys.argv[1]) as f: global _type_ids, _type _type_ids = {} raw = f.read() raw = f.read() collect_ids(raw) raw = re.sub(r'<staging-public-group type="(.+?)" first-id="(.+?)">(.+?)</staging-public-group>', finalize_group, raw, flags=re.DOTALL) raw = re.sub(r'<staging-public-group type="(.+?)" first-id="(.+?)">(.+?)</staging-public-group>', finalize_group, raw, flags=re.DOTALL) raw = re.sub(r' *\n', '\n', raw) raw = re.sub(r'\n{3,}', '\n\n', raw) with open(sys.argv[2], "w") as f: with open(sys.argv[2], "w") as f: f.write(raw) f.write(raw)