Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a36cc98a authored by Ryan Mitchell's avatar Ryan Mitchell
Browse files

Badging should print compiled platform version

aapt2 saves space by compiling all raw xml strings to the Res_value
structure. This causes the platformBuildVersionCode and
platformBuildVersionCodename attributes on the <manifest> tag to be
compilled as integers. aapt2 and aapt dump badging assumed these values
would be strings and is failing to print the value for these attributes.

With this change, the value will be printed regardless if it is encoded
as an integer or string.

Bug: 130830770
Test: manualy build APK and run aapt2 dump badging
Change-Id: I89487db36c6bc4d0fde3a410b7a64debfec5021e
parent 0dbbe879
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -291,8 +291,11 @@ class ManifestExtractor {
            }
          }
        }

        if (!attr->value.empty()) {
          return &attr->value;
        }
      }
      return nullptr;
    }

@@ -425,6 +428,8 @@ class Manifest : public ManifestExtractor::Element {
  const std::string* split = nullptr;
  const std::string* platformVersionName = nullptr;
  const std::string* platformVersionCode = nullptr;
  const int32_t* platformVersionNameInt = nullptr;
  const int32_t* platformVersionCodeInt = nullptr;
  const int32_t* compilesdkVersion = nullptr;
  const std::string* compilesdkVersionCodename = nullptr;
  const int32_t* installLocation = nullptr;
@@ -440,6 +445,10 @@ class Manifest : public ManifestExtractor::Element {
                                                           "platformBuildVersionName"));
    platformVersionCode = GetAttributeString(FindAttribute(manifest, {},
                                                           "platformBuildVersionCode"));
    platformVersionNameInt = GetAttributeInteger(FindAttribute(manifest, {},
                                                               "platformBuildVersionName"));
    platformVersionCodeInt = GetAttributeInteger(FindAttribute(manifest, {},
                                                               "platformBuildVersionCode"));

    // Extract the compile sdk info
    compilesdkVersion = GetAttributeInteger(FindAttribute(manifest, COMPILE_SDK_VERSION_ATTR));
@@ -460,9 +469,15 @@ class Manifest : public ManifestExtractor::Element {
    if (platformVersionName) {
      printer->Print(StringPrintf(" platformBuildVersionName='%s'", platformVersionName->data()));
    }
    if (platformVersionNameInt) {
      printer->Print(StringPrintf(" platformBuildVersionName='%d'", *platformVersionNameInt));
    }
    if (platformVersionCode) {
      printer->Print(StringPrintf(" platformBuildVersionCode='%s'", platformVersionCode->data()));
    }
    if (platformVersionCodeInt) {
      printer->Print(StringPrintf(" platformBuildVersionCode='%d'", *platformVersionCodeInt));
    }
    if (compilesdkVersion) {
      printer->Print(StringPrintf(" compileSdkVersion='%d'", *compilesdkVersion));
    }