diff options
author | John Reck <jreck@google.com> | 2011-02-02 10:42:25 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-02-07 17:42:11 -0800 |
commit | e6adaf57a9a4f05e88505e4a86c565b5f18a1d3b (patch) | |
tree | 4f03b39e27a22ada14262239e348c53695279c21 /src/com | |
parent | 7eaea797ac276c48bac62f5b787143282a3f4753 (diff) | |
download | packages_apps_Browser-e6adaf57a9a4f05e88505e4a86c565b5f18a1d3b.zip packages_apps_Browser-e6adaf57a9a4f05e88505e4a86c565b5f18a1d3b.tar.gz packages_apps_Browser-e6adaf57a9a4f05e88505e4a86c565b5f18a1d3b.tar.bz2 |
BP2 ContentResolver.notifyChange tests
Bug: 3431373
Change-Id: I0ce30213150c6dd51b128723f044bd32eb2b46a3
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 74cb773..85d6d64 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -16,6 +16,8 @@ package com.android.browser.provider; +import com.google.common.annotations.VisibleForTesting; + import com.android.browser.BookmarkUtils; import com.android.browser.BrowserBookmarksPage; import com.android.browser.R; @@ -34,6 +36,7 @@ import android.content.UriMatcher; import android.content.res.Resources; import android.content.res.TypedArray; import android.database.AbstractCursor; +import android.database.ContentObserver; import android.database.Cursor; import android.database.DatabaseUtils; import android.database.MatrixCursor; @@ -66,7 +69,7 @@ import java.util.HashMap; public class BrowserProvider2 extends SQLiteContentProvider { - static final String LEGACY_AUTHORITY = "browser"; + public static final String LEGACY_AUTHORITY = "browser"; static final Uri LEGACY_AUTHORITY_URI = new Uri.Builder() .authority(LEGACY_AUTHORITY).scheme("content").build(); @@ -319,6 +322,8 @@ public class BrowserProvider2 extends SQLiteContentProvider { DatabaseHelper mOpenHelper; SyncStateContentProviderHelper mSyncHelper = new SyncStateContentProviderHelper(); + // This is so provider tests can intercept widget updating + ContentObserver mWidgetObserver = null; final class DatabaseHelper extends SQLiteOpenHelper { static final String DATABASE_NAME = "browser2.db"; @@ -580,6 +585,19 @@ public class BrowserProvider2 extends SQLiteContentProvider { resolver.notifyChange(LEGACY_AUTHORITY_URI, null, !callerIsSyncAdapter); } + @VisibleForTesting + public void setWidgetObserver(ContentObserver obs) { + mWidgetObserver = obs; + } + + void refreshWidgets() { + if (mWidgetObserver == null) { + BookmarkThumbnailWidgetProvider.refreshWidgets(getContext()); + } else { + mWidgetObserver.dispatchChange(false); + } + } + @Override public String getType(Uri uri) { final int match = URI_MATCHER.match(uri); @@ -987,7 +1005,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { int deleted = deleteBookmarks(selection, selectionArgs, callerIsSyncAdapter); pruneImages(); if (deleted > 0) { - BookmarkThumbnailWidgetProvider.refreshWidgets(getContext()); + refreshWidgets(); } return deleted; } @@ -1150,7 +1168,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { } id = db.insertOrThrow(TABLE_BOOKMARKS, Bookmarks.DIRTY, values); - BookmarkThumbnailWidgetProvider.refreshWidgets(getContext()); + refreshWidgets(); break; } @@ -1320,7 +1338,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { callerIsSyncAdapter); pruneImages(); if (updated > 0) { - BookmarkThumbnailWidgetProvider.refreshWidgets(getContext()); + refreshWidgets(); } return updated; } @@ -1363,7 +1381,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { count = 1; } if (count > 0) { - BookmarkThumbnailWidgetProvider.refreshWidgets(getContext()); + refreshWidgets(); } return count; } |