Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 752444 - Detect missing Mobile root folders and fix. r=lucasr a=jpr

--HG--
branch : MOBILE140_2012050917_RELBRANCH
  • Loading branch information...
commit 7a9efd40fd1b27ed65c7f139ccba4d029f989e55 1 parent 636380b
@gcp gcp authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 mobile/android/base/ProfileMigrator.java
View
24 mobile/android/base/ProfileMigrator.java
@@ -127,6 +127,14 @@
// We use this to ignore the tags folder during migration.
private static final String ROOT_TAGS_FOLDER_NAME = "tags";
+ // Find the Mobile bookmarks root in places (bug 746860).
+ // We cannot rely on the name as that is locale-dependent.
+ // If it exists, it will have Id=6, fk=null, type=folder.
+ private static final String MOBILE_ROOT_QUERY =
+ "SELECT id FROM moz_bookmarks " +
+ "WHERE id=6 AND type=2 AND fk IS NULL AND parent=1";
+ private static final String MOBILE_ROOT_ID = "id";
+
private static final String BOOKMARK_QUERY_SELECT =
"SELECT places.url AS p_url," +
" bookmark.guid AS b_guid," +
@@ -671,6 +679,22 @@ protected void calculateReroot(SQLiteBridge db) {
cursor.moveToNext();
}
cursor.close();
+
+ // XUL Fennec doesn't mark the Mobile folder as a root,
+ // so fix that up here.
+ cursor = db.rawQuery(MOBILE_ROOT_QUERY, null);
+ if (cursor.moveToFirst()) {
+ Log.v(LOGTAG, "Mobile root found, adding to known roots.");
+ final int idCol = cursor.getColumnIndex(MOBILE_ROOT_ID);
+ final long mobileRootId = cursor.getLong(idCol);
+ mRerootMap.put(mobileRootId, getFolderId(Bookmarks.MOBILE_FOLDER_GUID));
+ Log.v(LOGTAG, "Name: mobile, pid=" + mobileRootId
+ + ", nid=" + mRerootMap.get(mobileRootId));
+ } else {
+ Log.v(LOGTAG, "Mobile root not found, is this a desktop profile?");
+ }
+ cursor.close();
+
} catch (SQLiteBridgeException e) {
Log.e(LOGTAG, "Failed to get bookmark roots: ", e);
// Do not try again.
Please sign in to comment.
Something went wrong with that request. Please try again.