Merge "Handle exceptions when accessing Content providers." into mnc-dev
This commit is contained in:
@@ -177,15 +177,19 @@ public class PhoneNumberUtils
|
|||||||
phoneColumn = ContactsContract.CommonDataKinds.Phone.NUMBER;
|
phoneColumn = ContactsContract.CommonDataKinds.Phone.NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Cursor c = context.getContentResolver().query(uri, new String[] {
|
Cursor c = null;
|
||||||
phoneColumn
|
try {
|
||||||
}, null, null, null);
|
c = context.getContentResolver().query(uri, new String[] { phoneColumn },
|
||||||
if (c != null) {
|
null, null, null);
|
||||||
try {
|
if (c != null) {
|
||||||
if (c.moveToFirst()) {
|
if (c.moveToFirst()) {
|
||||||
number = c.getString(c.getColumnIndex(phoneColumn));
|
number = c.getString(c.getColumnIndex(phoneColumn));
|
||||||
}
|
}
|
||||||
} finally {
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
Rlog.e(LOG_TAG, "Error getting phone number.", e);
|
||||||
|
} finally {
|
||||||
|
if (c != null) {
|
||||||
c.close();
|
c.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.internal.telephony;
|
package com.android.internal.telephony;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
@@ -282,10 +283,17 @@ public class CallerInfo {
|
|||||||
* number. The returned CallerInfo is null if no number is supplied.
|
* number. The returned CallerInfo is null if no number is supplied.
|
||||||
*/
|
*/
|
||||||
public static CallerInfo getCallerInfo(Context context, Uri contactRef) {
|
public static CallerInfo getCallerInfo(Context context, Uri contactRef) {
|
||||||
|
CallerInfo info = null;
|
||||||
return getCallerInfo(context, contactRef,
|
ContentResolver cr = CallerInfoAsyncQuery.getCurrentProfileContentResolver(context);
|
||||||
CallerInfoAsyncQuery.getCurrentProfileContentResolver(context)
|
if (cr != null) {
|
||||||
.query(contactRef, null, null, null, null));
|
try {
|
||||||
|
info = getCallerInfo(context, contactRef,
|
||||||
|
cr.query(contactRef, null, null, null, null));
|
||||||
|
} catch (RuntimeException re) {
|
||||||
|
Rlog.e(TAG, "Error getting caller info.", re);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user