зеркало из https://github.com/mozilla/gecko-dev.git
Bug 947018: Delete large amounts of database migration code. r=wesj
This commit is contained in:
Родитель
3485a87244
Коммит
223f0852fd
|
@ -157,7 +157,6 @@ public class BrowserContract {
|
|||
public static final String TAGS_FOLDER_GUID = "tags";
|
||||
public static final String TOOLBAR_FOLDER_GUID = "toolbar";
|
||||
public static final String UNFILED_FOLDER_GUID = "unfiled";
|
||||
public static final String READING_LIST_FOLDER_GUID = "readinglist";
|
||||
public static final String FAKE_DESKTOP_FOLDER_GUID = "desktop";
|
||||
public static final String PINNED_FOLDER_GUID = "pinned";
|
||||
|
||||
|
@ -342,53 +341,6 @@ public class BrowserContract {
|
|||
new String[] { _ID, DATASET_ID, URL, TITLE, DESCRIPTION, IMAGE_URL, FILTER };
|
||||
}
|
||||
|
||||
/*
|
||||
* Contains names and schema definitions for tables and views
|
||||
* no longer being used by current ContentProviders. These values are used
|
||||
* to make incremental updates to the schema during a database upgrade. Will be
|
||||
* removed with bug 947018.
|
||||
*/
|
||||
static final class Obsolete {
|
||||
public static final String TABLE_IMAGES = "images";
|
||||
public static final String VIEW_BOOKMARKS_WITH_IMAGES = "bookmarks_with_images";
|
||||
public static final String VIEW_HISTORY_WITH_IMAGES = "history_with_images";
|
||||
public static final String VIEW_COMBINED_WITH_IMAGES = "combined_with_images";
|
||||
|
||||
public static final class Images implements CommonColumns, SyncColumns {
|
||||
private Images() {}
|
||||
|
||||
public static final String URL = "url_key";
|
||||
public static final String FAVICON_URL = "favicon_url";
|
||||
public static final String FAVICON = "favicon";
|
||||
public static final String THUMBNAIL = "thumbnail";
|
||||
public static final String _ID = "_id";
|
||||
public static final String GUID = "guid";
|
||||
public static final String DATE_CREATED = "created";
|
||||
public static final String DATE_MODIFIED = "modified";
|
||||
public static final String IS_DELETED = "deleted";
|
||||
}
|
||||
|
||||
public static final class Combined {
|
||||
private Combined() {}
|
||||
|
||||
public static final String THUMBNAIL = "thumbnail";
|
||||
public static final String DISPLAY = "display";
|
||||
|
||||
public static final int DISPLAY_NORMAL = 0;
|
||||
public static final int DISPLAY_READER = 1;
|
||||
}
|
||||
|
||||
static final String TABLE_BOOKMARKS_JOIN_IMAGES = Bookmarks.TABLE_NAME + " LEFT OUTER JOIN " +
|
||||
Obsolete.TABLE_IMAGES + " ON " + Bookmarks.TABLE_NAME + "." + Bookmarks.URL + " = " +
|
||||
Obsolete.TABLE_IMAGES + "." + Obsolete.Images.URL;
|
||||
|
||||
static final String TABLE_HISTORY_JOIN_IMAGES = History.TABLE_NAME + " LEFT OUTER JOIN " +
|
||||
Obsolete.TABLE_IMAGES + " ON " + Bookmarks.TABLE_NAME + "." + History.URL + " = " +
|
||||
Obsolete.TABLE_IMAGES + "." + Obsolete.Images.URL;
|
||||
|
||||
static final String FAVICON_DB = "favicon_urls.db";
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
public static final class ReadingListItems implements CommonColumns, URLColumns, SyncColumns {
|
||||
private ReadingListItems() {}
|
||||
|
|
|
@ -11,14 +11,12 @@ import java.util.List;
|
|||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
import org.mozilla.gecko.db.BrowserContract.Combined;
|
||||
import org.mozilla.gecko.db.BrowserContract.FaviconColumns;
|
||||
import org.mozilla.gecko.db.BrowserContract.Favicons;
|
||||
import org.mozilla.gecko.db.BrowserContract.History;
|
||||
import org.mozilla.gecko.db.BrowserContract.Obsolete;
|
||||
import org.mozilla.gecko.db.BrowserContract.ReadingListItems;
|
||||
import org.mozilla.gecko.db.BrowserContract.SearchHistory;
|
||||
import org.mozilla.gecko.db.BrowserContract.Thumbnails;
|
||||
import org.mozilla.gecko.sync.Utils;
|
||||
import static org.mozilla.gecko.db.DBUtils.qualifyColumn;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
|
@ -61,7 +59,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
|
||||
static final String TABLE_BOOKMARKS_TMP = TABLE_BOOKMARKS + "_tmp";
|
||||
static final String TABLE_HISTORY_TMP = TABLE_HISTORY + "_tmp";
|
||||
static final String TABLE_IMAGES_TMP = Obsolete.TABLE_IMAGES + "_tmp";
|
||||
|
||||
private static final String[] mobileIdColumns = new String[] { Bookmarks._ID };
|
||||
private static final String[] mobileIdSelectionArgs = new String[] { Bookmarks.MOBILE_FOLDER_GUID };
|
||||
|
@ -74,37 +71,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
private void createBookmarksTable(SQLiteDatabase db) {
|
||||
debug("Creating " + TABLE_BOOKMARKS + " table");
|
||||
|
||||
db.execSQL("CREATE TABLE " + TABLE_BOOKMARKS + "(" +
|
||||
Bookmarks._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
Bookmarks.TITLE + " TEXT," +
|
||||
Bookmarks.URL + " TEXT," +
|
||||
Bookmarks.TYPE + " INTEGER NOT NULL DEFAULT " + Bookmarks.TYPE_BOOKMARK + "," +
|
||||
Bookmarks.PARENT + " INTEGER," +
|
||||
Bookmarks.POSITION + " INTEGER NOT NULL," +
|
||||
Bookmarks.KEYWORD + " TEXT," +
|
||||
Bookmarks.DESCRIPTION + " TEXT," +
|
||||
Bookmarks.TAGS + " TEXT," +
|
||||
Bookmarks.DATE_CREATED + " INTEGER," +
|
||||
Bookmarks.DATE_MODIFIED + " INTEGER," +
|
||||
Bookmarks.GUID + " TEXT NOT NULL," +
|
||||
Bookmarks.IS_DELETED + " INTEGER NOT NULL DEFAULT 0, " +
|
||||
"FOREIGN KEY (" + Bookmarks.PARENT + ") REFERENCES " +
|
||||
TABLE_BOOKMARKS + "(" + Bookmarks._ID + ")" +
|
||||
");");
|
||||
|
||||
db.execSQL("CREATE INDEX bookmarks_url_index ON " + TABLE_BOOKMARKS + "("
|
||||
+ Bookmarks.URL + ")");
|
||||
db.execSQL("CREATE INDEX bookmarks_type_deleted_index ON " + TABLE_BOOKMARKS + "("
|
||||
+ Bookmarks.TYPE + ", " + Bookmarks.IS_DELETED + ")");
|
||||
db.execSQL("CREATE UNIQUE INDEX bookmarks_guid_index ON " + TABLE_BOOKMARKS + "("
|
||||
+ Bookmarks.GUID + ")");
|
||||
db.execSQL("CREATE INDEX bookmarks_modified_index ON " + TABLE_BOOKMARKS + "("
|
||||
+ Bookmarks.DATE_MODIFIED + ")");
|
||||
}
|
||||
|
||||
private void createBookmarksTableOn13(SQLiteDatabase db) {
|
||||
debug("Creating " + TABLE_BOOKMARKS + " table");
|
||||
|
||||
db.execSQL("CREATE TABLE " + TABLE_BOOKMARKS + "(" +
|
||||
Bookmarks._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
Bookmarks.TITLE + " TEXT," +
|
||||
|
@ -135,30 +101,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
|
||||
private void createHistoryTable(SQLiteDatabase db) {
|
||||
debug("Creating " + TABLE_HISTORY + " table");
|
||||
db.execSQL("CREATE TABLE " + TABLE_HISTORY + "(" +
|
||||
History._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
History.TITLE + " TEXT," +
|
||||
History.URL + " TEXT NOT NULL," +
|
||||
History.VISITS + " INTEGER NOT NULL DEFAULT 0," +
|
||||
History.DATE_LAST_VISITED + " INTEGER," +
|
||||
History.DATE_CREATED + " INTEGER," +
|
||||
History.DATE_MODIFIED + " INTEGER," +
|
||||
History.GUID + " TEXT NOT NULL," +
|
||||
History.IS_DELETED + " INTEGER NOT NULL DEFAULT 0" +
|
||||
");");
|
||||
|
||||
db.execSQL("CREATE INDEX history_url_index ON " + TABLE_HISTORY + "("
|
||||
+ History.URL + ")");
|
||||
db.execSQL("CREATE UNIQUE INDEX history_guid_index ON " + TABLE_HISTORY + "("
|
||||
+ History.GUID + ")");
|
||||
db.execSQL("CREATE INDEX history_modified_index ON " + TABLE_HISTORY + "("
|
||||
+ History.DATE_MODIFIED + ")");
|
||||
db.execSQL("CREATE INDEX history_visited_index ON " + TABLE_HISTORY + "("
|
||||
+ History.DATE_LAST_VISITED + ")");
|
||||
}
|
||||
|
||||
private void createHistoryTableOn13(SQLiteDatabase db) {
|
||||
debug("Creating " + TABLE_HISTORY + " table");
|
||||
db.execSQL("CREATE TABLE " + TABLE_HISTORY + "(" +
|
||||
History._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
|
@ -173,36 +115,14 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
History.IS_DELETED + " INTEGER NOT NULL DEFAULT 0" +
|
||||
");");
|
||||
|
||||
db.execSQL("CREATE INDEX history_url_index ON " + TABLE_HISTORY + "("
|
||||
+ History.URL + ")");
|
||||
db.execSQL("CREATE UNIQUE INDEX history_guid_index ON " + TABLE_HISTORY + "("
|
||||
+ History.GUID + ")");
|
||||
db.execSQL("CREATE INDEX history_modified_index ON " + TABLE_HISTORY + "("
|
||||
+ History.DATE_MODIFIED + ")");
|
||||
db.execSQL("CREATE INDEX history_visited_index ON " + TABLE_HISTORY + "("
|
||||
+ History.DATE_LAST_VISITED + ")");
|
||||
}
|
||||
|
||||
private void createImagesTable(SQLiteDatabase db) {
|
||||
debug("Creating " + Obsolete.TABLE_IMAGES + " table");
|
||||
db.execSQL("CREATE TABLE " + Obsolete.TABLE_IMAGES + " (" +
|
||||
Obsolete.Images._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
Obsolete.Images.URL + " TEXT UNIQUE NOT NULL," +
|
||||
Obsolete.Images.FAVICON + " BLOB," +
|
||||
Obsolete.Images.FAVICON_URL + " TEXT," +
|
||||
Obsolete.Images.THUMBNAIL + " BLOB," +
|
||||
Obsolete.Images.DATE_CREATED + " INTEGER," +
|
||||
Obsolete.Images.DATE_MODIFIED + " INTEGER," +
|
||||
Obsolete.Images.GUID + " TEXT NOT NULL," +
|
||||
Obsolete.Images.IS_DELETED + " INTEGER NOT NULL DEFAULT 0" +
|
||||
");");
|
||||
|
||||
db.execSQL("CREATE INDEX images_url_index ON " + Obsolete.TABLE_IMAGES + "("
|
||||
+ Obsolete.Images.URL + ")");
|
||||
db.execSQL("CREATE UNIQUE INDEX images_guid_index ON " + Obsolete.TABLE_IMAGES + "("
|
||||
+ Obsolete.Images.GUID + ")");
|
||||
db.execSQL("CREATE INDEX images_modified_index ON " + Obsolete.TABLE_IMAGES + "("
|
||||
+ Obsolete.Images.DATE_MODIFIED + ")");
|
||||
db.execSQL("CREATE INDEX history_url_index ON " + TABLE_HISTORY + '('
|
||||
+ History.URL + ')');
|
||||
db.execSQL("CREATE UNIQUE INDEX history_guid_index ON " + TABLE_HISTORY + '('
|
||||
+ History.GUID + ')');
|
||||
db.execSQL("CREATE INDEX history_modified_index ON " + TABLE_HISTORY + '('
|
||||
+ History.DATE_MODIFIED + ')');
|
||||
db.execSQL("CREATE INDEX history_visited_index ON " + TABLE_HISTORY + '('
|
||||
+ History.DATE_LAST_VISITED + ')');
|
||||
}
|
||||
|
||||
private void createFaviconsTable(SQLiteDatabase db) {
|
||||
|
@ -233,15 +153,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
+ Thumbnails.URL + ")");
|
||||
}
|
||||
|
||||
private void createBookmarksWithImagesView(SQLiteDatabase db) {
|
||||
debug("Creating " + Obsolete.VIEW_BOOKMARKS_WITH_IMAGES + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + Obsolete.VIEW_BOOKMARKS_WITH_IMAGES + " AS " +
|
||||
"SELECT " + qualifyColumn(TABLE_BOOKMARKS, "*") +
|
||||
", " + Obsolete.Images.FAVICON + ", " + Obsolete.Images.THUMBNAIL + " FROM " +
|
||||
Obsolete.TABLE_BOOKMARKS_JOIN_IMAGES);
|
||||
}
|
||||
|
||||
private void createBookmarksWithFaviconsView(SQLiteDatabase db) {
|
||||
debug("Creating " + VIEW_BOOKMARKS_WITH_FAVICONS + " view");
|
||||
|
||||
|
@ -252,15 +163,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
" FROM " + TABLE_BOOKMARKS_JOIN_FAVICONS);
|
||||
}
|
||||
|
||||
private void createHistoryWithImagesView(SQLiteDatabase db) {
|
||||
debug("Creating " + Obsolete.VIEW_HISTORY_WITH_IMAGES + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + Obsolete.VIEW_HISTORY_WITH_IMAGES + " AS " +
|
||||
"SELECT " + qualifyColumn(TABLE_HISTORY, "*") +
|
||||
", " + Obsolete.Images.FAVICON + ", " + Obsolete.Images.THUMBNAIL + " FROM " +
|
||||
Obsolete.TABLE_HISTORY_JOIN_IMAGES);
|
||||
}
|
||||
|
||||
private void createHistoryWithFaviconsView(SQLiteDatabase db) {
|
||||
debug("Creating " + VIEW_HISTORY_WITH_FAVICONS + " view");
|
||||
|
||||
|
@ -271,363 +173,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
" FROM " + TABLE_HISTORY_JOIN_FAVICONS);
|
||||
}
|
||||
|
||||
private void createCombinedWithImagesView(SQLiteDatabase db) {
|
||||
debug("Creating " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " AS" +
|
||||
" SELECT " + Combined.BOOKMARK_ID + ", " +
|
||||
Combined.HISTORY_ID + ", " +
|
||||
// We need to return an _id column because CursorAdapter requires it for its
|
||||
// default implementation for the getItemId() method. However, since
|
||||
// we're not using this feature in the parts of the UI using this view,
|
||||
// we can just use 0 for all rows.
|
||||
"0 AS " + Combined._ID + ", " +
|
||||
Combined.URL + ", " +
|
||||
Combined.TITLE + ", " +
|
||||
Combined.VISITS + ", " +
|
||||
Combined.DATE_LAST_VISITED + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.FAVICON) + " AS " + Combined.FAVICON + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.THUMBNAIL) + " AS " + Obsolete.Combined.THUMBNAIL +
|
||||
" FROM (" +
|
||||
// Bookmarks without history.
|
||||
" SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " AS " + Combined.URL + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + " AS " + Combined.TITLE + ", " +
|
||||
"-1 AS " + Combined.HISTORY_ID + ", " +
|
||||
"-1 AS " + Combined.VISITS + ", " +
|
||||
"-1 AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_BOOKMARKS +
|
||||
" WHERE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + " AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " = 0 AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) +
|
||||
" NOT IN (SELECT " + History.URL + " FROM " + TABLE_HISTORY + ")" +
|
||||
" UNION ALL" +
|
||||
// History with and without bookmark.
|
||||
" SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.URL) + " AS " + Combined.URL + ", " +
|
||||
// Prioritize bookmark titles over history titles, since the user may have
|
||||
// customized the title for a bookmark.
|
||||
"COALESCE(" + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.TITLE) +")" + " AS " + Combined.TITLE + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History._ID) + " AS " + Combined.HISTORY_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.VISITS) + " AS " + Combined.VISITS + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.DATE_LAST_VISITED) + " AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_HISTORY + " LEFT OUTER JOIN " + TABLE_BOOKMARKS +
|
||||
" ON " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " = " + qualifyColumn(TABLE_HISTORY, History.URL) +
|
||||
" WHERE " + qualifyColumn(TABLE_HISTORY, History.URL) + " IS NOT NULL AND " +
|
||||
qualifyColumn(TABLE_HISTORY, History.IS_DELETED) + " = 0 AND (" +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " IS NULL OR " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + ")" +
|
||||
") LEFT OUTER JOIN " + Obsolete.TABLE_IMAGES +
|
||||
" ON " + Combined.URL + " = " + qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.URL));
|
||||
}
|
||||
|
||||
private void createCombinedWithImagesViewOn9(SQLiteDatabase db) {
|
||||
debug("Creating " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " AS" +
|
||||
" SELECT " + Combined.BOOKMARK_ID + ", " +
|
||||
Combined.HISTORY_ID + ", " +
|
||||
// We need to return an _id column because CursorAdapter requires it for its
|
||||
// default implementation for the getItemId() method. However, since
|
||||
// we're not using this feature in the parts of the UI using this view,
|
||||
// we can just use 0 for all rows.
|
||||
"0 AS " + Combined._ID + ", " +
|
||||
Combined.URL + ", " +
|
||||
Combined.TITLE + ", " +
|
||||
Combined.VISITS + ", " +
|
||||
Obsolete.Combined.DISPLAY + ", " +
|
||||
Combined.DATE_LAST_VISITED + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.FAVICON) + " AS " + Combined.FAVICON + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.THUMBNAIL) + " AS " + Obsolete.Combined.THUMBNAIL +
|
||||
" FROM (" +
|
||||
// Bookmarks without history.
|
||||
" SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " AS " + Combined.URL + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + " AS " + Combined.TITLE + ", " +
|
||||
"CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.PARENT) + " WHEN " +
|
||||
Bookmarks.FIXED_READING_LIST_ID + " THEN " + Obsolete.Combined.DISPLAY_READER + " ELSE " +
|
||||
Obsolete.Combined.DISPLAY_NORMAL + " END AS " + Obsolete.Combined.DISPLAY + ", " +
|
||||
"-1 AS " + Combined.HISTORY_ID + ", " +
|
||||
"-1 AS " + Combined.VISITS + ", " +
|
||||
"-1 AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_BOOKMARKS +
|
||||
" WHERE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + " AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " = 0 AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) +
|
||||
" NOT IN (SELECT " + History.URL + " FROM " + TABLE_HISTORY + ")" +
|
||||
" UNION ALL" +
|
||||
// History with and without bookmark.
|
||||
" SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.URL) + " AS " + Combined.URL + ", " +
|
||||
// Prioritize bookmark titles over history titles, since the user may have
|
||||
// customized the title for a bookmark.
|
||||
"COALESCE(" + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.TITLE) +")" + " AS " + Combined.TITLE + ", " +
|
||||
"CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.PARENT) + " WHEN " +
|
||||
Bookmarks.FIXED_READING_LIST_ID + " THEN " + Obsolete.Combined.DISPLAY_READER + " ELSE " +
|
||||
Obsolete.Combined.DISPLAY_NORMAL + " END AS " + Obsolete.Combined.DISPLAY + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History._ID) + " AS " + Combined.HISTORY_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.VISITS) + " AS " + Combined.VISITS + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.DATE_LAST_VISITED) + " AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_HISTORY + " LEFT OUTER JOIN " + TABLE_BOOKMARKS +
|
||||
" ON " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " = " + qualifyColumn(TABLE_HISTORY, History.URL) +
|
||||
" WHERE " + qualifyColumn(TABLE_HISTORY, History.URL) + " IS NOT NULL AND " +
|
||||
qualifyColumn(TABLE_HISTORY, History.IS_DELETED) + " = 0 AND (" +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " IS NULL OR " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + ")" +
|
||||
") LEFT OUTER JOIN " + Obsolete.TABLE_IMAGES +
|
||||
" ON " + Combined.URL + " = " + qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.URL));
|
||||
}
|
||||
|
||||
private void createCombinedWithImagesViewOn10(SQLiteDatabase db) {
|
||||
debug("Creating " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " AS" +
|
||||
" SELECT " + Combined.BOOKMARK_ID + ", " +
|
||||
Combined.HISTORY_ID + ", " +
|
||||
// We need to return an _id column because CursorAdapter requires it for its
|
||||
// default implementation for the getItemId() method. However, since
|
||||
// we're not using this feature in the parts of the UI using this view,
|
||||
// we can just use 0 for all rows.
|
||||
"0 AS " + Combined._ID + ", " +
|
||||
Combined.URL + ", " +
|
||||
Combined.TITLE + ", " +
|
||||
Combined.VISITS + ", " +
|
||||
Obsolete.Combined.DISPLAY + ", " +
|
||||
Combined.DATE_LAST_VISITED + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.FAVICON) + " AS " + Combined.FAVICON + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.THUMBNAIL) + " AS " + Obsolete.Combined.THUMBNAIL +
|
||||
" FROM (" +
|
||||
// Bookmarks without history.
|
||||
" SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " AS " + Combined.URL + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + " AS " + Combined.TITLE + ", " +
|
||||
"CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.PARENT) + " WHEN " +
|
||||
Bookmarks.FIXED_READING_LIST_ID + " THEN " + Obsolete.Combined.DISPLAY_READER + " ELSE " +
|
||||
Obsolete.Combined.DISPLAY_NORMAL + " END AS " + Obsolete.Combined.DISPLAY + ", " +
|
||||
"-1 AS " + Combined.HISTORY_ID + ", " +
|
||||
"-1 AS " + Combined.VISITS + ", " +
|
||||
"-1 AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_BOOKMARKS +
|
||||
" WHERE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + " AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " = 0 AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) +
|
||||
" NOT IN (SELECT " + History.URL + " FROM " + TABLE_HISTORY + ")" +
|
||||
" UNION ALL" +
|
||||
// History with and without bookmark.
|
||||
" SELECT " + "CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " WHEN 0 THEN " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " ELSE NULL END AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.URL) + " AS " + Combined.URL + ", " +
|
||||
// Prioritize bookmark titles over history titles, since the user may have
|
||||
// customized the title for a bookmark.
|
||||
"COALESCE(" + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.TITLE) +")" + " AS " + Combined.TITLE + ", " +
|
||||
"CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.PARENT) + " WHEN " +
|
||||
Bookmarks.FIXED_READING_LIST_ID + " THEN " + Obsolete.Combined.DISPLAY_READER + " ELSE " +
|
||||
Obsolete.Combined.DISPLAY_NORMAL + " END AS " + Obsolete.Combined.DISPLAY + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History._ID) + " AS " + Combined.HISTORY_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.VISITS) + " AS " + Combined.VISITS + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.DATE_LAST_VISITED) + " AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_HISTORY + " LEFT OUTER JOIN " + TABLE_BOOKMARKS +
|
||||
" ON " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " = " + qualifyColumn(TABLE_HISTORY, History.URL) +
|
||||
" WHERE " + qualifyColumn(TABLE_HISTORY, History.URL) + " IS NOT NULL AND " +
|
||||
qualifyColumn(TABLE_HISTORY, History.IS_DELETED) + " = 0 AND (" +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " IS NULL OR " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + ")" +
|
||||
") LEFT OUTER JOIN " + Obsolete.TABLE_IMAGES +
|
||||
" ON " + Combined.URL + " = " + qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.URL));
|
||||
}
|
||||
|
||||
private void createCombinedWithImagesViewOn11(SQLiteDatabase db) {
|
||||
debug("Creating " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " AS" +
|
||||
" SELECT " + Combined.BOOKMARK_ID + ", " +
|
||||
Combined.HISTORY_ID + ", " +
|
||||
// We need to return an _id column because CursorAdapter requires it for its
|
||||
// default implementation for the getItemId() method. However, since
|
||||
// we're not using this feature in the parts of the UI using this view,
|
||||
// we can just use 0 for all rows.
|
||||
"0 AS " + Combined._ID + ", " +
|
||||
Combined.URL + ", " +
|
||||
Combined.TITLE + ", " +
|
||||
Combined.VISITS + ", " +
|
||||
Obsolete.Combined.DISPLAY + ", " +
|
||||
Combined.DATE_LAST_VISITED + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.FAVICON) + " AS " + Combined.FAVICON + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.THUMBNAIL) + " AS " + Obsolete.Combined.THUMBNAIL +
|
||||
" FROM (" +
|
||||
// Bookmarks without history.
|
||||
" SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " AS " + Combined.URL + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + " AS " + Combined.TITLE + ", " +
|
||||
"CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.PARENT) + " WHEN " +
|
||||
Bookmarks.FIXED_READING_LIST_ID + " THEN " + Obsolete.Combined.DISPLAY_READER + " ELSE " +
|
||||
Obsolete.Combined.DISPLAY_NORMAL + " END AS " + Obsolete.Combined.DISPLAY + ", " +
|
||||
"-1 AS " + Combined.HISTORY_ID + ", " +
|
||||
"-1 AS " + Combined.VISITS + ", " +
|
||||
"-1 AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_BOOKMARKS +
|
||||
" WHERE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + " AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " = 0 AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) +
|
||||
" NOT IN (SELECT " + History.URL + " FROM " + TABLE_HISTORY + ")" +
|
||||
" UNION ALL" +
|
||||
// History with and without bookmark.
|
||||
" SELECT " + "CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " WHEN 0 THEN " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " ELSE NULL END AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.URL) + " AS " + Combined.URL + ", " +
|
||||
// Prioritize bookmark titles over history titles, since the user may have
|
||||
// customized the title for a bookmark.
|
||||
"COALESCE(" + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.TITLE) +")" + " AS " + Combined.TITLE + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History._ID) + " AS " + Combined.HISTORY_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.VISITS) + " AS " + Combined.VISITS + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.DATE_LAST_VISITED) + " AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_HISTORY + " LEFT OUTER JOIN " + TABLE_BOOKMARKS +
|
||||
" ON " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " = " + qualifyColumn(TABLE_HISTORY, History.URL) +
|
||||
" WHERE " + qualifyColumn(TABLE_HISTORY, History.URL) + " IS NOT NULL AND " +
|
||||
qualifyColumn(TABLE_HISTORY, History.IS_DELETED) + " = 0 AND (" +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " IS NULL OR " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + ") " +
|
||||
") LEFT OUTER JOIN " + Obsolete.TABLE_IMAGES +
|
||||
" ON " + Combined.URL + " = " + qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.URL));
|
||||
}
|
||||
|
||||
private void createCombinedViewOn12(SQLiteDatabase db) {
|
||||
debug("Creating " + VIEW_COMBINED + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + VIEW_COMBINED + " AS" +
|
||||
" SELECT " + Combined.BOOKMARK_ID + ", " +
|
||||
Combined.HISTORY_ID + ", " +
|
||||
// We need to return an _id column because CursorAdapter requires it for its
|
||||
// default implementation for the getItemId() method. However, since
|
||||
// we're not using this feature in the parts of the UI using this view,
|
||||
// we can just use 0 for all rows.
|
||||
"0 AS " + Combined._ID + ", " +
|
||||
Combined.URL + ", " +
|
||||
Combined.TITLE + ", " +
|
||||
Combined.VISITS + ", " +
|
||||
Obsolete.Combined.DISPLAY + ", " +
|
||||
Combined.DATE_LAST_VISITED +
|
||||
" FROM (" +
|
||||
// Bookmarks without history.
|
||||
" SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " AS " + Combined.URL + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + " AS " + Combined.TITLE + ", " +
|
||||
"CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.PARENT) + " WHEN " +
|
||||
Bookmarks.FIXED_READING_LIST_ID + " THEN " + Obsolete.Combined.DISPLAY_READER + " ELSE " +
|
||||
Obsolete.Combined.DISPLAY_NORMAL + " END AS " + Obsolete.Combined.DISPLAY + ", " +
|
||||
"-1 AS " + Combined.HISTORY_ID + ", " +
|
||||
"-1 AS " + Combined.VISITS + ", " +
|
||||
"-1 AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_BOOKMARKS +
|
||||
" WHERE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + " AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " = 0 AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) +
|
||||
" NOT IN (SELECT " + History.URL + " FROM " + TABLE_HISTORY + ")" +
|
||||
" UNION ALL" +
|
||||
// History with and without bookmark.
|
||||
" SELECT " + "CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " WHEN 0 THEN " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " ELSE NULL END AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.URL) + " AS " + Combined.URL + ", " +
|
||||
// Prioritize bookmark titles over history titles, since the user may have
|
||||
// customized the title for a bookmark.
|
||||
"COALESCE(" + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.TITLE) +")" + " AS " + Combined.TITLE + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History._ID) + " AS " + Combined.HISTORY_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.VISITS) + " AS " + Combined.VISITS + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.DATE_LAST_VISITED) + " AS " + Combined.DATE_LAST_VISITED +
|
||||
" FROM " + TABLE_HISTORY + " LEFT OUTER JOIN " + TABLE_BOOKMARKS +
|
||||
" ON " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " = " + qualifyColumn(TABLE_HISTORY, History.URL) +
|
||||
" WHERE " + qualifyColumn(TABLE_HISTORY, History.URL) + " IS NOT NULL AND " +
|
||||
qualifyColumn(TABLE_HISTORY, History.IS_DELETED) + " = 0 AND (" +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " IS NULL OR " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + ") " +
|
||||
")");
|
||||
|
||||
debug("Creating " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES + " AS" +
|
||||
" SELECT *, " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.FAVICON) + " AS " + Combined.FAVICON + ", " +
|
||||
qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.THUMBNAIL) + " AS " + Obsolete.Combined.THUMBNAIL +
|
||||
" FROM " + VIEW_COMBINED + " LEFT OUTER JOIN " + Obsolete.TABLE_IMAGES +
|
||||
" ON " + Combined.URL + " = " + qualifyColumn(Obsolete.TABLE_IMAGES, Obsolete.Images.URL));
|
||||
}
|
||||
|
||||
private void createCombinedViewOn13(SQLiteDatabase db) {
|
||||
debug("Creating " + VIEW_COMBINED + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + VIEW_COMBINED + " AS" +
|
||||
" SELECT " + Combined.BOOKMARK_ID + ", " +
|
||||
Combined.HISTORY_ID + ", " +
|
||||
// We need to return an _id column because CursorAdapter requires it for its
|
||||
// default implementation for the getItemId() method. However, since
|
||||
// we're not using this feature in the parts of the UI using this view,
|
||||
// we can just use 0 for all rows.
|
||||
"0 AS " + Combined._ID + ", " +
|
||||
Combined.URL + ", " +
|
||||
Combined.TITLE + ", " +
|
||||
Combined.VISITS + ", " +
|
||||
Obsolete.Combined.DISPLAY + ", " +
|
||||
Combined.DATE_LAST_VISITED + ", " +
|
||||
Combined.FAVICON_ID +
|
||||
" FROM (" +
|
||||
// Bookmarks without history.
|
||||
" SELECT " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " AS " + Combined.URL + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + " AS " + Combined.TITLE + ", " +
|
||||
"CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.PARENT) + " WHEN " +
|
||||
Bookmarks.FIXED_READING_LIST_ID + " THEN " + Obsolete.Combined.DISPLAY_READER + " ELSE " +
|
||||
Obsolete.Combined.DISPLAY_NORMAL + " END AS " + Obsolete.Combined.DISPLAY + ", " +
|
||||
"-1 AS " + Combined.HISTORY_ID + ", " +
|
||||
"-1 AS " + Combined.VISITS + ", " +
|
||||
"-1 AS " + Combined.DATE_LAST_VISITED + ", " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.FAVICON_ID) + " AS " + Combined.FAVICON_ID +
|
||||
" FROM " + TABLE_BOOKMARKS +
|
||||
" WHERE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + " AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " = 0 AND " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) +
|
||||
" NOT IN (SELECT " + History.URL + " FROM " + TABLE_HISTORY + ")" +
|
||||
" UNION ALL" +
|
||||
// History with and without bookmark.
|
||||
" SELECT " + "CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " WHEN 0 THEN " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks._ID) + " ELSE NULL END AS " + Combined.BOOKMARK_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.URL) + " AS " + Combined.URL + ", " +
|
||||
// Prioritize bookmark titles over history titles, since the user may have
|
||||
// customized the title for a bookmark.
|
||||
"COALESCE(" + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TITLE) + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.TITLE) +")" + " AS " + Combined.TITLE + ", " +
|
||||
// Only use DISPLAY_READER if the matching bookmark entry inside reading
|
||||
// list folder is not marked as deleted.
|
||||
"CASE " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.IS_DELETED) + " WHEN 0 THEN CASE " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.PARENT) + " WHEN " + Bookmarks.FIXED_READING_LIST_ID +
|
||||
" THEN " + Obsolete.Combined.DISPLAY_READER + " ELSE " + Obsolete.Combined.DISPLAY_NORMAL + " END ELSE " +
|
||||
Obsolete.Combined.DISPLAY_NORMAL + " END AS " + Obsolete.Combined.DISPLAY + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History._ID) + " AS " + Combined.HISTORY_ID + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.VISITS) + " AS " + Combined.VISITS + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.DATE_LAST_VISITED) + " AS " + Combined.DATE_LAST_VISITED + ", " +
|
||||
qualifyColumn(TABLE_HISTORY, History.FAVICON_ID) + " AS " + Combined.FAVICON_ID +
|
||||
" FROM " + TABLE_HISTORY + " LEFT OUTER JOIN " + TABLE_BOOKMARKS +
|
||||
" ON " + qualifyColumn(TABLE_BOOKMARKS, Bookmarks.URL) + " = " + qualifyColumn(TABLE_HISTORY, History.URL) +
|
||||
" WHERE " + qualifyColumn(TABLE_HISTORY, History.URL) + " IS NOT NULL AND " +
|
||||
qualifyColumn(TABLE_HISTORY, History.IS_DELETED) + " = 0 AND (" +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " IS NULL OR " +
|
||||
qualifyColumn(TABLE_BOOKMARKS, Bookmarks.TYPE) + " = " + Bookmarks.TYPE_BOOKMARK + ") " +
|
||||
")");
|
||||
|
||||
debug("Creating " + VIEW_COMBINED_WITH_FAVICONS + " view");
|
||||
|
||||
db.execSQL("CREATE VIEW IF NOT EXISTS " + VIEW_COMBINED_WITH_FAVICONS + " AS" +
|
||||
" SELECT " + qualifyColumn(VIEW_COMBINED, "*") + ", " +
|
||||
qualifyColumn(TABLE_FAVICONS, Favicons.URL) + " AS " + Combined.FAVICON_URL + ", " +
|
||||
qualifyColumn(TABLE_FAVICONS, Favicons.DATA) + " AS " + Combined.FAVICON +
|
||||
" FROM " + VIEW_COMBINED + " LEFT OUTER JOIN " + TABLE_FAVICONS +
|
||||
" ON " + Combined.FAVICON_ID + " = " + qualifyColumn(TABLE_FAVICONS, Favicons._ID));
|
||||
}
|
||||
|
||||
private void createCombinedViewOn19(SQLiteDatabase db) {
|
||||
/*
|
||||
The v19 combined view removes the redundant subquery from the v16
|
||||
|
@ -725,6 +270,7 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
qualifyColumn(TABLE_FAVICONS, Favicons.DATA) + " AS " + Combined.FAVICON +
|
||||
" FROM " + VIEW_COMBINED + " LEFT OUTER JOIN " + TABLE_FAVICONS +
|
||||
" ON " + Combined.FAVICON_ID + " = " + qualifyColumn(TABLE_FAVICONS, Favicons._ID));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -735,8 +281,8 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
table.onCreate(db);
|
||||
}
|
||||
|
||||
createBookmarksTableOn13(db);
|
||||
createHistoryTableOn13(db);
|
||||
createBookmarksTable(db);
|
||||
createHistoryTable(db);
|
||||
createFaviconsTable(db);
|
||||
createThumbnailsTable(db);
|
||||
|
||||
|
@ -777,7 +323,7 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
ReadingListItems.IS_DELETED + " TINYINT DEFAULT 0, " +
|
||||
ReadingListItems.GUID + " TEXT UNIQUE NOT NULL, " +
|
||||
ReadingListItems.DATE_MODIFIED + " INTEGER NOT NULL, " +
|
||||
ReadingListItems.DATE_CREATED + " INTEGER NOT NULL, " +
|
||||
ReadingListItems.DATE_CREATED + " INTEGER NOT NULL, " +
|
||||
ReadingListItems.LENGTH + " INTEGER DEFAULT 0 ); ");
|
||||
|
||||
db.execSQL("CREATE INDEX reading_list_url ON " + TABLE_READING_LIST + "("
|
||||
|
@ -797,10 +343,8 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
R.string.bookmarks_folder_tags, 3);
|
||||
createOrUpdateSpecialFolder(db, Bookmarks.UNFILED_FOLDER_GUID,
|
||||
R.string.bookmarks_folder_unfiled, 4);
|
||||
createOrUpdateSpecialFolder(db, Bookmarks.READING_LIST_FOLDER_GUID,
|
||||
R.string.bookmarks_folder_reading_list, 5);
|
||||
createOrUpdateSpecialFolder(db, Bookmarks.PINNED_FOLDER_GUID,
|
||||
R.string.bookmarks_folder_pinned, 6);
|
||||
R.string.bookmarks_folder_pinned, 5);
|
||||
}
|
||||
|
||||
private void createOrUpdateSpecialFolder(SQLiteDatabase db,
|
||||
|
@ -810,12 +354,11 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
values.put(Bookmarks.TYPE, Bookmarks.TYPE_FOLDER);
|
||||
values.put(Bookmarks.POSITION, position);
|
||||
|
||||
if (guid.equals(Bookmarks.PLACES_FOLDER_GUID))
|
||||
if (guid.equals(Bookmarks.PLACES_FOLDER_GUID)) {
|
||||
values.put(Bookmarks._ID, Bookmarks.FIXED_ROOT_ID);
|
||||
else if (guid.equals(Bookmarks.READING_LIST_FOLDER_GUID))
|
||||
values.put(Bookmarks._ID, Bookmarks.FIXED_READING_LIST_ID);
|
||||
else if (guid.equals(Bookmarks.PINNED_FOLDER_GUID))
|
||||
} else if (guid.equals(Bookmarks.PINNED_FOLDER_GUID)) {
|
||||
values.put(Bookmarks._ID, Bookmarks.FIXED_PINNED_LIST_ID);
|
||||
}
|
||||
|
||||
// Set the parent to 0, which sync assumes is the root
|
||||
values.put(Bookmarks.PARENT, Bookmarks.FIXED_ROOT_ID);
|
||||
|
@ -841,8 +384,9 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
|
||||
private boolean isSpecialFolder(ContentValues values) {
|
||||
String guid = values.getAsString(Bookmarks.GUID);
|
||||
if (guid == null)
|
||||
if (guid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return guid.equals(Bookmarks.MOBILE_FOLDER_GUID) ||
|
||||
guid.equals(Bookmarks.MENU_FOLDER_GUID) ||
|
||||
|
@ -958,7 +502,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
" RENAME TO " + TABLE_BOOKMARKS_TMP);
|
||||
|
||||
debug("Dropping views and indexes related to " + TABLE_BOOKMARKS);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_BOOKMARKS_WITH_IMAGES);
|
||||
|
||||
db.execSQL("DROP INDEX IF EXISTS bookmarks_url_index");
|
||||
db.execSQL("DROP INDEX IF EXISTS bookmarks_type_deleted_index");
|
||||
|
@ -966,7 +509,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
db.execSQL("DROP INDEX IF EXISTS bookmarks_modified_index");
|
||||
|
||||
createBookmarksTable(db);
|
||||
createBookmarksWithImagesView(db);
|
||||
|
||||
createOrUpdateSpecialFolder(db, Bookmarks.PLACES_FOLDER_GUID,
|
||||
R.string.bookmarks_folder_places, 0);
|
||||
|
@ -981,15 +523,16 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_BOOKMARKS_TMP);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Migrate a history table from some old version to the newest one by creating the new table and
|
||||
* copying all the data over.
|
||||
*/
|
||||
private void migrateHistoryTable(SQLiteDatabase db) {
|
||||
debug("Renaming history table to " + TABLE_HISTORY_TMP);
|
||||
db.execSQL("ALTER TABLE " + TABLE_HISTORY +
|
||||
" RENAME TO " + TABLE_HISTORY_TMP);
|
||||
|
||||
debug("Dropping views and indexes related to " + TABLE_HISTORY);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_HISTORY_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
|
||||
db.execSQL("DROP INDEX IF EXISTS history_url_index");
|
||||
db.execSQL("DROP INDEX IF EXISTS history_guid_index");
|
||||
|
@ -997,8 +540,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
db.execSQL("DROP INDEX IF EXISTS history_visited_index");
|
||||
|
||||
createHistoryTable(db);
|
||||
createHistoryWithImagesView(db);
|
||||
createCombinedWithImagesView(db);
|
||||
|
||||
db.execSQL("INSERT INTO " + TABLE_HISTORY + " SELECT * FROM " + TABLE_HISTORY_TMP);
|
||||
|
||||
|
@ -1006,86 +547,16 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_HISTORY_TMP);
|
||||
}
|
||||
|
||||
private void migrateImagesTable(SQLiteDatabase db) {
|
||||
debug("Renaming images table to " + TABLE_IMAGES_TMP);
|
||||
db.execSQL("ALTER TABLE " + Obsolete.TABLE_IMAGES +
|
||||
" RENAME TO " + TABLE_IMAGES_TMP);
|
||||
|
||||
debug("Dropping views and indexes related to " + Obsolete.TABLE_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_HISTORY_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
|
||||
db.execSQL("DROP INDEX IF EXISTS images_url_index");
|
||||
db.execSQL("DROP INDEX IF EXISTS images_guid_index");
|
||||
db.execSQL("DROP INDEX IF EXISTS images_modified_index");
|
||||
|
||||
createImagesTable(db);
|
||||
createHistoryWithImagesView(db);
|
||||
createCombinedWithImagesView(db);
|
||||
|
||||
db.execSQL("INSERT INTO " + Obsolete.TABLE_IMAGES + " SELECT * FROM " + TABLE_IMAGES_TMP);
|
||||
|
||||
debug("Dropping images temporary table");
|
||||
db.execSQL("DROP TABLE IF EXISTS " + TABLE_IMAGES_TMP);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom1to2(SQLiteDatabase db) {
|
||||
migrateBookmarksTable(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom2to3(SQLiteDatabase db) {
|
||||
debug("Dropping view: " + Obsolete.VIEW_BOOKMARKS_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_BOOKMARKS_WITH_IMAGES);
|
||||
|
||||
createBookmarksWithImagesView(db);
|
||||
|
||||
debug("Dropping view: " + Obsolete.VIEW_HISTORY_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_HISTORY_WITH_IMAGES);
|
||||
|
||||
createHistoryWithImagesView(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom3to4(SQLiteDatabase db) {
|
||||
migrateBookmarksTable(db, new BookmarkMigrator3to4());
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom4to5(SQLiteDatabase db) {
|
||||
createCombinedWithImagesView(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom5to6(SQLiteDatabase db) {
|
||||
debug("Dropping view: " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
|
||||
createCombinedWithImagesView(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom6to7(SQLiteDatabase db) {
|
||||
debug("Removing history visits with NULL GUIDs");
|
||||
db.execSQL("DELETE FROM " + TABLE_HISTORY + " WHERE " + History.GUID + " IS NULL");
|
||||
|
||||
debug("Update images with NULL GUIDs");
|
||||
String[] columns = new String[] { Obsolete.Images._ID };
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = db.query(Obsolete.TABLE_IMAGES, columns, Obsolete.Images.GUID + " IS NULL", null, null ,null, null, null);
|
||||
ContentValues values = new ContentValues();
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
values.put(Obsolete.Images.GUID, Utils.generateGuid());
|
||||
db.update(Obsolete.TABLE_IMAGES, values, Obsolete.Images._ID + " = ?", new String[] {
|
||||
cursor.getString(cursor.getColumnIndexOrThrow(Obsolete.Images._ID))
|
||||
});
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
migrateBookmarksTable(db);
|
||||
migrateHistoryTable(db);
|
||||
migrateImagesTable(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom7to8(SQLiteDatabase db) {
|
||||
|
@ -1122,157 +593,38 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
db.execSQL("DROP TABLE " + TABLE_DUPES);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom8to9(SQLiteDatabase db) {
|
||||
createOrUpdateSpecialFolder(db, Bookmarks.READING_LIST_FOLDER_GUID,
|
||||
R.string.bookmarks_folder_reading_list, 5);
|
||||
|
||||
debug("Dropping view: " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
|
||||
createCombinedWithImagesViewOn9(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom9to10(SQLiteDatabase db) {
|
||||
debug("Dropping view: " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
|
||||
createCombinedWithImagesViewOn10(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom10to11(SQLiteDatabase db) {
|
||||
debug("Dropping view: " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
|
||||
db.execSQL("CREATE INDEX bookmarks_type_deleted_index ON " + TABLE_BOOKMARKS + "("
|
||||
+ Bookmarks.TYPE + ", " + Bookmarks.IS_DELETED + ")");
|
||||
|
||||
createCombinedWithImagesViewOn11(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom11to12(SQLiteDatabase db) {
|
||||
debug("Dropping view: " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
|
||||
createCombinedViewOn12(db);
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom12to13(SQLiteDatabase db) {
|
||||
// Update images table with favicon URLs
|
||||
SQLiteDatabase faviconsDb = null;
|
||||
Cursor c = null;
|
||||
try {
|
||||
final String FAVICON_TABLE = "favicon_urls";
|
||||
final String FAVICON_URL = "favicon_url";
|
||||
final String FAVICON_PAGE = "page_url";
|
||||
|
||||
String dbPath = mContext.getDatabasePath(Obsolete.FAVICON_DB).getPath();
|
||||
faviconsDb = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READONLY);
|
||||
String[] columns = new String[] { FAVICON_URL, FAVICON_PAGE };
|
||||
c = faviconsDb.query(FAVICON_TABLE, columns, null, null, null, null, null, null);
|
||||
int faviconIndex = c.getColumnIndexOrThrow(FAVICON_URL);
|
||||
int pageIndex = c.getColumnIndexOrThrow(FAVICON_PAGE);
|
||||
while (c.moveToNext()) {
|
||||
ContentValues values = new ContentValues(1);
|
||||
String faviconUrl = c.getString(faviconIndex);
|
||||
String pageUrl = c.getString(pageIndex);
|
||||
values.put(FAVICON_URL, faviconUrl);
|
||||
db.update(Obsolete.TABLE_IMAGES, values, Obsolete.Images.URL + " = ?", new String[] { pageUrl });
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// If we can't read from the database for some reason, we won't
|
||||
// be able to import the favicon URLs. This isn't a fatal
|
||||
// error, so continue the upgrade.
|
||||
Log.e(LOGTAG, "Exception importing from " + Obsolete.FAVICON_DB, e);
|
||||
} finally {
|
||||
if (c != null)
|
||||
c.close();
|
||||
if (faviconsDb != null)
|
||||
faviconsDb.close();
|
||||
}
|
||||
|
||||
createFaviconsTable(db);
|
||||
|
||||
// Import favicons into the favicons table
|
||||
db.execSQL("ALTER TABLE " + TABLE_HISTORY
|
||||
+ " ADD COLUMN " + History.FAVICON_ID + " INTEGER");
|
||||
db.execSQL("ALTER TABLE " + TABLE_BOOKMARKS
|
||||
+ " ADD COLUMN " + Bookmarks.FAVICON_ID + " INTEGER");
|
||||
|
||||
// Add favicon_id column to the history/bookmarks tables. We wrap this in a try-catch
|
||||
// because the column *may* already exist at this point (depending on how many upgrade
|
||||
// steps have been performed in this operation). In which case these queries will throw,
|
||||
// but we don't care.
|
||||
try {
|
||||
c = db.query(Obsolete.TABLE_IMAGES,
|
||||
new String[] {
|
||||
Obsolete.Images.URL,
|
||||
Obsolete.Images.FAVICON_URL,
|
||||
Obsolete.Images.FAVICON,
|
||||
Obsolete.Images.DATE_MODIFIED,
|
||||
Obsolete.Images.DATE_CREATED
|
||||
},
|
||||
Obsolete.Images.FAVICON + " IS NOT NULL",
|
||||
null, null, null, null);
|
||||
|
||||
while (c.moveToNext()) {
|
||||
long faviconId = -1;
|
||||
int faviconUrlIndex = c.getColumnIndexOrThrow(Obsolete.Images.FAVICON_URL);
|
||||
String faviconUrl = null;
|
||||
if (!c.isNull(faviconUrlIndex)) {
|
||||
faviconUrl = c.getString(faviconUrlIndex);
|
||||
Cursor c2 = null;
|
||||
try {
|
||||
c2 = db.query(TABLE_FAVICONS,
|
||||
new String[] { Favicons._ID },
|
||||
Favicons.URL + " = ?",
|
||||
new String[] { faviconUrl },
|
||||
null, null, null);
|
||||
if (c2.moveToFirst()) {
|
||||
faviconId = c2.getLong(c2.getColumnIndexOrThrow(Favicons._ID));
|
||||
}
|
||||
} finally {
|
||||
if (c2 != null)
|
||||
c2.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (faviconId == -1) {
|
||||
ContentValues values = new ContentValues(4);
|
||||
values.put(Favicons.URL, faviconUrl);
|
||||
values.put(Favicons.DATA, c.getBlob(c.getColumnIndexOrThrow(Obsolete.Images.FAVICON)));
|
||||
values.put(Favicons.DATE_MODIFIED, c.getLong(c.getColumnIndexOrThrow(Obsolete.Images.DATE_MODIFIED)));
|
||||
values.put(Favicons.DATE_CREATED, c.getLong(c.getColumnIndexOrThrow(Obsolete.Images.DATE_CREATED)));
|
||||
faviconId = db.insert(TABLE_FAVICONS, null, values);
|
||||
}
|
||||
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(FaviconColumns.FAVICON_ID, faviconId);
|
||||
db.update(TABLE_HISTORY, values, History.URL + " = ?",
|
||||
new String[] { c.getString(c.getColumnIndexOrThrow(Obsolete.Images.URL)) });
|
||||
db.update(TABLE_BOOKMARKS, values, Bookmarks.URL + " = ?",
|
||||
new String[] { c.getString(c.getColumnIndexOrThrow(Obsolete.Images.URL)) });
|
||||
}
|
||||
} finally {
|
||||
if (c != null)
|
||||
c.close();
|
||||
db.execSQL("ALTER TABLE " + TABLE_HISTORY +
|
||||
" ADD COLUMN " + History.FAVICON_ID + " INTEGER");
|
||||
db.execSQL("ALTER TABLE " + TABLE_BOOKMARKS +
|
||||
" ADD COLUMN " + Bookmarks.FAVICON_ID + " INTEGER");
|
||||
} catch (SQLException e) {
|
||||
// Don't care.
|
||||
debug("Exception adding favicon_id column. We're probably fine." + e);
|
||||
}
|
||||
|
||||
createThumbnailsTable(db);
|
||||
|
||||
// Import thumbnails into the thumbnails table
|
||||
db.execSQL("INSERT INTO " + TABLE_THUMBNAILS + " ("
|
||||
+ Thumbnails.URL + ", "
|
||||
+ Thumbnails.DATA + ") "
|
||||
+ "SELECT " + Obsolete.Images.URL + ", " + Obsolete.Images.THUMBNAIL
|
||||
+ " FROM " + Obsolete.TABLE_IMAGES
|
||||
+ " WHERE " + Obsolete.Images.THUMBNAIL + " IS NOT NULL");
|
||||
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_BOOKMARKS_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_HISTORY_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + Obsolete.VIEW_COMBINED_WITH_IMAGES);
|
||||
db.execSQL("DROP VIEW IF EXISTS " + VIEW_COMBINED);
|
||||
db.execSQL("DROP VIEW IF EXISTS bookmarks_with_images");
|
||||
db.execSQL("DROP VIEW IF EXISTS history_with_images");
|
||||
db.execSQL("DROP VIEW IF EXISTS combined_with_images");
|
||||
|
||||
createBookmarksWithFaviconsView(db);
|
||||
createHistoryWithFaviconsView(db);
|
||||
createCombinedViewOn13(db);
|
||||
|
||||
db.execSQL("DROP TABLE IF EXISTS " + Obsolete.TABLE_IMAGES);
|
||||
db.execSQL("DROP TABLE IF EXISTS images");
|
||||
}
|
||||
|
||||
private void upgradeDatabaseFrom13to14(SQLiteDatabase db) {
|
||||
|
@ -1425,26 +777,10 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
// database schema version.
|
||||
for (int v = oldVersion + 1; v <= newVersion; v++) {
|
||||
switch(v) {
|
||||
case 2:
|
||||
upgradeDatabaseFrom1to2(db);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
upgradeDatabaseFrom2to3(db);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
upgradeDatabaseFrom3to4(db);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
upgradeDatabaseFrom4to5(db);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
upgradeDatabaseFrom5to6(db);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
upgradeDatabaseFrom6to7(db);
|
||||
break;
|
||||
|
@ -1453,22 +789,10 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
upgradeDatabaseFrom7to8(db);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
upgradeDatabaseFrom8to9(db);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
upgradeDatabaseFrom9to10(db);
|
||||
break;
|
||||
|
||||
case 11:
|
||||
upgradeDatabaseFrom10to11(db);
|
||||
break;
|
||||
|
||||
case 12:
|
||||
upgradeDatabaseFrom11to12(db);
|
||||
break;
|
||||
|
||||
case 13:
|
||||
upgradeDatabaseFrom12to13(db);
|
||||
break;
|
||||
|
@ -1507,14 +831,12 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
table.onUpgrade(db, oldVersion, newVersion);
|
||||
}
|
||||
|
||||
// If an upgrade after 12->13 fails, the entire upgrade is rolled
|
||||
// back, but we can't undo the deletion of favicon_urls.db if we
|
||||
// delete this in step 13; therefore, we wait until all steps are
|
||||
// complete before removing it.
|
||||
if (oldVersion < 13 && newVersion >= 13
|
||||
&& mContext.getDatabasePath(Obsolete.FAVICON_DB).exists()
|
||||
&& !mContext.deleteDatabase(Obsolete.FAVICON_DB)) {
|
||||
throw new SQLException("Could not delete " + Obsolete.FAVICON_DB);
|
||||
// Delete the obsolete favicon database after all other upgrades complete.
|
||||
// This can probably equivalently be moved into upgradeDatabaseFrom12to13.
|
||||
if (oldVersion < 13 && newVersion >= 13) {
|
||||
if (mContext.getDatabasePath("favicon_urls.db").exists()) {
|
||||
mContext.deleteDatabase("favicon_urls.db");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1559,10 +881,6 @@ final class BrowserDatabaseHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private static final String qualifyColumn(String table, String column) {
|
||||
return DBUtils.qualifyColumn(table, column);
|
||||
}
|
||||
|
||||
// Calculate these once, at initialization. isLoggable is too expensive to
|
||||
// have in-line in each log call.
|
||||
private static final boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
|
||||
|
|
|
@ -37,7 +37,6 @@ public class AndroidBrowserBookmarksDataAccessor extends AndroidBrowserRepositor
|
|||
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;
|
||||
|
|
|
@ -203,8 +203,6 @@ public class AndroidBrowserBookmarksRepositorySession extends AndroidBrowserRepo
|
|||
*/
|
||||
public static boolean forbiddenGUID(final String recordGUID) {
|
||||
return recordGUID == null ||
|
||||
// Temporarily exclude reading list items (Bug 762118; re-enable in Bug 762109.)
|
||||
BrowserContract.Bookmarks.READING_LIST_FOLDER_GUID.equals(recordGUID) ||
|
||||
BrowserContract.Bookmarks.PINNED_FOLDER_GUID.equals(recordGUID) ||
|
||||
BrowserContract.Bookmarks.PLACES_FOLDER_GUID.equals(recordGUID) ||
|
||||
BrowserContract.Bookmarks.TAGS_FOLDER_GUID.equals(recordGUID);
|
||||
|
@ -221,8 +219,6 @@ public class AndroidBrowserBookmarksRepositorySession extends AndroidBrowserRepo
|
|||
*/
|
||||
public static boolean forbiddenParent(final String parentGUID) {
|
||||
return parentGUID == null ||
|
||||
// Temporarily exclude reading list items (Bug 762118; re-enable in Bug 762109.)
|
||||
BrowserContract.Bookmarks.READING_LIST_FOLDER_GUID.equals(parentGUID) ||
|
||||
BrowserContract.Bookmarks.PINNED_FOLDER_GUID.equals(parentGUID);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
}
|
||||
|
||||
private void ensureEmptyDatabase() throws Exception {
|
||||
Cursor c = null;
|
||||
Cursor c;
|
||||
|
||||
String guid = BrowserContract.Bookmarks.GUID;
|
||||
|
||||
|
@ -50,15 +50,13 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
guid + " != ? AND " +
|
||||
guid + " != ? AND " +
|
||||
guid + " != ? AND " +
|
||||
guid + " != ? AND " +
|
||||
guid + " != ?",
|
||||
new String[] { BrowserContract.Bookmarks.PLACES_FOLDER_GUID,
|
||||
BrowserContract.Bookmarks.MOBILE_FOLDER_GUID,
|
||||
BrowserContract.Bookmarks.MENU_FOLDER_GUID,
|
||||
BrowserContract.Bookmarks.TAGS_FOLDER_GUID,
|
||||
BrowserContract.Bookmarks.TOOLBAR_FOLDER_GUID,
|
||||
BrowserContract.Bookmarks.UNFILED_FOLDER_GUID,
|
||||
BrowserContract.Bookmarks.READING_LIST_FOLDER_GUID });
|
||||
BrowserContract.Bookmarks.UNFILED_FOLDER_GUID });
|
||||
|
||||
c = mProvider.query(appendUriParam(BrowserContract.Bookmarks.CONTENT_URI, BrowserContract.PARAM_SHOW_DELETED, "1"), null, null, null, null);
|
||||
assertCountIsAndClose(c, 7, "All non-special bookmarks and folders were deleted");
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TestBookmarks extends AndroidSyncTestCase {
|
|||
protected static final String LOG_TAG = "BookmarksTest";
|
||||
|
||||
/**
|
||||
* Trivial test that forbidden records (reading list prior to Bug 762109, pinned items…)
|
||||
* Trivial test that forbidden records such as pinned items
|
||||
* will be ignored if processed.
|
||||
*/
|
||||
public void testForbiddenItemsAreIgnored() {
|
||||
|
@ -58,32 +58,25 @@ public class TestBookmarks extends AndroidSyncTestCase {
|
|||
final long now = System.currentTimeMillis();
|
||||
final String bookmarksCollection = "bookmarks";
|
||||
|
||||
final BookmarkRecord toRead = new BookmarkRecord("daaaaaaaaaaa", "bookmarks", now - 1, false);
|
||||
final BookmarkRecord pinned = new BookmarkRecord("pinpinpinpin", "bookmarks", now - 1, false);
|
||||
final BookmarkRecord normal = new BookmarkRecord("baaaaaaaaaaa", "bookmarks", now - 2, false);
|
||||
|
||||
final BookmarkRecord readingList = new BookmarkRecord(Bookmarks.READING_LIST_FOLDER_GUID,
|
||||
bookmarksCollection, now - 3, false);
|
||||
final BookmarkRecord pinnedItems = new BookmarkRecord(Bookmarks.PINNED_FOLDER_GUID,
|
||||
bookmarksCollection, now - 4, false);
|
||||
|
||||
toRead.type = normal.type = pinned.type = "bookmark";
|
||||
readingList.type = "folder";
|
||||
normal.type = "bookmark";
|
||||
pinned.type = "bookmark";
|
||||
pinnedItems.type = "folder";
|
||||
|
||||
toRead.parentID = Bookmarks.READING_LIST_FOLDER_GUID;
|
||||
pinned.parentID = Bookmarks.PINNED_FOLDER_GUID;
|
||||
normal.parentID = Bookmarks.TOOLBAR_FOLDER_GUID;
|
||||
|
||||
readingList.parentID = Bookmarks.PLACES_FOLDER_GUID;
|
||||
pinnedItems.parentID = Bookmarks.PLACES_FOLDER_GUID;
|
||||
|
||||
inBegunSession(repo, new SimpleSuccessBeginDelegate() {
|
||||
@Override
|
||||
public void onBeginSucceeded(RepositorySession session) {
|
||||
assertTrue(((AndroidBrowserBookmarksRepositorySession) session).shouldIgnore(toRead));
|
||||
assertTrue(((AndroidBrowserBookmarksRepositorySession) session).shouldIgnore(pinned));
|
||||
assertTrue(((AndroidBrowserBookmarksRepositorySession) session).shouldIgnore(readingList));
|
||||
assertTrue(((AndroidBrowserBookmarksRepositorySession) session).shouldIgnore(pinnedItems));
|
||||
assertFalse(((AndroidBrowserBookmarksRepositorySession) session).shouldIgnore(normal));
|
||||
finishAndNotify(session);
|
||||
|
@ -115,24 +108,6 @@ public class TestBookmarks extends AndroidSyncTestCase {
|
|||
assertFalse(guids.contains("dapinneditem"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Trivial test that reading list records will be skipped if present in the DB.
|
||||
*/
|
||||
public void testReadingListIsNotRetrieved() {
|
||||
final AndroidBrowserBookmarksRepository repo = new AndroidBrowserBookmarksRepository();
|
||||
|
||||
// Ensure that it exists.
|
||||
setUpFennecReadingListRecord();
|
||||
|
||||
// It's there in the DB…
|
||||
final ArrayList<String> roots = fetchChildrenDirect(BrowserContract.Bookmarks.FIXED_ROOT_ID);
|
||||
Logger.info(LOG_TAG, "Roots: " + roots);
|
||||
assertTrue(roots.contains(Bookmarks.READING_LIST_FOLDER_GUID));
|
||||
|
||||
// … but not when we fetch.
|
||||
assertFalse(fetchGUIDs(repo).contains(Bookmarks.READING_LIST_FOLDER_GUID));
|
||||
}
|
||||
|
||||
public void testRetrieveFolderHasAccurateChildren() {
|
||||
AndroidBrowserBookmarksRepository repo = new AndroidBrowserBookmarksRepository();
|
||||
|
||||
|
@ -864,17 +839,6 @@ public class TestBookmarks extends AndroidSyncTestCase {
|
|||
return values;
|
||||
}
|
||||
|
||||
protected ContentValues fennecReadingListRecord() {
|
||||
final ContentValues values = specialFolder();
|
||||
final String title = getApplicationContext().getResources().getString(R.string.bookmarks_folder_reading_list);
|
||||
|
||||
values.put(BrowserContract.SyncColumns.GUID, Bookmarks.READING_LIST_FOLDER_GUID);
|
||||
values.put(Bookmarks._ID, Bookmarks.FIXED_READING_LIST_ID);
|
||||
values.put(Bookmarks.PARENT, Bookmarks.FIXED_ROOT_ID);
|
||||
values.put(Bookmarks.TITLE, title);
|
||||
return values;
|
||||
}
|
||||
|
||||
protected long setUpFennecMobileRecordWithoutTitle() {
|
||||
ContentResolver cr = getApplicationContext().getContentResolver();
|
||||
ContentValues values = fennecMobileRecordWithoutTitle();
|
||||
|
@ -897,10 +861,6 @@ public class TestBookmarks extends AndroidSyncTestCase {
|
|||
insertRow(fennecPinnedChildItemRecord());
|
||||
}
|
||||
|
||||
protected void setUpFennecReadingListRecord() {
|
||||
insertRow(fennecReadingListRecord());
|
||||
}
|
||||
|
||||
//
|
||||
// Fennec fake layer.
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче