summaryrefslogtreecommitdiff
path: root/tools/aapt2/java/ProguardRules.cpp
AgeCommit message (Collapse)Author
2020-03-06Merge "Generate "keep" rules for android:name and class attributes" am: ↵Automerger Merge Worker
a13d7fc861 am: 4da226a984 Change-Id: I4443b84896684ac3249108316487035319b4f52e
2020-03-05Generate "keep" rules for android:name and class attributesJeremy Woods
We should keep classes that are in the android:name or class xml attributes. Test: m -j aapt2_tests Bug: 142601969 Change-Id: Ia67365bd702bae75d38b9572d68e9930e856e0f8
2019-12-12Merge "Generate "keep" rules for actionProviderClass and actionViewClass"TreeHugger Robot
2019-12-02Add "no-proguard-location-reference" flag to aapt2Jean-Luc Coelho
This fixes relocatability issues with the code shrinkers. Bug: 144529940 Test: None Change-Id: I65e08e850193e67dcdf4c533d9e66332714f0c8c
2019-11-11Speed up WriteKeepSet when generate_conditional_proguard_rules is off.Brian Duff
The results of CollectLocations() are only used if the --proguard-conditional-keep-rules option is set, but the function is always called when the --proguard option is set. Since this function can be slow on particularly large resource sets, avoid calling it unless --proguard-conditional-keep-rules is set. Change-Id: If259d41cdab16abad8ca62f30d8beb5ebf33575a Bug: 144236322 Test: aapt2_tests
2019-09-10Generate "keep" rules for actionProviderClass and actionViewClassDonald Chai
Apps commonly use the versions of the attributes from AndroidX, which will be unqualified. Bug: 30888677 Change-Id: Id7cb32b28edb1cd1b8113a8c9a7ee29107a1b67e Tested: aapt2_tests
2019-03-06Make sure Proguard keeps zygote preload class.Martijn Coenen
Bug: 127262679 Test: atest ProguardRulesTest Change-Id: Ib082404e08d98b25fcecbf680afb4af37fe2786b
2018-09-25Restore Proguard behavior and add minimal flagRyan Mitchell
We previously changed AAPT2 to correctly only generate keep rules for the constructors required to inflate the different views. This cause projects that did not have keep rules for the other constructors that were accessed through reflection to have runtime crashes. This change adds a flag to the link stage (--proguard-minimal-keep-rules) that allows AAPT2 to only keep the constructors required for layout inflation. If the flag is not present, then AAPT2 will generate less specific keep rules than keep all constructors. Bug: 116201243 Test: aapt2_tests Change-Id: I8bb5cdf8446518ab153ea988e1243ca9494258c7
2018-07-20Only keep necessary constructor for custom view nodesJake Wharton
This expands the Context+AttributeSet constructor specificity from only work on <view class=> nodes to <my.Type> nodes. Bug: 37123156 Test: make aapt2_tests Change-Id: I8fb950731383f86bee225333bda27baf5a7a34c5
2018-07-20Only keep methods with correct signature for more typesJake Wharton
- For transition and pathMotion attributes the method must have Context and AttributeSet parameters. - For actionViewClass and actionProviderClass attributes the constructor must have a single Context parameter. - For Fragment's class or name attributes the constructor must have zero parameters. Bug: 37123156 Test: make aapt2_tests Change-Id: I34017abd182867ba95172835051d114cb2f3b3ac
2018-07-18Add rule emissions for appComponentFactoryJake Wharton
This attribute was added in API 28 and is reflectively instantiated from a zero-argument constructor. Test: make aapt2_tests Change-Id: Ie9de0764165c6fe6c6fcda6cc38b0cc633f03bbd
2018-06-11Only keep methods with correct signature for view/menu clickJake Wharton
For View's onClick attribute the method must have a single argument of type android.view.View. For a MenuItem's onClick attribute the method must have a single argument of type android.view.MenuItem. Since these rules match all types and any return type, matching by signature is the only available specificity that can be added. Bug: 37123156 Test: make aapt2_tests Change-Id: I4b82f5ef9e62a8ecffaab424e269df627825709e
2018-06-11Only keep default constructor of manifest itemsJake Wharton
Reflection-based instantiation of manifest-declared types is only done on the default (aka no-argument) constructor. While these types are unlikely to have alternate constructors (unlike the others listed in the bug), there's no reason to generate overly keep-y rules for them. Bug: 37123156 Test: make aapt2_tests Change-Id: Ic83a2671a54ea5dd558bfcacf033a60e9568ab8c
2018-05-24AAPT2: Add Proguard rules for nav fragmentsRyan Mitchell
Adds generation of proguard rules for fragments in res/navigation. All android:name attributes have keep rules generated for the classes they reference. Bug: 69929974 Test: aapt2_tests Change-Id: I05a87484ab357ea5629b73caad8488182f474e1f
2017-11-20Fix conditional keep rules for new semanticsAdam Koski
New conditional syntax is a logical AND, not OR. This means if a resource should be conditionally kept by multiple ids, we need to generate a separate rule for each condition (which will be interpreted as OR). Test: unit tests Bug: 69341430 Change-Id: I0786c65561d36fbf43d181a2dfd0c7eaf1d96b8c
2017-11-16AAPT2: Move all file output to FileOutputStreamAdam Lesinski
FileOutputStream is safe to use on Windows, as it opens files using our compatibility API. Bug: 68262818 Test: make aapt2_tests Change-Id: Ib0b27e93edd609b49b1327db7d9867a002198ebb
2017-11-10Change conditional keep rule syntaxAdam Koski
Google's ProGuard fork is migrating to a new syntax that upstream ProGuard 6.0 will also support. Test: unit tests Bug: 69162105 Change-Id: I3b6d7e82eb99c2e2af6c4d851a4f97ec3e471b55
2017-10-20AAPT2: Produce Conditional Proguard Keep RulesAdam Koski
Add the option to produce keep rules that conditional keep based on usage of R identifiers. This allows Proguard to potentially shrink more code if resources are not used. Currently only produces conditional rules for classes referenced in layout resources because they are the most common and has the easiest transitive usage chain to analyze. Bug: 63628451 Test: make aapt2_tests and manual testing Change-Id: I6c1af7affd64af40c80e004d8506a9463444b2c3
2017-08-17AAPT2: Change XmlDom to exclude Namespace as a nodeAdam Lesinski
In preparation for exporting an XML proto format for UAM to consume, this change brings the XML DOM API more in line with other APIs that do not make the Namespace a separate node. Treating Namespace declarations as just properties of an Element node makes the implementation of algorithms much simpler, as the constraints that Namespace nodes have only one child are now built in and traversing to find Element nodes is much simpler. Also made a bunch of quality of life improvements, like formatting and comment style. Test: make aapt2_tests Change-Id: Ib97ff1c4252b7907e2cc1f13a448dc4ca3b809a4
2017-06-28AAPT2: Emit more proguard keep rules for layouts and menusAdam Lesinski
<fragment> tags in layouts use the class attribute to determine which Fragment subclass to load, and fallback on android:name if class is not set. AAPT2 only emitted a proguard rule for the class attribute for <fragment>, when it should emit a proguard rule for the android:name attribute as well. AAPT2 didn't handle menu XML, so support for actionViewClass, actionProviderClass and onClick is added. Bug: 62216174 Test: make aapt2_tests Change-Id: Ie8675c2bd899a5b51f3661eb0901ab8c9a16fd70
2016-10-26AAPT2: Rename to match new styleAdam Lesinski
Use Google3 naming style to match new projects' and open source google projects' style. Preferred to do this in a massive CL so as to avoid style inconsistencies that plague legacy code bases. This is a relatively NEW code base, may as well keep it up to date. Test: name/style refactor - existing tests pass Change-Id: Ie80ecb78d46ec53efdfca2336bb57d96cbb7fb87
2016-07-20Aapt main dex proguard rules - always keep applicationIvan Gavrilovic
Aapt with -D option was not keeping the application and instrumentation subclasses, which were instead handled by mainDexClasses.rules. Instead, include them in the aapt -D output. Change-Id: Ia3b89fc2edd45d379c4d06f0bf674716646fcb3d
2016-07-13AAPT2: Remove usage of u16stringAdam Lesinski
For legacy reasons, we kept around the use of UTF-16 internally in AAPT2. We don't need this and this CL removes all instances of std::u16string and StringPiece16. The only places still needed are when interacting with the ResTable APIs that only operate in UTF16. Change-Id: I492475b84bb9014fa13bf992cff447ee7a5fe588
2016-04-22AAPT2: ProGuard config for components in main dex.Rohit Agrawal
Create an analogue of "aapt2 --proguard" which outputs a proguard configuration that keeps only components which need to be in the main dex. Bug: 27383099 Change-Id: I61d652bfcdfc18e1614e852bd6f7540efd15f780
2015-12-17AAPT2: Fix references to private parentAdam Lesinski
Change-Id: Id4697551b6c8cb6167f562de593006ae3c6158c0
2015-11-19AAPT2: Fail compiling when private symbols are referencedAdam Lesinski
Also moved some XML specific stuff into its own directory, and refactored ReferenceLinker a bit. Change-Id: I912247a82023c1bbf72dc191fbdaf62858cbec0c
2015-11-02AAPT2: Add Manifest fixing/validationAdam Lesinski
Change-Id: I7f6d8b74d1c590adc356b4da55cb6cb777cdf1da
2015-10-30AAPT2: Support generating Manifest.javaAdam Lesinski
This includes comments from AndroidManifest.xml. Change-Id: I412d9ecb12bad20a49a683d6b3bea4a0be1235ae