diff options
author | Tom Taylor <tomtaylor@google.com> | 2011-01-06 11:58:36 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-01-06 11:58:36 -0800 |
commit | 33bfa9ef9648ab090c1913a8debac5bb49a84d31 (patch) | |
tree | 55f4aca563c17e70ddc3f07326e07b00a525b624 | |
parent | 39aaab4496cb6c37901103f1f91a244a39e4f6ab (diff) | |
parent | cd3e6c33df50eafedb9a8b765770ffe49b138fe1 (diff) | |
download | Mms-33bfa9ef9648ab090c1913a8debac5bb49a84d31.tar.gz |
Merge "Fix recycler NPE" into gingerbread
-rw-r--r-- | src/com/android/mms/util/Recycler.java | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/com/android/mms/util/Recycler.java b/src/com/android/mms/util/Recycler.java index c0ae45df..23c304c1 100644 --- a/src/com/android/mms/util/Recycler.java +++ b/src/com/android/mms/util/Recycler.java @@ -248,6 +248,9 @@ public abstract class Recycler { @Override protected boolean anyThreadOverLimit(Context context) { Cursor cursor = getAllThreads(context); + if (cursor == null) { + return false; + } int limit = getMessageLimit(context); try { while (cursor.moveToNext()) { @@ -258,9 +261,15 @@ public abstract class Recycler { SMS_MESSAGE_PROJECTION, "locked=0", null, "date DESC"); // get in newest to oldest order - - if (msgs.getCount() >= limit) { - return true; + if (msgs == null) { + return false; + } + try { + if (msgs.getCount() >= limit) { + return true; + } + } finally { + msgs.close(); } } } finally { @@ -433,6 +442,9 @@ public abstract class Recycler { @Override protected boolean anyThreadOverLimit(Context context) { Cursor cursor = getAllThreads(context); + if (cursor == null) { + return false; + } int limit = getMessageLimit(context); try { while (cursor.moveToNext()) { @@ -444,11 +456,16 @@ public abstract class Recycler { "thread_id=" + threadId + " AND locked=0", null, "date DESC"); // get in newest to oldest order - if (msgs.getCount() >= limit) { - msgs.close(); - return true; + if (msgs == null) { + return false; + } + try { + if (msgs.getCount() >= limit) { + return true; + } + } finally { + cursor.close(); } - msgs.close(); } } finally { cursor.close(); |