Loading tools/aapt2/Debug.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -339,6 +339,14 @@ void Debug::PrintTable(const ResourceTable& table, const DebugPrintTableOptions& printer->Print("("); printer->Print(value->config.to_string()); printer->Print(") "); if (value->value->GetFlag()) { printer->Print("(featureFlag="); if (value->value->GetFlag()->negated) { printer->Print("!"); } printer->Print(value->value->GetFlag()->name); printer->Print(") "); } value->value->Accept(&headline_printer); if (options.show_sources && !value->value->GetSource().path.empty()) { printer->Print(" src="); Loading @@ -355,6 +363,12 @@ void Debug::PrintTable(const ResourceTable& table, const DebugPrintTableOptions& printer->Print("("); printer->Print(value->config.to_string()); printer->Print(") "); printer->Print("(featureFlag="); if (value->value->GetFlag()->negated) { printer->Print("!"); } printer->Print(value->value->GetFlag()->name); printer->Print(") "); value->value->Accept(&headline_printer); if (options.show_sources && !value->value->GetSource().path.empty()) { printer->Print(" src="); Loading tools/aapt2/Resource.h +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ struct FeatureFlagAttribute { std::string name; bool negated = false; std::string ToString() { std::string ToString() const { return (negated ? "!" : "") + name; } Loading tools/aapt2/ResourceTable.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -247,6 +247,21 @@ ResourceConfigValue* ResourceEntry::FindOrCreateFlagDisabledValue( return newValue; } ResourceConfigValue* ResourceEntry::FindFlagDisabledValue(const FeatureFlagAttribute& flag, const android::ConfigDescription& config, android::StringPiece product) { auto iter = std::lower_bound(flag_disabled_values.begin(), flag_disabled_values.end(), ConfigFlagKey{&config, product, flag}, lt_config_flag_key_ref()); if (iter != flag_disabled_values.end()) { ResourceConfigValue* value = iter->get(); const auto& value_flag = value->value->GetFlag().value(); if (value_flag == flag && value->config == config && value->product == product) { return value; } } return nullptr; } bool ResourceEntry::HasDefaultValue() const { // The default config should be at the top of the list, since the list is sorted. return !values.empty() && values.front()->config == ConfigDescription::DefaultConfig(); Loading @@ -271,7 +286,7 @@ ResourceTable::CollisionResult ResourceTable::ResolveFlagCollision(FlagStatus ex case FlagStatus::NoFlag: return CollisionResult::kTakeNew; case FlagStatus::Disabled: return CollisionResult::kKeepOriginal; return CollisionResult::kConflict; case FlagStatus::Enabled: return CollisionResult::kTakeNew; default: Loading tools/aapt2/ResourceTable.h +4 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,10 @@ class ResourceEntry { android::StringPiece product); std::vector<ResourceConfigValue*> FindAllValues(const android::ConfigDescription& config); ResourceConfigValue* FindFlagDisabledValue(const FeatureFlagAttribute& flag, const android::ConfigDescription& config, android::StringPiece product = {}); // Either returns the existing ResourceConfigValue in the disabled list with the given flag, // config, and product or creates a new one and returns that. In either case the returned value // does not have the flag set on the value so it must be set by the caller. Loading tools/aapt2/ResourceValues.h +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class Value { flag_ = val; } std::optional<FeatureFlagAttribute> GetFlag() const { const std::optional<FeatureFlagAttribute>& GetFlag() const { return flag_; } Loading Loading
tools/aapt2/Debug.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -339,6 +339,14 @@ void Debug::PrintTable(const ResourceTable& table, const DebugPrintTableOptions& printer->Print("("); printer->Print(value->config.to_string()); printer->Print(") "); if (value->value->GetFlag()) { printer->Print("(featureFlag="); if (value->value->GetFlag()->negated) { printer->Print("!"); } printer->Print(value->value->GetFlag()->name); printer->Print(") "); } value->value->Accept(&headline_printer); if (options.show_sources && !value->value->GetSource().path.empty()) { printer->Print(" src="); Loading @@ -355,6 +363,12 @@ void Debug::PrintTable(const ResourceTable& table, const DebugPrintTableOptions& printer->Print("("); printer->Print(value->config.to_string()); printer->Print(") "); printer->Print("(featureFlag="); if (value->value->GetFlag()->negated) { printer->Print("!"); } printer->Print(value->value->GetFlag()->name); printer->Print(") "); value->value->Accept(&headline_printer); if (options.show_sources && !value->value->GetSource().path.empty()) { printer->Print(" src="); Loading
tools/aapt2/Resource.h +1 −1 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ struct FeatureFlagAttribute { std::string name; bool negated = false; std::string ToString() { std::string ToString() const { return (negated ? "!" : "") + name; } Loading
tools/aapt2/ResourceTable.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -247,6 +247,21 @@ ResourceConfigValue* ResourceEntry::FindOrCreateFlagDisabledValue( return newValue; } ResourceConfigValue* ResourceEntry::FindFlagDisabledValue(const FeatureFlagAttribute& flag, const android::ConfigDescription& config, android::StringPiece product) { auto iter = std::lower_bound(flag_disabled_values.begin(), flag_disabled_values.end(), ConfigFlagKey{&config, product, flag}, lt_config_flag_key_ref()); if (iter != flag_disabled_values.end()) { ResourceConfigValue* value = iter->get(); const auto& value_flag = value->value->GetFlag().value(); if (value_flag == flag && value->config == config && value->product == product) { return value; } } return nullptr; } bool ResourceEntry::HasDefaultValue() const { // The default config should be at the top of the list, since the list is sorted. return !values.empty() && values.front()->config == ConfigDescription::DefaultConfig(); Loading @@ -271,7 +286,7 @@ ResourceTable::CollisionResult ResourceTable::ResolveFlagCollision(FlagStatus ex case FlagStatus::NoFlag: return CollisionResult::kTakeNew; case FlagStatus::Disabled: return CollisionResult::kKeepOriginal; return CollisionResult::kConflict; case FlagStatus::Enabled: return CollisionResult::kTakeNew; default: Loading
tools/aapt2/ResourceTable.h +4 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,10 @@ class ResourceEntry { android::StringPiece product); std::vector<ResourceConfigValue*> FindAllValues(const android::ConfigDescription& config); ResourceConfigValue* FindFlagDisabledValue(const FeatureFlagAttribute& flag, const android::ConfigDescription& config, android::StringPiece product = {}); // Either returns the existing ResourceConfigValue in the disabled list with the given flag, // config, and product or creates a new one and returns that. In either case the returned value // does not have the flag set on the value so it must be set by the caller. Loading
tools/aapt2/ResourceValues.h +1 −1 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class Value { flag_ = val; } std::optional<FeatureFlagAttribute> GetFlag() const { const std::optional<FeatureFlagAttribute>& GetFlag() const { return flag_; } Loading