362 Commits

Author SHA1 Message Date
Adam Lesinski
25f48886b2 ResourcesManager: Allow managed addition of library asset paths
This allows WebView to add itself to the ResourcesManager and
remain their even after configuration changes and multi-window
changes.

Bug:29112218
Change-Id: I2cb131ae2c61fb58c48babafdd46c1882be96aa9
2016-06-15 12:00:18 -07:00
Adam Lesinski
76da37e1cf Performance improvements in AssetManager
Change the implementation of getLocales() to iterate the set of
configurations using a templated method, instead of using the result
of getConfigurations().

Also remove the check for AndroidManifest.xml when adding an asset path.
This is unneccessary.

Bug:28625993
Change-Id: I16de5da598d0c371421d1dc8eee054dce9baf53a
2016-05-20 15:04:09 -07:00
Adam Lesinski
8ac51d14b6 Resource shared libraries: fix theme references
Theme values that would reference other theme values would not work
if they were declared in a shared library.

We now introduce a parallel resource type to TYPE_DYNAMIC_REFERENCE,
TYPE_DYNAMIC_ATTRIBUTE, which allows us to lookup and resolve
theme value references from shared libraries.

Bug:28687378
Change-Id: I4f2364e3e8b567679f90784fcaaea12b6b05e926
2016-05-10 10:45:52 -07:00
Shammi Khattar
7134ce3540 ZipUtils: Fix wrong timestamps when getEntryInfo
"tm_mon" format should align with "ZipEntry::setModWhen" in aapt.
"tm_isdst" should be initialized, or it will because random value
and cause error in function mktime().

BUG:28021145

(cherry picked from commit bb0eb3f4cb33c077b296a18555a9a1a966ff696b)

Change-Id: Ia39cf63fcd4bb39c24af080562960279106f526c
2016-04-28 15:07:34 +00:00
Adam Lesinski
666b6fbba1 Fix order of operation issue with ResStringPool
Due to ! taking precedence over bitwise &, the condition for
checking non-null terminated string blocks is incorrect.

Adds parentheses for the correct behavior.

Bug:28288210
Change-Id: Ie31fa239e5f869e6bb28deb6ae190f41f1aa4d92
2016-04-21 10:05:06 -07:00
Adam Lesinski
b7e1ce0775 Optimize ResTable::getLocales() to improve bindApplication performance
Change from linear searching for uniqueness to binary search.

Bug:27198799
Change-Id: I1ccb6e93cc213810848f07d631d9d8de7c719803
2016-04-18 15:06:50 -07:00
Tim Murray
98e80076c6 Revert "Optimize ResTable::getLocales() to improve bindApplication performance"
This reverts commit 5520581b5f043fb858b5b2044ff33ad8545a6d38.

bug 28189634

Change-Id: I2d2b859f6d9bd44434fa901cce990583f514980c
2016-04-14 16:06:29 -07:00
Adam Lesinski
5520581b5f Optimize ResTable::getLocales() to improve bindApplication performance
Change from linear searching for uniqueness to binary search.

Bug:27198799
Change-Id: Ifa4672929df286c4693ab1f77716f08945941b0c
2016-04-13 13:25:09 -07:00
Adam Lesinski
1d7172e598 AAPT2: Suppress warnings from libandroidfw when built for host
Certain error cases are expected (like not finding a package) when
using libandroidfw on the host side for AAPT2. Suppress those warnings
and let AAPT2 handle error cases.

Change-Id: I3de97128686c03c89c5b99559bf46d4f2f1dfe4d
2016-03-30 16:22:33 -07:00
Adam Lesinski
ff5808d223 AssetManager: Cache a pre-filtered list of configurations
When we set the parameters for a ResTable, we can pre-filter which
resources match and only look at that smaller list when getting entries.
This helps A LOT with types that have many configurations, like strings
and all their various locales.

We must store the cached entries in a parallel data structure because parts
of the main Type object are shared with other ResTables, causing data races.

Bug:25499111
Change-Id: I63e37dcbd683fc9f1e7d0f3a6ed4c1c01e0fc575
2016-03-09 17:33:14 -08:00
Adam Lesinski
53185a50d1 Merge "Revert "AssetManager: Cache a pre-filtered list of configurations"" into nyc-dev 2016-03-07 20:22:24 +00:00
Adam Lesinski
fa7d78ae87 Revert "AssetManager: Cache a pre-filtered list of configurations"
There is a race due to the modification of shared data structures in the framework ResTable.

See b/27499488

This reverts commit d4b169173ad7805369204277580d3942cb08174a.

Change-Id: I3f400a2ad3b5ffc652b84dd5fe777f7cf34b5548
2016-03-07 19:39:56 +00:00
Roozbeh Pournader
7960898f6f Fix script-related parts of locale resource matching
Previously, a bit was kept to find if the script of a locale was
explicitly "provided" in a resource. This was not backward
compatible, and failed in some edge cases when the package was
created with older versions of AAPT that did not set the bit.

The cases would happen when the old resource had an explicit script
specified in its locale, but since the "provided" bit was not set in
the package, we would assume that the script was computed by us.

This CL replaces the "provided" bit with a "computed" bit, so the
default value of the bit (set to "false" for old packages) would be
correct.

Bug: 27156990
Change-Id: I99e7f1ad8f70c90e25ab3640ed34cc1a6f8d1d64
2016-03-03 15:19:37 -08:00
Adam Lesinski
d4b169173a AssetManager: Cache a pre-filtered list of configurations
When we set the parameters for a ResTable, we can pre-filter which
resources match and only look at that smaller list when getting entries.
This helps A LOT with types that have many configurations, like strings
and all their various locales.

Bug:25499111
Change-Id: Ie6894c44bc67e16a10dbe028c8f3e119e5c29ac7
2016-02-25 15:29:17 -08:00
Roozbeh Pournader
4de4596ac1 Fix locale matching algorithm for resources
We get ResTables two different ways: one is from AAPT, another from
settings-based requests from the Java side. In the settings-based
requests, localeScript will be autocomputed, but for AAPT-filled
tables (especially if they come from older versions of AAPT), we need
to compute the script.

Previously, locales that came from packages were incorrectly assumed
to have "undeterminable" scripts, rather than "undetermined" scripts.
This led to us mistakenly falling back to the old logic of requiring
the locales' countries to match, rather than just looking at computed
scripts.

Bug: 27157452

Change-Id: Id7e346d3ecfb17273ffb63de5bcb4849a6eafbbd
2016-02-12 05:18:38 +00:00
Roozbeh Pournader
27953c349f Make default resources a better match for en-US requests
When locale fallback landed, resources which specified an 'English'
locale started to be considered a better match for en-US, even though
traditionally, apps tend to ship US English resources under their
default locale.

This fixes that, and makes en-US requests match default locales.

Bug: 26756573
Bug: 26789680
Bug: 26803868
Change-Id: I460c276bfc6ddba0439dcdf87497a0aece0fa05d
2016-02-01 14:56:52 -08:00
John Reck
1a2d84acbd ALOGE is not ALOGV
Change-Id: I973cd7ce28bed38934aab0818e581a948a12cb42
2016-01-22 09:17:41 -08:00
Michael Wright
6cfa1cc4b0 Merge "Add choreographer API to the NDK." 2016-01-22 00:31:40 +00:00
Michael Wright
3d3fe5026a Add choreographer API to the NDK.
Change-Id: Icb8cffd3cd3bd06814466be72db3e26f6a62cbc6
2016-01-21 16:30:33 -08:00
Roozbeh Pournader
b927c559e1 Implement smarter locale resource selection
* Add support for determining script from language and region.
* Add support for determining special parents of locales.
* Add support for smart comparison of locales with only a difference
  in region, using the locale parentage tree.
* Fix LocaleData.matchScore() to not fallback to old locale matching
  behavior if we can't determine a script.
* Allow four-character variant codes. (Previously, only five- to
  eight-character variant codes were allowed.)

Bug: 7296673
Bug: 26589793
Change-Id: Ibde0a48c0564ff383b41068095a5cbacfe7b94bc
2016-01-21 13:47:22 -08:00
Roozbeh Pournader
1c686f2ce6 Avoid matching system locales in locale negotiation
Also:
1. Add AssetManager method for finding non-system locales: This is
used in per-app locale negotiation. (Normally,
AssetManager#getLocales() returns both system and non-system
locales.)

2. Match pseudolocales correctly in locale negotiation.

Bug: 25800576
Bug: 26236938
Change-Id: I116caf3a91c290deb4ad68b291c65b7035b18dd4
2016-01-04 13:53:54 -08:00
Tao Bai
1375e5f180 Add test to cover loading shared-lib with appAsLib as true.
This patch made AppAsLib_test use its own resource

Bug 22487604

Change-Id: Iac4cc949f1b25c326a287a49e0b031bf6831e9e9
2015-11-06 14:33:49 -08:00
Tao Bai
ab5bca1519 Merge "Load app resource as shared library." 2015-09-09 16:08:12 +00:00
Tao Bai
a6d7e3fb9c Load app resource as shared library.
- Added aapt command line flag --app-as-shared-lib to build app resources
  that could be loaded as shared lib at runtime.
- Added new method AssetManager.addAssetPathAsSharedLibrary() to load an
  app resource as shared library.

Bug 22487604

Change-Id: Ib9b33c35f9c2b7129f3ba205de03d4564623ea39
2015-09-08 18:48:42 -07:00
Dan Willemsen
a3e05c4ccb am 83533a23: am 13786e28: am 60dd5d59: Merge "Remove USE_MINGW, whitelist windows modules"
* commit '83533a235c64a3b3cbecf152b678585f1e6b3577':
  Remove USE_MINGW, whitelist windows modules
2015-09-01 17:05:59 +00:00
Dan Willemsen
13786e281e am 60dd5d59: Merge "Remove USE_MINGW, whitelist windows modules"
* commit '60dd5d5966ebe993f5a81c46d9dea62c207abfd3':
  Remove USE_MINGW, whitelist windows modules
2015-09-01 16:37:10 +00:00
Dan Willemsen
4aa679ff96 Remove USE_MINGW, whitelist windows modules
Bug: 23566667
Change-Id: Ie6b8c51e2b6d6273f99f4e361c440136d7c6915c
2015-08-28 15:28:26 -07:00
Dan Albert
344e838d22 am 598319d0: am 16e5aba9: am 4a2a890b: Merge "Fix mismatched new[]/delete."
* commit '598319d01743427aa67faf4f54ae6d837c8c6d2e':
  Fix mismatched new[]/delete.
2015-08-14 21:49:13 +00:00
Dan Albert
598319d017 am 16e5aba9: am 4a2a890b: Merge "Fix mismatched new[]/delete."
* commit '16e5aba9c8157b3ffdcdceda378896a43f074748':
  Fix mismatched new[]/delete.
2015-08-14 21:43:19 +00:00
Dan Albert
f13f1efab2 am 16e5aba9: am 4a2a890b: Merge "Fix mismatched new[]/delete."
* commit '16e5aba9c8157b3ffdcdceda378896a43f074748':
  Fix mismatched new[]/delete.
2015-08-14 21:43:16 +00:00
Dan Albert
8dc8313c3e Fix mismatched new[]/delete.
The new clang will emit a warning for this.

Change-Id: Ie0edc46461eb5edb2a7ad33a3a7f6cef2d825c36
2015-08-14 14:12:29 -07:00
Elliott Hughes
4c807349bd am 344d347a: am 39669d7f: am 6fdc6333: Merge "Lose HAVE_ANDROID_OS from frameworks/base."
* commit '344d347af22705aa2fa80602d27a5682a72b5f69':
  Lose HAVE_ANDROID_OS from frameworks/base.
2015-08-12 23:56:18 +00:00
Elliott Hughes
344d347af2 am 39669d7f: am 6fdc6333: Merge "Lose HAVE_ANDROID_OS from frameworks/base."
* commit '39669d7f6b8fedef3468ab3d417c93a21df528af':
  Lose HAVE_ANDROID_OS from frameworks/base.
2015-08-12 23:28:30 +00:00
Elliott Hughes
17b4be07fe am 39669d7f: am 6fdc6333: Merge "Lose HAVE_ANDROID_OS from frameworks/base."
* commit '39669d7f6b8fedef3468ab3d417c93a21df528af':
  Lose HAVE_ANDROID_OS from frameworks/base.
2015-08-12 23:21:56 +00:00
Elliott Hughes
ba3fe56edc Lose HAVE_ANDROID_OS from frameworks/base.
Change-Id: I713881fdbaec7cbbb5e7f2f4be6f9b8be3d2ca4e
2015-08-12 14:49:53 -07:00
Filip Gruszczynski
2349332f9f Only relaunch activity on significant size configuration changes.
Currently if the configuration width/height/smallest width changes, we
relaunch the activity or invoke onConfigurationChanged callback. When it
comes to size based configuration changes it might not be necessary: if
the size change doesn't pass one of the threshold defined by the
resources, it means there is no need to relaunch the activity.

In this CL the ActivityManager will receive the thresholds from the
application and use them to decide, whether to relaunch the activity.
The application reads the thresholds from the resources, specifically
from resource qualifiers used by the app.

Change-Id: Ie3cf0a172dc1ba0b865cf30c2962e7cfd9ad8436
2015-08-10 13:47:31 -07:00
Yusuke Sato
3a4d02220f am 61234dea: am bd4c482b: Merge "Clean up AssetManager::scanAndMergeZipLocked"
* commit '61234deafe78ded05569edfab24536cdb4bd7720':
  Clean up AssetManager::scanAndMergeZipLocked
2015-08-06 01:40:24 +00:00
Yusuke Sato
e15a5871bd am 61234dea: am bd4c482b: Merge "Clean up AssetManager::scanAndMergeZipLocked"
* commit '61234deafe78ded05569edfab24536cdb4bd7720':
  Clean up AssetManager::scanAndMergeZipLocked
2015-08-06 01:39:44 +00:00
Yusuke Sato
c1efd41f3f Fix build breakage caused by I5ebe0438019958d883a7fda6bd92ea4484211d23 (AOSP)
Change-Id: Icea0ac00c56b5c8aa21134fc49b518cda4759e36
2015-08-05 14:41:52 -07:00
Yusuke Sato
fa451e3776 am 5387f60b: Merge "Fix build breakage caused by r.android.com/162907" into mnc-dr-dev-plus-aosp
* commit '5387f60ba26ae89e31e776202fbf13287dc620a8':
  Fix build breakage caused by r.android.com/162907
2015-08-05 20:44:58 +00:00
Yusuke Sato
6120883971 am 3251f2aa: am 3383b141: am a024acb8: Merge "Let findSupportedAbi and hasRenderscriptBitcode scan only relevant files"
* commit '3251f2aab75c8c905cc59b428d99812b5575ebdb':
  Let findSupportedAbi and hasRenderscriptBitcode scan only relevant files
2015-08-05 20:36:43 +00:00
Yusuke Sato
ead2088efe Fix build breakage caused by r.android.com/162907
Change-Id: Ifeb7b57ce79f3d8c0edadf03d14853e72840d49e
2015-08-05 13:14:53 -07:00
Yusuke Sato
3251f2aab7 am 3383b141: am a024acb8: Merge "Let findSupportedAbi and hasRenderscriptBitcode scan only relevant files"
* commit '3383b141c3ac4426279e649ebcee535890203c3f':
  Let findSupportedAbi and hasRenderscriptBitcode scan only relevant files
2015-08-05 19:09:41 +00:00
Yusuke Sato
eb24da62ac am 3383b141: am a024acb8: Merge "Let findSupportedAbi and hasRenderscriptBitcode scan only relevant files"
* commit '3383b141c3ac4426279e649ebcee535890203c3f':
  Let findSupportedAbi and hasRenderscriptBitcode scan only relevant files
2015-08-05 19:05:17 +00:00
Yusuke Sato
05f648e1d3 Clean up AssetManager::scanAndMergeZipLocked
Now that ZipFileRO::startIteration supports prefix/suffix matching,
we can pass dirName to the function for simpler code and slightly
better performance.

(cherry-pick of c796ad0a8be6df4a3b354690dfe5ce1df8136c09)

Change-Id: I0e2ac58de28020c2af8d8e569a97592b09596185
2015-08-03 17:24:42 -07:00
Yusuke Sato
957c23775f Let findSupportedAbi and hasRenderscriptBitcode scan only relevant files
for better performance. Without the optimization, these two functions
may check more than 100k file names in the pre-installed APK files,
which can take a few seconds to finish even on a recent device.

(cherry-pick of 34fe3df8519523dbb4bc27010fa57f259d5e868d)

Bug: 21957428
Change-Id: I5ebe0438019958d883a7fda6bd92ea4484211d23
2015-08-03 17:24:32 -07:00
Yusuke Sato
7bfd7048f2 Merge "Clean up AssetManager::scanAndMergeZipLocked" 2015-08-03 17:41:19 +00:00
Elliott Hughes
1db1b5821f am 204b4157: am f8a6a2f6: Merge "Use _WIN32 rather than HAVE_WINSOCK."
* commit '204b4157b3fdbeea8859c4ad0e29be18d74e6f5f':
  Use _WIN32 rather than HAVE_WINSOCK.
2015-07-30 15:47:11 +00:00
Elliott Hughes
d065fd415c am 204b4157: am f8a6a2f6: Merge "Use _WIN32 rather than HAVE_WINSOCK."
* commit '204b4157b3fdbeea8859c4ad0e29be18d74e6f5f':
  Use _WIN32 rather than HAVE_WINSOCK.
2015-07-30 15:46:55 +00:00
Elliott Hughes
59cbe8d107 Use _WIN32 rather than HAVE_WINSOCK.
Change-Id: I0821d2af8473c359e8b73aec455000cb7c42f690
2015-07-29 17:49:27 -07:00