100 Commits

Author SHA1 Message Date
Adam Lesinski
347040cf84 am 740acf21: am c7801877: Merge "Fix issue where non-resource attributes would cause obtainStyleAttributes to fail" into lmp-mr1-dev
* commit '740acf213c56c406132294790fa2fadd0380cfa7':
  Fix issue where non-resource attributes would cause obtainStyleAttributes to fail
2014-12-11 00:07:02 +00:00
Adam Lesinski
5dce5e67db Fix issue where non-resource attributes would cause obtainStyleAttributes to fail
A sentinal value of 0x00000000 was used to mark the first time an AttributeFinder
was used. If the resource ID of an attribute was also 0x00000000 (which occurs with
non-resource attributes, like 'style'), then it would be mistaken as the sentinel
start value.

Bug:18421787
Change-Id: I4be353e0f8c940cb6f262d155129f048dcc444ae
2014-12-10 10:51:48 -08:00
Adam Lesinski
e97908d32e Merge commit '0953ab27' into manualmerge
Change-Id: I36dea45f7571096136ea7bda5e2680bd85a0df32
2014-12-05 11:06:21 -08:00
Adam Lesinski
8e5362f20e am 503071ae: am a2b5067a: Merge "RRO: prevent duplicate system overlays"
* commit '503071ae41374a66f61e53e05a91243473db83b9':
  RRO: prevent duplicate system overlays
2014-12-04 09:21:45 +00: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
a2b5067aee Merge "RRO: prevent duplicate system overlays" 2014-12-03 17:44:18 +00:00
Adam Lesinski
11bdd5b10b Merge commit '06d8b7b8' into manualmerge
Conflicts:
	core/jni/android_util_AssetManager.cpp

Change-Id: I77b72d0d3ec8184ccd97419e4c76b7d55b1a52ca
2014-11-17 12:17:16 -08:00
Andreas Gampe
5bf0c65eef am f89a2fda: Merge "Frameworks/base: Fix two warnings in cmds"
* commit 'f89a2fdacb2ba907f180188dc79f9de81e3eb254':
  Frameworks/base: Fix two warnings in cmds
2014-11-08 02:04:43 +00:00
Andreas Gampe
ebee1379ea Frameworks/base: Fix two warnings in cmds
Change-Id: Ifb9c7fb7a2d28c13010ddc186bea5f5f0daefb4a
2014-11-08 01:04:45 +00:00
Andreas Gampe
dc9c109af8 resolved conflicts for merge of 487ae9b8 to lmp-mr1-dev-plus-aosp
Change-Id: I395f184d885a7ef30aa113ab01fcaacc94243008
2014-11-07 15:14:02 -08:00
Andreas Gampe
2204f0bf56 Frameworks/base: Wall Werror in libs/androidfw
Turn on -Wall -Werror in libs/androidfw. Fix warnings. Refactor
some code.

Change-Id: I66fe54ace433c15dee5de328b149ca142f74b2dd
2014-11-07 13:35:05 -08:00
Mårten Kongstad
cb7b63d928 RRO: prevent duplicate system overlays
System overlays, ie overlays with targetPackage="android", were loaded
twice, which caused all sorts of issues. Ensure they are only loaded
once, which will be during Zygote initialization.

Bug: 17765434
Change-Id: Ia5064045c77f713c58fb78adc3942f6af1abdc93
2014-11-07 16:08:22 +01:00
Adam Lesinski
a7d1d73a47 Implement back-tracking when searching for attributes in XML or resource bag
Shared libraries have their package ID assigned at run-time, so some
of the guarantees we used to have about sort order of attributes in
bags or XML elements no longer hold.

This CL adds back-tracking and can jump to the nearest attribute with the
same package ID and continue searching.

This means that attributes with the same package ID must be sorted by increasing
resource ID, as was the case before.

Attributes with the same package ID must be grouped together, but the groups can
be in any order. Ex: 0x02010001, 0x02010002, 0x01010000, 0x01010010, 0x7f010032

Bug:17666947
Change-Id: I9c198bbb6ca788849aac85b6323606ea5d9550d6
2014-11-04 16:34:34 -08:00
Adam Lesinski
668f0a356c Merge "Fix issues that will be present in C++11" into lmp-mr1-dev 2014-11-03 23:38:43 +00: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
Alan Viverette
f296940502 Distinguish unspecified and explicit null values in resources
BUG: 17919345
Change-Id: Ic4f04f7dd0f986f58a749b5950d80c1cfdb074ea
2014-10-29 17:09:36 -07:00
Adam Lesinski
8d2556f0de am 8bdb265f: am 19f9d54f: Merge "Fix backwards compat problem with AAPT public attrs" into lmp-dev
* commit '8bdb265f0a73bc6f2114ca70f141c214a23696c7':
  Fix backwards compat problem with AAPT public attrs
2014-09-19 18:37:15 +00:00
Adam Lesinski
82a2dd8efe Fix backwards compat problem with AAPT public attrs
AAPT has traditionally assigned resource IDs to public attributes,
and then followed those public definitions with private attributes.

--- PUBLIC ---
| 0x01010234 | attr/color
| 0x01010235 | attr/background

--- PRIVATE ---
| 0x01010236 | attr/secret
| 0x01010237 | attr/shhh

Each release, when attributes are added, they take the place of the private
attributes and the private attributes are shifted down again.

--- PUBLIC ---
| 0x01010234 | attr/color
| 0x01010235 | attr/background
| 0x01010236 | attr/shinyNewAttr
| 0x01010237 | attr/highlyValuedFeature

--- PRIVATE ---
| 0x01010238 | attr/secret
| 0x01010239 | attr/shhh

Platform code may look for private attributes set in a theme. If an app
compiled against a newer version of the platform uses a new public
attribute that happens to have the same ID as the private attribute
the older platform is expecting, then the behavior is undefined.

We get around this by detecting any newly defined attributes (in L),
copy the resource into a -v21 qualified resource, and delete the
attribute from the original resource. This ensures that older platforms
don't see the new attribute, but when running on L+ platforms, the
attribute will be respected.

We still need to address this problem in the platform moving forward,
as this will only help us in the transition from pre L to L.

Bug:17520380
Change-Id: Ia2a985798b50006c21c7c3431d30d9598f27cd91
2014-09-18 14:05:24 -07:00
Dan Albert
20ec4fa229 resolved conflicts for merge of 6c585756 to lmp-dev-plus-aosp
Change-Id: I5a25f2bac44ac5efcd7462af91005e09680a1d96
2014-09-08 22:25:54 -07:00
Dan Albert
f348c15ecf Use char16_t for char things.
When compiling in C++ mode, the compiler will complain about conversions
from uint16_t to char16_t. Be consistent in using char16_t for strings.

Change-Id: I052b6176ced635162920b31560052d9a64f92764
2014-09-08 18:30:08 -07:00
Adam Lesinski
ad2d07d2d9 Stamp platform version code into app Apks
The versionCode of theframework resources that an app is built against
gets stamped inside an app's AndroidManifest.xml in the <manifest>
tag as "platformBuildVersionCode" and "platformBuildVersionName"
attributes.

Bug:17207635
Change-Id: Id573c3dffcbca38eec9c0eb3e89f4a547e3361d3
2014-08-27 18:28:49 -07:00
Adam Lesinski
31245b4f06 Introduce anydpi density resource qualifier
This is meant to be used with scaleable vector
drawables, and are chosen as the best match unless
there is a configuration that matches the density
requested exactly.

Bug:17007265
Change-Id: Ic3288d0236fe0bff20bb1599aba2582c25b0db32
2014-08-25 17:47:30 -07:00
Adam Lesinski
6022debdbc AAPT: Fix regression generating dynamic ref table for shared libraries
AAPT stopped generating dynamic reference tables for shared libraries.

Change-Id: Ib0025811bdca1a4756eb21080dd6b6bb3fc1ca3d
2014-08-20 17:55:33 -07:00
Adam Lesinski
833f3ccbc8 AAPT support for feature splits
This change allows the developer to add a base package for
which to build a feature split. The generated resource types
will begin after the base APK's defined types so as not
to collide or override resources.

Multiple features can be generated by first choosing an
arbitrary order for the features. Then for each feature,
the base APK and any preceding features are specified
with the --feature-of flags.

So with a base APK 'A' and features, 'B', and 'C',
'B' would be built with

aapt package [...] --feature-of A [...]

and 'C' would be built with

aapt package [...] --feature-of A --feature-of B [...]

Change-Id: I1be66e3f8df9a737b21c71f8a93685376c7e6780
2014-08-04 18:48:14 -07:00
Martin Kosiba
7df3625d5b Allow for appending of resources to an AssetManager.
BUG: 11505352
Change-Id: Ifa290580a6dc63c2f471d0bbf5f066db14aed4d7
2014-07-17 18:10:02 +01:00
Adam Lesinski
f90f2f8dc3 Support multiple resource tables with same package
In order to support APK split features, the resource
table needs to support loading multiple resource
tables with the same package but potentially new set
of type IDs.

This adds some complexity as the type ID space changes
from dense and ordered to potentially sparse.

A ByteBucketArray is used to store the type IDs in
a memory efficient way that allows for fast retrieval.

In addition, the IDMAP format has changed. We no longer
need random access to the type data, since we store the
types differently. However, random access to entries of
a given type is still required.

Change-Id: If6f5be680b405b368941d9c1f2b5d2ddca964160
2014-06-18 19:20:08 +00:00
John Spurlock
0a0454fdcc am 642421aa: am 5c31e487: Merge "Introduce new UI_MODE_TYPE_WATCH and qualifier." into klp-modular-dev
* commit '642421aa7f284817cc1a972a7f9c7a64696a0116':
  Introduce new UI_MODE_TYPE_WATCH and qualifier.
2014-04-04 19:34:11 +00:00
John Spurlock
642421aa7f am 5c31e487: Merge "Introduce new UI_MODE_TYPE_WATCH and qualifier." into klp-modular-dev
* commit '5c31e487c4577e1c47ee7c949325d6a13f0d462e':
  Introduce new UI_MODE_TYPE_WATCH and qualifier.
2014-04-04 19:28:09 +00:00
John Spurlock
6c191299a7 Introduce new UI_MODE_TYPE_WATCH and qualifier.
Default ui mode to watch if we have FEATURE_WATCH.

Bug:13395758
Change-Id: Ie5ff95de60e69e91ad3612c7d2f1fca7f49061bd
2014-04-04 15:21:53 -04:00
Adam Lesinski
de898ff429 Shared library resource support
Shared libraries can now export resources for applications
to use.

Exporting resources works the same way the framework exports
resources, by defining the public symbols in res/values/public.xml.

Building a shared library requires aapt to be invoked with the
--shared-lib option. Shared libraries will be assigned a package
ID of 0x00 at build-time. At runtime, all loaded shared libraries
will be assigned a new package ID.

Currently, shared libraries should not import other shared libraries,
as those dependencies will not be loaded at runtime.

At runtime, reflection is used to update the package ID of resource
symbols in the shared library's R class file. The package name of
the R class file is assumed to be the same as the shared library's
package name declared in its manifest. This will be customizable in
a future commit.

See /tests/SharedLibrary/ for examples of a shared library and its
client.

Bug:12724178
Change-Id: I60c0cb8ab87849f8f8a1a13431562fe8603020a7
2014-03-25 12:09:56 -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
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
Dianne Hackborn
4385d37813 Fix build.
At least part of what is broken.  Other stuff still seems to be.

(cherry picked from 32bb5fae353b5bb6275e75952e89c514c7369cee)

Change-Id: I280376645166fe772ff7a31ff2e8494dce2adbf8
2014-02-12 10:11:34 +00: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
Michael Wright
d6b473713f Move inputservice over to frameworks/native
Remove all of the pieces except the PointerController and SpriteController over
to frameworks/native in preparation for inputflinger. Those two need to stay in
frameworks/base for now because they depend on Skia currently. In the long run
they should be merged into either the InputManager or the WindowManager rather
than as a part of the inputservice / inputflinger.

Try 2.

Change-Id: I84259356d3eb8efc5aefb9d6b311b5fc590ea3ed
2014-02-11 10:47:36 -08: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
Christopher Tate
ca0b0c18e7 Fix MCC/MNC typo
Manual merge of https://android-review.googlesource.com/70831 across
the header refactoring.

Change-Id: I28b6a61e89b68d914124122882976a9d2f81a609
2014-01-27 10:31:11 -08:00