162 Commits

Author SHA1 Message Date
Ryan Mitchell
db21f09a8e Revert^2 "libandroidfw hardening for IncFs"
55ef6167a2c235bd88c7216238b2001b46795b79

Change-Id: I02d4890d181655dfd0a14c188468db512559d27b
2020-11-17 23:01:35 +00:00
Ryan Mitchell
55ef6167a2 Revert "libandroidfw hardening for IncFs"
Revert "Move map_ptr to incfs namspace"

Revert submission 12787270

Reason for revert: b/173250495
Reverted Changes:
I5cd1bc8a2:libandroidfw hardening for IncFs
Ice5dbcfb2:Move map_ptr to incfs namspace
I29ccdc8ed:Do not cache bag parent stack until requested
I1e9e9acaa:Cache resolved theme values

Change-Id: Ib90ef68339710086df41e9abe0833a542d03a74f
2020-11-13 23:55:20 +00:00
Ryan Mitchell
c75c2e0922 libandroidfw hardening for IncFs
Migrate libandroifw to using incfs::util::map_ptr to prevent processes
from crashing when parsing the resources.arsc, parsing compiled xml,
files, and retrieving resource values.

This change propagates incremental failures to the JNI level where they
are raised as ResourcesNotFoundException.

Performance of ResourcesPerfWorkloads without change (time in
nanoseconds):
[1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.883s)
    youtube_ns_median: 93812805
    youtube_ns_standardDeviation: 4387062
    youtube_ns_mean: 94455597
[2/3] com.android.resources.perf.PerfTest#maps: PASSED (11.265s)
    maps_ns_standardDeviation: 2997543
    maps_ns_mean: 83480371
    maps_ns_median: 82210941
[3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.963s)
    gmail_ns_median: 266141091
    gmail_ns_standardDeviation: 3492043
    gmail_ns_mean: 267472765

With change and verification forcibly enabled for all apks
(including the framework-res.apk):
[1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.646s)
    youtube_ns_median: 101999396
    youtube_ns_standardDeviation: 4625782
    youtube_ns_mean: 102631770
[2/3] com.android.resources.perf.PerfTest#maps: PASSED (11.286s)
    maps_ns_standardDeviation: 2692088
    maps_ns_mean: 91326538
    maps_ns_median: 90519884
[3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.694s)
    gmail_ns_median: 290284442
    gmail_ns_standardDeviation: 5764632
    gmail_ns_mean: 291660464

With change and verification disabled:
[1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.748s)
    youtube_ns_median: 95490747
    youtube_ns_standardDeviation: 7282249
    youtube_ns_mean: 98442515
[2/3] com.android.resources.perf.PerfTest#maps: PASSED (10.862s)
    maps_ns_standardDeviation: 4484213
    maps_ns_mean: 87912988
    maps_ns_median: 86325549
[3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.034s)
    gmail_ns_median: 282175838
    gmail_ns_standardDeviation: 6560876
    gmail_ns_mean: 282869146

These tests were done on a Pixel 3 and with cpu settings configured by
libs/hwui/tests/scripts/prep_generic.sh:

 Locked CPUs 4,5,6,7 to 1459200 / 2803200 KHz
 Disabled CPUs 0,1,2,3

Bug: 160635104
Bug: 169423204
Test: boot device && atest ResourcesPerfWorkloads

Change-Id: I5cd1bc8a2257bffaba6ca4a1c96f4e6640106866
2020-11-12 08:13:44 -08:00
Pirama Arumuga Nainar
ea5cf9f31c Merge "For Win32, don't cast ssize_t while printing" am: aaf8d7aa2e
am: 466ada94fe

Change-Id: I39b73406a41ecc5396c39648f8e05e8a88e7aaee
2018-05-14 11:22:57 -07:00
Pirama Arumuga Nainar
dc36bb6dea For Win32, don't cast ssize_t while printing
Bug: http://b/69933068

This is a partial revert of
https://android-review.googlesource.com/c/platform/frameworks/base/+/109433
so we can use Clang for windows cross compilation.

Clang does not allow a cast to 'signed size_t' and both Clang and
current MinGW accept a ssize_t to the '%zd' format specifier.

Test: m native-host, m native-host-cross with both MinGW and Clang
Change-Id: I5366622b91be1433f6c533c55a9ae429b57c7a27
2018-05-11 23:22:10 +00:00
Nick Butcher
e78a816966 Prevent AAPT from versioning <animated-selector> tags.
Bug: 69359529
Test: Manually tested with ag/3178054
Change-Id: I10ae4d96c2a31a0a7c363d7a9292ecdfd3bb526a
2018-02-09 11:36:27 +00:00
ztenghui
ab2a38c03d AAPT leave <gradient> alone for VDC
bug: 62421666
Test: Tested with changes for Gradient of VDC.

Change-Id: I07b39721aeaaafd888416a0f71f6cbd5fce97732
2017-10-16 10:34:27 -07:00
Adam Lesinski
54b58ba5cc Fix issue with unresolved IDs in adaptive icons
Adaptive icons were versioned correctly, but skipped the compilation
/ resource ID assignment phase. This CL fixes the glitch.

Bug: 34829129
Test: manual
Change-Id: I93739a8b10fac53a048d95b330edf381684a807c
2017-04-18 18:05:02 -07:00
Adam Lesinski
cf1f1d9128 AAPT: Version <adaptive-icon> to v26
Bug: 35908647
Test: manual
Change-Id: Ic8f43efe34385192fbab18675eb5898ed80912a5
2017-03-28 19:16:11 +00:00
ztenghui
205548561c disable versioning for objectAnimator to support path motion
bug:33527757

Test: replace the AAPT in local SDK, and make sure the propertyX/YName
still works within ObjectAnimator.

Change-Id: Ic9bb14cd228dcf7e4d250bd0f6cb5f0c31a14183
2017-03-21 16:44:00 -07:00
ztenghui
010df88f90 Disable versioning for pathInterpolator when no-version-vectors is on.
Test: manually build demo app for support lib, and works!
bug:33527757

Change-Id: I3badea18b2eb8cddea94f7e44f9129bb55ed9649
2017-03-07 16:12:07 -08:00
Adam Lesinski
af463961bc Merge "AAPT: Fix --feature-of to allow non-public symbol visibility" 2017-02-08 14:07:22 +00:00
Adam Lesinski
fa1e9d7ad0 AAPT: Fix --feature-of to allow non-public symbol visibility
Test: manual
Change-Id: Iada18b201c6463011002f96285a64c64565a6e1c
2017-01-24 16:16:09 -08:00
Yuichi Araki
4d35cca96c AAPT: Add --no-version-transitions flag
Add a new flag to disable versioning of Transition related XMLs.
Transition support library will use this to handle these XMLs on older
API levels.

Test: make libaapt_tests AaptTestAppOne
Bug: 34427868
Change-Id: I66e81cca049e71ef6704177b2ca21c9cdeaff78f
2017-01-24 14:59:51 +09:00
Adam Lesinski
081d1b4cf6 AAPT: Handle gaps in resources when building splits
Due to public ID assignment, gaps in resource type and entry
IDs can occur. This can lead to null pointer dereferencing
if not careful. This happened in ResourceTable::getDensityVaryingResources()
which is called when building Splits.

Bug:30879690
Change-Id: I588e4dcd2e042fccfcb2e87967b5cbd0d23b4497
2016-08-15 18:45:00 -07:00
Chih-Hung Hsieh
9b8528fee4 Fix clang-tidy warnings in aapt and aapt2.
* Add explicit keyword to conversion constructors.
* Add NOLINT(implicit) comments for implicit conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
* Use const reference type to avoid unnecessary copy.
Bug: 30413862
Test: build with WITH_TIDY=1

Change-Id: Id6d21961f313a1ad92b15a37fdaa5be9e8ab48e1
2016-08-11 15:16:41 -07:00
Adam Lesinski
4d219da3c4 AAPT: Fix feature split generation of ID resources
ID resources that get generated on demand with the
notation @+id/name were previously not given the
appropriate type ID offset when being built as feature
splits.

This change declares an ID type ahead of time so that
the type ID offset is applied before IDs can be generated.

Bug:30607637
Change-Id: I122a9133cb01b35e9892103ec52fc228dc65bf1a
2016-08-03 16:54:15 -07:00
Adam Lesinski
526d73be4a AAPT: Don't keep processing files that failed to be added
AAPT will continue ahead without reporting an error if a file
failed to be added to the ResourceTable. This would cause crashes
later when the file was assumed to be present.

Bug:30200166
Change-Id: Ieb2daf97ccf0345153b6f4598d130a38d108c937
2016-07-18 17:07:41 -07:00
Adam Lesinski
afc79be228 AAPT: Allow duplicate attribute definitions if identical
This allows libraries to coexist a bit easier, since a lot of them
declare the same attribute. When used together they cause errors.
Bug:27101533

Change-Id: I649cf17bc587c4814f849d5ac522daf74495adcf
2016-02-26 15:57:59 -08:00
Adam Lesinski
525db2489d Revert "AAPT: Allow duplicate attribute definitions if identical"
This reverts commit c25283b5e206ceae2aa6eb01877b79c3c1f0adfb.

Change-Id: I2f42a4360fa53c4333494afe0178dcec56d62d8e
2016-02-25 23:13:08 +00:00
Adam Lesinski
c25283b5e2 AAPT: Allow duplicate attribute definitions if identical
This allows libraries to coexist a bit easier, since a lot of them
declare the same attribute. When used together they cause errors.
Bug:27101533

Change-Id: I10327251636392e810637a79e7c9aa514f3f07a6
2016-02-22 09:25:06 -08:00
Adam Lesinski
78713998f9 Specify private resource package in Android.mk
Private resource package shouldn't be buried in some resource file.
It can now be specified on the command line via the Android.mk file.

Change-Id: I9e3cb0bf54830d6b021077af271913306c024701
2015-12-07 14:52:53 -08:00
Adam Lesinski
07dfd2d864 Implement AAPT Bundle format
AAPT will scan XML files looking for the <aapt:attr> XML tag.

<!-- @layout/bundle.xml -->
<ImageView xmlns:aapt="http://schemas.android.com/aapt">
  <aapt:attr name="android:src">
    <vector android:pathData="..." ...>
    </vector>
  </aapt:attr>
</ImageView>

The SINGLE child element of the <aapt:attr> tag is extracted into its own top
level resource. It is given a generated name.

The parent element of <aapt:attr> is then given the resource attribute that was assigned
to the `name' attribute. The value is set to a reference to the generated resource.

<!-- @layout/bundle.xml -->
<ImageView android:src="@drawable/bundle_1.xml">
</ImageView>

<!-- @layout/bundle_1.xml -->
<vector android:pathData="..." ...>
</vector>

Bug:22627686
Change-Id: I8575fc4f739011402662fbf6b3db96df0012f598
2015-11-30 14:43:43 -08:00
Adam Lesinski
5b9847ca3f Revert "Implement AAPT Bundle format"
This reverts commit 9d0f7d44d5cc5322415f52f7ce03cc37a478b350.

Caused a build breakage when parsing some attributes.

Change-Id: I89ca958b2f2e820d353648df8aadd90bbe8d8339
2015-11-30 21:07:44 +00:00
Adam Lesinski
9d0f7d44d5 Implement AAPT Bundle format
AAPT will scan XML files looking for the <aapt:attr> XML tag.

<!-- @layout/bundle.xml -->
<ImageView xmlns:aapt="http://schemas.android.com/aapt">
  <aapt:attr name="android:src">
    <vector android:pathData="..." ...>
    </vector>
  </aapt:attr>
</ImageView>

The SINGLE child element of the <aapt:attr> tag is extracted into its own top
level resource. It is given a generated name.

The parent element of <aapt:attr> is then given the resource attribute that was assigned
to the `name' attribute. The value is set to a reference to the generated resource.

<!-- @layout/bundle.xml -->
<ImageView android:src="@drawable/bundle_1.xml">
</ImageView>

<!-- @layout/bundle_1.xml -->
<vector android:pathData="..." ...>
</vector>

Bug:22627686
Change-Id: I31bc96aae30d38bfd0b16508d0f585de5fd88a07
2015-11-24 15:38:40 -08:00
Adam Lesinski
beb9e33bfb AAPT: Fix regression in resource versioning
With a set of resources with the following configurations:

()
(land)

the regression caused any resources that needed to be versioned in configuration () to be lost.

Bug:23038206
Change-Id: I2f1b0313fb780ac241e7aaa487cb37dfb79c36aa
2015-08-14 13:41:46 -07:00
Adam Lesinski
f45d2fad2e AAPT: Fix resource versioning
Resource generation was greedy, so when an attribute with sdk level 21 was used in a resource
with v1, and a different attribute with sdk level 21 was used in a resource with v11,
a v21 resource would be synthesized, but it would contain the attribute from v1 instead of v11.

This change fixes the issue, having the higher versioned resource take precedence.

Bug:22793816
Change-Id: Ia687f56b0d9969e424111477d55d9804255b22e9
2015-07-28 12:26:57 -07:00
Adrian Roos
5892248580 aapt: add option for stricter symbol generation
Adds an option that prevents generating java symbols for string
resources that don't have a default localization.

Bug: 21537397
Change-Id: Ifafa942b24d5cdbed93651cde363e859be13d395
2015-06-02 02:55:52 +00:00
Adam Lesinski
6e46056abc AAPT: Add flag to disable versioning of vector related XML
AAPT automatically versions XML files according to the SDK level
in which their attributes were introduced. Support libraries
know how to handle resources built against newer SDKs, so offer
the option to disable some of the automatic versioning, namely
vectors.

Bug:19336994
Change-Id: I9f9d0ae8f2a0c28404f82e27de416f80e38493c9
2015-04-21 14:27:02 -07:00
Colin Cross
1be312dfb0 Merge "Re-enable -Wall and -Werror that were lost in a merge" 2015-04-09 00:49:56 +00:00
Colin Cross
01f185633c Re-enable -Wall and -Werror that were lost in a merge
-Wall and -Werror were lost during a merge when they were added to
aaptCFLAGS instead of aaptCFlags.  Fix the typo, and the warnings
that crept in while it was disabled.

Change-Id: Ib944b8d6149278e4f3861c1acac277bcd95cc7c2
2015-04-08 17:48:23 -07:00
Elliott Hughes
b12f2410c7 Only Windows doesn't have %zd.
Change-Id: I0e4b0fdc61641c5ecb724fd096bd2315dcf8ed4a
2015-04-03 12:56:45 -07:00
Dan Albert
f8d6a4ba87 resolved conflicts for merge of 701f9c2f to stage-aosp-master
Change-Id: I42e0411c0acef4b15137491ecaaed95d9b1cd0c1
2015-03-05 15:41:39 -08:00
Dan Albert
030f536009 Stop using namespace std.
The pattern of #include and using namespace std here fails to build
with GCC. At first glance it's a GCC bug rather than libc++ doing
something wrong. Regardless, it can be worked around by just
specifying std:: where appropriate.

Bug: 19606303
Change-Id: I5652682eae7ca7559cf2a9307909859013440781
2015-03-04 13:54:20 -08:00
Adam Lesinski
5c61dfc25f am e488ce86: am 94e30215: Merge "AAPT: Handle all old unversioned attribute usage" into lmp-mr1-dev
* commit 'e488ce8668538b45c586eba21f5bca288d749686':
  AAPT: Handle all old unversioned attribute usage
2015-01-14 20:47:47 +00:00
Adam Lesinski
28994d8d18 AAPT: Handle all old unversioned attribute usage
All references to attributes defined in pre-LOLLIPOP_MR1 SDK
are moved to version qualified resource entries.

Bug:18221682
Change-Id: Ifd739530ebcf99e6bc7ddb3f10bc5e05f0726e62
2015-01-14 12:02:15 -08:00
Adam Lesinski
22bfb75ebb am 0f0e85a6: Merge "AAPT: attributes showing up after v21 attributes would be removed for pre-21 devices" into lmp-mr1-dev
automerge: 465d123

* commit '465d123464eadf180b618164b2ed23702bca3d86':
  AAPT: attributes showing up after v21 attributes would be removed for pre-21 devices
2014-12-16 01:43:16 +00:00
Adam Lesinski
ea4e5ecc27 AAPT: attributes showing up after v21 attributes would be removed for pre-21 devices
There was an inconsistency in the indexing when removing attributes
in layouts. Now we account for that shift that happens when you delete
an attribute.

Bug:18707321
Change-Id: I656eee3fb614168fa8ceeff379e8594708961dad
2014-12-10 15:55:27 -08:00
Adam Lesinski
e97908d32e Merge commit '0953ab27' into manualmerge
Change-Id: I36dea45f7571096136ea7bda5e2680bd85a0df32
2014-12-05 11:06:21 -08:00
Adam Lesinski
9b624c186c AAPT: Move private attrs to new type for framework
Private attributes are typically placed after public
attributes in the resource table. Each time a new version
of the Android framework is released, new public attributes
take the place of the private attributes, and the private
attributes are shifted after the new public ones.

This means that any apps built against the newer SDK
may inadvertently be using private attributes on older
devices.

This change moves all private attributes to a completely
different type ID, so there will never be collisions across
versions.

These private attributes are automatically moved to a synthesized
type only for the system resources.

Bug:18263655

Change-Id: I7a850512953fadcc9f3524d509cea30249782db8
2014-12-03 15:59:20 -08:00
Adam Lesinski
d660e05c84 am 8aa93764: Merge "Fixing NULL pointer access causing segmentation fault in aapt"
* commit '8aa93764ea025b1c20f96b366ae6efb17e4f2d67':
  Fixing NULL pointer access causing segmentation fault in aapt
2014-11-11 19:53:52 +00:00
Adam Lesinski
4d29c66930 Merge commit 'fa31eb2c' into manualmerge
Conflicts:
	tools/split-select/RuleGenerator_test.cpp

Change-Id: I0d1261301d433f32e857cf1b0d75a861205f7625
2014-11-10 14:32:11 -08:00
Jörgen Ekström
da44fe0e1f Fixing NULL pointer access causing segmentation fault in aapt
In cases where resource packages are generated which does
not have public resources for all resource types - NULL
pointers sneaks into the mOrderedConfigs vector causing
the aapt tool to crash. The solution in this fix simply
ignores the NULL elements when later processing the sorted
vector.

The NULL elements are inserted during applyPublicEntryOrder
function call

Change-Id: I8b7135932e2d235018da2e2f7e09f0d22f1b2f59
2014-11-07 13:41:06 +00:00
Adam Lesinski
dcdfe9fef4 split-select: Fix rules generated for anydpi density
Change-Id: I9de569ca9a76eb22df4d0e178df847ba1c7d0b01
2014-11-06 14:57:34 -08:00
Adam Lesinski
685d363d7a Merge commit 'fb96e54' into manualmerge
Conflicts:
	tools/aapt/Resource.cpp

Change-Id: I4147c3550e9426f3429146eaeb16f10ba76b5b15
2014-11-05 12:30:25 -08:00
Adam Lesinski
de7de47fef Add error checking to aapt for split generation
Change-Id: Ica627db6a671f6a6c35f98bfd9c03598ffe103ce
2014-11-03 15:55:44 -08:00
Adam Lesinski
4bf58108d4 Fix issues that will be present in C++11
- char16_t is a distinct type, so stay consistent
  with it throughout the code base.
- char16_t is defined as minimum size of 16 bits.
  Since we mmap and cast data structures onto raw memory,
  we need a precise definition (uint16_t), so we cast between
  that (and static_assert that they are the same size).

Change-Id: I869c32637543bbcfb39d2643e7d9df10d33acd3c
2014-11-03 11:49:47 -08:00
Adam Lesinski
217b17a915 am d3969d92: am 6dfe03ae: am 73a8c596: am 3f8c7dec: Merge "AAPT: Fix path for final generated resources on Windows" into lmp-dev
* commit 'd3969d927eef2f04ec097244c5f2bff5e7c0689e':
  AAPT: Fix path for final generated resources on Windows
2014-10-20 21:16:17 +00:00
Adam Lesinski
3986e52cf9 am 3f8c7dec: Merge "AAPT: Fix path for final generated resources on Windows" into lmp-dev
* commit '3f8c7dec6b3fd4ac7fc99fe4e41cd0fa1b97bcad':
  AAPT: Fix path for final generated resources on Windows
2014-10-20 20:59:49 +00:00
Adam Lesinski
aff7c2447d AAPT: Fix path for final generated resources on Windows
Change-Id: Id11ac79b281b51747c73f90406ebd60023c54f92
2014-10-20 12:15:25 -07:00