Use myUserId() only in registerContentObserver()
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
Loading
Please register or sign in to comment