Commit Graph

19 Commits

Author SHA1 Message Date
Udam Saini
b228df32d9 Allows features to link to other feature splits without namespacing.
Add uses-split dependencies to AppInfo. At link time, this is used
and allows features to reference other features, before
resource namespacing is implemented in Android Studio.

bug:135681292
Test: Link_test, ReferenceLinker_test, and integration tests.
Change-Id: Ifdf0067e7370552b6b9d4d6d4713d4484b6ea154
2019-06-26 13:30:35 -07:00
Ryan Mitchell
90b7a08aaf Revert "Fix loaded apk string pool order"
This reverts commit 4e9a922ede.

Reason for revert: <b/122518436>

Change-Id: I3650b2c6c9bdfa69a3034f9ca49e95a9698c3cdd
2019-02-15 14:37:45 -08:00
Winson
f54c9a1d72 De-duplicate entries written with AAPT2 convert
There was no check for whether we had already written a specific file path to the APK when using the convert command.

If the resources table points 2 resource IDs at the same file on disk, the convert command would write the file twice, creating two entries.

This holds a set of file paths already written and ignores duplicates.

Bug: 123271593

Test: Ran convert on linked bug's weird.apk
Test: aapt2_tests case for duplicate entries

Change-Id: Ia22515bf8e8297624aaadbf6a9e47159026c63e5
2019-01-24 16:10:16 -08:00
Ryan Mitchell
479fa39d65 Remove raw values from proto APK
Raw attribute values are not included in xml files when building binary
APKs but they are when building proto APKs. Remove raw attribute values
and create a new convert flag that (--keep-raw-values) that allows raw
value to be kept.

Also added flag to link to keep raw attribute values.

Bug: 115915884
Bug: 116700688
Test: aapt2_tests
Change-Id: Id50136b775b3f43d159ca06181282f6a7b8eaf40
2019-01-03 16:19:04 -08:00
Ryan Mitchell
4e9a922ede Fix loaded apk string pool order
Loading in an APk changed the ordering of strings in the string pool.
When loading an apk, assign the strings to the same index as they
are in the ResStringPool.

Bug: 118831219
Test: "aapt2 dump strings left.apk" prints in the correct order,
"aapt2 convert left.apk --output-format binary -o left_binary.apk" has
entries in the correct order, and aapt2_tests

Change-Id: I00014c02195f39c1152a110e90083d9b14e9216e
2018-11-15 11:37:01 -08: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
Ryan Mitchell
e0eba7a3bb AAPT2: Increase maximum proto size
Deserializing a proto form a string throws an error when 64MB have been
read from the stream. This change removes the maximum size but shows a
warning when a proto is larger than 64MB.

Bug: 114020398
Test: manual test with resources.pb greater than 64MB
Change-Id: Iee397b6709d79a9338133a6136fe6e8f70a4964c
2018-09-12 08:54:07 -07:00
Ryan Mitchell
f3649d6690 AAPT2: Compile --zip flag
Added a --zip flag similar to --dir that allows resources to be passed
into "aapt2 compile" using a zip file.

Also refactored Compile.cpp to be easier to mock and test in the future.

Bug: 74574557
Test: aapt2_tests
Change-Id: Idb90cb97e23a219525bdead38220cbf7bc6f3cab
2018-08-14 15:42:01 -07:00
Chris Warrington
58e2fbf169 Revert "AAPT2: Automatic Static Library Namespacing."
This reverts commit 481f027ddc.

Reason for revert: Not needed any more

Bug: 111543815
Test: existing unit and integration tests
Change-Id: I87b039192682636d81c2d33512495cb005c9504d
2018-07-23 17:23:25 +01:00
Ryan Mitchell
833a1a6c4a AAPT2: Refactor flags into commands
Refactors the flag based command invocation into classes that make using
subcommands easier.

Test: manual tests of printing
Change-Id: Ic8df6af0be30db552e32150afebecbfeec7e1075
2018-07-13 14:26:06 -07:00
Ryan Mitchell
a15c2a8957 Check the size of the strings in the StringPool before flattening.
Test: Tested for normal functionality when string does not exceed
maximum length and tests for detection of string that is too lonhg for
UTF8i
Bug: b/74176037

Change-Id: Ic71d3671a069e7012e8ca107e79e071499eebbf6
2018-03-29 15:42:13 -07:00
Chris Warrington
481f027ddc AAPT2: Automatic Static Library Namespacing.
Introduces a link flag --auto-namespace-static-lib for use when linking
static libraries.

When linking a static library with compiled sources that have references
to resources in provided libraries without an explicit package name,
the flag enables automatic inference of the package.

If a resource is present in the package that is being compiled, that is
used, otherwise the reference is rewritten to the highest precedence
resource with matching name and type.

Test: m out/host/linux-x86/nativetest64/aapt2_tests/aapt2_tests && \
      $ANDROID_HOST_OUT/nativetest64/aapt2_tests/aapt2_tests
Test: m frameworks/base/tools/aapt2/integration-tests
Change-Id: I6c6017e054654d1f60782d0a428a7a2a47f8952b
2018-03-14 15:05:39 +00:00
Adam Lesinski
bbf429795d AAPT2: Fix issue with deserializing binary XML
We assumed that a raw text value set for an attribute meant there
were no compiled values set either.

This would only really happen for attributes that did not belong to any
namespace (no prefix:), since we always kept their raw string values
in case some code relied on it.

Bug: 72700446
Test: make aapt2_tests
Change-Id: Icba40a1d4b181bfe7cad73131c4dbe5ba7f8b085
2018-02-14 16:11:23 -08:00
David Chaloupka
b66db4ec4c Adjust file reference type in 'aapt2 convert'
When converting between binary and proto APKs in either direction, the
'aapt2 convert' command did not adjust FileReference type for entries
inside the resource table. This fix makes in-place changes of the resource
table passed to ConvertApk, which is safe since the resource table is
thrown away after the conversion.

Bug: 71854843
Test: Manual
Change-Id: Ide6e141269392db15b399db3566f18175f5133d5
2018-01-17 11:07:44 +00:00
Tom Dobek
725fb12c0d Aapt2 convert: skip processing resources when resource table is absent.
Test: manual

Change-Id: Iafe20f98857a29d625e7a57a9201db6279d43e45
2017-12-11 10:30:12 +00:00
Pierre Lecesne
d8b4beaae9 AAPT2 - Add ProtoApkSerializer implementation to convert from Binary to Proto.
Also new flag to choose the conversion direction:
  --output_format [binary|proto].

Test: Manual

Change-Id: I61d381aa49869b0fd6bd9f017dda0cac5ca998bb
2017-11-14 09:05:27 +00:00
Pierre Lecesne
d55bef78a5 AAPT2 - Convert command to copy all the files.
Test: Manual

Change-Id: I8705966cb34ff41eb362126a35956720147fae91
2017-11-13 21:07:34 +00:00
Pierre Lecesne
7e8549dd57 Refactor Convert command to use a ISerializer interface.
This will allow for other implementations.

Test: Manual

Change-Id: Ibf9cf8f5ac2b5b8e51a5fb684b434a0f59a3cbee
2017-11-10 05:04:48 +00:00
Adam Lesinski
8780eb6e49 AAPT2: Add convert command
This command allows a developer to convert their proto APK
(generated from the link phase using --proto-format) into
a binary APK suitable for use on device.

  aapt2 convert -o output.apk input.apk

Test: manual + make aapt2_tests
Change-Id: I10a7c33bb4b57006d01fe00a8bf92f78e04e7e50
2017-11-01 10:58:28 -07:00