OSDN Git Service

Make DocumentCursor opt-out of having a self-observer
authorAnton Hansson <hansson@google.com>
Tue, 30 Apr 2019 15:57:10 +0000 (16:57 +0100)
committerAnton Hansson <hansson@google.com>
Fri, 3 May 2019 12:33:57 +0000 (13:33 +0100)
commitd79473f881c62587c6f51ff2f9c3818fdd98a6f6
tree67da3da8340262696f9a1e3edf908872eebbbc03
parentb037feb130fdbf6c761e03fc04b7733502fab0b3
Make DocumentCursor opt-out of having a self-observer

A content observer is registered by default when setting a notification
uri for a Cursor, in order to make the Cursor correctly notify listeners
of all changes to its URI, not just the ones made locally.

This is not required for DocumentCursor, because it already has a
separate mechanism for watching for all changes made to the data backed
by the cursor.

This avoids DocumentProviders having to call into system_server to
answer queries about directory trees, which can otherwise add up to
significant amounts of time for large directory trees. In my tests,
this improves the performance of iterating through a directory by
roughly 20%. This number is likely to be higher on non-test devices,
that probably see more binder contention, and will also depend on the
structure of the file tree.

Bug: 130276310
Test: SAF test app
Change-Id: I386363b0608c420e9847caf6fbf6686641c955e2
core/java/android/database/AbstractCursor.java
core/java/com/android/internal/content/FileSystemProvider.java