summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2015-06-04 10:47:08 -0700
committerMakoto Onuki <omakoto@google.com>2015-06-04 11:19:26 -0700
commitcabd7cf832f5b160c30bff9c7b975bbf21a95d8e (patch)
treedb248a574540d7cdc58c9581a9544e416fe902df /src/com
parente9b0be19881605e5d23404c95d2da357ab0879b9 (diff)
downloadpackages_providers_ContactsProvider-cabd7cf832f5b160c30bff9c7b975bbf21a95d8e.zip
packages_providers_ContactsProvider-cabd7cf832f5b160c30bff9c7b975bbf21a95d8e.tar.gz
packages_providers_ContactsProvider-cabd7cf832f5b160c30bff9c7b975bbf21a95d8e.tar.bz2
Fix NPE in enterprise API & fix unit tests.
Bug 21632829 Bug 21634841 Change-Id: Ic18f44e8de31fe48b1d3b7f3a49c355a4865aeca
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 6cf6d98..7e91192 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -6771,6 +6771,10 @@ public class ContactsProvider2 extends AbstractContactsProvider
final Uri remoteUri = maybeAddUserId(localUri, corpUserId);
final Cursor managedCursor = getContext().getContentResolver().query(remoteUri,
projection, selection, selectionArgs, sortOrder, null);
+ if (managedCursor == null) {
+ // No corp results. Just return the local result.
+ return primaryCursor;
+ }
final Cursor[] cursorArray = new Cursor[] {
primaryCursor, new EnterprisePhoneCursorWrapper(managedCursor)
};
@@ -6814,10 +6818,7 @@ public class ContactsProvider2 extends AbstractContactsProvider
local.close();
throw th;
}
-
- if (local != null) {
- local.close();
- }
+ // "local" is still open. If we fail the managed CP2 query, we'll still return it.
// Step 2. No rows found in the local db, and there is a corp profile. Look at the corp
// DB.
@@ -6831,7 +6832,11 @@ public class ContactsProvider2 extends AbstractContactsProvider
// Note in order to re-write the cursor correctly, we need all columns from the corp cp2.
final Cursor corp = getContext().getContentResolver().query(remoteUri, null,
selection, selectionArgs, sortOrder, /* cancellationsignal */null);
+ if (corp == null) {
+ return local;
+ }
try {
+ local.close();
if (VERBOSE_LOGGING) {
MoreDatabaseUtils.dumpCursor(TAG, "corp raw", corp);
}