Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Make the liftcycle of cursor under the Activity
Browse files Browse the repository at this point in the history
The cursors of ComposeCardActivity and ConversationList
were never be closed. So the database will throw an
CursorWindowAllocationException if the cursors which not
be closed are too many to be allocated then the database
will return a NULL cursor back to onQueryComplete().
After that Mms will be crashed by the NullPointerException.

Change-Id: Ib8730b326edf9177bbcce48a42b85405acff51ba
Signed-off-by: Roger Chen <cxr514033970@gmail.com>
  • Loading branch information
cxr514033970 committed May 30, 2012
1 parent 06ff769 commit 6f82efc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/com/android/mms/ui/ComposeMessageActivity.java
Expand Up @@ -2090,6 +2090,13 @@ protected void onStop() {
mConversation.blockMarkAsRead(false);

if (mMsgListAdapter != null) {
// Close the cursor in the ListAdapter if the activity stopped.
Cursor cursor = mMsgListAdapter.getCursor();

if (cursor != null && !cursor.isClosed()) {
cursor.close();
}

mMsgListAdapter.changeCursor(null);
}

Expand Down
7 changes: 7 additions & 0 deletions src/com/android/mms/ui/ConversationList.java
Expand Up @@ -281,6 +281,13 @@ protected void onStop() {
// multi-select mode (if we're in it) and remove all the selections.
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);

// Close the cursor in the ListAdapter if the activity stopped.
Cursor cursor = mListAdapter.getCursor();

if (cursor != null && !cursor.isClosed()) {
cursor.close();
}

mListAdapter.changeCursor(null);
}

Expand Down

0 comments on commit 6f82efc

Please sign in to comment.