Commit Graph

755 Commits

Author SHA1 Message Date
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
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
Ryan Mitchell
9e7af75776 Merge "AAPT2: Add the rest of supported manifest elements" 2018-09-13 23:50:24 +00:00
Ryan Mitchell
917caf75be Merge "AAPT2: Fail on invalid id names in compiled xml" 2018-09-13 21:28:40 +00:00
Ryan Mitchell
db0cad4c35 AAPT2: Fix windows multiple directory creation
When attempting to create directories on different drives, AAPT2 would
fail because it would attempt to call _wmkdir on the drive
(eg. _wmkdir("D:\")). Split on directories after the drive letter
instead.

Bug: 68936311
Test: manual testing using Android Studio
Change-Id: Iad47f466af6f82d4ac402e9bf52853edaa9a5e0b
2018-09-13 15:27:58 +00:00
Ryan Mitchell
7984854750 AAPT2: Fail on invalid id names in compiled xml
AAPT2 was not erroring on invalid resource ids created in layouts with
creation syntax. This change causes this to error suring compile.

Bug: 71394154
Test: aapt2_tests
Change-Id: Idf16fb4bd011ed2d65e8c48f7cba0429ead5a055
2018-09-13 15:23:56 +00: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
28afe682cd AAPT2: Add the rest of supported manifest elements
Adds elemnts that are parsed in PackageParser to the manifest parsing of
AAPT2.

<package> found in <manifest>
<preferred> found in <manifest><application><activity>

Bug: 79755007
Test: manual building of broken targets listed in the bug
Change-Id: Ic7d17e62d04aa46757d2ed7482ec0aff93ce9ee5
2018-09-07 15:19:53 -07:00
TreeHugger Robot
bd263a40ca Merge "AAPT2: Fix dump apk format" 2018-08-31 00:01:40 +00: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
Ryan Mitchell
8d4ee973fa AAPT2: Fix resource table load time regression
A previous change (deee395) caused duplicate entries to be created for
entries eith entry ids greater than 0x0ff. This is because the wrong
data type was used (uint8_t instead of uint16_t). This made loading in
resources slower as well since more entries had to be iterated over.

Bug: 36051266
Test: Dumping all resources in 700 apks found in the android tree took 1
minute instead of 5 minutes. Created a test in aapt2_tests.

Change-Id: I1c3d830da517a56ac3496221dbe605c72e0c6014
2018-08-27 22:35:34 +00:00
TreeHugger Robot
7d64dbe87a Merge "dump package name" 2018-08-24 19:34:34 +00: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
ed72380fac Merge "AAPT2: Add supported manifest elements" 2018-08-23 21:45:53 +00:00
Todd Kennedy
595d12e581 Merge "Mark symbols as dynamic for shared libraries" am: c07d4e7118 am: 857718307c
am: 6b8d5414e0

Change-Id: I9bb2b7333abb11747d48a4ced8686052c77963aa
2018-08-21 03:26:41 -07:00
Treehugger Robot
c07d4e7118 Merge "Mark symbols as dynamic for shared libraries" 2018-08-20 21:31:28 +00:00
Donald Chai
e0936a1fda Merge "Include values in error message." 2018-08-20 17:11:01 +00:00
Ryan Mitchell
93a2daf1c0 Merge "AAPT2: Set array element keys" 2018-08-20 16:41:33 +00:00
Donald Chai
9f1911181d Include values in error message.
Bug: 112554546
Test: N/A
Change-Id: I56c468a9a4f162f6ce8079d6b4b61c5ec4b8f633
2018-08-20 03:48:47 +00:00
Ryan Mitchell
0f7da5eda8 AAPT2: Set array element keys
Many google3 apps using lemon resource filtering had difficulty
converting to aapt2. AAPT2 never set the name of the ResTable_map name
value mapping.

Bug: 78472540
Test: blaze build java/com/google/android/apps/gmail:Gmail_go_release
and checking that all array resources are present
Change-Id: I3d253a4c52c6100085e4c1083f4c36a943f11c76
2018-08-17 14:37:33 -07:00
Ryan Mitchell
ead275e19f Merge "AAPT2: Compile --zip flag" 2018-08-16 17:26:08 +00: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
1a8a69075e Merge "AAPT2: Loosen loading apk format requirements" 2018-08-14 22:51:35 +00: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
Ryan Mitchell
dc8d0be1e2 Merge "AAPT2: Update SDK development codename to Q" 2018-08-14 18:20:57 +00:00
Ryan Mitchell
eef1b6cd4b Merge "AAPT2: Adaptive icon refactor" 2018-08-14 18:20:57 +00:00
Ryan Mitchell
eb9c9ac8b8 AAPT2: Update SDK development codename to Q
Test: aapt2_tests
Change-Id: I815e0bfc786660d6ad70897287fb5fb21023068c
2018-08-14 09:33:22 -07:00
TreeHugger Robot
f2c5ee5900 Merge "AAPT2: partial files contain only local resources" 2018-08-13 18:07:38 +00:00
Ryan Mitchell
70f797208c AAPT2: Adaptive icon refactor
Part of a refactor to specify sdk version for all <adaptive-icons> xml
resources.

Bug: 79676805
Test: build success
Change-Id: I1cf1109103722a9562eaf6bf2dcd68d0ef8757eb
2018-08-13 07:37:24 -07:00
Ryan Mitchell
66f6cfb8a5 AAPT2: Add supported manifest elements
Adds some elements present in res/values/attrs_manifest.xml to manifest
parsing.

<additional-certificate> in <manifest><application><uses-static-library>
<meta-data> in <manifest><permission>
<package-verifier> in <manifest>
<restrict-update> in <manifest>

Bug: 79755007
Test: manual
Change-Id: I50520a99ce5ced9908001430b2108d7a5c71f8a7
2018-08-10 09:27:35 -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
Ryan Mitchell
792dbbb2ab Merge "AAPT2: Version code major flag" 2018-08-08 23:53:14 +00:00
Ryan Mitchell
a9e316051b AAPT2: Do not overlay comments
Always take the original comment of a resource. Resources passed in
through regular file arguments and resources added using the -R and
--auto-add-overlay flags will keep the same comments when overlayed by
another resource.

This will allow R.java files to remain consistent across devices between
product overlays.

Bug: 70641212
Test: aapt2_tests
Change-Id: I4ed1037a8d42f7e77d85e5c2a8ee78051053831a
2018-07-31 16:11:49 -07:00
Ryan Mitchell
704090e02a AAPT2: Version code major flag
Adds flag --version-code-major that injects android:versionCodeMajor
into the manifest if none is present or when overriding.

Bug: 109883459
Test: aapt2_tests
Change-Id: I10b27abb8fa8a99a41976c42c4d684b99978b4f9
2018-07-31 22:06:24 +00:00
Izabela Orlowska
f67d486e58 AAPT2: partial files contain only local resources
When writing a partial R file for the compiled file, only include
resources defined locally - meaning those without a package. Do not
write resources from other packages (e.g. "android").

Test: manual
Bug: 73927419
Change-Id: I84241352e643ca1f22a581e6847372e2a4278824
2018-07-25 09:50:15 +00:00
Todd Kennedy
196dbc379b Mark symbols as dynamic for shared libraries
Bug: 111425000
Change-Id: Ic1a68ac90d5e0443a536ee9ce75a72bc370cd673
Test: build, install and run the shared library test application
2018-07-24 21:55:12 +00: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
TreeHugger Robot
24a464a9be Merge "Only keep necessary constructor for custom view nodes" 2018-07-20 17:14:35 +00:00
TreeHugger Robot
41dcc4eac5 Merge "Only keep methods with correct signature for more types" 2018-07-20 16:36:24 +00:00
Ryan Mitchell
848585e1a4 Merge "AAPT2: Fix R.java for styleable in different package" 2018-07-20 15:18:05 +00:00
Jake Wharton
cc65b8dba6 Only keep necessary constructor for custom view nodes
This expands the Context+AttributeSet constructor specificity from only work on <view class=> nodes to <my.Type> nodes.

Bug: 37123156
Test: make aapt2_tests
Change-Id: I8fb950731383f86bee225333bda27baf5a7a34c5
2018-07-20 10:44:11 -04:00
Jake Wharton
98100c3828 Only keep methods with correct signature for more types
- For transition and pathMotion attributes the method must have Context and AttributeSet parameters.
- For actionViewClass and actionProviderClass attributes the constructor must have a single Context parameter.
- For Fragment's class or name attributes the constructor must have zero parameters.

Bug: 37123156
Test: make aapt2_tests
Change-Id: I34017abd182867ba95172835051d114cb2f3b3ac
2018-07-20 10:44:11 -04:00
Jake Wharton
e4bd160284 Add rule emissions for appComponentFactory
This attribute was added in API 28 and is reflectively instantiated from a zero-argument constructor.

Test: make aapt2_tests
Change-Id: Ie9de0764165c6fe6c6fcda6cc38b0cc633f03bbd
2018-07-18 12:09:17 -04:00
Jake Wharton
cfbc767b61 Add Application name to manifest test case
Test: make aapt2_tests
Change-Id: I4df26375bdf480b7d09e9cf816b7a9feaa141115
2018-07-18 12:09:17 -04:00
Ryan Mitchell
5fa2bb14ec AAPT2: Fix long version code bugs
Refactoring areas in AAPT2 that use android:versionCode to also use
abdroid:versionCodeMajor. Does not add versionCodeMajor command line flag yet.

Bug: 109883459
Test: aapt2_tests
Change-Id: I573fbea37491cf8c5742f9e385c66ee64c4e5166
2018-07-13 23:41:46 +00:00