Fix an NPE when ContactInfoHelper tries to retrieve remote directories.
Bug: 73593111
Test: None
PiperOrigin-RevId: 186370203
Change-Id: I7b328dc546c9ae828f70c0467d03243305591ea9
diff --git a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java
index 0422655..e99533a 100644
--- a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java
+++ b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java
@@ -15,7 +15,6 @@
package com.android.dialer.phonenumbercache;
import android.annotation.TargetApi;
-import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
@@ -299,12 +298,12 @@
VERSION.SDK_INT >= VERSION_CODES.N
? Directory.ENTERPRISE_CONTENT_URI
: Directory.CONTENT_URI;
- ContentResolver cr = context.getContentResolver();
- Cursor cursor = cr.query(uri, new String[] {Directory._ID}, null, null, null);
- int idIndex = cursor.getColumnIndex(Directory._ID);
+ Cursor cursor =
+ context.getContentResolver().query(uri, new String[] {Directory._ID}, null, null, null);
if (cursor == null) {
return remoteDirectories;
}
+ int idIndex = cursor.getColumnIndex(Directory._ID);
try {
while (cursor.moveToNext()) {
long directoryId = cursor.getLong(idIndex);