зеркало из https://github.com/mozilla/pjs.git
Bug 707124 - Add query to BrowserProvider to fetch DB schema version (r=blassey, a=mfinkle)
This commit is contained in:
Родитель
f176aae200
Коммит
12b1c24ddb
|
@ -111,4 +111,12 @@ public class BrowserContract {
|
|||
|
||||
public static final String VISITS = "visits";
|
||||
}
|
||||
|
||||
public static final class Schema {
|
||||
private Schema() {}
|
||||
|
||||
public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "schema");
|
||||
|
||||
public static final String VERSION = "version";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
|||
import org.mozilla.gecko.db.BrowserContract.CommonColumns;
|
||||
import org.mozilla.gecko.db.BrowserContract.History;
|
||||
import org.mozilla.gecko.db.BrowserContract.Images;
|
||||
import org.mozilla.gecko.db.BrowserContract.Schema;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentUris;
|
||||
|
@ -53,6 +54,7 @@ import android.content.ContentValues;
|
|||
import android.content.Context;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteQueryBuilder;
|
||||
|
@ -66,6 +68,8 @@ public class BrowserProvider extends ContentProvider {
|
|||
|
||||
static final String DATABASE_NAME = "browser.db";
|
||||
|
||||
static final int DATABASE_VERSION = 1;
|
||||
|
||||
static final String TABLE_BOOKMARKS = "bookmarks";
|
||||
static final String TABLE_HISTORY = "history";
|
||||
static final String TABLE_IMAGES = "images";
|
||||
|
@ -82,6 +86,9 @@ public class BrowserProvider extends ContentProvider {
|
|||
// Image matches
|
||||
static final int IMAGES = 300;
|
||||
|
||||
// Schema matches
|
||||
static final int SCHEMA = 400;
|
||||
|
||||
static final String DEFAULT_BOOKMARKS_SORT_ORDER = Bookmarks.IS_FOLDER
|
||||
+ " DESC, " + Bookmarks.POSITION + " ASC, " + Bookmarks._ID
|
||||
+ " ASC";
|
||||
|
@ -101,6 +108,7 @@ public class BrowserProvider extends ContentProvider {
|
|||
static final HashMap<String, String> BOOKMARKS_PROJECTION_MAP = new HashMap<String, String>();
|
||||
static final HashMap<String, String> HISTORY_PROJECTION_MAP = new HashMap<String, String>();
|
||||
static final HashMap<String, String> IMAGES_PROJECTION_MAP = new HashMap<String, String>();
|
||||
static final HashMap<String, String> SCHEMA_PROJECTION_MAP = new HashMap<String, String>();
|
||||
|
||||
private HashMap<String, DatabaseHelper> mDatabasePerProfile;
|
||||
|
||||
|
@ -152,6 +160,12 @@ public class BrowserProvider extends ContentProvider {
|
|||
map.put(Images.DATE_CREATED, qualifyColumn(TABLE_IMAGES, Images.DATE_CREATED));
|
||||
map.put(Images.DATE_MODIFIED, qualifyColumn(TABLE_IMAGES, Images.DATE_MODIFIED));
|
||||
map.put(Images.GUID, qualifyColumn(TABLE_IMAGES, Images.GUID));
|
||||
|
||||
// Schema
|
||||
URI_MATCHER.addURI(BrowserContract.AUTHORITY, "schema", SCHEMA);
|
||||
|
||||
map = SCHEMA_PROJECTION_MAP;
|
||||
map.put(Schema.VERSION, Schema.VERSION);
|
||||
}
|
||||
|
||||
static final String qualifyColumn(String table, String column) {
|
||||
|
@ -195,8 +209,6 @@ public class BrowserProvider extends ContentProvider {
|
|||
}
|
||||
|
||||
final class DatabaseHelper extends SQLiteOpenHelper {
|
||||
static final int DATABASE_VERSION = 1;
|
||||
|
||||
public DatabaseHelper(Context context, String databasePath) {
|
||||
super(context, databasePath, null, DATABASE_VERSION);
|
||||
}
|
||||
|
@ -696,6 +708,15 @@ public class BrowserProvider extends ContentProvider {
|
|||
break;
|
||||
}
|
||||
|
||||
case SCHEMA: {
|
||||
Log.d(LOGTAG, "Query is on schema: " + uri);
|
||||
|
||||
MatrixCursor schemaCursor = new MatrixCursor(new String[] { Schema.VERSION });
|
||||
schemaCursor.newRow().add(DATABASE_VERSION);
|
||||
|
||||
return schemaCursor;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unknown query URI " + uri);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче