OSDN Git Service

Extended locales in AAPT / AssetManager.
authorNarayan Kamath <narayan@google.com>
Tue, 21 Jan 2014 15:32:36 +0000 (15:32 +0000)
committerNarayan Kamath <narayan@google.com>
Mon, 10 Feb 2014 15:50:16 +0000 (15:50 +0000)
commit91447d88f2bdf9c2bf8d1a53570efef6172fba74
treedc46e96130696c26e8fd3883227314ef5c0b7ad1
parent378c6775a62d9c461cde51f06c1b14bb014c78fd
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
13 files changed:
core/java/android/content/res/Resources.java
include/androidfw/ResourceTypes.h
libs/androidfw/AssetManager.cpp
libs/androidfw/ResourceTypes.cpp
libs/androidfw/tests/ResourceTypes_test.cpp
tools/aapt/AaptAssets.cpp
tools/aapt/AaptAssets.h
tools/aapt/Command.cpp
tools/aapt/Resource.cpp
tools/aapt/ResourceFilter.cpp
tools/aapt/ResourceFilter.h
tools/aapt/ResourceIdCache.h
tools/aapt/ResourceTable.cpp