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
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
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
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
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 44fa342eb9)
Apps commonly use the versions of the attributes from AndroidX, which
will be unqualified.
Bug: 30888677
Change-Id: Id7cb32b28edb1cd1b8113a8c9a7ee29107a1b67e
Tested: aapt2_tests
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
* 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
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
This is to allow idmap2 to access ConfigDescription.
Test: libandroidfw_tests
Test: aapt2_tests
Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
Merged-In: I54210bbbd8dad5903cb7100807df977efa394ad5
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
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
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
- 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
This attribute was added in API 28 and is reflectively instantiated from a zero-argument constructor.
Test: make aapt2_tests
Change-Id: Ie9de0764165c6fe6c6fcda6cc38b0cc633f03bbd
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
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
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
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
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
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
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
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
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
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
FileOutputStream is safe to use on Windows, as it opens
files using our compatibility API.
Bug: 68262818
Test: make aapt2_tests
Change-Id: Ib0b27e93edd609b49b1327db7d9867a002198ebb
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
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
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