Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
aapt2: add stringified resource configuration to Configuration.proto
Browse files Browse the repository at this point in the history
This is needed for adevtool, to reuse large ConfigDescription.to_string() function which is used
for describing resource qualifiers, e.g. "values-mcc123-sw600dp-night-en".
  • Loading branch information
muhomorr authored and thestinger committed Sep 18, 2023
1 parent e92c7ce commit df5b9be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/aapt2/Configuration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,6 @@ message Configuration {
//

string product = 25;

string stringified = 100;
}
3 changes: 3 additions & 0 deletions tools/aapt2/cmd/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class ConvertCommand : public Command {
" '%s' output format", kOutputFormatBinary),
&xml_flattener_options_.keep_raw_values);
AddOptionalSwitch("-v", "Enables verbose logging", &verbose_);
AddOptionalSwitch("--for-adevtool", "This flag exists to prevent using adevtool with "
"upstream aapt2 which lacks the Configuration.proto customization.", &for_adevtool_);
}

int Action(const std::vector<std::string>& args) override;
Expand All @@ -56,6 +58,7 @@ class ConvertCommand : public Command {
std::string output_path_;
std::optional<std::string> output_format_;
bool verbose_ = false;
bool for_adevtool_ = false;
};

int Convert(IAaptContext* context, LoadedApk* input, IArchiveWriter* output_writer,
Expand Down
1 change: 1 addition & 0 deletions tools/aapt2/format/proto/ProtoSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static pb::Visibility::Level SerializeVisibilityToPb(Visibility::Level state) {
}

void SerializeConfig(const ConfigDescription& config, pb::Configuration* out_pb_config) {
out_pb_config->set_stringified(config.to_string());
out_pb_config->set_mcc(config.mcc);
out_pb_config->set_mnc(config.mnc);
out_pb_config->set_locale(config.GetBcp47LanguageTag());
Expand Down

0 comments on commit df5b9be

Please sign in to comment.