summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Kennedy <skennedy@google.com>2013-06-07 08:48:23 -0700
committerScott Kennedy <skennedy@google.com>2013-06-07 08:48:23 -0700
commit17d266469a185c44a705732310b8296393bc1668 (patch)
tree24b39ce513a06c5925257e1803453a5286dba8cd
parent31b46a1c8d707ca384c044e3e996ced2a2e52dd4 (diff)
downloadandroid_frameworks_ex-17d266469a185c44a705732310b8296393bc1668.tar.gz
android_frameworks_ex-17d266469a185c44a705732310b8296393bc1668.tar.bz2
android_frameworks_ex-17d266469a185c44a705732310b8296393bc1668.zip
Fix a NPE
We may not get a cursor back from query(), and if that happens, we shouldn't try to use the null cursor. Bug: 9287151 Change-Id: Ie91d8003f51ea160e5b709a5cd6bcabefc3c687a
-rw-r--r--chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java60
1 files changed, 33 insertions, 27 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
index 0693df2..ef34379 100644
--- a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
+++ b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
@@ -140,8 +140,12 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
try {
directoryCursor = context.getContentResolver().query(DirectoryListQuery.URI,
DirectoryListQuery.PROJECTION, null, null, null);
- paramsList = BaseRecipientAdapter.setupOtherDirectories(context, directoryCursor,
- account);
+ if (directoryCursor == null) {
+ paramsList = null;
+ } else {
+ paramsList = BaseRecipientAdapter.setupOtherDirectories(context,
+ directoryCursor, account);
+ }
} finally {
if (directoryCursor != null) {
directoryCursor.close();
@@ -157,35 +161,37 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
matchesNotFound.addAll(unresolvedAddresses);
- Cursor directoryContactsCursor = null;
- for (String unresolvedAddress : unresolvedAddresses) {
- for (int i = 0; i < paramsList.size(); i++) {
- try {
- directoryContactsCursor = doQuery(unresolvedAddress, 1,
- paramsList.get(i).directoryId, account,
- context.getContentResolver(), query);
- } finally {
- if (directoryContactsCursor != null
- && directoryContactsCursor.getCount() == 0) {
- directoryContactsCursor.close();
- directoryContactsCursor = null;
- } else {
- break;
+ if (paramsList != null) {
+ Cursor directoryContactsCursor = null;
+ for (String unresolvedAddress : unresolvedAddresses) {
+ for (int i = 0; i < paramsList.size(); i++) {
+ try {
+ directoryContactsCursor = doQuery(unresolvedAddress, 1,
+ paramsList.get(i).directoryId, account,
+ context.getContentResolver(), query);
+ } finally {
+ if (directoryContactsCursor != null
+ && directoryContactsCursor.getCount() == 0) {
+ directoryContactsCursor.close();
+ directoryContactsCursor = null;
+ } else {
+ break;
+ }
}
}
- }
- if (directoryContactsCursor != null) {
- try {
- final Map<String, RecipientEntry> entries =
- processContactEntries(directoryContactsCursor);
+ if (directoryContactsCursor != null) {
+ try {
+ final Map<String, RecipientEntry> entries =
+ processContactEntries(directoryContactsCursor);
- for (final String address : entries.keySet()) {
- matchesNotFound.remove(address);
- }
+ for (final String address : entries.keySet()) {
+ matchesNotFound.remove(address);
+ }
- callback.matchesFound(entries);
- } finally {
- directoryContactsCursor.close();
+ callback.matchesFound(entries);
+ } finally {
+ directoryContactsCursor.close();
+ }
}
}
}