summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-01-25 13:40:07 -0800
committerWinson Chung <winsonc@google.com>2011-01-26 14:32:14 -0800
commitf37d23799b6b33ab8fdda303debe7d973e43d147 (patch)
tree80b0eac032fe48f005e17913026a96df01f98fcf /src/com/android/browser
parentd3bf86fd84f4f1a75cc9cd26f818ae157c806d9b (diff)
downloadpackages_apps_Browser-f37d23799b6b33ab8fdda303debe7d973e43d147.tar.gz
packages_apps_Browser-f37d23799b6b33ab8fdda303debe7d973e43d147.tar.bz2
packages_apps_Browser-f37d23799b6b33ab8fdda303debe7d973e43d147.zip
Updating widget to handle issues that may arise with recent service bind/unbind changes. (3395366)
- This should be resolved properly with MR1 refactor of the bookmarks widget Change-Id: I7b4b143007a0a5c16720d5edae594e6a655261e7
Diffstat (limited to 'src/com/android/browser')
-rw-r--r--src/com/android/browser/widget/BookmarkThumbnailWidgetService.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
index 51ba2ca18..1c7856f3a 100644
--- a/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
+++ b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
@@ -75,14 +75,16 @@ public class BookmarkThumbnailWidgetService extends RemoteViewsService {
private static final int BOOKMARK_INDEX_TOUCH_ICON = 5;
private static final int BOOKMARK_INDEX_THUMBNAIL = 7;
- private Map<Integer, BookmarkFactory> mFactories;
+ // The service will likely be destroyed at any time, so we need to keep references to the
+ // factories across services connections.
+ private static final Map<Integer, BookmarkFactory> mFactories =
+ new HashMap<Integer, BookmarkFactory>();
private Handler mUiHandler;
private BookmarksObserver mBookmarksObserver;
@Override
public void onCreate() {
super.onCreate();
- mFactories = new HashMap<Integer, BookmarkFactory>();
mUiHandler = new Handler();
mBookmarksObserver = new BookmarksObserver(mUiHandler);
getContentResolver().registerContentObserver(
@@ -109,6 +111,12 @@ public class BookmarkThumbnailWidgetService extends RemoteViewsService {
BookmarkFactory fac = mFactories.get(widgetId);
if (fac != null && folderId >= 0) {
fac.changeFolder(folderId);
+ } else {
+ // This a workaround to the issue when the Browser process crashes, after which
+ // mFactories is not populated (due to onBind() not being called). Calling
+ // notifyDataSetChanged() will trigger a connection to be made.
+ AppWidgetManager.getInstance(getApplicationContext())
+ .notifyAppWidgetViewDataChanged(widgetId, R.id.bookmarks_list);
}
}
return START_STICKY;