946 Commits

Author SHA1 Message Date
Makoto Onuki
eab9e7f801 Don't add API annotations in the internal R.java
I'm trying to enable a check for the following structure:
```
/** @hide */
public class Class1 {
    /** @hide */
    @SystemApi // Invalid because the class is hidden.
    public void method1() { }
}
```

The internal R.java file violates this, which this change is going to fix.

Bug: 159162473
Test: build (treehugger)
Test: atest aapt2_tests

Merged-in: I613e8611ddaf5f8e4761d351d4cd0142d59c7cc9
Change-Id: I613e8611ddaf5f8e4761d351d4cd0142d59c7cc9
2020-06-23 09:35:36 -07:00
Ryan Mitchell
ad19790515 Do not rename R.java package
Cherry picks the rest of Id9d10e16f32533da1b67ab72ac846791526e7a76.

When the --rename-resources-package flag is used, only rename the
package name within the resources.arsc. Generate the R.java under
the package name defined by the manifest unless --custom-package is
used.

Test: manual
Bug: 147434671
Merged-In: Iab30ff9d3d136fa1e5464913f8d493df22c5c1c4
Change-Id: I896b8c69793cff714a950081fd8521e4acf0cf25
2020-05-21 12:06:25 -07:00
Ryan Mitchell
9ed5638125 Do not rename R.java package
When the --rename-resources-package flag is used, only rename the
package name within the resources.arsc. Generate the R.java under
the package name defined by the manifest unless --custom-package is
used.

(This is a cherry pick.)

Bug: 147434671
Test: manual
Merged-In: Id9d10e16f32533da1b67ab72ac846791526e7a76
Change-Id: Id9d10e16f32533da1b67ab72ac846791526e7a76
2020-05-13 09:04:14 -07:00
Ryan Mitchell
940ae50498 Add --rename-resources-package to aapt2
There is currently no way to change the package name encoded in the
resources table. This change adds a flag that controls rewriting the
package name encoded into the resources table. This flag does not
rewrite the package name in the manifest xml.

(This is a cherry pick.)

Bug: 147434671
Test: manual
Merged-In: I435ba07e29df0522c3a44cc5f2c460004a02d71c
Change-Id: I435ba07e29df0522c3a44cc5f2c460004a02d71c
2020-05-07 17:03:12 -07:00
Roshan Pius
29c974a624 aapt2: Add command to rename overlay "targetPackage" attribute
Bug: 154960712
Test: atest ManifestFixerTest
Change-Id: I556fc11e271337de40c70d4ed56a0381a2f79712
Merged-In: I556fc11e271337de40c70d4ed56a0381a2f79712
2020-04-28 00:30:04 +00:00
Orion Hodson
63f06b738d Add explicit dependencies on jni_headers
Preparation for removing implicit include paths for jni.h from soong.

Also remove unnecessary jni.h includes from PathParser.{h,cpp}.

Bug: 152482542
Test: lunch aosp_x86_64 && m checkbuild
Change-Id: Ib18afa3d2c93ed3ce69204286d5177991100fd7e
Exempt-From-Owner-Approval: build refactoring
2020-04-16 08:26:14 +00:00
Dan Willemsen
0985ac8982 Master is now S
Bug: 150754986
Test: treehugger
Change-Id: I44d1b5a0fea74e2bb9e332dcb8486fd30fbd2f07
Merged-In: I44d1b5a0fea74e2bb9e332dcb8486fd30fbd2f07
2020-04-10 05:18:32 +00:00
Chih-Hung Hsieh
7a616f65d6 Suppress bugprone-use-after-move warnings
Bug: 150783499
Test: WITH_TIDY=1 make
Change-Id: Ifdd5d89d2207caba765e8f74e8a86f6b6b4ff609
2020-03-06 10:04:30 -08:00
Jeremy Woods
4bdc698d9f Generate "keep" rules for android:name and class attributes
We should keep classes that are in the android:name or class xml
attributes.

Test: m -j aapt2_tests
Bug: 142601969
Change-Id: Ia67365bd702bae75d38b9572d68e9930e856e0f8
2020-03-05 13:06:26 -08:00
Chih-Hung Hsieh
f2ef6579f2 Fix clang-tidy performance-faster-string-find warnings
Bug: 30411878
Test: build with WITH_TIDY=1
Change-Id: I7fd815aa401fbcaff97b772f3ba5d6f1d2034011
2020-02-11 14:27:11 -08:00
Treehugger Robot
7b56a5075d Merge "Add option to avoid clobbering visibility of <declare-styleable>" 2020-01-17 18:21:24 +00:00
Donald Chai
f80d0ae89b Add option to avoid clobbering visibility of <declare-styleable>
"aapt2 compile" marks styleables as public instead of preserving
information from <public/> or --visibility options.  This behavior can
now be disabled via --preserve-visibility-of-styleables.

Bug: 146649511
Change-Id: Ifb8ab396573d1393df737a59625e79e9cf2494a7
Tested: aapt2_tests
2020-01-07 21:17:59 -08:00
Brian Duff
2f7e4d1a82 Speed up WriteKeepSet when generate_conditional_proguard_rules is off.
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-11 09:47:18 -08:00
Donald Chai
6e914e8baf Merge "Fix computation of 'entry_length' in AAPT2 container format" 2019-11-08 06:13:54 +00:00
Donald Chai
6f613875a1 Fix computation of 'entry_length' in AAPT2 container format
When the protobuf header (or data payload) size are a multiple of 4,
"entry_length" (called "aligned size" in the code) would have counted bytes that
are never actually written.

Bug: 139418052
Change-Id: Ia688a82a67f3807f7feb0be03670bf2827b1d6a1
(cherry picked from commit b99e50922bf8a5eb9f034c1d232646fda122e83c)
2019-11-08 05:15:38 +00:00
Donald Chai
34ebc8f435 [aapt2] Fix infinite loop in proguard::CollectLocations
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-11-08 05:13:53 +00:00
Treehugger Robot
a5e26c955b Merge "[aapt2] Pseudolocalize <plurals> values." 2019-11-07 22:59:41 +00:00
Donald Chai
98c6138c70 [aapt2] Pseudolocalize <plurals> values.
(.won slaer roF)

Bug: 134190774
Test: aapt2_tests
Change-Id: If307af4adfb1d556c41d7cb08590d1c25287f992
(cherry picked from commit 4c3da0f8a4e3db7ae6a0dff3888d7faab3198bb1)
2019-11-07 10:32:09 -08:00
Ryan Mitchell
ac55e41f24 Fix memory leak in aapt2
Fix a memory leak in Main.cpp.

Bug: 141312058
Test: m -j aapt2 SANITIZE_TARGET=address
Change-Id: I54b61792ab75e2f59298dd38168653e496c84bff
2019-09-25 16:26:29 +00:00
Steven Moreland
2700afda04 aapt2: disable leak detection
When building with SANATIZE_HOST=address and ASAN_OPTIONS="" in order to
test that leaks are removed from AIDL, was hitting leaks here.
Explicitly setting ASAN_OPTIONS here so that we can detect leaks in
other host tools.

Bug: 141312058
Test: AIDL's runtests_asan.sh
Change-Id: Ibc599ab75bbf63eab1c7747d17952390a7967e87
2019-09-19 18:18:23 +00:00
Elliott Hughes
a65cae9e7f Move off ZipString and over to std::string/std::string_view as appropriate.
(Cherrypick to AOSP master, resolving merge conflicts.)

Bug: http://b/129068177
Test: treehugger
Change-Id: Ib46761d89772d3a3c655a39df573fd305c117d19
Merged-In: Ib46761d89772d3a3c655a39df573fd305c117d19
2019-06-17 16:05:19 -07:00
Elliott Hughes
78de4f999d Move off ZipString and over to std::string/std::string_view as appropriate.
Bug: http://b/129068177
Test: treehugger
Change-Id: Ib46761d89772d3a3c655a39df573fd305c117d19
2019-06-17 16:47:58 +00:00
Ian Pedowitz
563abce4ed Merge "Revert "Revert "Android Q is API 29""" into qt-dev
am: a326dfb1e5

Change-Id: I0674668835cd5a281e8a01c4b5bdb870595a8305
2019-05-15 13:36:05 -07:00
Ian Pedowitz
a326dfb1e5 Merge "Revert "Revert "Android Q is API 29""" into qt-dev 2019-05-15 16:28:54 +00:00
Elliott Hughes
78e68ceb2b Merge "Don't explicitly specify no prefix/suffix." am: 480d18c472
am: d47c87a2e6

Change-Id: I7cc6d962ec602c844ad9e7f6179260e247b04dc8
2019-05-13 11:22:04 -07:00
Ian Pedowitz
1912a57900 Revert "Revert "Android Q is API 29""
This reverts commit 60c71cee6ec064a0d2f4c6608fdb54bf95545d45.

Reason for revert: Rolling forward for Q-Finalization

Bug: 131429032
Bug: 129975435
Change-Id: Idd812d93b767d8a672b9ada58c8bcc2441395847
2019-05-12 19:44:42 +00:00
Elliott Hughes
65c8b86b3f Don't explicitly specify no prefix/suffix.
Bug: http://b/129068177
Test: treehugger
Change-Id: Ica29efa3c3e49f556157cb0f82fdadef91aadba8
2019-05-11 00:13:09 +00:00
Elliott Hughes
f31f126ed8 Don't explicitly specify no prefix/suffix.
Bug: http://b/129068177
Test: treehugger
Change-Id: I987c88c17b7d1fd01129545bdbd4178de446188c
2019-05-10 17:02:14 -07:00
Ryan Mitchell
bfdebbbd3d Merge "DO NOT MERGE: Fixed broken aapt2 tests" into qt-dev
am: cbe933a40f

Change-Id: Ic0da145919936b8427ba9c6504606f1708832631
2019-05-07 10:48:07 -07:00
TreeHugger Robot
cbe933a40f Merge "DO NOT MERGE: Fixed broken aapt2 tests" into qt-dev 2019-05-07 17:28:17 +00:00
Ryan Mitchell
a5cfb6cf9a Merge "Build aapt2 statically on windows" into qt-dev
am: 274a7b2975

Change-Id: I6684ea4e1d1f2e44059da8ea3b3cec7b82987bff
2019-05-06 17:59:08 -07:00
Ryan Mitchell
ac3bfcfc2a DO NOT MERGE: Fixed broken aapt2 tests
Some tests starting failing when
b435101ec8aa827375e837c4843f6444145e1f4c was merged. It seems on qt-dev
aapt2_host_unit_tests does not run while it does on master.

Bug: 131762014
Bug: 129146717
Test: aapt2_tests
Change-Id: I701b275989c908acb78190be0930785712cb5686
2019-05-06 23:47:09 +00:00
Ryan Mitchell
319fc02cb8 Build aapt2 statically on windows
Prebuilt script is no longer updating libwinpthread-1.dll. Link the
windows executable statically so aapt2 will no longer require the
dependency on the dll.

Bug: 131883685
Test: manual test of aapt2.exe on windows without libwinpthread-1.dll
Change-Id: If78a8ec3030003862c18e3967e4d8333fde7928a
2019-05-06 19:07:58 +00:00
Ian Pedowitz
85ff9dacc5 Merge "Revert "RESTRICT AUTOMERGE Android Q is API 29"" into qt-dev
am: 40a8e99740

Change-Id: I1e2472a230baae25c2abe070a0ec75b9a8319c06
2019-05-02 14:48:57 -07:00
Ian Pedowitz
a17eabdc62 Merge changes from topic "QT-SDK-Finalization" into qt-dev
am: 917936172f

Change-Id: Ia7d0a4971a702966968abb59685dd1a13dff03ec
2019-05-02 14:14:57 -07:00
Ian Pedowitz
60c71cee6e Revert "RESTRICT AUTOMERGE Android Q is API 29"
This reverts commit 8a3d1f96e1736c7e0493ebb71ed2904dffdebbfd.

Reason for revert: QT SDK Finalization. Will be merged again on/after May 13th

Bug: 131429032
Bug: 129975435
Change-Id: I7a48ef6a057a97ebd9903b7e934a7d95ec97f00e
2019-05-02 00:55:51 +00:00
Suprabh Shukla
8a3d1f96e1 RESTRICT AUTOMERGE Android Q is API 29
Time may be eternal, Captain, but our patience is not. It's time to put
an end to your trek through the stars.

Test: Builds, boots.

Bug: 131429032
Bug: 129975435
Change-Id: Ia2367124afb642dac0fb365e4fa096db1c648adb
2019-05-01 14:11:18 -07:00
Ryan Mitchell
b505cc84bf Merge "Fix unknown resource type error message" into qt-dev
am: dd76b346d4

Change-Id: I1af6f93d990a940876dbb65fe7b158ff6a81a576
2019-04-30 11:05:27 -07:00
Ryan Mitchell
f07c58b97d Merge changes from topic "aapt2-attr" into qt-dev
am: ac919fcfcc

Change-Id: I97cffd87de2b8b9167af79fc07c83dfdf00dd10e
2019-04-30 06:06:31 -07:00
Ryan Mitchell
d2e25b9382 Merge "DO NOT MERGE: Do not allow overlaying of attributes with conflicting formats" into qt-dev
am: 515e9b3b63

Change-Id: Iebe16a02b6721e777af8afbd5bc395c47c510f0e
2019-04-29 11:59:54 -07:00
TreeHugger Robot
dd76b346d4 Merge "Fix unknown resource type error message" into qt-dev 2019-04-29 14:48:53 +00:00
Ryan Mitchell
ac919fcfcc Merge changes from topic "aapt2-attr" into qt-dev
* changes:
  Add formats for declare-styleable attributes
  No new attributes in declare-styleables when format is not provided
2019-04-27 01:54:11 +00:00
Ryan Mitchell
2e2c3b6220 Fix unknown resource type error message
Instead of printing the tag name, print the type name when the type was
unable to be recognized. The type name is initialized to the tag name
and changes when a type attribute is defined..

Bug: 37891551
Test: manual
Change-Id: I9b0e6a6f2d96a8c5af71fbca8e83c947a8e308bf
2019-04-26 01:16:52 -07:00
Ryan Mitchell
b435101ec8 DO NOT MERGE: Do not allow overlaying of attributes with conflicting formats
aapt(1) does not allow for attributes to be redefined with a different
format. Also, attributes declared with enums or flags are never allowed to be
redefined. This change will not allow attributes to be redefined with a
conflicting format in aapt2.

Bug: 129146717
Test: aapt2_tests
Change-Id: Idc43d6d689199ba2cdc672d009ede22eaa75a10c
2019-04-24 09:59:55 +00:00
Ryan Mitchell
acde95c3fc No new attributes in declare-styleables when format is not provided
AAPT does not allow for attributes declared in declare-styleables
that do not have a format to create new attribute resources. AAPT2
does and should not.

Bug: 131100106
Test: aapt2_tests
Change-Id: Id00884dc9ed939672df90f670a7915d4b6d232c1
2019-04-23 08:32:30 -07:00
Ryan Mitchell
2e6bb9db6a Merge "Add build number to aapt2 version" into qt-dev
am: 743266643a

Change-Id: I464776e52e7d5d010221beb42c046c497aafb02a
2019-04-18 12:39:15 -07:00
Ryan Mitchell
743266643a Merge "Add build number to aapt2 version" into qt-dev 2019-04-18 19:04:40 +00:00
Ryan Mitchell
8ea093e88d Merge "Add odm and oem policies" into qt-dev
am: 9c88c1e93e

Change-Id: I61a3f83f395f2befa4fc4b6e96a4cde962b29875
2019-04-17 18:59:01 -07:00
TreeHugger Robot
9c88c1e93e Merge "Add odm and oem policies" into qt-dev 2019-04-18 01:39:51 +00:00
Ryan Mitchell
3a60b9c4d2 master designated for R. Update MAX_PLATFORM_VERSION, etc.
Test: aapt2_tests
Bug: 128934651
Change-Id: I179f7b92dcf65e77f039e6cd42d91bf5b1461e35
Merged-In: I179f7b92dcf65e77f039e6cd42d91bf5b1461e35
2019-04-17 18:12:52 -07:00