diff options
author | John Reck <jreck@google.com> | 2011-07-29 14:58:10 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-07-29 15:06:19 -0700 |
commit | e17db4221f15a19fa636602ae317263cdde1a325 (patch) | |
tree | 9472907bbcb7c86ef04ebc98d78a0bb799ce9585 /src | |
parent | 1b9353cbf59678721d48313cb92189a1530f0483 (diff) | |
download | packages_apps_Browser-e17db4221f15a19fa636602ae317263cdde1a325.zip packages_apps_Browser-e17db4221f15a19fa636602ae317263cdde1a325.tar.gz packages_apps_Browser-e17db4221f15a19fa636602ae317263cdde1a325.tar.bz2 |
Fix race condition
Bug: 5042778
There was a chance that the widget refresh would happen before
the SQL transaction was committed. Meaning the widget would correctly
be notified, but it would refresh before the delete actually occured
Change-Id: Ie7ae3104077c9ebeba4928d3fe7b6a6793f31ca1
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index 1821b50..0c1fd42 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -355,6 +355,7 @@ public class BrowserProvider2 extends SQLiteContentProvider { SyncStateContentProviderHelper mSyncHelper = new SyncStateContentProviderHelper(); // This is so provider tests can intercept widget updating ContentObserver mWidgetObserver = null; + boolean mUpdateWidgets = false; final class DatabaseHelper extends SQLiteOpenHelper { static final String DATABASE_NAME = "browser2.db"; @@ -766,10 +767,19 @@ public class BrowserProvider2 extends SQLiteContentProvider { } void refreshWidgets() { - if (mWidgetObserver == null) { - BookmarkThumbnailWidgetProvider.refreshWidgets(getContext()); - } else { - mWidgetObserver.dispatchChange(false); + mUpdateWidgets = true; + } + + @Override + protected void onEndTransaction(boolean callerIsSyncAdapter) { + super.onEndTransaction(callerIsSyncAdapter); + if (mUpdateWidgets) { + if (mWidgetObserver == null) { + BookmarkThumbnailWidgetProvider.refreshWidgets(getContext()); + } else { + mWidgetObserver.dispatchChange(false); + } + mUpdateWidgets = false; } } |