127 Commits

Author SHA1 Message Date
Mark Salyzyn
7e9e305994 am 9ca25502: am 48250e14: am 9a09a523: am 0b472ae1: Merge "androidfw: resolve 64-bit build issues"
* commit '9ca25502c05854288733ee5142e8bf6594821f83':
  androidfw: resolve 64-bit build issues
2014-03-19 19:58:00 +00:00
Mark Salyzyn
00adb8685e androidfw: resolve 64-bit build issues
- uid_t/gid_t cast to unsigned long
- unused argument warnings
- tab and space requirements

Change-Id: Ib446d8165b9082be02edb55e6b71fd1a03ea3431
2014-03-19 11:11:14 -07:00
Narayan Kamath
b5c4e7fd38 resolved conflicts for merge of 92860a74 to master
Change-Id: I3036ef9f1251c756092dc5ee2c4fed8146855e1e
2014-03-10 10:57:05 +00:00
Narayan Kamath
6381dd4ff2 LP64: Make 9 patches architecture agnostic.
The Res_png_9patch struct had several pointer members
whose size differed between 32 and 64 bit platforms.

These members have been replaced by uint32_t offsets
to serialized data. The serialized form for 9patches
places a Res_png_9patch object at the beginning of
serialized data, followed by int32_t arrays of xDivs,
yDivs and colors.

Note that these offsets are not strictly required,
since they can be computed from the values of numXDivs,
numYDivs & numColors, however they are called in tight
loops so having them computed once is a beneficial.

This change also removed the unused patch_equals function
from aapt's Image.cpp.

Change-Id: I3b9ac8ae5c05510d41377cae4dff1c69b40c2531
2014-03-10 10:00:02 +00:00
Narayan Kamath
e0d10cd923 am d8ccf8b7: am be094d89: am 8fb22ae7: am eee2c72f: Merge "Various format string fixes for 64bit"
* commit 'd8ccf8b789461e1706d10df44d109849fa974fc5':
  Various format string fixes for 64bit
2014-02-28 13:53:15 +00:00
Kévin PETIT
95ece35c2f Various format string fixes for 64bit
Change-Id: I74532a4e0400033f5ee3e3f6827ac42f77d16f53
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
2014-02-24 17:39:46 +00:00
Christopher Tate
b048c33d5b Don't assume that we're at start of file at ctor time
BackupDataReader / BackupDataWriter were implicitly assuming that when
instantiated, the underlying fd was positioned at start-of-file.  If one
tried to e.g. open an existing data stream to append further data to it,
things might randomly fail (at read time, possibly when consuming the
stream later) due to incorrect alignment of the data entities: the
appending writer would assume that no padding was needed to achieve
correct alignment, and this might easily be false.

Now the underlying native reader/writer helpers recognize the true
position within the file when constructed, and as a result it's now
safe to e.g. construct a BackupDataOutput for an existing file and
then append to it.

Change-Id: If0484921e687852f923a4b4efabff573a6c16981
2014-02-21 12:58:04 -08:00
Narayan Kamath
f9bf991cb5 am bcb433b4: am b1903653: am 128599e4: am 2b3c14bf: Merge "libandroidfw: fix build error for 64-bit"
* commit 'bcb433b43acb424ff7bc6afab03ce12d8cc9a198':
  libandroidfw: fix build error for 64-bit
2014-02-20 21:28:09 +00:00
Patrik Bannura
443dd9313f libandroidfw: fix build error for 64-bit
Fixed casting int to pointer in logging code.
Previously ints where printed as pointers and
the %p format specifier was used for convenience
to get hex output. This change uses %x and also
gets rid of the casts.

Change-Id: Ia2539769d245f50c0f3884119f80682defe69d61
2014-02-20 10:06:23 +00:00
Narayan Kamath
788fa41482 Extended locales in AAPT / AssetManager.
Support 3 letter language codes, script codes &
variants. The bulk of the changes are related to
the implementation of command line filtering of
locales etc. The previous code assumed that the
value of each "axis" (locale, density, size etc.)
could be represented by a 4 byte type. This is
no longer the case.

This change introduces a new class, AaptLocaleValue
which holds a (normalized) locale parsed from a
directory name or a filter string. This class takes
responsibility for parsing locales as well as
writing them to ResTable_config structures, which is
their representation in the resource table.

This includes minor changes at the java / JNI level
for AssetManager. We now call locale.toLanguageTag()
to give the native layer a well formed BCP-47 tag.
I've removed some duplicated parsing code in
AssetManager.cpp and replaced them with functions on
ResTable_config. The native getLocales function has
been changed to return well formed BCP-47 locales as
well, so that the corresponding java function can use
Locale.forLanguageTag to construct a Locale object
out of it.

Finally, this change introduces default and copy
constructors for ResTable_config to prevent having
to memset() the associated memory to 0 on every
stack allocation.

(cherry-picked from commit 91447d88f2bdf9c2bf8d1a53570efef6172fba74)

Change-Id: I1b43086860661012f949fb8e5deb7df44519b854
2014-02-14 14:08:57 +00:00
Narayan Kamath
48620f1d1b AssetManager support for 3 letter lang/country codes.
- 3 letter codes are packed into the existing 32 bit locale
  field in ResTable_config
- We introduce new fields for script / variant information.

Note that we define a "match" between two ResTable_config
structures to be purely on the basis of their language &
country (disregarding the script and the variant). However,
configs with scripts and variants are considered to be more
specific than those without.

(cherry picked from commit 378c6775a62d9c461cde51f06c1b14bb014c78fd)

Change-Id: I7dce82a3fe2412834252723f458826ae41535a78
2014-02-14 14:08:23 +00:00
Nick Kralevich
d5c8044e7e resolved conflicts for merge of 1cbea39f to master
Change-Id: Ib33484546c6a03cbc4cd96e97d9d785d68e10700
2014-02-12 14:41:25 -08:00
Nick Kralevich
1cbea39fe1 resolved conflicts for merge of dd3d95f1 to klp-volantis-dev
Change-Id: I96c0f0da852a0b3cf8aef9158678d38aa30f456f
2014-02-12 14:08:06 -08:00
Colin Cross
ecbeae74f2 Use size_t* in AssetManager::createIdmap
ResTable::createIdmap takes a size_t*, and the idmap command is
passing in a size_t*, make AssetManager::createIdmap take a
size_t*.  Should fix the mac build.

Change-Id: Idc16dedfe2aa7367c75f89a937a8242d494e8f8e
2014-02-11 18:02:06 -08:00
Dianne Hackborn
d9e385b111 Fix build.
At least part of what is broken.  Other stuff still seems to be.

Change-Id: I367dc0377bd5b4e59d9d9b68f3506bf1d64aa591
(cherry picked from commit 32bb5fae353b5bb6275e75952e89c514c7369cee)
2014-02-11 22:47:42 +00:00
Dianne Hackborn
32bb5fae35 Fix build.
At least part of what is broken.  Other stuff still seems to be.

Change-Id: I367dc0377bd5b4e59d9d9b68f3506bf1d64aa591
2014-02-11 14:22:14 -08:00
Dianne Hackborn
47b80be208 am be49403a: am 0cd115e1: am 578087e3: Merge "New command line tool \'idmap\'"
* commit 'be49403a0362c18edaeafe59ac09baac14294dee':
  New command line tool 'idmap'
2014-02-11 20:44:38 +00:00
Narayan Kamath
91447d88f2 Extended locales in AAPT / AssetManager.
Support 3 letter language codes, script codes &
variants. The bulk of the changes are related to
the implementation of command line filtering of
locales etc. The previous code assumed that the
value of each "axis" (locale, density, size etc.)
could be represented by a 4 byte type. This is
no longer the case.

This change introduces a new class, AaptLocaleValue
which holds a (normalized) locale parsed from a
directory name or a filter string. This class takes
responsibility for parsing locales as well as
writing them to ResTable_config structures, which is
their representation in the resource table.

This includes minor changes at the java / JNI level
for AssetManager. We now call locale.toLanguageTag()
to give the native layer a well formed BCP-47 tag.
I've removed some duplicated parsing code in
AssetManager.cpp and replaced them with functions on
ResTable_config. The native getLocales function has
been changed to return well formed BCP-47 locales as
well, so that the corresponding java function can use
Locale.forLanguageTag to construct a Locale object
out of it.

Finally, this change introduces default and copy
constructors for ResTable_config to prevent having
to memset() the associated memory to 0 on every
stack allocation.

Change-Id: I899a56a9a182ee6be52b9389d1ae59266f5482e9
2014-02-10 15:50:16 +00:00
Narayan Kamath
378c6775a6 AssetManager support for 3 letter lang/country codes.
- 3 letter codes are packed into the existing 32 bit locale
  field in ResTable_config
- We introduce new fields for script / variant information.

Note that we define a "match" between two ResTable_config
structures to be purely on the basis of their language &
country (disregarding the script and the variant). However,
configs with scripts and variants are considered to be more
specific than those without.

Change-Id: I3c2e909ebbebdbbd0ab72a639d531b2b9fdbd9b9
2014-02-10 15:33:30 +00:00
Mårten Kongstad
48d22323ce Runtime resource overlay, iteration 2
Support any number of overlay packages. Support any target package.

UPDATED PACKAGE MATCHING
------------------------
In Runtime resource overlay, iteration 1, only a single overlay package
was considered. Package matching was based on file paths:
/vendor/overlay/system/framework-res.apk corresponded to
/system/framework-res.apk. Introduce a more flexible matching scheme
where any package is an overlay package if its manifest includes

    <overlay targetPackage="com.target.package"/>

For security reasons, an overlay package must fulfill certain criteria
to take effect: see below.

THE IDMAP TOOL AND IDMAP FILES
------------------------------
Idmap files are created by the 'idmap' binary; idmap files must be
present when loading packages. For the Android system, Zygote calls
'idmap' as part of the resource pre-loading. For application packages,
'idmap' is invoked via 'installd' during package installation (similar
to 'dexopt').

UPDATED FLOW
------------
The following is an outline of the start-up sequences for the Android
system and Android apps. Steps marked with '+' are introduced by this
commit.

Zygote initialization
   Initial AssetManager object created
+    idmap --scan creates idmaps for overlays targeting 'android', \
           stores list of overlays in /data/resource-cache/overlays.list
   AssetManager caches framework-res.apk
+  AssetManager caches overlay packages listed in overlays.list

Android boot
   New AssetManager's ResTable acquired
     AssetManager re-uses cached framework-res.apk
+    AssetManager re-uses cached 'android' overlays (if any)

App boot
   ActivityThread prepares AssetManager to load app.apk
+  ActivityThread prepares AssetManager to load app overlays (if any)
   New AssetManager's ResTable acquired as per Android boot

SECURITY
--------
Overlay packages are required to be pre-loaded (in /vendor/overlay).
These packages are trusted by definition. A future iteration of runtime
resource overlay may add support for downloaded overlays, which would
likely require target and overlay signatures match for the overlay to
be trusted.

LOOKUP PRIORITY
---------------
During resource lookup, packages are sequentially queried to provide a
best match, given the constraints of the current configuration. If any
package provide a better match than what has been found so far, it
replaces the previous match. The target package is always queried last.

When loading a package with more than one overlay, the order in which
the overlays are added become significant if several packages overlay
the same resource.

Had downloaded overlays been supported, the install time could have been
used to determine the load order. Regardless, for pre-installed
overlays, the install time is randomly determined by the order in which
the Package Manager locates the packages during initial boot. To support
a well-defined order, pre-installed overlay packages are expected to
define an additional 'priority' attribute in their <overlay> tags:

    <overlay targetPackage="com.target.package" priority="1234"/>

Pre-installed overlays are loaded in order of their priority attributes,
sorted in ascending order.

Assigning the same priority to several overlays targeting the same base
package leads to undefined behaviour. It is the responsibility of the
vendor to avoid this.

The following example shows the ResTable and PackageGroups after loading
an application and two overlays. The resource lookup framework will
query the packages in the order C, B, A.

        +------+------+-     -+------+------+
        | 0x01 |      |  ...  |      | 0x7f |
        +------+------+-     -+------+------+
            |                           |
        "android"                Target package A
                                        |
                       Pre-installed overlay B (priority 1)
                                        |
                       Pre-installed overlay C (priority 2)

Change-Id: If49c963149369b1957f7d2303b3dd27f669ed24e
2014-02-03 11:20:30 +01:00
Mårten Kongstad
65a05fd56d New command line tool 'idmap'
Introduce a new tool 'idmap' to handle generation and verification of
idmap files. The tool is modelled on 'dexopt', and is intended to be
used similarly, notably by 'installd'.
See cmds/idmap/idmap.cpp for further documentation on 'idmap'.

Note: this commit is interdependent on a commit in project build/ to add
'idmap' to PRODUCT_PACKAGES.

Note: the changes to androidfw are only stubs. The actual implementation
will be provided in Runtime resource overlay, iteration 2.

Change-Id: I7131b74ece1e46c8a9c0a31d103e686aa07da2bb
2014-02-03 09:47:16 +01:00
Narayan Kamath
7c4887f66b Change ResourceType cookies to int32_t.
Also change the order of parameters in ResTable constructors
to avoid ambiguity.

(cherry picked from commit 00b314436f4fdfada4bbf1e79ec12e9fa38aeaf1)

Change-Id: I874c5d03c134dc3c331fba423b5280366296287c
2014-01-31 13:47:27 +00:00
Narayan Kamath
00b314436f Change ResourceType cookies to int32_t.
Also change the order of parameters in ResTable constructors
to avoid ambiguity.

Change-Id: If7bfa1f640dddca39b9f26a3ce84081fa7b6e6e3
2014-01-28 16:27:52 +00:00
Narayan Kamath
a0c6260705 AssetManager cookies should be int32_t and not void*.
Cookies are really indices into vectors and arrays, so
they don't need to be void*. We choose int32_t instead
of size_t to allow their width to be well specified.

Change-Id: I319f271bd4f102dee7cb9f00df4c75ea697456f5
2014-01-27 10:31:11 -08:00
Narayan Kamath
90f58dbf79 Add libutils dependency for libandroidfw host build.
(cherry picked from commit 070274ec0ccb8643c52e41e4119f356f0f51bc36)

Change-Id: I25acff1d36b3adce14b2576485bda93c914d7f5d
2014-01-27 10:31:11 -08:00
Narayan Kamath
560566d291 Reimplement ZipFileRO in terms of libziparchive.
This lets us share zip archive processing code with both
the runtime (Art, dalvik) and critical java code
(StrictJarFile).

This change also moves several utility methods to ZipUtils
and dedups code across several zip inflation methods.

One of the side effects of this change is that several
processing loops are now O(n) instead of O(n^2).

bug: 10193060

(cherry picked from commit afd31e08299008fdc5c2813f21b2573f29dc53df)

Change-Id: Iae67e62f1dc6dfc3f43e29bc38e3ffd1cb14d191
2014-01-27 10:31:11 -08:00
Elliott Hughes
e1aa223657 Re-apply androidfw fixes lost by the directory rearrangement.
Assignment to wrong variable in libs/androidfw/AssetManager.cpp.
https://code.google.com/p/android/issues/detail?id=61560

Missing delete[]s in libs/androidfw/ObbFile.cpp.
https://code.google.com/p/android/issues/detail?id=61549

Change-Id: I24e6867284d70a7793d78e62d1a836cbee310fb0
2014-01-27 10:31:10 -08:00
Adam Lesinski
16c4d154dc Revert "move libandroidfw to frameworks/native"
This reverts commit 84b6292c33d71b5739828d08aa8101d1954577f2.
2014-01-27 10:31:10 -08:00
Narayan Kamath
745d4efc83 AssetManager cookies should be int32_t and not void*.
Cookies are really indices into vectors and arrays, so
they don't need to be void*. We choose int32_t instead
of size_t to allow their width to be well specified.

(cherry picked from commit ebfdd0f467e39c3af8d92cade78263935340acb7)
(cherry picked from commit a7fa2e592e2e579e5acdb903dba83fc074ebc215)
(cherry picked from commit a9d5701b034ed2d9771b3f0943e1add00741d7cd)

Change-Id: I2aed3db568b6fdc487bf99e2c5dd123206736fda
2014-01-27 11:20:24 +00:00
Narayan Kamath
070274ec0c Add libutils dependency for libandroidfw host build.
Change-Id: I7fe0bb466f0b1cdbfef8934da2231ad20f05b648
2013-12-11 16:48:07 +00:00
Narayan Kamath
afd31e0829 Reimplement ZipFileRO in terms of libziparchive.
This lets us share zip archive processing code with both
the runtime (Art, dalvik) and critical java code
(StrictJarFile).

This change also moves several utility methods to ZipUtils
and dedups code across several zip inflation methods.

One of the side effects of this change is that several
processing loops are now O(n) instead of O(n^2).

bug: 10193060

Change-Id: I3c7188496837a47246c4f342e45485a70fef3169
2013-12-09 16:23:16 +00:00
The Android Open Source Project
dbccd44a63 Merge commit 'b873a17ce7be0a9771c24999adca6964431728f6' into HEAD
Change-Id: I938755073e70602cc8f51ce9bd420fdcf870cecd
2013-11-22 11:18:57 -08:00
Elliott Hughes
c367d48c55 Fix a variety of small publicly-reported bugs.
Possible NULL dereference in cmds/bootanimation/BootAnimation.cpp.
https://code.google.com/p/android/issues/detail?id=61556

Missing fclose in core/jni/android_os_Debug.cpp.
https://code.google.com/p/android/issues/detail?id=61546

Bad loop guards in core/jni/android_util_Process.cpp.
https://code.google.com/p/android/issues/detail?id=61557

Assignment to wrong variable in libs/androidfw/AssetManager.cpp.
https://code.google.com/p/android/issues/detail?id=61560

Missing delete[]s in libs/androidfw/ObbFile.cpp.
https://code.google.com/p/android/issues/detail?id=61549

Leaks on error in tools/aapt/Images.cpp.
https://code.google.com/p/android/issues/detail?id=61552

Two missing fclose calls in tools/aapt/Resource.cpp.
https://code.google.com/p/android/issues/detail?id=61553

Missing fclose in tools/aidl/aidl.cpp.
https://code.google.com/p/android/issues/detail?id=61554

Change-Id: I5820f3824e72d07a9acb776cf0af3e7443f5694a
2013-10-29 13:12:55 -07:00
Mike Lockwood
84b6292c33 move libandroidfw to frameworks/native
Change-Id: Ic5b8a2742c7141156ab0f00ca29097bfe92bce60
2013-10-03 10:30:18 -07:00
Chris Wren
fd5f566db8 add a test for BackupData helpers.
Bug: 10821481
Change-Id: I3e28123d36927ae4a22d26378b8bf1cd4e87cfd2
2013-09-25 19:33:21 +00:00
Kenny Root
1c7cf90af4 Fix another off-by-one error in ZipFileRO
Bug: 10424836
Change-Id: I491458bd31ef39e87127d061427b32a3d59ac807
2013-09-11 15:28:39 -07:00
Kenny Root
0d6c2d7b9d Reconcile differences between zip implementations
Reconcile the difference between ZipFileRO and java.util.ZipFile to have
the same behavior.

Bug: 10424836
Change-Id: I6bde1bad7e20065ee650945fd43a913c05ce5ac7
2013-09-11 11:44:40 -07:00
Kenny Root
0c4b3646b0 Revert "Reconcile differences between zip implementations"
This reverts commit 9ffddc7eb50653cf60ce6b27a0e1945eed5b5ce1.

Change-Id: Ifeba63511211bfc2b375f2205e319e91403b7d06
2013-09-11 18:10:09 +00:00
Kenny Root
9ffddc7eb5 Reconcile differences between zip implementations
Reconcile the difference between ZipFileRO and java.util.ZipFile to have
the same behavior.

Bug: 10424836
Change-Id: Iff159c9e1a91b59f6c5346dc0278cb9e4bbc1a39
2013-09-11 00:29:18 +00:00
Elliott Hughes
83ad4e393a Remove an unused C zip API.
Change-Id: I10ae849bdedf3e3bb97547c4f9e5a20742e9d6b1
2013-08-05 14:12:50 -07:00
Dianne Hackborn
d45c68dd24 Resource memory optimization.
Don't ever need the cached UTF-16 string conversions on the
device.  Don't need to create those strings, and don't need
to create the lookup array for them at all.  This requires
fixing all of the remaining places in the platform where we
interacted with the resources with the blind assumption that
the strings are UTF-16.

Change-Id: Ia0e5a150499837471e494e85b23b05fa06e0cf1d
2013-07-31 15:57:49 -07:00
Colin Cross
0d6e7315eb add static dependency on liblog
Change-Id: I8056aa744b37ef0c31229329a0de79c58c5955ea
2013-07-23 18:04:24 -07:00
Jeff Brown
9d3b1a424c Move input library code to frameworks/native.
No longer compile libandroidfw as a static library on the device
since it already exists as a shared library.  Keeping the static
library would force us to provide a static library version of
libinput for the device as well which doesn't make sense.

Change-Id: I3517881b87b47dcc209d80dbd0ac6b5cf29a766f
2013-07-01 20:11:42 -07:00
Jeff Brown
0618148f90 input: Handle a few extra error conditions.
It turns out that SOCK_SEQPACKET sockets may sometimes return
ECONNREFUSED or ECONNRESET errors when the peer dies instead of
the usual EPIPE.

Bug: 9479906
Change-Id: Ia7e572b08bf63e43ba5aeda58281508beb5f8c73
2013-06-18 16:10:49 -07:00
Nick Kralevich
631500ef58 Move VelocityTracker.cpp to target build only
VelocityTracker.cpp makes reference to property_get, which
doesn't make a lot of sense when compiling for the host.
Compile this file for the target only.

Keyboard.cpp: Remove unnecessary include file.

Change-Id: Iee9edd81953b2e7e815005770ce286a6ec586f20
2013-05-21 15:04:14 -07:00
Mathias Agopian
1f5762e646 libutils clean-up
Change-Id: I11ee943da23a66828455a9770fc3c5ceb4bbcaa9
2013-05-07 17:09:46 -07:00
Bjorn Bringert
fb903a45d7 Allow compiling aapt for the device
Changes:

- The static device version of libandroidfw now includes
  the extra functions needed by aapt. I could only find
  a few host tools that use the static library, so this is
  hopefully not a problem.

- The pseudolocalization code is moved into aapt.
  It was previously in libhost, but only used by aapt.

Change-Id: Ib393ebb7dcebee8abbb628cbe5255ea1679674ac
2013-04-26 15:07:09 +01:00
Dianne Hackborn
c51d050f1b Maybe fix issue #8620910: Win_sdk build failed and unable to create...
...the sdk platform repo

Change-Id: Ib6cd7c0dfb9b6217ae79af3e2ac25fe0442996e3
2013-04-15 15:36:53 -07:00
Dianne Hackborn
f7be4800df Add new resources trace, also trace apk dex loading.
Change-Id: Ia48566efb21ee018659bd976ddb3a0f4997b9a3a
2013-04-12 14:53:10 -07:00
Michael Wright
bdb706e48d Merge "Pipe through device resolution information" into jb-mr2-dev 2013-04-05 21:43:31 +00:00