Bug 1357896 - Let BrowserProvider handle bookmark timestamps on insertion r=rnewman
Otherwise we end up with modified<created, since we're generating 'modified' just before
BrowserProvider generates 'created'. BrowserProvider will handle these timestamps missing
from the bookmark ContentValues during an insertion.
MozReview-Commit-ID: DundFG1kaAb
--- a/mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
@@ -1131,25 +1131,24 @@ public class LocalBrowserDB extends Brow
String where = param + " = ?";
String[] args = new String[] { value };
int updated = cr.update(mParentsUriWithProfile, values, where, args);
debug("Updated " + updated + " rows to new modified time.");
}
private void addBookmarkItem(ContentResolver cr, String title, String uri, long folderId) {
- final long now = System.currentTimeMillis();
ContentValues values = new ContentValues();
if (title != null) {
values.put(Bookmarks.TITLE, title);
}
+ // Timestamps (modified and created) will be set by BrowserProvider.
values.put(Bookmarks.URL, uri);
values.put(Bookmarks.PARENT, folderId);
- values.put(Bookmarks.DATE_MODIFIED, now);
// Get the page's favicon ID from the history table
final Cursor c = cr.query(mHistoryUriWithProfile,
new String[] { History.FAVICON_ID },
History.URL + " = ?",
new String[] { uri },
null);
try {
@@ -1176,17 +1175,17 @@ public class LocalBrowserDB extends Brow
new String[] { uri });
// Bump parent modified time using its ID.
debug("Bumping parent modified time for addition to: " + folderId);
final String where = Bookmarks._ID + " = ?";
final String[] args = new String[] { String.valueOf(folderId) };
ContentValues bumped = new ContentValues();
- bumped.put(Bookmarks.DATE_MODIFIED, now);
+ bumped.put(Bookmarks.DATE_MODIFIED, System.currentTimeMillis());
final int updated = cr.update(mBookmarksUriWithProfile, bumped, where, args);
debug("Updated " + updated + " rows to new modified time.");
}
@Override
@RobocopTarget
public boolean addBookmark(ContentResolver cr, String title, String uri) {