diff --git a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksDataAccessor.java b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksDataAccessor.java
index 5f121b66740..e187aff4311 100644
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksDataAccessor.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksDataAccessor.java
@@ -31,9 +31,14 @@ public class AndroidBrowserBookmarksDataAccessor extends AndroidBrowserRepositor
*/
private static final String BOOKMARK_IS_FOLDER = BrowserContract.Bookmarks.TYPE + " = " +
BrowserContract.Bookmarks.TYPE_FOLDER;
- private static final String GUID_NOT_TAGS_OR_PLACES = BrowserContract.SyncColumns.GUID + " NOT IN ('" +
- BrowserContract.Bookmarks.TAGS_FOLDER_GUID + "', '" +
- BrowserContract.Bookmarks.PLACES_FOLDER_GUID + "')";
+
+ // SQL fragment to retrieve GUIDs whose ID mappings should be tracked by this session.
+ // Exclude folders we don't want to sync.
+ private static final String GUID_SHOULD_TRACK = BrowserContract.SyncColumns.GUID + " NOT IN ('" +
+ BrowserContract.Bookmarks.TAGS_FOLDER_GUID + "', '" +
+ BrowserContract.Bookmarks.PLACES_FOLDER_GUID + "', '" +
+ BrowserContract.Bookmarks.READING_LIST_FOLDER_GUID + "', '" +
+ BrowserContract.Bookmarks.PINNED_FOLDER_GUID + "')";
private static final String EXCLUDE_SPECIAL_GUIDS_WHERE_CLAUSE;
static {
@@ -71,7 +76,7 @@ public class AndroidBrowserBookmarksDataAccessor extends AndroidBrowserRepositor
return BrowserContractHelpers.BOOKMARKS_CONTENT_URI;
}
- protected Uri getPositionsUri() {
+ protected static Uri getPositionsUri() {
return BrowserContractHelpers.BOOKMARKS_POSITIONS_CONTENT_URI;
}
@@ -86,8 +91,9 @@ public class AndroidBrowserBookmarksDataAccessor extends AndroidBrowserRepositor
BrowserContract.Bookmarks._ID };
protected Cursor getGuidsIDsForFolders() throws NullCursorException {
- // Exclude "places" and "tags", in case they've ended up in the DB.
- String where = BOOKMARK_IS_FOLDER + " AND " + GUID_NOT_TAGS_OR_PLACES;
+ // Exclude items that we don't want to sync (pinned items, reading list,
+ // tags, the places root), in case they've ended up in the DB.
+ String where = BOOKMARK_IS_FOLDER + " AND " + GUID_SHOULD_TRACK;
return queryHelper.safeQuery(".getGuidsIDsForFolders", GUID_AND_ID, where, null, null);
}
diff --git a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
index f953e7ab4d5..e4ec077c38b 100644
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java
@@ -131,14 +131,19 @@ public class AndroidBrowserBookmarksRepositorySession extends AndroidBrowserRepo
* Additionally, the mobile root is annotated. In Firefox Sync, PlacesUtils is
* used to find the IDs of these special folders.
*
- * Sync skips over `places` and `tags` when finding IDs.
- *
- * We need to consume records with these various guids, producing a local
+ * We need to consume records with these various GUIDs, producing a local
* representation which we are able to stably map upstream.
*
+ * Android Sync skips over the contents of some special GUIDs -- `places`, `tags`,
+ * etc. -- when finding IDs.
+ * Some of these special GUIDs are part of desktop structure (places, tags). Some
+ * are part of Fennec's custom data (readinglist, pinned).
+ *
+ * We don't want to upload or apply these records.
+ *
* That is:
*
- * * We should not upload a `places` record or a `tags` record.
+ * * We should not upload a `places`,`tags`, `readinglist`, or `pinned` record.
* * We can stably _store_ menu/toolbar/unfiled/mobile as special GUIDs, and set
* their parent ID as appropriate on upload.
*
diff --git a/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java b/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java
index 006dd7c8145..090a9ace481 100644
--- a/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java
+++ b/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java
@@ -5,7 +5,6 @@
package org.mozilla.gecko.sync.repositories.android;
import java.util.ArrayList;
-import java.util.HashMap;
import org.mozilla.gecko.background.common.log.Logger;
import org.mozilla.gecko.sync.repositories.InactiveSessionException;
@@ -30,6 +29,7 @@ import org.mozilla.gecko.sync.repositories.domain.Record;
import android.content.ContentUris;
import android.database.Cursor;
import android.net.Uri;
+import android.util.SparseArray;
/**
* You'll notice that all delegate calls *either*:
@@ -71,7 +71,7 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
* In this case, we search the database for a matching record explicitly using
* findByRecordString
.
*/
- protected HashMap recordToGuid;
+ protected SparseArray recordToGuid;
public AndroidBrowserRepositorySession(Repository repository) {
super(repository);
@@ -105,6 +105,7 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
*
* For example, a session subclass might skip records of an unsupported type.
*/
+ @SuppressWarnings("static-method")
public boolean shouldIgnore(Record record) {
return false;
}
@@ -115,6 +116,7 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
*
* Example: translating remote folder names into local names.
*/
+ @SuppressWarnings("static-method")
protected void fixupRecord(Record record) {
return;
}
@@ -134,6 +136,7 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
* @return The transformed record. Can be null.
* @throws NullCursorException
*/
+ @SuppressWarnings("static-method")
protected Record transformRecord(Record record) throws NullCursorException {
return record;
}
@@ -679,12 +682,12 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
if (recordToGuid == null) {
createRecordToGuidMap();
}
- return recordToGuid.get(new Integer(recordString.hashCode()));
+ return recordToGuid.get(Integer.valueOf(recordString.hashCode()));
}
protected void createRecordToGuidMap() throws NoGuidForIdException, NullCursorException, ParentNotFoundException {
Logger.info(LOG_TAG, "BEGIN: creating record -> GUID map.");
- recordToGuid = new HashMap();
+ recordToGuid = new SparseArray();
// TODO: we should be able to do this entire thing with string concatenations within SQL.
// Also consider whether it's better to fetch and process every record in the DB into
@@ -699,7 +702,7 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
if (record != null) {
final String recordString = buildRecordString(record);
if (recordString != null) {
- recordToGuid.put(new Integer(recordString.hashCode()), record.guid);
+ recordToGuid.put(Integer.valueOf(recordString.hashCode()), record.guid);
}
}
cur.moveToNext();
@@ -757,7 +760,7 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
if (recordToGuid == null) {
createRecordToGuidMap();
}
- recordToGuid.put(new Integer(recordString.hashCode()), guid);
+ recordToGuid.put(Integer.valueOf(recordString.hashCode()), guid);
}
protected abstract Record prepareRecord(Record record);