A bunch of updates to BrowserProvider2.

The images are now shared between the history
and bookmarks tables so updates to one are
reflected in the other.

Added a parameter for specifying a limit when
calling query().

Added a combined view of history and bookmarks.

Added a way to get a distinct list of the
accounts providing bookmarks.

Added the ability to find the server unique
IDs for parent and insert_after when doing
a query for a row.

Change-Id: I9afa15bcf7ca68468793c49fbec701e516e4540e
diff --git a/src/com/android/browser/DownloadTouchIcon.java b/src/com/android/browser/DownloadTouchIcon.java
index 1442683..7bb93dc 100644
--- a/src/com/android/browser/DownloadTouchIcon.java
+++ b/src/com/android/browser/DownloadTouchIcon.java
@@ -36,6 +36,7 @@
 import android.os.Bundle;
 import android.os.Message;
 import android.provider.BrowserContract;
+import android.provider.BrowserContract.Images;
 import android.webkit.WebView;
 
 import java.io.ByteArrayOutputStream;
@@ -101,15 +102,15 @@
     @Override
     public Void doInBackground(String... values) {
         if (mContentResolver != null) {
-            mCursor = Bookmarks.queryBookmarksForUrl(mContentResolver,
+            mCursor = Bookmarks.queryCombinedForUrl(mContentResolver,
                     mOriginalUrl, mUrl);
         }
 
-        boolean inBookmarksDatabase = mCursor != null && mCursor.getCount() > 0;
+        boolean inDatabase = mCursor != null && mCursor.getCount() > 0;
 
         String url = values[0];
 
-        if (inBookmarksDatabase || mMessage != null) {
+        if (inDatabase || mMessage != null) {
             AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
             HttpHost httpHost = Proxy.getPreferredHttpHost(mActivity, url);
             if (httpHost != null) {
@@ -130,7 +131,7 @@
                         if (content != null) {
                             Bitmap icon = BitmapFactory.decodeStream(
                                     content, null, null);
-                            if (inBookmarksDatabase) {
+                            if (inDatabase) {
                                 storeIcon(icon);
                             } else if (mMessage != null) {
                                 Bundle b = mMessage.getData();
@@ -177,17 +178,16 @@
             return;
         }
 
-        final ByteArrayOutputStream os = new ByteArrayOutputStream();
-        icon.compress(Bitmap.CompressFormat.PNG, 100, os);
-        ContentValues values = new ContentValues();
-        values.put(BrowserContract.Bookmarks.TOUCH_ICON,
-                os.toByteArray());
-
         if (mCursor.moveToFirst()) {
+            final ByteArrayOutputStream os = new ByteArrayOutputStream();
+            icon.compress(Bitmap.CompressFormat.PNG, 100, os);
+
+            ContentValues values = new ContentValues();
+            values.put(Images.TOUCH_ICON, os.toByteArray());
+            values.put(Images.URL, mCursor.getString(0));
+
             do {
-                mContentResolver.update(ContentUris.withAppendedId(
-                        BrowserContract.Bookmarks.CONTENT_URI, mCursor.getLong(0)),
-                        values, null, null);
+                mContentResolver.update(Images.CONTENT_URI, values, null, null);
             } while (mCursor.moveToNext());
         }
     }