summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/ContentResolver.java
Commit message (Collapse)AuthorAgeFilesLines
* Use myUserId() only in registerContentObserver()Christopher Tate2012-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The reason for this is a bit subtle: we want to guarantee that when a content observer is registered using the public API, it is *always* bound to the host user's view of the data behind the observed Uri, never the calling user's. Now, the reason it was the calling user in the first place is that the Settings provider (and potentially any singleton provider) needs the observers underlying Cursors returned from query() to be tied to the caller's user, not the provider's host user. In order to accomplish that now that the public-facing behavior is always tied to the host user, the concrete class that implements the Cursor type handled by the Settings provider has been extended with a new hidden API for setting a notification observer tied to an arbitrary user; and then the provider explicitly downcasts the query result's Cursor to that class in order to register the notification observer. We can do this safely because this is platform code; if we change the way that these underlying cursors are constructed, we can just fix this point of call to follow along. If they get out of sync in the future, the Settings provider will scream bloody murder in the log and throw a crashing exception. Bug 7231549 Change-Id: I0aaceebb8b4108c56f8b9964ca7f9e698ddd91c8
* Multiuser awareness in content observer infrastructureChristopher Tate2012-09-201-2/+2
| | | | | | | | | | | | | | | | | | Content observers are registered under the calling user's identity, not under the provider host's identity (unless the caller is using the new permissioned entry points that allow observers to be registered for a different user's view of the data). The most important implication of this is that when the settings provider is directly queried, the Cursor returned to the app is wired for change notifications based on that calling app's user. Note that it is not possible to use query() / insert() to read/write data for different users. All such manipulations should use the standard get* / put* methods in Settings.*. Bug 7122169 Change-Id: If5d9ec44927e5e56e4e7635438f4ef48a5430986
* Per-user content observer APIsChristopher Tate2012-09-171-2/+20
| | | | | | | | | | | | | | | | | | | | Callers with INTERACT_ACROSS_USERS_FULL permission can now observe content for a given user's view (and can notify content uri changes targeted to a specific user). An observer watching for UserHandle.USER_ALL will see all notifications for the given uri across all users; similarly, a notifier who specifies USER_ALL will broadcast the change to all observers across all users. The API handles both USER_ALL or USER_CURRENT, and explicitly forbids any other "pseudouser" designations. This CL also revs the Settings provider to notify with USER_ALL for changes to global settings, and with only the affected user's handle for all other changes. Bug 7122169 Change-Id: I94248b11aa91d1beb0a36432e82fe5725bb1264f
* More multi-user stuff:Dianne Hackborn2012-09-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - New (hidden) isUserRunning() API. - Maintain LRU list of visited users. - New FLAG_IS_DATA_ONLY for ApplicationInfo. - Clean up pending intent records when force-stopping a user (or package). (Also fixes bug #6880627: PendingIntent.getService() returns stale intent of force stopped app) - Fix force-stopping when installing an app to do the force-stop across all users for that app. - When selecting which processes to kill during a force stop, do this based on the actual packages loaded in the process, not just process name matching. - You can now use --user option in am when starting activities, services, and instrumentation. - The am --user option accepts "current" and "all" as arguments. - The pm uninstall command now uninstalls for all users, so it matches the semantics of the install command. - PhoneWindowManager now explicitly says to start home in the current user. - Activity manager call to retrieve the MIME type from a content provider now takes a user argument, so it will direct this to the proper user. - The package manager uninstall paths are now implemented around PackageSetting, not PackageParser.Package. This allows them to work even if the application's apk has been removed (in which case it only exists as a PackageSetting, not the PackageParser.Package parsed from the apk). Change-Id: I3522f6fcf32603090bd6e01cc90ce70b6c5aae40
* Added or fixed doctrings for required permissions.Nicolas Falliere2012-06-181-0/+30
| | | | | Bug: 6591338 Change-Id: Ia2092f9994854701b5fa1425c371817367ae07ec
* Fix (mostly) issue #5109947: Race condition between retrieving a...Dianne Hackborn2012-05-291-93/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...content provider and updating its oom adj This introduces the concept of an "unstable" reference on a content provider. When holding such a reference (and no normal stable ref), the content provider dying will not cause the client process to be killed. This is used in ContentResolver.query(), .openAssetFileDescriptor(), and .openTypedAssetFileDescriptor() to first access the provider with an unstable reference, and if at the point of calling into the provider we find it is dead then acquiring a new stable reference and doing the operation again. Thus if the provider process dies at any point until we get the result back, our own process will not be killed and we can safely retry the operation. Arguably there is still the potential for a race -- if somehow the provider is killed way late by the OOM killer after the query or open has returned -- but this should now be *extremely* unlikely. We also continue to have the issue with the other calls, but these are much less critical, and the same model can't be used there (we wouldn't want to execute two insert operations for example). The implementation of this required some significant changes to the underlying plumbing of content providers, now keeping track of the two different reference counts, and managing them appropriately. To facilitate this, the activity manager now has a formal connection object for a client reference on a content provider, which hands to the application when opening the provider. These changes have allowed a lot of the code to be cleaned up and subtle issues closed. For example, when a process is crashing, we now have a much better idea of the state of content provider clients (olding a stable ref, unstable ref, or waiting for it to launch), so that we can correctly handle each of these. The client side code is also a fair amount cleaner, though in the future there is more than should be done. In particular, the two ProviderClientRecord and ProviderRefCount classes should be combined into one, part of which is exposed to the ContentResolver internal API as a reference on a content provider with methods for updating reference counts and such. Some day we'll do that. Change-Id: I87b10d1b67573ab899e09ca428f1b556fd669c8c
* Add infrastructure for accessing "unstable" content providers.Dianne Hackborn2012-05-091-53/+155
| | | | | | | We have an API and some stuff that purports to this, but no real implementation yet. Change-Id: I93555440014a50fdf79fa3f65318d90fb82265b4
* Move CancellationSignal to android.os package.Jeff Brown2012-05-071-0/+3
| | | | | Bug: 6427830 Change-Id: I39451bb1e1d4a8d976ed1c671234f0c8c61658dd
* Add direct support for HTML formatted text in ClipData etc.Dianne Hackborn2012-04-131-1/+1
| | | | | | | | | | | When using the clipboard, ACTION_SEND, etc., you can now supply HTML formatted text as one of the representations. This is exposed as a set of methods on ClipData for building items with HTML formatted text, and retrieving and coercing to HTML (and styled) text. In addtion, there is a new EXTRA_HTML_TEXT for interoperating with the old ACTION_SEND protocol. Change-Id: I8846520a480c8a5f829ec1e693aeebd425ac170d
* Fix obvious typos under frameworks/base/coreKen Wakasa2012-03-091-1/+1
| | | | Change-Id: Ia5fc3db1bb51824e7523885553be926bcc42d736
* am dbc591e2: am c69d6134: am 6ae4fe94: am 9303919d: Merge "Adds ↵Jean-Baptiste Queru2012-03-011-1/+6
|\ | | | | | | | | | | | | documentation for ContentResolver notifyChange()" * commit 'dbc591e27686486c732fca2f94fde645e3487b7a': Adds documentation for ContentResolver notifyChange()
| * Adds documentation for ContentResolver notifyChange()Steve Pomeroy2012-01-181-1/+6
| | | | | | | | | | | | | | | | Adds clarifying documentation to ContentResolver#notifyChange() to explain interaction with the sync framework. Change-Id: Ia1a1ed173e230bc11aa778268749323536ca434f Signed-off-by: Steve Pomeroy <steve@staticfree.info>
* | Rename CancellationSignal using preferred spelling.Jeff Brown2012-02-021-8/+8
| | | | | | | | | | Bug: 5943637 Change-Id: I12a339f285f4db58e79acb5fd8ec2fc1acda5265
* | Implement a cancelation mechanism for queries.Jeff Brown2012-01-271-1/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | Added new API to enable cancelation of SQLite and content provider queries by means of a CancelationSignal object. The application creates a CancelationSignal object and passes it as an argument to the query. The cancelation signal can then be used to cancel the query while it is executing. If the cancelation signal is raised before the query is executed, then it is immediately terminated. Change-Id: If2c76e9a7e56ea5e98768b6d4f225f0a1ca61c61
* | Clean up content observer code.Jeff Brown2012-01-231-4/+10
|/ | | | | | | | | | | | | | | | Improved the documentation a little bit. Fixed a bug in ContentService wherein if a ContentObserver was passed as an argument and its deliverSelfNotifications() method returned true, then notifyChange would tell all observers that the change was a self-change even though it was only a self-change from the perspective of the provided observer. Deprecated ContentObservable.notifyChange since it is never used and in general it shouldn't be because we want the notification to be posted to the handler. Change-Id: Idde49eb40777e011a068f2adae8a32f779dfb923
* Merge "Add a CrossProcessCursorWrapper. Bug: 5220669"Jeff Brown2011-10-141-1/+2
|\
| * Add a CrossProcessCursorWrapper.Jeff Brown2011-10-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 5220669 The CrossProcessCursorWrapper is a useful building block for wrapping cursors that will be sent to processes remotely. It can also transform normal Cursors into CrossProcessCursors transparently. The new class fixes common performance problems and bugs that applications have encountered when implementing ContentProviders. Change-Id: Icc59fec10add3f7d8cfbd0495447860c1872c752
* | docs: add developer guide cross-references, Project ACRE, Round 2Joe Fernandez2011-10-141-0/+6
|/ | | | Change-Id: I39a534ae3a2a34b4dabc333a09961012ef911d3e
* Implement CloseGuard in ContentResolver.Jeff Brown2011-10-091-5/+20
| | | | | | | | Also, don't try to close the cursor from the finalizer, it just won't work because quite probably the Binder underneath it has already been finalized or is about to be. Change-Id: I6363cd30f32abe15412948d126e0bcc5f62943c5
* Fix a bug where a provider could be never released.Jean Chalard2011-07-281-2/+2
| | | | | Bug: 5034192 Change-Id: I5d4adf27ea933687d4a0bc5ee76d57b74e708eec
* Remove the deprecated things from Config.java. These haven't been working ↵Joe Onorato2011-04-071-3/+2
| | | | | | since before 1.0. Change-Id: Ic2e8fa68797ea9d486f4117f3d82c98233cdab1e
* am 2e390809: Merge "Unhide Content{Resolver,Provider}.call()" into honeycombBrad Fitzpatrick2011-01-121-4/+57
|\ | | | | | | | | * commit '2e3908097b1c86004d50c0a070ca6b76a4d0d7c5': Unhide Content{Resolver,Provider}.call()
| * Unhide Content{Resolver,Provider}.call()Brad Fitzpatrick2011-01-121-4/+57
| | | | | | | | Change-Id: Ic7833b921f5a8e70ef7d565bfdf461e6e135ff1b
* | am 52d70722: am cb842753: Merge "Closing cursor in finalizer to avoid GREF ↵Brad Fitzpatrick2011-01-121-1/+3
|\ \ | |/ |/| | | | | | | | | and fd leak in acore" * commit '52d70722654548d156bd7a1cb8c1f05b94b09f06': Closing cursor in finalizer to avoid GREF and fd leak in acore
| * Closing cursor in finalizer to avoid GREF and fd leak in acoreJohannes Carlsson2011-01-101-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The finalize() call did not clean up completely, this eventually caused the android.process.acore to crash since it ran out of fds and GREF to increased above 2000 if an application forgot to close its cursor objects. A warning was also added when this happens so that application developers can correct their mistake. The included test case tries to verify that the finalizer works as expected by creating a bunch of Cursor objects without closing them (without this fix the acore process crashes after about 400 iterations and the test case ends with "Process crashed"). Change-Id: I11e485cef1ac02e718b2742108aa88793666c31d
* | am e90a1b16: am 752942ec: Merge "The phone is crashing when unknown mime ↵Jean-Baptiste Queru2010-12-281-0/+4
|\ \ | |/ | | | | | | | | | | content is transferred." * commit 'e90a1b16a3d6c559cb7fc47ad967a1810d88e923': The phone is crashing when unknown mime content is transferred.
| * The phone is crashing when unknown mime content is transferred.Ola Olsson2010-12-211-0/+4
| | | | | | | | | | | | | | The content resolver does not take care of the IllegalStateException that is thrown in getType and that needs to be fixed. Change-Id: I3e66f1aa259ab91fb9233e1ba07faa1ab6c3f2dd
* | Add getCurrentSyncs() to the SDK, which replaces the deprecatedFred Quintana2010-10-081-2/+26
| | | | | | | | | | | | getCurrentSync(). Change-Id: I1112df41e48ed93ff4c0c5af4825dbdce0c4cccc
* | resolved conflicts for merge of a8bce7c8 to masterDianne Hackborn2010-09-271-4/+3
|\ \ | |/ | | | | Change-Id: I34526a3aed6591639e1a1bff8f42e0c5d8e328cc
| * Allow all apps to call ContentResolver.getType().Dianne Hackborn2010-09-261-12/+46
| | | | | | | | | | | | | | | | | | I can't find the bug number for this, but it is needed for some things we are doing where the app building an intent may not have access to the URI in the data field. This is for HC, but doing in GB to avoid introducing integration issues. Change-Id: I0cac971854198b18775d2a73deb80f23431bfbe2
* | Allow all apps to call ContentResolver.getType().Dianne Hackborn2010-09-271-10/+45
| | | | | | | | | | | | | | | | | | I can't find the bug number for this, but it is needed for some things we are doing where the app building an intent may not have access to the URI in the data field. This is for HC, but doing in GB to avoid introducing integration issues. Change-Id: I0cac971854198b18775d2a73deb80f23431bfbe2
* | Add new ContentProvider for doing conversions to data streams.Dianne Hackborn2010-08-081-24/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces basic infrastructure that should allow content providers holding complex data to perform on-demand conversion of their data to streams of various types. It is achieved through two new content provider APIs, one to interrogate the possible stream MIME types the provider can return, and the other to request a stream of data in a particular MIME type. Because implementations of this will often need to do on-demand data conversion, there is also a utility intoduced in ContentProvider for subclasses to easily run a function to write data into a pipe that is read by the client. This feature is mostly intended for cut and paste and drag and drop, as the complex data interchange allowing the source and destination to negotiate data types and copy (possible large) data between them. However because it is fundamental facility of ContentProvider, it can be used in other places, such as for more advanced GET_CONTENT data exchanges. An example implementation of this would be in ContactsProvider, which can now provider a data stream when a client opens certain pieces of it data, to return data as flat text, a vcard, or other format. Change-Id: I58627ea4ed359aa7cf2c66274adb18306c209cb2
* | resolved conflicts for merge of 2eb12a47 to masterDianne Hackborn2010-06-241-2/+3
|\ \ | |/ | | | | Change-Id: I79eb9d9f083e51ec1b99145d81632683669e7a99
| * Some ActivityThread/ActivityManager cleanup.Dianne Hackborn2010-06-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | - Move PackageInfo out of ActivityThread, renaming to LoadedApk. - Rename some of the other PacakgeInfo inner classes to better represent what they are. - Rename HistoryRecord to ActivityRecord. - Introduce AppGlobals, to eventually let ActivityThread become package scoped. Change-Id: Ib714c54ceb3cdbb525dce3db9505f31042e88cf0
* | New XmlDocumentProvider class.Gilles Debunne2010-06-231-5/+4
|/ | | | | | | | Minor changes in the Adapters.java helper class. Extracts data out of a XML document using an XPath-like syntax. Change-Id: I0617b0783f11c86118b42cd8485d54440810c805
* bug:2622719 move 'forcing of cursor execution' to ContentProviderVasu Nori2010-04-281-0/+2
| | | | | | | | | revert part of the CL: Ia561135e974a44ad3e3774ecb23c6a3d0fc38176 and add it to ContentProvider.query() to force query execution in worker thread, instead of having the main thread incur the cost of query execution and potentially get ANR Change-Id: I0ea8a170bd954a421f4ad825f8090319a83a5b2b
* Missed these ones in the previous rename.Brad Fitzpatrick2010-04-081-2/+2
| | | | | | BUG=2581935 Change-Id: I12e7fc924d7164ab4a5ff7bd6ee52a10f7551ad4
* some changes due to an API reviewFred Quintana2010-03-301-3/+3
| | | | | | | | | | | | | | | - make EntityIterator extend Iterator and thus not throw a RemoteException, instead converting it into a RuntimeException. - rename ActiveSyncInfo to SyncInfo - change getActiveSync to getCurrentSync - remove the accessors in SyncInfo and instead make the final fields publicly accessible - made AbstractThreadedSyncAdapter.cancelSync not take a thread Change-Id: I99fde5585bc5f1e95f4873ffbba189074a8d6372 http://b/issue?id=2553539 http://b/issue?id=2553541 http://b/issue?id=2553550
* Fix small typo in javadoc: "deleting" -> "updating"Omari Stephens2010-03-101-1/+1
| | | | Change-Id: Ie0464aa92d33eb5b076a8122f5bd6317fd44a7b2
* Add "call" method on ContentProvider.Brad Fitzpatrick2010-03-051-1/+1
| | | | | | | | | | | | | This permits implementing interfaces which are faster than using remote Cursors. It then uses it for Settings & SettingProvider, which together account for ~50% of total ContentProvider event loop stalls across Froyo dogfooders. For fetching Settings this looks like it should reduce average Settings lookup from 10 ms to 0.4 ms on Sholes, once the SettingsProvider serves most gets from in-memory cache. Currently it brings the Sholes average down from 10ms to 2.5 ms while still using SQLite queries on each get.
* expose some sync control methodsFred Quintana2010-02-261-4/+24
| | | | | | | | | | | | - ActiveSyncInfo - ContentResolver.addStatusChangeListener - SYNC_OBSERVER_TYPE_SETTINGS - SYNC_OBSERVER_TYPE_PENDING - SYNC_OBSERVER_TYPE_ACTIVE - make the ContentService resilient to nulls passed in to the status change listener registration and unregistration calls bug http://b/issue?id=2337197
* Reduce SQLiteDatabase and ContentResolver EventLog logging thresholds.Brad Fitzpatrick2010-02-221-2/+2
| | | | | | Turns out the database is used a ton, and not particularly quickly, so these were spamming the logs at their prior 100ms thresholds. Setting it to 500ms now. (still sub-sampled, so should be ~5x less spammy...)
* Measure walltime in ContentResolver and SQLiteDatabase operations logging.Brad Fitzpatrick2010-02-111-10/+11
| | | | | | | | | Previously, SQLiteDatabase was using Debug.threadCpuTimeNanos(), which doesn't include I/O time (user-perceived latency), and ContentResolver was using System.currentTimeMillis(), which didn't account for deep sleeps. Now both are consistently using SystemClock.uptimeMillis().
* Log ContentProvider operations to the EventLog.Brad Fitzpatrick2010-02-091-7/+106
| | | | | | | | Just like with db_operation, operations over 100ms are always logged, while operations under that are subsampled. This will help with performance analysis, getting real-world performance numbers from dogfooders.
* - change the SyncManager to retry MANUAL syncs that encounter a soft errorFred Quintana2010-02-081-1/+59
| | | | | | | | | | | | | | | | | | | | - make the sync dump handle the case where there are no accounts - fix a bug that caused the SyncManager to burn up CPU in the system process The following was implemented: scheduler offers: - settings to disable sync - retries of certain errors - backoffs want a way to control these when scheduling a sync - "ignore_settings" - "ignore initial backoff" - "manual" : ignore settings, ignore initial backoff - "do not retry" - need to change the default behavior of not retrying manual syncs to retry regardless
* add sync pollingFred Quintana2010-02-051-0/+60
| | | | | | | | | - added the ability to specify that a sync (of account/authority/extras) should occur at a given frequency - the existing daily poll code was replaced with seeding each account/authority with a 24 hour periodic sync - enhanced the "adb shell dumpsys content" output to show the periodic syncs and when they will next run
* ContentResolver.query() includes performance considerationsTom O'Neill2010-01-081-16/+28
| | | | | | | Mention the desirability of using "?"-substitution in the where clause, and reemphasize the importance of using an explicit projection. Change-Id: Iaa489d50db409f34e78bcd55253e5a4e53445cf2
* am 328c0e79: - removed the concept of Entity from the ContentProvider APIs - ↵Fred Quintana2009-12-101-90/+0
| | | | | | | | | removed the parcelling ability from Entity and EntityIterator and made them public - added an EntityIterator abstract implementation that allow easy wrapping of a Cursor - changed the VCard c Merge commit '328c0e7986aa6bb7752ec6de3da9c999920bb55f' into eclair-mr2-plus-aosp * commit '328c0e7986aa6bb7752ec6de3da9c999920bb55f': - removed the concept of Entity from the ContentProvider APIs
* - hide Entity and all its referencesFred Quintana2009-10-061-0/+2
| | | | | | | - remove updateEntity and insertEntity, since they are not used - add the RawContacts.Entity class, which is used in lieu of the android.content.Entity
* Remove GAIA stringCostin Manolache2009-09-291-1/+1
|