summaryrefslogtreecommitdiff
path: root/tools/aapt2/java
AgeCommit message (Collapse)Author
2020-03-26aapt2: Preserve annotation parameters for SystemApi.Narayan Kamath
SystemAPI can now be parameterized. Note that this change preserves the content of the annotation params without attempting to interpret them in any way. This means that references to types outside of java.lang must be fully qualified. Test: atest aapt2_tests Bug: 147581540 Change-Id: I0630fb1c7c7a7f5918ff2dca32fb8e078b367751
2020-02-12Merge "Fix clang-tidy performance-faster-string-find warnings" am: ↵Automerger Merge Worker
57fb318ca3 am: 7c0f0d3cec am: 40ef6319ca Change-Id: Id9d31a0c5cf41a0bb4a58326faa79511a1d8cc4a
2020-02-11Fix clang-tidy performance-faster-string-find warningsChih-Hung Hsieh
Bug: 30411878 Test: build with WITH_TIDY=1 Change-Id: I7fd815aa401fbcaff97b772f3ba5d6f1d2034011
2019-12-12Merge "Generate "keep" rules for actionProviderClass and actionViewClass"TreeHugger Robot
2019-12-09Merge "Fix aapt2 JavaClassGenerator Maybe#value() call before check"TreeHugger Robot
2019-12-06Fix aapt2 JavaClassGenerator Maybe#value() call before checkRyan Mitchell
Previous refactor accidentally assumed all attributes would have resolvable symbols when generating the R class. Restore previous behavior of calling SkipSymbol before retrieving the attribute comment. Bug: 145685954 Test: m TeleService Change-Id: Ie8e1092556bc0b6a764462ffa0b99a876bcbd70e
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-26Factor out repeated shift instructions to reduce code sizeDonald Chai
R8 has some O(n^3) analysis somewhere, so this should speed up analysis of "onResourcesLoaded" by 1.5^3=3.3x. Bug: 145052564 Change-Id: Ib6ab111511d6bd3afae0c29cd00f743e7128768a Tested: aapt2_tests
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-11-08[aapt2] Fix infinite loop in proguard::CollectLocationsDonald Chai
std::set only works correctly when the < comparator is a strict weak ordering, while UsageLocation::operator< was actually implementing !=. Bug: 134190468 Change-Id: Icb9407e9c8451f9fcb4eb9b2cea310e3bcaf159e Tested: aapt2_tests, and b/134190468#comment1 (cherry picked from commit 44fa342eb91b90df7998fa2808e21af75aafaf39)
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-06-03[aapt2] Fix infinite loop in proguard::CollectLocationsDonald Chai
std::set only works correctly when the < comparator is a strict weak ordering, while UsageLocation::operator< was actually implementing !=. Bug: 134190468 Change-Id: Icb9407e9c8451f9fcb4eb9b2cea310e3bcaf159e Tested: aapt2_tests, and b/134190468#comment1
2019-03-06Make sure Proguard keeps zygote preload class.Martijn Coenen
Bug: 127262679 Test: atest ProguardRulesTest Change-Id: Ib082404e08d98b25fcecbf680afb4af37fe2786b
2019-01-04Merge "Fix/suppress aapt/aapt2 google-explicit-constructor warnings" am: ↵Chih-Hung Hsieh
cdf6be573f am: d42fe48c93 am: 0bf62f1309 Change-Id: Iffb7e4a145b172a35dd58b9450d4a5184d8b07f7
2019-01-04Fix/suppress aapt/aapt2 google-explicit-constructor warningsChih-Hung Hsieh
* Add explicit to conversion constructors/operators * Use NOLINT or NOLINTNEXTLINE to suppress warnings on intended converters Bug: 28341362 Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor Change-Id: Ie02101ea7c422e8add535c111a30a2f21ead0ace
2018-12-17Merge "Fix performance-for-range-copy warnings" am: bc29242288 am: 7adb73f332Chih-Hung Hsieh
am: 2296036a40 Change-Id: Ia99ea6c9633986e68340bc88983d06baa7a1c597
2018-12-17Fix performance-for-range-copy warningsChih-Hung Hsieh
Bug: 30413223 Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,performance* Change-Id: Ie481e88025a7a1f3abde8ff63420d5ccd8577e52
2018-12-03Add @hide support for styleable attributesRyan Mitchell
AAPT2 generates documentation for styleables. The documentation contains references to the attributes of the styleable. If the attributes are marked @hide, remove the references to the attributes in the generated coments. Bug: 120262117 Test: m -j offline-sdk-docs Change-Id: I541002077b17771d89caead04df2f4ae66c623f0
2018-10-08libandroidfw: move ConfigDescription from aapt2 to libandroidfwMårten Kongstad
This is to allow idmap2 to access ConfigDescription. Test: libandroidfw_tests Test: aapt2_tests Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5 Merged-In: I54210bbbd8dad5903cb7100807df977efa394ad5
2018-10-08libandroidfw: move ConfigDescription from aapt2 to libandroidfwMårten Kongstad
This is to allow idmap2 to access ConfigDescription. Test: libandroidfw_tests Test: aapt2_tests Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
2018-10-03Merge "Restore Proguard behavior and add minimal flag"Ryan Mitchell
2018-10-01Merge "Do not use StringPiece in ExtractJavaIdentifier" am: 20ecc6397b am: ↵Pirama Arumuga Nainar
206ccf1f61 am: 7472303ff4 Change-Id: Idd910ad9fb743093f8e43ddcdf5770722b4393e6
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-09-25Do not use StringPiece in ExtractJavaIdentifierPirama Arumuga Nainar
Bug: http://b/91353691 After assigning the result of TransformToFieldName to 'result', the underlying storage is destroyed after the 'if' statement of the function call. 'result' ends up with garbage if the identifier has a '-'. ManifestClassGeneratorTest.NormalizePermissionNames is broken for this reason in 32-bit Windows when using libc++ and 32-bit Linux. ASAN also reports this failure for both 32-bit and 64-bit linux. Test: Run test on the cases mentioned above and ensure all of them pass. Change-Id: I69163c423c1171b7ac7838f2abe06bdf8058df4c
2018-07-20Merge "Only keep necessary constructor for custom view nodes"TreeHugger Robot
2018-07-20Merge "Only keep methods with correct signature for more types"TreeHugger Robot
2018-07-20Merge "AAPT2: Fix R.java for styleable in different package"Ryan Mitchell
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-07-18Add Application name to manifest test caseJake Wharton
Test: make aapt2_tests Change-Id: I4df26375bdf480b7d09e9cf816b7a9feaa141115
2018-07-13AAPT2: Fix R.java for styleable in different packageRyan Mitchell
When generating the R.java file, attributes of styleables do not always have package names on them. This caused a problem where when an apk that was previously linked and that also contained a declare-styleable is linked again to an AndroidManifest.xml with a different package name, styleable attributes' resource symbols could not be looked up correctly. This change does not rename the resources but makes sure that the java generator finds the attribute symbols correctly. Bug: 110877419 Test: Created a test in aapt2_tests and verified correct behavior of repro example from bug Change-Id: Ib99d84cbe44dadca86603bc610ad3f4e09e3fb11
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-11Improve tests for ProGuard rules, add transition testsJake Wharton
Test: make aapt2_tests Change-Id: If3300a9f82ad90189b74aab03c0d7f649e74e3f3
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
2018-03-05Merge "Don't dereference a null pointer"TreeHugger Robot
2018-03-02Don't dereference a null pointerTodd Kennedy
If we don't specifiy an output for R.java, don't try to write data to the class definition Change-Id: I3ad471ec93dcb8baf13f221174065679cce311ad Fixes: 72547268 Test: out/host/linux-x86/nativetest64/aapt2_tests/aapt2_tests
2018-02-13AAPT2: normalize Manifest java identifiers.Izabela Orlowska
Currently AAPT2 does not allow permissions which last piece contains the "-" symbol (since it is an illegal character for a java identifier). AAPT1 would normalize the last piece, therefore creating a valid java identifier. This CL makes AAPT2 behave in a similar way to AAPT1, but instead of modifying the original value of the permission string, modifies only the java identifier part, leaving the permission string unchanged. Fixes: 72980877 Test: updated Change-Id: Ie44317e07407341ba3e91a84d9b06980547b3448
2018-01-17Merge "aapt2: Fix issue with Manifest duplicate handling"TreeHugger Robot
2018-01-16aapt2: Fix issue with Manifest duplicate handlingAdam Lesinski
Fixed a memory-corruption issue that led to multiple duplicate permission entries being generated for Manifest.java. Bug: 71641288 Test: make aapt2_tests Change-Id: I8cd37929c4883aaba2beebbf874c7ee3234d51d8
2018-01-11AAPT2: Allow compatible duplicate AttributesAdam Lesinski
If a resource XML file defines two compatible Attributes, they should be merged without throwing an error. Ex: <declare-styleable> <attr name="conflict" format="string" /> </declare-styleable> <declare-styleable> <attr name="conflict" format="string|reference" /> </declare-styleable> In this case, string|reference and string are the same, so these should merge correctly. Bug: 65699599 Test: make aapt2_tests Test: make AaptBasicTest Change-Id: I7b0f956d2332f7f0b458acd59ca0a606b2cfdf95
2017-12-18AAPT2: Propagate SPEC_OVERLAYABLE flag to final APKAdam Lesinski
Resources can be marked as overlayable, which means they can be overlaid by runtime resource overlays. This change propagates this state to the final resource table that is installed on device. Future work: - Have the idmap tool respect the overlayable state and ignore entries that overlay anything else. Bug: 64980941 Test: make aapt2_tests Change-Id: Id45b1e141a281be2ee32a4ac3096fcf1114d523b
2017-12-05AAPT2: allow to generate R.txt without R.javaIzabela Orlowska
Bug: 69956357 Test: manual Change-Id: If2bc32bd4efb1ea17c6cba7a17f2b2300164ede0
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-11-07AAPT2: Better debugging outputAdam Lesinski
Test: make aapt2_tests Change-Id: I7778b773201381538dc1f2e376abee4eb33e44c0
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-09-29AAPT2: Fix R.java styleable + indices orderingAdam Lesinski
Make sure that Styleables are directly followed by their indices. If not, Robolectric breaks. This is not strictly incorrect to have an arbitrary ordering in R.java, but its easier to just support Robolectric in this case. Bug: 65837293 Test: make aapt2_tests (cherry picked from commit af85c4deb667843a227d62275fe6992005f4c38d) Change-Id: Ia59ba58427ade386d075ca9fc9eb5b53e35beca0