diff options
author | Roshan Pius <rpius@google.com> | 2015-07-15 19:23:28 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-15 19:23:30 +0000 |
commit | 4e9c63cbe1712f750d5eaaa044e957c7f7696bf8 (patch) | |
tree | 556df21071b064bf6cd0ff0031941b6bec4acc1f /telephony | |
parent | 68fd7c798d213bbe304775b13d775ee868abb448 (diff) | |
parent | 93018a4d983f0c7063fd0b243436364cd191e0a9 (diff) | |
download | frameworks_base-4e9c63cbe1712f750d5eaaa044e957c7f7696bf8.zip frameworks_base-4e9c63cbe1712f750d5eaaa044e957c7f7696bf8.tar.gz frameworks_base-4e9c63cbe1712f750d5eaaa044e957c7f7696bf8.tar.bz2 |
Merge "Handle exceptions when accessing Content providers." into mnc-dev
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/android/telephony/PhoneNumberUtils.java | 16 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/CallerInfo.java | 16 |
2 files changed, 22 insertions, 10 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index d18b86a..79146f3 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -177,15 +177,19 @@ public class PhoneNumberUtils phoneColumn = ContactsContract.CommonDataKinds.Phone.NUMBER; } - final Cursor c = context.getContentResolver().query(uri, new String[] { - phoneColumn - }, null, null, null); - if (c != null) { - try { + Cursor c = null; + try { + c = context.getContentResolver().query(uri, new String[] { phoneColumn }, + null, null, null); + if (c != null) { if (c.moveToFirst()) { 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(); } } diff --git a/telephony/java/com/android/internal/telephony/CallerInfo.java b/telephony/java/com/android/internal/telephony/CallerInfo.java index 5cd5d4e..be7e702 100644 --- a/telephony/java/com/android/internal/telephony/CallerInfo.java +++ b/telephony/java/com/android/internal/telephony/CallerInfo.java @@ -16,6 +16,7 @@ package com.android.internal.telephony; +import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; @@ -282,10 +283,17 @@ public class CallerInfo { * number. The returned CallerInfo is null if no number is supplied. */ public static CallerInfo getCallerInfo(Context context, Uri contactRef) { - - return getCallerInfo(context, contactRef, - CallerInfoAsyncQuery.getCurrentProfileContentResolver(context) - .query(contactRef, null, null, null, null)); + CallerInfo info = null; + ContentResolver cr = CallerInfoAsyncQuery.getCurrentProfileContentResolver(context); + if (cr != 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; } /** |