Show loading, error, and info messages as footers.

A provider can include extras in their Cursors to indicate that
loading is ongoing, or include an error or informational message,
which are now shown in footer views.

Fix registration to always get change notifications.

Test provider that verifies common provider behavior of holding
a reference to "cloud" resources that are released by GC when the
remote Cursor is closed.  Also used to validate Recents behavior
for slow providers.

Bug: 10599268
Change-Id: I331c31058dbb80261e7d279b851197c65ac87e32
diff --git a/src/com/android/documentsui/DirectoryLoader.java b/src/com/android/documentsui/DirectoryLoader.java
index 3f016b5..6ea57d7 100644
--- a/src/com/android/documentsui/DirectoryLoader.java
+++ b/src/com/android/documentsui/DirectoryLoader.java
@@ -77,11 +77,12 @@
                     .getContentResolver().acquireUnstableContentProviderClient(authority);
             final Cursor cursor = result.client.query(
                     mUri, null, null, null, getQuerySortOrder(mSortOrder), mSignal);
+            cursor.registerContentObserver(mObserver);
+
             final Cursor withRoot = new RootCursorWrapper(mUri.getAuthority(), mRootId, cursor, -1);
             final Cursor sorted = new SortingCursorWrapper(withRoot, mSortOrder);
 
             result.cursor = sorted;
-            result.cursor.registerContentObserver(mObserver);
         } catch (Exception e) {
             result.exception = e;
             ContentProviderClient.closeQuietly(result.client);