25 Commits

Author SHA1 Message Date
Mårten Kongstad
1d3b64855b aapt2: add 'dump overlayable' command
Add a command to print a resource table's <overlayable> resources. Given
the following input

  <overlayable name="TestResources">
    <policy type="system">
      <item type="string" name="a" />
    </policy>
    <policy type="sytem|vendor">
      <item type="string" name="b" />
      <item type="string" name="c" />
    </policy>
  </overlayable>

aapt2 dump overlayable will produce

  name="TestResources" actor=""
    policies="system"
      string/a
    policies="system|vendor"
      string/b
      string/c

Bug: 120609160
Test: manual (aapt2 dump overlayable $(gettop)/frameworks/base/cmds/idmap2/tests/data/target/target.apk)
Change-Id: I21041e6169c62d01f1a469624911ce7cad3e18a8
2019-09-18 07:35:44 -07:00
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
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
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
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
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
Ryan Mitchell
dea2fe3f9f AAPT2: Fix dump apk format
Dumping resources printed the incorrect apk type.

Bug: 113062289
Test: manual
Change-Id: I8b250a470afa26697f80b1dfa8ba677ed654a958
2018-08-30 13:48:54 -07:00
Todd Kennedy
908b7fcfa1 dump package name
Test: aapt2 dump packagename foo.apk
Bug: 113105112
Change-Id: Ibea429adc3a2a890be10548824583addc59ad42d
2018-08-24 10:55:44 -07:00
Ryan Mitchell
5d2755129d AAPT2: Reformatted dump command invocations
Use with:
  aapt2 dump apc [apc]
  aapt2 dump configurations [apk]
  aapt2 dump strings [apk]
  aapt2 dump resources [apk]
  aapt2 dump xmlstrings [apk] --file [file]
  aapt2 dump xmltree [apk] --file [file]

Will add permissions and badging in a later commit.

Bug: 73351292
Test: Manual tests of the commands
Change-Id: I97eec01222af14053a98bd70255f1bfecd16b1c4
2018-08-14 15:56:29 -07:00
Ryan Mitchell
83a37adfbb AAPT2: Loosen loading apk format requirements
The Android runtime and AAPT are more lenient of apk format, allowing
for duplicate enty, types, and configs. This change loosens the
ResourceTable's checks on resource uniqueness when apks are loaded; not
when ResourceTables are being created by aapt2.

Bug: 36051266
Test: Tested using apks in bug with allow_duplicates on and off
Change-Id: I9296417bf2dc53e1e891479a53679a0388210d50
2018-08-09 10:57:29 -07:00
Chris Warrington
58e2fbf169 Revert "AAPT2: Automatic Static Library Namespacing."
This reverts commit 481f027ddc3e0ff0e1838a9375c1286e8ad70d70.

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
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
da9eba300b Dump XML files in aapt2 dump
Test: manual
Change-Id: Id7f656c1385f6d1fec8eaa993c8e2b36bb1ae5b0
2018-02-14 10:49:32 -08:00
Adam Lesinski
71be70507d AAPT2: Propagate SPEC_OVERLAYABLE flag to final APK
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-18 14:16:02 -08:00
Adam Lesinski
93190b79d1 AAPT2: Better debugging output
Test: make aapt2_tests
Change-Id: I7778b773201381538dc1f2e376abee4eb33e44c0
2017-11-07 11:21:10 -08: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
Adam Lesinski
e59f0d80ec AAPT2: Enable building proto artifacts
- This will allow the bundle tool to ingest the outputs of the aapt2 link
  phase.

Bug: 64143208
Test: manual
Change-Id: I1a4b3ce5c2ffbbdc4bc642c3371a9ef2e7e9ad71
2017-10-19 13:22:48 -07:00
Adam Lesinski
0045116606 AAPT2: Define and Implement AAPT Container Format
AAPT Container Format (.apc) is a simple container that
enumerates the various intermediate files that AAPT2 generates
during the compile phase.

The format is defined in formats.md.

For now, continue using the .flat extension for the container file,
and keep making use of the .flata zip for storing multiple files.
This will allow easier integration with existing build systems and allow
the evolution of the APC format to better handle arbitrarily large
files.

Test: make aapt2_tests
Change-Id: Id7216e5b76316bdd683f0fa4eaf2d2da273ba815
2017-10-19 12:50:53 -07:00
Adam Lesinski
4670805ea4 AAPT2: Move format related files under same directory
Test: make aapt2_tests
Change-Id: Id72cdfc12ba3add294048e60c55f2461344464bf
2017-10-04 14:26:55 -07:00
Adam Lesinski
8cdca1bd72 AAPT2: Cleanup proto classes/methods and add XML serialization
Test: make aapt2_tests
Change-Id: I01ac2285af6771a683533c033a59ae6cfe875d93
2017-09-28 20:43:22 -07:00
Adam Lesinski
4ffea04064 AAPT2: Define intermediate compiled XML proto
This proto format is meant to encapsulate more information
that is specific to Android and allows for easier validation
and manipulation across tools.

Test: make aapt2_tests
Change-Id: I13bc34a460671fc0a36246be0d287a3d37d244d6
2017-08-23 11:54:38 -07:00
Pierre Lecesne
aadf27e1b5 Return exit code 1 when an error occurs during 'aapt2 dump'.
Bug: 37975355
Test: Manual
Change-Id: Ia29483a4aa10c98e75fe38ac0082759c8574a649
2017-05-09 09:16:24 +01:00
Adam Lesinski
b522f04bc2 AAPT2: Allow truncating of package names
ResTable_package header only allows 127 UTF-16 characters, so AAPT
would truncate the real package name to fit. AAPT2 would error-out
on any package name longer than 127 UTF-16 characters. This strictness
is not required except when building shared libraries, which use the
full package name as a way of identifying the runtime assigned
package ID to package name mapping.

Bug: 36940145
Test: make aapt2_tests
Change-Id: I7d2b7e50c7ab30c6a6c4f15d310e711f68e35091
2017-04-21 17:02:09 -07:00
Adam Lesinski
d0f492db03 AAPT2: Share split functionality between link and optimize
Generating splits should be possible to do from the optimize command.
This means that a lot of infrastructure around split APKs can be
shared by both the optimize and link phase.

Bug: 35925830
Change-Id: Ia88b9e4bff300a56353b2f7a4a2547c8eb43a299
Test: manual
2017-04-10 11:59:18 -07:00