From 7bea0364b6f8932f54cdb518de1014f408f0f3f3 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Tue, 12 Sep 2017 13:01:56 -0700 Subject: Fixed crash in RemoteContactCusror. Test: manual PiperOrigin-RevId: 168427349 Change-Id: Ie58920b76266ebb298210b5faac8fcbda4dbcd15 --- .../searchfragment/remote/RemoteContactsCursor.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'java/com/android/dialer/searchfragment') diff --git a/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java b/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java index e6f3c2607..5d80a452c 100644 --- a/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java +++ b/java/com/android/dialer/searchfragment/remote/RemoteContactsCursor.java @@ -118,12 +118,19 @@ public final class RemoteContactsCursor extends MergeCursor implements SearchCur int position = getPosition(); // proceed backwards until we reach the header row, which contains the directory ID. while (moveToPrevious()) { - int id = getInt(getColumnIndex(COLUMN_DIRECTORY_ID)); - if (id != -1) { - // return the cursor to it's original position/state - moveToPosition(position); - return id; + int columnIndex = getColumnIndex(COLUMN_DIRECTORY_ID); + if (columnIndex == -1) { + continue; } + + int id = getInt(columnIndex); + if (id == -1) { + continue; + } + + // return the cursor to it's original position/state + moveToPosition(position); + return id; } throw Assert.createIllegalStateFailException("No directory id for contact at: " + position); } -- cgit v1.2.3