Commit Graph

801 Commits

Author SHA1 Message Date
Mårten Kongstad
4b55bd77fb AAPT2: propagate SPEC_OVERLAYABLE to splits
A resource marked SPEC_OVERLAYABLE in the base package was not marked as
such in the corresponding split packages. Add missing copy statement.

Test: manual (aapt2 dump test content in libandroidfw)
Change-Id: I800e92111a9da7c6f5e83f8a546d260c8d93b308
(cherry picked from commit ee41b3a36dcd87f79f3c2a21383a97743530099d)
2018-11-07 08:23:06 -08:00
TreeHugger Robot
e0c2f7e17d Merge "RRO: Added partition policies for overlays" 2018-11-06 16:49:55 +00:00
Ryan Mitchell
e4e989ccba RRO: Added partition policies for overlays
<overlayable> tags can now have policy elements that indicate which
partition the overlay apk must reside on in order to be allowed to
overlay a resource. This change only adds parsing of <policy> and
encoding of policy in the proto ResourceTable. A later change will add
the encoding of policy and overlayable in the binary APK.

<overlayable>
  <policy type="system|vendor|product|product_services|public" >
    <item type="string" name="oof" />
  </policy>
</overlayable>

Bug: 110869880
Test: make aapt2_tests
Change-Id: I8d4ed7b0e01f981149c6e3190af1681073b79b03
2018-11-06 00:10:26 +00:00
Ryan Mitchell
67f94b4002 Merge "Fix incorrect proto apk loading" 2018-10-17 23:53:04 +00:00
Ryan Mitchell
ec74f2fbd5 Fix incorrect proto apk loading
If a proto apk is missing resources.pb, AAPT2 would fail to detrmine the
apk format because of an incorrect check. This fixes that check and
removes the checking fuction from the LoadedApk header.

Bug: 117820549
Test: removed resources.pb from proto apks and confirmed that loading in
apks still works

Change-Id: If3628a821e7b59c7dfcbefb502b6080be083cec1
2018-10-17 09:30:01 -07:00
Dan Willemsen
9ad6ab595d Merge "Stop using DIST_DIR directly, use dist-for-goals instead" am: a8f2601d28 am: 9b767e275e
am: fa5b204029

Change-Id: Ic052f5d1de317c2f271f5a2df83c733c79978679
2018-10-16 18:01:26 -07:00
Treehugger Robot
a8f2601d28 Merge "Stop using DIST_DIR directly, use dist-for-goals instead" 2018-10-17 00:18:07 +00:00
Ryan Mitchell
d4bf08501a Merge "Preserve compression of xml files in convert" 2018-10-12 16:42:34 +00:00
Ryan Mitchell
05aebf46b4 Preserve compression of xml files in convert
Respect the compression the original compression of xml files when using
aapt2 convert. Uncompressed files should remain uncompressed, and
compressed files should remain compressed.

Bug: 117289326
Test: manual
Change-Id: I81b431b4a4abd81f5694ea7dc3b3c6ec8c13ca32
2018-10-11 17:14:29 -07:00
Treehugger Robot
e75f2f504e Merge changes from topic "aapt2-manifest-elements"
* changes:
  Remove workarounds for b/79755007
  AAPT2: Add the rest of supported manifest elements
  AAPT2: Add supported manifest elements
2018-10-10 22:29:57 +00:00
Treehugger Robot
b14c887974 Merge "libandroidfw: move ConfigDescription from aapt2 to libandroidfw" 2018-10-09 21:43:38 +00:00
Treehugger Robot
62a5d4249f Merge changes from topic "idmap2-prerequisites"
* changes:
  AssetManager2: optionally keep non-matching configs
  AAPT2: optionally keep resources without default value
  libandroidfw: add resource ID iterator
2018-10-09 21:43:38 +00:00
Dan Willemsen
5cc1700171 Stop using DIST_DIR directly, use dist-for-goals instead
As a preparation in refactoring how we handle dist, I'm making
everything use dist-for-goals. In this case, instead of fully relying on
a phony rule, write the gtest xml into an intermediate folder, and use
dist-for-goals to copy that into the dist dir.

Bug: 117463001
Test: DIST_DIR=dist m aapt2_run_host_unit_tests dist
Test: DIST_DIR=dist m aapt2_run_host_unit_tests dist   (reruns test)
Change-Id: I166c2b3088703875c6028c3479aec7cf09f3f635
2018-10-09 14:28:35 -07:00
Aurimas Liutikas
13e6a1dc3e Add style parents dump command.
This command prints out the parent graph of a given style

Test: out/host/linux-x86/bin/aapt2 dump styleparents \
    --style Widget.MaterialComponents.TextInputLayout.FilledBox \
    out/target/product/generic_x86/system/priv-app/SystemUIGoogle/SystemUIGoogle.apk
Change-Id: Ib2ace7e90bee6f1c4b6a184edc591b1a3993db75
2018-10-09 13:55:31 -07:00
TreeHugger Robot
1e7b9347d7 Merge "Created resuable DumpApkCommand and added "badger"" 2018-10-09 19:15:47 +00:00
Ryan Mitchell
8cf68fcac1 Merge "Add rtmitchell to AAPT2 OWNERS" am: 0d3f4e61c9 am: f1aadaf8c5
am: ca7411c0e9

Change-Id: Ie50f8397291a83194c556e7647fe071788ebcdd9
2018-10-09 10:51:55 -07:00
Ryan Mitchell
214846df59 Created resuable DumpApkCommand and added "badger"
This change refactors the dump commands to inherit from a base
DumpApkCommand and adds a command that prints out an ASCII
image of a badger if the user wrote "badger" instead of
"badging". The command is hidden from the help menu.

Bug: 73535002
Test: manual
Change-Id: I9bdd8a7bbf6a4282c4933e5c478f6d1d8e32d99e
2018-10-09 10:51:25 -07:00
TreeHugger Robot
96af49eb01 Merge "AAPT2: optionally keep resources without default value" 2018-10-09 17:32:29 +00:00
Mårten Kongstad
f99eda450f AAPT2: optionally keep resources without default value
Teach "aapt2 link" about a new flag --no-resource-removal. When given,
aapt2 will not filter out resources that lack default values. This is
useful mostly when building overlay packages that define resources for
non-default configurations, such as only for values-sv.

Test: manual: build package with resource only in values-vs, verify apk with aapt2 dump
Change-Id: Idc513bcb3f43bbff7f073163562c3dfccdb9bc9b
Merged-In: Idc513bcb3f43bbff7f073163562c3dfccdb9bc9b
2018-10-09 14:02:14 +00:00
Mårten Kongstad
d8d290107a AAPT2: optionally keep resources without default value
Teach "aapt2 link" about a new flag --no-resource-removal. When given,
aapt2 will not filter out resources that lack default values. This is
useful mostly when building overlay packages that define resources for
non-default configurations, such as only for values-sv.

Test: manual: build package with resource only in values-vs, verify apk with aapt2 dump
Change-Id: Idc513bcb3f43bbff7f073163562c3dfccdb9bc9b
2018-10-09 07:01:17 -07:00
Mårten Kongstad
5c541f6e36 libandroidfw: move ConfigDescription from aapt2 to libandroidfw
This is to allow idmap2 to access ConfigDescription.

Test: libandroidfw_tests
Test: aapt2_tests
Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
Merged-In: I54210bbbd8dad5903cb7100807df977efa394ad5
2018-10-08 09:56:09 -07:00
TreeHugger Robot
6d659e8ceb Merge "libandroidfw: move ConfigDescription from aapt2 to libandroidfw" 2018-10-08 15:41:13 +00:00
Mårten Kongstad
24c9aa6541 libandroidfw: move ConfigDescription from aapt2 to libandroidfw
This is to allow idmap2 to access ConfigDescription.

Test: libandroidfw_tests
Test: aapt2_tests
Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
2018-10-08 06:50:22 -07:00
TreeHugger Robot
b61b0e5731 Merge "Implement issue #112113117: Ad library dependency declaration in manifest" 2018-10-05 00:45:06 +00:00
Dianne Hackborn
813d7503c8 Implement issue #112113117: Ad library dependency declaration in manifest
You can now do a new form of <uses-package> that allows you to
specify a type of package along with required cert digests (like
uses-static-library).

This defines the new attribute needed for this and XML tag, and
updates aapt2 to actually allow uses-library in the manifest and
output this data with "dump badging".

While doing this I realized that "dump badging" was not printing
the data for uses-static-library or uses-library, so do those too.

Bug: 112113117
Test: manual
Change-Id: I5d02010aad9cb44675504a317df9cced421be8a1
2018-10-04 15:27:15 -07:00
Ryan Mitchell
2250c93f14 Fix badging meta-data value
Integer meta data values were not printing correctly and instead were
printing as empty strings. Attempt to retrieve the integer value of the
attribute if the value is not a string.

Bug: 117260085
Test: manual
Change-Id: I1cef672e03d07728819ca584b484dc372984c823
2018-10-04 13:15:23 -07:00
Ryan Mitchell
6d0dbbbab3 Add rtmitchell to AAPT2 OWNERS
Per talks with Svet, it is time I became a co-owner of AAPT2 with
toddke. I look forward to continuing to support and improve AAPT2.

Change-Id: I3a0f1c8a708abc41045b95dc958dbeb96a5160ff
2018-10-04 11:54:29 -07:00
Ryan Mitchell
5c5f0cdd04 Merge "Fix failing Windows tests" 2018-10-03 20:56:06 +00:00
Ryan Mitchell
8b7e1a8803 Merge "Restore Proguard behavior and add minimal flag" 2018-10-03 20:54:14 +00:00
Ryan Mitchell
0ce89734d1 Fix failing Windows tests
Some tests were not written to run on Windows correctly. Compile also
has a bug that caused using the --zip flag to fail on Windows.
iswspace does count the non breaking space as Whiespace on Windows but
not on Unix based systems

Bug: 117156986
Change-Id: I999375162bdfdf86fb25992ee88e2962ab90b577
Test: aapt2_tests and wine aapt2_tests.exe
2018-10-03 11:35:37 -07:00
Ryan Mitchell
56e559862d Merge "Use empty data if file in zip has length 0" 2018-10-02 17:23:32 +00:00
Chih-hung Hsieh
3b761c6b3b Merge "Add noexcept to move constructors and assignment operators." am: 9166e89374 am: 15dcc77fee
am: 07a7250da3

Change-Id: I74a6b6e53ba4f22b79b855e146aa260b2eaddb27
2018-10-01 18:59:22 -07:00
Pirama Arumuga Nainar
c691c0528e Merge "Do not use StringPiece in ExtractJavaIdentifier" am: 20ecc6397b am: 206ccf1f61
am: 7472303ff4

Change-Id: Idd910ad9fb743093f8e43ddcdf5770722b4393e6
2018-10-01 18:00:49 -07:00
Chih-hung Hsieh
9166e89374 Merge "Add noexcept to move constructors and assignment operators." 2018-10-02 00:37:46 +00:00
Treehugger Robot
20ecc6397b Merge "Do not use StringPiece in ExtractJavaIdentifier" 2018-10-01 23:37:31 +00:00
Chih-Hung Hsieh
fc81626ba6 Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: Ic3993d88eb3066aef402d74c4d543c56a1dfd5c3
2018-10-01 20:23:02 +00:00
Ryan Mitchell
63c6be63a4 Merge "Change FileStream test buffer from char* void*" am: b839befd7b am: 47be78e523
am: 5d63c53071

Change-Id: I79fed846a0d7bd20be13a5d3845bfe1a171f5b62
2018-09-26 15:46:37 -07:00
Ryan Mitchell
8f37734cf4 Change FileStream test buffer from char* void*
It seems like GoogleTest prints string parameters before checking them.
This can be a problem in FileStream tests since these buffers are not
null terminated.  ASan reports heap-buffer-overflow.

Test: m SANITIZE_HOST=address
out/soong/.intermediates/frameworks/base/tools/aapt2/aapt2_tests/linux_glibc_x86_64_asan/aapt2_tests \
      LD_LIBRARY_PATH=out/soong/.intermediates/external/libcxx/libc++/linux_glibc_x86_64_shared
out/soong/.intermediates/frameworks/base/tools/aapt2/aapt2_tests/linux_glibc_x86_64_asan/aapt2_tests

Change-Id: I9a1956d815729de23c7038fb0d498240eb917070
2018-09-26 14:54:45 -07:00
Ryan Mitchell
7e5236dc56 Restore Proguard behavior and add minimal flag
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-25 15:20:59 -07:00
Pirama Arumuga Nainar
9ba5cb4796 Do not use StringPiece in ExtractJavaIdentifier
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-09-25 13:21:35 -07:00
Ryan Mitchell
f6fe9b6dab Use empty data if file in zip has length 0
Mmap fails when the length of a file in a zip is 0, so use an
aapt::io::EmptyData when the file length is 0.

Bug: 113094267
Test: manual
Change-Id: I2c1071293bf9b0fe33e8c279c8d78ff906fba5d6
2018-09-24 13:41:35 -07:00
Aurimas Liutikas
23ad8d73ac Merge "Add basic details on aapt2 development." 2018-09-20 21:01:15 +00:00
Ryan Mitchell
c95add6ddc Merge "AAPT2: Increase maximum proto size" 2018-09-19 18:33:46 +00:00
Ryan Mitchell
500d3f1aee Merge "AAPT2: Added badging and permission" 2018-09-19 00:10:11 +00:00
Ryan Mitchell
fc225b21c1 AAPT2: Added badging and permission
Added the remaining dump commands to aapt2.
aapt2 dump badging [apk]
aapt2 dump permissions [apk]

Bug: 73351292
Test: Diffing aapt and aapt2 output across apps from the Android tree
Change-Id: Idee820db410ad8d777d0d250c2657e7b83112a00
2018-09-18 13:17:01 -07:00
Aurimas Liutikas
c94b7551c5 Add basic details on aapt2 development.
Writing down notes for getting started on aapt2.

Test: None
Change-Id: I15c2518bf0ba5c455b83277d24ed683bfb9e446c
2018-09-18 10:36:13 -07:00
TreeHugger Robot
837cefb8c4 Merge "Don't allow splitting on an empty configuration" 2018-09-18 00:17:57 +00:00
Todd Kennedy
9fbdf89dda Don't allow splitting on an empty configuration
When aapt breaks out splits, it may remove the SDK constraint [if
it's lower than the min sdk]. If that is the only constraint, we
would create a resource split with no constraints. Don't allow
that situation. There must always be _some_ constraint.

Bug: 113115970
Test: atest CtsAppSecurityHostTestCases:SplitTests
Test: aapt2_tests
Change-Id: I424c875677c3be2a3ff5ddd39100b998bd650a4b
2018-09-17 14:16:21 -07:00
Ryan Mitchell
f4b2999910 Merge "AAPT2: Convert from Modified UTF-8 ResStringPool" 2018-09-14 22:36:28 +00:00
Ryan Mitchell
4353d61b8b AAPT2: Convert from Modified UTF-8 ResStringPool
Since ResStringPools are encoded using Modified UTF-8, retrieving
strings from the string pool convert the strings to UTF-8 before
returning.

Bug: 114734350
Test: m aapt2_tests
Change-Id: Ib459018186f4c5b40f3f3786425a335ecfb9ed02
2018-09-14 09:23:44 -07:00