diff options
author | adhiti <adhiti@codeaurora.org> | 2013-12-10 16:09:13 +0530 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 13:57:46 -0800 |
commit | 6a5657f340b059c92c4e085ba95705c356779780 (patch) | |
tree | 89b20e6543a2d85bf44fe633e6d368bdb7bfef02 /src | |
parent | fa006ef01cf4425264546f23085ce51d3f23f0a6 (diff) | |
download | packages_apps_Browser-6a5657f340b059c92c4e085ba95705c356779780.zip packages_apps_Browser-6a5657f340b059c92c4e085ba95705c356779780.tar.gz packages_apps_Browser-6a5657f340b059c92c4e085ba95705c356779780.tar.bz2 |
Browser: Fix browser force close
Issue: Cursor was accessed by handler thread
when it was closed. During Orientation change,
BrowserBookmarksPage#onDestroyView is called
which clears all the loaders [and cursors].
Simultaneously ThreadedCursorAdapter#loadRowObject
is getting called which then calls
BrowserBookmarksAdapter#getRowObject
where closed cursor is accessed and force close happens.
Fix: Synchronized cursors wrt main thread and handler thread.
Checked mCursorAdapter for invalid conditions
CRs-Fixed: 576176
Change-Id: I9f16c2f1a55f35e8256bbf56afce3538850f9d42
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/BrowserBookmarksPage.java | 4 | ||||
-rw-r--r-- | src/com/android/browser/util/ThreadedCursorAdapter.java | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java index cb53107..3a0c65a 100644 --- a/src/com/android/browser/BrowserBookmarksPage.java +++ b/src/com/android/browser/BrowserBookmarksPage.java @@ -411,7 +411,9 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte LoaderManager lm = getLoaderManager(); lm.destroyLoader(LOADER_ACCOUNTS); for (int id : mBookmarkAdapters.keySet()) { - lm.destroyLoader(id); + synchronized (mBookmarkAdapters.get(id).mCursorLock) { + lm.destroyLoader(id); + } } mBookmarkAdapters.clear(); } diff --git a/src/com/android/browser/util/ThreadedCursorAdapter.java b/src/com/android/browser/util/ThreadedCursorAdapter.java index 72a07ea..d350999 100644 --- a/src/com/android/browser/util/ThreadedCursorAdapter.java +++ b/src/com/android/browser/util/ThreadedCursorAdapter.java @@ -39,7 +39,7 @@ public abstract class ThreadedCursorAdapter<T> extends BaseAdapter { private static final boolean DEBUG = false; private Context mContext; - private Object mCursorLock = new Object(); + public Object mCursorLock = new Object(); private CursorAdapter mCursorAdapter; private T mLoadingObject; private Handler mLoadHandler; @@ -150,6 +150,10 @@ public abstract class ThreadedCursorAdapter<T> extends BaseAdapter { return; } synchronized (mCursorLock) { + if ((mCursorAdapter == null) || (mCursorAdapter.getCursor() == null) + || mCursorAdapter.getCursor().isClosed()) { + return; + } Cursor c = (Cursor) mCursorAdapter.getItem(position); if (c == null || c.isClosed()) { return; |