diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-06-27 16:21:42 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-06-29 21:56:58 -0700 |
commit | 5e8fa3a24835a1ad39f758f630a61c83133eabf8 (patch) | |
tree | c357223fa7c0d85b482b6cf82a6ebe4aadb20076 /tools/aapt2/diff/Diff.cpp | |
parent | d4e80c6a4b99a24b0cf3a14a42123ec593412a7f (diff) |
AAPT2: Improve diff command
Change-Id: Ia1e2f8482c7192ef50126b61bed7975297332767
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; |