From 9c0dd8caacff99ba76bbb9dc2cab156cded505a8 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Fri, 10 Jul 2009 17:51:48 -0700 Subject: First real cut of bookmarks backup agent The agent now does backup/restore of the bookmarks table. Whether to back up is determined by flattening the bookmark table, CRCing the flattened representation, and comparing the CRC with the previous backup pass's version. If they differ (or if the file size differs), the table is deemed to have changed and we send the flattened file off to the server as a single key. On restore, the bookmark records are read individually from the flattened representation, the existing bookmarks table is queried for a matching URL, and if none exists the bookmark is inserted into the table. Bookmarks.addBookmark() now takes a boolean argument "retainIcon." When false, the implementation will not call into the web icon database. This is necessary during restore because the web icon database is only available from the Browser app's main thread, but restore happens without the app proper being involved. The other call points for addBookmark() have been updated to pass 'true,' i.e. preserving the current behavior. --- src/com/android/browser/Bookmarks.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/com/android/browser/Bookmarks.java') diff --git a/src/com/android/browser/Bookmarks.java b/src/com/android/browser/Bookmarks.java index 97e6b2086..a3dc919ac 100644 --- a/src/com/android/browser/Bookmarks.java +++ b/src/com/android/browser/Bookmarks.java @@ -47,9 +47,13 @@ import java.util.Date; * @param cr The ContentResolver being used to add the bookmark to the db. * @param url URL of the website to be bookmarked. * @param name Provided name for the bookmark. + * @param retainIcon Whether to retain the page's icon in the icon database. + * This will usually be true except when bookmarks are + * added by a settings restore agent. */ /* package */ static void addBookmark(Context context, - ContentResolver cr, String url, String name) { + ContentResolver cr, String url, String name, + boolean retainIcon) { // Want to append to the beginning of the list long creationTime = new Date().getTime(); // First we check to see if the user has already visited this @@ -137,7 +141,9 @@ import java.util.Date; cr.insert(Browser.BOOKMARKS_URI, map); } } - WebIconDatabase.getInstance().retainIconForPageUrl(url); + if (retainIcon) { + WebIconDatabase.getInstance().retainIconForPageUrl(url); + } cursor.deactivate(); if (context != null) { Toast.makeText(context, R.string.added_to_bookmarks, -- cgit v1.2.3