OSDN Git Service

Offer to cache ContentResolver-related Bundles.
authorJeff Sharkey <jsharkey@android.com>
Sat, 12 Mar 2016 00:25:11 +0000 (17:25 -0700)
committerJeff Sharkey <jsharkey@android.com>
Mon, 14 Mar 2016 17:45:50 +0000 (11:45 -0600)
commit8731408b11a24e3a92188653548f2c90bf866a32
treec00e9166958a03623a7b78d0169c4537c330ec15
parentc070a099f5e96d7d6eb4553b9d4591708bab20af
Offer to cache ContentResolver-related Bundles.

There are a handful of core system services that collect data from
third-party ContentProviders by spinning them up and then caching the
results locally in memory.  However, if those apps are killed due to
low-memory pressure, they lose that cached data and have to collect
it again from scratch.  It's impossible for those apps to maintain a
correct cache when not running, since they'll miss out on Uri change
notifications.

To work around this, this change introducing a narrowly-scoped
caching mechanism that maps from Uris to Bundles.  The cache is
isolated per-user and per-calling-package, and internally it's
optimized to keep the Uri notification flow as fast as possible.
Each Bundle is invalidated whenever a notification event for a Uri
key is sent, or when the package hosting the provider is changed.

This change also wires up DocumentsUI to use this new mechanism,
which improves cold-start performance from 3300ms to 1800ms.  The
more DocumentsProviders a system has, the more pronounced this
benefit is.  Use BOOT_COMPLETED to build the cache at boot.

Add more permission docs, send a missing extra in DATA_CLEARED
broadcast.

Bug: 18406595
Change-Id: If3eae14bb3c69a8b83a65f530e081efc3b34d4bc
core/java/android/content/ContentResolver.java
core/java/android/content/IContentService.aidl
core/res/AndroidManifest.xml
packages/DocumentsUI/AndroidManifest.xml
packages/DocumentsUI/src/com/android/documentsui/BootReceiver.java [new file with mode: 0644]
packages/DocumentsUI/src/com/android/documentsui/RootsCache.java
packages/DocumentsUI/src/com/android/documentsui/model/RootInfo.java
services/core/java/com/android/server/am/ActivityManagerService.java
services/core/java/com/android/server/content/ContentService.java