Commit Graph

5744 Commits

Author SHA1 Message Date
Yi Jin
0473f88b9f Create protoc-gen-cppstream tool to auto-generate cpp proto field Ids.
It is very similiar to protoc-gen-javastream, which generates field Ids used
by ProtoOutputStream.cpp to dump protobuf data.

Bug: 65641021
Test: compile the streaming_proto:
      $ mmm -j frameworks/base/tools/streaming_proto/
      and run:
      $ PATH=$PATH:out/host/linux-x86/bin/protoc-gen-cppstream aprotoc
      --cppstream_out=tmp/
      frameworks/base/core/proto/android/service/procstats.proto
      frameworks/base/core/proto/android/util/common.proto

Change-Id: I68becc80b5166455455c5df28cd698601b4a1c1d
2017-10-11 11:04:39 -07:00
Kweku Adams
a437d577ef Merge "incidentd: Fix printing of repeated scalar fields." 2017-10-06 00:38:53 +00:00
Kweku Adams
ee6495982f incidentd: Fix printing of repeated scalar fields.
Also add check for when enum value can't be found and fixing output
formatting for some int types.

BUG: 65633831
Test: check incident_report output of repeated enums.
Change-Id: I329eef9b3bb0026259ea465ab67e71952df1a4e4
2017-10-05 16:48:00 -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
897f6ddd31 Merge "AAPT2: Preserve line numbers when deserializing from binary XML" into oc-mr1-dev am: 9b581c7bc1
am: 8284349fc9

Change-Id: Iadd7362ae8456279ebec3a4577ba5be0c8bf19d7
2017-10-03 22:07:18 +00:00
Adam Lesinski
8284349fc9 Merge "AAPT2: Preserve line numbers when deserializing from binary XML" into oc-mr1-dev
am: 9b581c7bc1

Change-Id: I55d8c73df0ce751472e58a9ae505c94edc90c68e
2017-10-03 21:51:09 +00:00
Shane Farmer
e17993597e AAPT2: Set compatible-screens in manifest for multi-APK
If an artifact in a multi-apk set is for a scpecific set of screen
densities then update the manifest to set the compatible-screens element
to match.

Test: ran unit tests
Test: manually ran optimize command

Change-Id: I07e90850ab2f4647a8623acbeaccbebbe81c3a6a
2017-10-03 16:14:07 +00:00
Shane Farmer
810fd18435 AAPT2: Update versionCode in multi-APKs.
Set versionCode in the AndroidManifest.xml so each artifact has a unique
version code. This will allow the play store to serve up the correct
APKs.

The versionCode is determined by taking the versionCode from the input
APK and adding the configured version to that. If an artifact does not
have a version, the next version is used based on the order in the
configuration file. If the firs artifact does not have a version, it
starts at 1, so that all artifacts have a different version code to the
base APK.

Bug: 64972562

Test: unit tests
Test: manually optimized an APK into multiple APKs and confirmed versions:
  aapt dump badging ${apk} | grep versionCode

Change-Id: Ie12b3e42bbd8ce9a2819712c2c56b24c0a901e6b
2017-10-03 16:13:04 +00:00
Shane Farmer
3edd472643 AAPT2: Set the minSdkVersion when generating multiple APKs.
When generating multiple APKs from a configuration file, check to see if
we have filtered resource by minSdkVersion and update the manifest to
reflect this. We only want to inflate and modify the manifest file if
there is an update to be applied.

Bug: 37944703
Bug: 67005138

Test: Ran unit tests
Test: Manually split an APK and verified the manifest by dumping with
      AAPT (both xmltree and badging).

Change-Id: I64a0e4889d7d9e57373369b044a091287b06cc35
2017-10-03 16:02:38 +00:00
Yunlian Jiang
08e76846b6 Merge "Replace strcpy with memcpy." am: bb115bac41 am: 16951dcb54 am: 23f6dca5fd
am: 61879522fe

Change-Id: Iaf1e0edbb3902714621492d6dd53458c1ad50b01
2017-10-03 04:44:37 +00:00
Yunlian Jiang
61879522fe Merge "Replace strcpy with memcpy." am: bb115bac41 am: 16951dcb54
am: 23f6dca5fd

Change-Id: I446973c3b96f253e3c3fc2dfda7647cd3e625916
2017-10-03 04:38:07 +00:00
Yunlian Jiang
16951dcb54 Merge "Replace strcpy with memcpy."
am: bb115bac41

Change-Id: I28c118a609d999fe1ef6bd126557e63076f452c6
2017-10-03 04:20:17 +00:00
Treehugger Robot
bb115bac41 Merge "Replace strcpy with memcpy." 2017-10-03 04:09:48 +00:00
Adam Lesinski
0da683bd8d AAPT2: Preserve line numbers when deserializing from binary XML
Bug: 65827146
Test: make aapt2_tests
Change-Id: Idbfea640eb8727fe209ebc6eb072296845d9f282
2017-10-02 17:00:07 -07:00
TreeHugger Robot
466df70cc5 Merge "AAPT2: Fix R.java styleable + indices ordering" 2017-10-02 09:43:01 +00:00
Adam Lesinski
761d4341fc AAPT2: Fix R.java styleable + indices ordering
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
2017-09-29 11:20:45 -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
d3ffa844f5 AAPT2: Cleanup Visitors for XML and Values
Test: make aapt2_tests
Change-Id: Ib61f64c155a380115610edeaf2d65e60258a2426
2017-09-28 14:08:50 -07:00
Yunlian Jiang
d32ae10f4c Replace strcpy with memcpy.
This fixes the warning
Call to function 'strcpy' is insecure as it does not provide bounding of
the memory buffer. As a side effect, it sliences the warning
frameworks/base/tools/aapt/Images.cpp:1270:50: warning: Potential leak
of memory pointed to by field 'data' [clang-analyzer-unix.Malloc]
frameworks/base/tools/aapt2/compile/Png.cpp:562:42: warning: Potential
leak of memory pointed to by field 'data' [clang-analyzer-unix.Malloc].

Bug: None
Test: The warning is gone.

Change-Id: I25f68ff85bea7069c21549c7deb7920d1877069e
2017-09-26 16:02:11 -07:00
Adam Lesinski
b58c3ef023 AAPT2: Convert binary ResTable_config to proto
Test: make aapt2_tests
Change-Id: I8641f13ce41cd58ac8bc3da31c4e15a7b3f06092
2017-09-26 14:48:35 -07:00
Adam Lesinski
5bd4423710 AAPT2: Move to proto3
We're going to be using the Any proto field in ConfigDescription,
so migrate to proto3.

Test: make aapt2_tests
Change-Id: I43b91f4dfc448251f4352e48586b3b15502c033d
2017-09-26 12:07:51 -07:00
Adam Lesinski
e33de76a16 Merge changes Id8bdb14e,I573a6735,Ia804777f,Ia68122cb,Ia1997800, ... into oc-mr1-dev
am: e02983681a

Change-Id: I42369e6fb7bd121e45b5a002cd5f00e05221ead3
2017-09-15 16:57:21 +00:00
Adam Lesinski
689ce3f658 AAPT2: Bump to version 2.19
Test: manual
Bug: 65645766
Change-Id: Id8bdb14e498bd79ff642f9ad56ef05ec7a5825af
Merged-In: Id8bdb14e498bd79ff642f9ad56ef05ec7a5825af
2017-09-15 08:49:24 +00:00
TreeHugger Robot
a6f1cf4764 Merge "AAPT2: Bump to version 2.19" 2017-09-15 02:31:35 +00:00
Adam Lesinski
3420eed699 AAPT2: Bump to version 2.19
Test: manual
Bug: 65645766
Change-Id: Id8bdb14e498bd79ff642f9ad56ef05ec7a5825af
2017-09-14 17:00:56 -07:00
Adam Lesinski
a91d5c39ed AAPT2: Fix issue with resource deduping
Resource deduping relies on the definitions of
ConfigDescription.ConflictsWith, ConfigDescription.IsCompatibleWith,
and ConfigDescription.Dominates.

ConflictsWith is supposed to ignore range-based qualifiers, like
version, density, smallest width, screen size, etc.

This was not the case for screen size, and was assumed that the
choice of screen size is mutually exclusive.

This CL fixes the assumption and includes screen size (small, normal, large, xlarge)
as a qualifier that does not conflict.

Bug: 64397629
Bug: 65645766
Test: make aapt2_tests
Change-Id: I573a6735fedd7721a10ba32902bc5d27ef99b88e
Merged-In: I573a6735fedd7721a10ba32902bc5d27ef99b88e
2017-09-14 11:31:48 -07:00
Adam Lesinski
40e869e2a5 AAPT: Dump badging should pickup strings from the right package
A bug in the dump badging command caused strings to be looked up in the
first loaded package only.

Bug: 64948230
Bug: 65645766
Test: none
Change-Id: Ia804777fe3f963004a5c053129ef6e0c94b7f6a3
Merged-In: Ia804777fe3f963004a5c053129ef6e0c94b7f6a3
2017-09-14 11:31:40 -07:00
Adam Lesinski
f1a7e04851 AAPT2: Change the daemon mode to be line based
Accept a set of arguments separated by newlines.
This avoids path separator conflicts with the argument
format for passing splits.

Test: manual
Bug: 65645766
Change-Id: Ia68122cb77b7dde2292a0fd953e79f02996ac01c
Merged-In: Ia68122cb77b7dde2292a0fd953e79f02996ac01c
2017-09-14 11:31:30 -07:00
Izabela Orlowska
96ed7c3b17 AAPT2: better error handling for daemon mode
Test: manual
Bug: 65645766
Change-Id: Ia1997800ad94f386dbbb4195011395ecee1ba91f
Merged-In: Ia1997800ad94f386dbbb4195011395ecee1ba91f
2017-09-14 11:31:22 -07:00
Adam Lesinski
6e241e7e54 AAPT2: Fix regression in Manifest.java permissions
Permissions defined with the same leaf name emit the same
string symbol, which causes collisions. AAPT would override
the symbol with the last one seen.

Do the same thing as AAPT, but emit a warning.

Bug: 64472942
Bug: 65645766
Test: make aapt2_tests
Change-Id: I17b9dc7e8d8bd80db98869394c93695cb453bebd
Merged-In: I17b9dc7e8d8bd80db98869394c93695cb453bebd
2017-09-14 11:31:13 -07:00
Adam Lesinski
b791721cd1 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
Bug: 65645766
Change-Id: I13bc34a460671fc0a36246be0d287a3d37d244d6
Merged-In: I13bc34a460671fc0a36246be0d287a3d37d244d6
2017-09-14 11:31:04 -07:00
Adam Lesinski
44ec315e06 AAPT2: Add a daemon mode
Gradle and other build tools that need to frequently interact with aapt2
can use the daemon mode to issue regular CLI commands without paying
the process start cost for each invocation.

Test: manual
Bug: 65645766
Change-Id: I543858ed46496278bad643f0dae688c924ec6c3f
Merged-In: I543858ed46496278bad643f0dae688c924ec6c3f
2017-09-14 11:30:56 -07:00
Adam Lesinski
68b5e8a439 AAPT2: Fix mkdirs implementation
Once switched to using std::string, the mkdirs implementation was
trying to create an empty string when an absolute file path on
linux or macOS was used.

Bug: 62336414
Bug: 65645766
Test: manual
Change-Id: I52f3050b410a923ca48f353b0983667c16d00ee8
Merged-In: I52f3050b410a923ca48f353b0983667c16d00ee8
2017-09-14 11:30:48 -07:00
Adam Lesinski
5c33fb5408 AAPT2: Change XmlDom to exclude Namespace as a node
In preparation for exporting an XML proto format for UAM to consume,
this change brings the XML DOM API more in line with other APIs that
do not make the Namespace a separate node.

Treating Namespace declarations as just properties of an Element
node makes the implementation of algorithms much simpler, as
the constraints that Namespace nodes have only one child
are now built in and traversing to find Element nodes
is much simpler.

Also made a bunch of quality of life improvements, like formatting and
comment style.

Test: make aapt2_tests
Bug: 65645766
Change-Id: Ib97ff1c4252b7907e2cc1f13a448dc4ca3b809a4
Merged-In: Ib97ff1c4252b7907e2cc1f13a448dc4ca3b809a4
2017-09-14 11:30:38 -07:00
Adam Lesinski
5b54ca2d72 AAPT2: Fix windows unicode path issues
Mingw64 was being difficult, so instead of defining a wmain entrypoint,
the command line parameters are parsed manually using built-in Windows
methods that support Unicode. The results are converted to UTF8 and
handled just like the rest of the linux/mac version of the code.

This also removes dependencies on std::istream in favour of a
FileInputStream which calls the appropriate unicode version of
open to read a file.

No speed regressions found on Linux or MacOS.

Bug: 62336414
Bug: 63830502
Bug: 65645766
Test: manual
Change-Id: I597da51e33729ed1b98bf246e7e773337fd3fee8
Merged-In: I597da51e33729ed1b98bf246e7e773337fd3fee8
2017-09-14 11:30:29 -07:00
Adam Lesinski
cb1e6f95ae AAPT2: Fix typo in Config parsing
The 'any' syntax of a configuration is rarely used so this has not been
an issue in the field.

Test: none
Bug: 65645766
Change-Id: Icb9cb2d5ad061e3ea1c43dc1cd7ca2f222965cdc
Merged-In: Icb9cb2d5ad061e3ea1c43dc1cd7ca2f222965cdc
2017-09-14 11:30:18 -07:00
Adam Lesinski
e116ebe0bc AAPT2: Change proto format to reduce usage of StringPool
The StringPool class is a binary blob and makes it difficult to
modify the proto files from external tools (like bundle-tool).

Size increase of full build is negligible.

Test: make aapt2_tests
Bug: 65645766
Change-Id: I984755170c315730ab751b51133f8fb2f614f6af
Merged-In: I984755170c315730ab751b51133f8fb2f614f6af
2017-09-14 11:29:47 -07:00
Adam Lesinski
ee0e486d36 AAPT2: Add navigation type
Test: build succeeds
Bug: 65645766
Change-Id: I7d49366c7cc4a93c29bad4cb9f13eec23ad05bd2
Merged-In: I7d49366c7cc4a93c29bad4cb9f13eec23ad05bd2
2017-09-14 11:29:34 -07:00
Adam Lesinski
18fc9f65d0 AAPT2: Document Format.proto
Test: none
Bug: 65645766
Change-Id: I6b05bcdece5a310201d3ab0790a4ea1d23698e96
Merged-In: I6b05bcdece5a310201d3ab0790a4ea1d23698e96
2017-09-14 11:29:24 -07:00
Yi Jin
7e0b4e5880 Fixes regarding to comments in ag/2839267
1. use struct {} to instantiate privacy fields for efficiency reason
2. use vector<uint8_t>* instead of vector<uint8_t>& to indicate the
caller knows the value gets changed.
3. binary search privay policy for sections

Bug: 65595927
Test: unit test covers
Change-Id: Ic58c2f607465d1a7f10352b9a38c3d8b1a5cf352
2017-09-13 14:32:42 -07:00
Yi Jin
a425dc36e8 Merge "Implement PII Stripper, part 2" 2017-09-12 21:35:19 +00:00
Adam Lesinski
fa6058118e AAPT2: Fix processing of quotes in XML
When processing attributes in XML, quotes can't be used to mark a
section as whitespace preserving, so the assumption should be that the
entire string is whitespace preserving, which makes quote characters
literals.

Bug: 62840718
Bug: 62840406
Test: make aapt2_tests
Change-Id: I4afff02148b5b8e78833abf1f323c2f5325d6155
2017-09-11 13:05:38 -07:00
Shane Farmer
4b8ca8be4d AAPT2: Handle inflating compiled attributes.
* Added the resource ID pulled from the XML parser into the compiled
attribattribue. This allows binary attributes such as the version code
and min SDK values to be available whern flattening the XmlResource back
into an APK file.

* Only add a compiled value if the attribute value was not a string.
This allows string values like the package name and version name to be
flattened back into an APK file.

Before making this change, aapt would segfault when dumping the manifest
and dumping badging would be missing values. After making this change,
the manifest and badging are dumping correctly.

Test: ran unit tests
Test: manually ran optimize against an APK
Change-Id: I885bb06557b032b9f702e8065d637d359c2b519b
2017-09-11 19:45:33 +00:00
Dan Willemsen
116abe23c4 Merge changes I93cf24d4,I32e438ef am: 30798ad13a am: c28d591b36 am: 59225490b8
am: 2e9ec5f0de

Change-Id: Ie590c34bce9d0218bb9b48294756dae04e9210b7
2017-09-10 02:15:34 +00:00
Dan Willemsen
2e9ec5f0de Merge changes I93cf24d4,I32e438ef am: 30798ad13a am: c28d591b36
am: 59225490b8

Change-Id: I6cf57e951900b3df816070feee0d3bf92a6a5a7d
2017-09-10 02:05:05 +00:00
Dan Willemsen
c28d591b36 Merge changes I93cf24d4,I32e438ef
am: 30798ad13a

Change-Id: I0b178c8523d0c5829d731f6ed05cfa3fe89ad9b4
2017-09-10 01:44:06 +00:00
Treehugger Robot
30798ad13a Merge changes I93cf24d4,I32e438ef
* changes:
  Convert host tools to Android.bp
  Rename aapt_defaults to aapt2_defaults
2017-09-10 01:29:21 +00:00
Dan Willemsen
24041fe213 Merge "Convert incident_report and incident-section-gen to Android.bp"
am: d928842ab6

Change-Id: I0e0ff3d75ce5f9dc302052c1da057db8d5d35cd7
2017-09-09 22:11:38 +00:00
Dan Willemsen
8487558120 Merge changes Ia3bcece1,Icd26dc1e am: ec462238f6 am: c201a6bb7d am: 9539d236e7
am: eb211c23d5

Change-Id: I0b4d324af3a1d7dad4648a9d0ffe0d8c44bee6a9
2017-09-09 20:03:39 +00:00
Dan Willemsen
eb211c23d5 Merge changes Ia3bcece1,Icd26dc1e am: ec462238f6 am: c201a6bb7d
am: 9539d236e7

Change-Id: I2a5c73a54004c1aa378d25776de0d2080544137d
2017-09-09 19:54:02 +00:00