summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser/provider
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-12-22 13:23:54 -0800
committerJohn Reck <jreck@google.com>2010-12-22 16:11:13 -0800
commit9c001cd8e022a477dbf0d166f48098c9283d3847 (patch)
tree35e48ee223c4a319caec53a8a2746aa149116e1b /src/com/android/browser/provider
parent246ee01c0c146962e9050ad2b30fc7729acd9acc (diff)
downloadpackages_apps_Browser-9c001cd8e022a477dbf0d166f48098c9283d3847.zip
packages_apps_Browser-9c001cd8e022a477dbf0d166f48098c9283d3847.tar.gz
packages_apps_Browser-9c001cd8e022a477dbf0d166f48098c9283d3847.tar.bz2
Fixes CTS failures
Bug: 3306992 Change-Id: I5956746eac4622a64d50c72b57589f797f0d97a1
Diffstat (limited to 'src/com/android/browser/provider')
-rw-r--r--src/com/android/browser/provider/BrowserProvider2.java38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index 1eaad25..1b90cb3 100644
--- a/src/com/android/browser/provider/BrowserProvider2.java
+++ b/src/com/android/browser/provider/BrowserProvider2.java
@@ -41,6 +41,7 @@ import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.provider.BaseColumns;
+import android.provider.Browser;
import android.provider.Browser.BookmarkColumns;
import android.provider.BrowserContract;
import android.provider.BrowserContract.Accounts;
@@ -85,8 +86,6 @@ public class BrowserProvider2 extends SQLiteContentProvider {
static final String DEFAULT_SORT_HISTORY = History.DATE_LAST_VISITED + " DESC";
- static final String DEFAULT_SORT_SEARCHES = Searches.DATE + " DESC";
-
private static final String[] SUGGEST_PROJECTION = new String[] {
Bookmarks._ID,
Bookmarks.URL,
@@ -641,6 +640,10 @@ public class BrowserProvider2 extends SQLiteContentProvider {
Bookmarks.ACCOUNT_TYPE + "=? AND " + Bookmarks.ACCOUNT_NAME + "=? ");
selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,
new String[] { accountType, accountName });
+ } else {
+ selection = DatabaseUtils.concatenateWhere(selection,
+ Bookmarks.ACCOUNT_TYPE + " IS NULL AND " +
+ Bookmarks.ACCOUNT_NAME + " IS NULL ");
}
// Set a default sort order if one isn't specified
@@ -760,9 +763,6 @@ public class BrowserProvider2 extends SQLiteContentProvider {
// fall through
}
case SEARCHES: {
- if (sortOrder == null) {
- sortOrder = DEFAULT_SORT_SEARCHES;
- }
qb.setTables(TABLE_SEARCHES);
qb.setProjectionMap(SEARCHES_PROJECTION_MAP);
break;
@@ -796,7 +796,10 @@ public class BrowserProvider2 extends SQLiteContentProvider {
}
case LEGACY:
case COMBINED: {
- qb = new SQLiteQueryBuilder();
+ if ((match == LEGACY || match == LEGACY_ID)
+ && projection == null) {
+ projection = Browser.HISTORY_PROJECTION;
+ }
String[] args = createCombinedQuery(uri, projection, qb);
if (selectionArgs == null) {
selectionArgs = args;
@@ -913,10 +916,23 @@ public class BrowserProvider2 extends SQLiteContentProvider {
return args;
}
- int deleteBookmarks(String selection, String[] selectionArgs,
+ int deleteBookmarks(Uri uri, String selection, String[] selectionArgs,
boolean callerIsSyncAdapter) {
//TODO cascade deletes down from folders
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+ // Look for account info
+ String accountType = uri.getQueryParameter(Bookmarks.PARAM_ACCOUNT_TYPE);
+ String accountName = uri.getQueryParameter(Bookmarks.PARAM_ACCOUNT_NAME);
+ if (!TextUtils.isEmpty(accountType) && !TextUtils.isEmpty(accountName)) {
+ selection = DatabaseUtils.concatenateWhere(selection,
+ Bookmarks.ACCOUNT_TYPE + "=? AND " + Bookmarks.ACCOUNT_NAME + "=? ");
+ selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,
+ new String[] { accountType, accountName });
+ } else {
+ selection = DatabaseUtils.concatenateWhere(selection,
+ Bookmarks.ACCOUNT_TYPE + " IS NULL AND " +
+ Bookmarks.ACCOUNT_NAME + " IS NULL ");
+ }
if (callerIsSyncAdapter) {
return db.delete(TABLE_BOOKMARKS, selection, selectionArgs);
}
@@ -941,7 +957,7 @@ public class BrowserProvider2 extends SQLiteContentProvider {
// fall through
}
case BOOKMARKS: {
- int deleted = deleteBookmarks(selection, selectionArgs, callerIsSyncAdapter);
+ int deleted = deleteBookmarks(uri, selection, selectionArgs, callerIsSyncAdapter);
pruneImages();
return deleted;
}
@@ -1006,7 +1022,7 @@ public class BrowserProvider2 extends SQLiteContentProvider {
boolean isBookmark = c.getInt(1) != 0;
String url = c.getString(2);
if (isBookmark) {
- deleted += deleteBookmarks(Bookmarks._ID + "=?",
+ deleted += deleteBookmarks(uri, Bookmarks._ID + "=?",
new String[] { Long.toString(id) },
callerIsSyncAdapter);
db.delete(TABLE_HISTORY, History.URL + "=?",
@@ -1311,6 +1327,10 @@ public class BrowserProvider2 extends SQLiteContentProvider {
}
return count;
}
+
+ case SEARCHES: {
+ return db.update(TABLE_SEARCHES, values, selection, selectionArgs);
+ }
}
throw new UnsupportedOperationException("Unknown update URI " + uri);
}