mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 858992 - Don't sync pinned bookmarks. r=nalexander
This commit is contained in:
parent
a592e45880
commit
420fc897ca
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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
|
||||
* <code>findByRecordString</code>.
|
||||
*/
|
||||
protected HashMap<Integer, String> recordToGuid;
|
||||
protected SparseArray<String> 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<Integer, String>();
|
||||
recordToGuid = new SparseArray<String>();
|
||||
|
||||
// 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);
|
||||
|
Loading…
Reference in New Issue
Block a user