Aprof support for JNI libraries

Change-Id: If958d11bac3506c4616a90d2c74f6d9d0aa6d02d

Signed-off-by: Kito Cheng <kito@0xlab.org>
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.

Change-Id: I7131b74ece1e46c8a9c0a31d103e686aa07da2bb
Runtime resource overlay, iteration 2

Support any number of overlays. Support any target package.

In runtime resource overlay, iteration 1, only a single overlay
package was considered. Matching was based on file paths
(/vendor/overlay/system/framework-res.apk corresponding to
/system/framework-res.apk). Introduce a more flexible identification of
overlay packages so that any package is an overlay package if if
specifies the following manifest

<manifest>
    <overlay target="T" priority="P"/>
</manifest>

where T is the package name of the target package, ie the package whose
resources are to be overlaid, and P is an integer [0, 9999] described
below.

During resource lookup, packages are queried to provide a best match
given a configuration. If any package can provide a better match than
what has been found so far, the previous match is discarded. The
priority value P provides the order in which to query overlay packages.
Packages with higher priority value will be queried later. Target
packages are always queried last.

Two overlay packages with the same priority targeting the same target
package leads to undefined behaviour.

The idmap file format has been updated to include the paths to the
corresponding target and overlay packages. This makes idmap files act
both as translation data and as control files: if an idmap file is
present, then and only then should its overlay be loaded. This makes
it possible to enable and disable installed overlay packages. To cache
idmap files, the asset manager considers symbolic links to idmap files
rather than the files themselves.

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').

For security and version matching reasons, apply a self-imposed
restriction on overlay packages: only load overlays from
/vendor/overlay. This restriction may be relaxed in a future iteration.

Change-Id: If49c963149369b1957f7d2303b3dd27f669ed24e
Runtime resource overlay, iteration 2

Support any number of overlays. Support any target package.

In runtime resource overlay, iteration 1, only a single overlay
package was considered. Matching was based on file paths
(/vendor/overlay/system/framework-res.apk corresponding to
/system/framework-res.apk). Introduce a more flexible identification of
overlay packages so that any package is an overlay package if if
specifies the following manifest

<manifest>
    <overlay target="T" priority="P"/>
</manifest>

where T is the package name of the target package, ie the package whose
resources are to be overlaid, and P is an integer [0, 9999] described
below.

During resource lookup, packages are queried to provide a best match
given a configuration. If any package can provide a better match than
what has been found so far, the previous match is discarded. The
priority value P provides the order in which to query overlay packages.
Packages with higher priority value will be queried later. Target
packages are always queried last.

Two overlay packages with the same priority targeting the same target
package leads to undefined behaviour.

The idmap file format has been updated to include the paths to the
corresponding target and overlay packages. This makes idmap files act
both as translation data and as control files: if an idmap file is
present, then and only then should its overlay be loaded. This makes
it possible to enable and disable installed overlay packages. To cache
idmap files, the asset manager considers symbolic links to idmap files
rather than the files themselves.

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').

For security and version matching reasons, apply a self-imposed
restriction on overlay packages: only load overlays from
/vendor/overlay. This restriction may be relaxed in a future iteration.

Change-Id: If49c963149369b1957f7d2303b3dd27f669ed24e

Conflicts:
	libs/androidfw/ResourceTypes.cpp
Runtime resource overlay, iteration 2, test cases

Add automated test cases for runtime resource overlay, iteration 2.

The tests cases are a mixture of python to run 'adb shell' commands and
regular instrumentation tests. Python is also used to reboot the Android
device between tests, to setup different overlay scenarios for
framework-res.apk.

Run core/tests/overlaytests/testrunner.py --help for more information on
how to execute the test suite.

Change-Id: I692aa1a7ad073efd116b24f9ec7f197dfd65dfef

Conflicts:
	core/res/res/values/config.xml
	core/res/res/values/symbols.xml
Fix build

Change-Id: Ia9514d0debe0b6b8e53d9bfeb8f7879b6811afd1