diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2016-06-30 06:29:53 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-06-30 06:29:54 +0000 |
commit | 2726f482f1ea6ed4e0aa5636e6db9df5566936fa (patch) | |
tree | f6e0e5adc73fa06a15734512269428364a0cb553 /tools/aapt2/diff/Diff.cpp | |
parent | 46822051519464648bbfb1848371251d19fbfc3e (diff) | |
parent | 5e8fa3a24835a1ad39f758f630a61c83133eabf8 (diff) |
Merge "AAPT2: Improve diff command"
Diffstat (limited to 'tools/aapt2/diff/Diff.cpp')
-rw-r--r-- | tools/aapt2/diff/Diff.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/aapt2/diff/Diff.cpp b/tools/aapt2/diff/Diff.cpp index 67333a228cdf..1ff6ef6cd2b1 100644 --- a/tools/aapt2/diff/Diff.cpp +++ b/tools/aapt2/diff/Diff.cpp @@ -16,6 +16,7 @@ #include "Flags.h" #include "ResourceTable.h" +#include "ValueVisitor.h" #include "io/ZipArchive.h" #include "process/IResourceTableConsumer.h" #include "process/SymbolTable.h" @@ -385,6 +386,24 @@ static bool emitResourceTableDiff(IAaptContext* context, LoadedApk* apkA, Loaded return diff; } +class ZeroingReferenceVisitor : public ValueVisitor { +public: + using ValueVisitor::visit; + + void visit(Reference* ref) override { + if (ref->name && ref->id) { + if (ref->id.value().packageId() == 0x7f) { + ref->id = {}; + } + } + } +}; + +static void zeroOutAppReferences(ResourceTable* table) { + ZeroingReferenceVisitor visitor; + visitAllValuesInTable(table, &visitor); +} + int diff(const std::vector<StringPiece>& args) { DiffContext context; @@ -405,6 +424,10 @@ int diff(const std::vector<StringPiece>& args) { return 1; } + // Zero out Application IDs in references. + zeroOutAppReferences(apkA->getResourceTable()); + zeroOutAppReferences(apkB->getResourceTable()); + if (emitResourceTableDiff(&context, apkA.get(), apkB.get())) { // We emitted a diff, so return 1 (failure). return 1; |