AAPT2: Add version collapsing
When an app specifies (or imports) resources with various
configurations for different SDK versions, specifying
a minSdk will make many of those resources unreachable.
Version collapsing will prune out the resources specified
for SDK versions less than the minSdk.
If, however, there is no exact matching resource for the
minSdk version, the next smallest SDK version is kept.
Change-Id: Ic7bcab6c59d65c97c67c8767358abb57cdec60a4
diff --git a/tools/aapt2/test/Context.h b/tools/aapt2/test/Context.h
index 96752d3..36f568b 100644
--- a/tools/aapt2/test/Context.h
+++ b/tools/aapt2/test/Context.h
@@ -58,17 +58,19 @@
return false;
}
+ int getMinSdkVersion() override {
+ return mMinSdkVersion;
+ }
+
private:
friend class ContextBuilder;
- Context() : mNameMangler({}) {
- }
-
Maybe<std::u16string> mCompilationPackage;
Maybe<uint8_t> mPackageId;
StdErrDiagnostics mDiagnostics;
SymbolTable mSymbols;
- NameMangler mNameMangler;
+ NameMangler mNameMangler = NameMangler({});
+ int mMinSdkVersion = 0;
};
class ContextBuilder {
@@ -96,6 +98,11 @@
return *this;
}
+ ContextBuilder& setMinSdkVersion(int minSdk) {
+ mContext->mMinSdkVersion = minSdk;
+ return *this;
+ }
+
std::unique_ptr<Context> build() {
return std::move(mContext);
}