aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-09-20 19:31:39 +0900
committerJean Chalard <jchalard@google.com>2013-09-20 19:55:31 +0900
commitd0cf6b7623f99f453724b7579e5a70333d06e9c9 (patch)
treee60534832efd563fd759b4fe604341c9ea874e4e /java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java
parent3de1aca289d9fa1173b61cac0a93537d72f41c4b (diff)
downloadlatinime-d0cf6b7623f99f453724b7579e5a70333d06e9c9.tar.gz
latinime-d0cf6b7623f99f453724b7579e5a70333d06e9c9.tar.xz
latinime-d0cf6b7623f99f453724b7579e5a70333d06e9c9.zip
Catch SQLiteException from remote processes
...to avoid catching fire when the Contacts or User dictionary providers crash and burn. Bug: 10200036 Change-Id: I73e9d126ce6d34ebc7e6ac03d94af1c12dde7eda
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java
index 67eb7f3dd..ffeb92784 100644
--- a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java
@@ -22,6 +22,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
+import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.os.SystemClock;
import android.provider.BaseColumns;
@@ -145,8 +146,10 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
cursor.close();
}
}
- } catch (IllegalStateException e) {
- Log.e(TAG, "Contacts DB is having problems");
+ } catch (final SQLiteException e) {
+ Log.e(TAG, "SQLiteException in the remote Contacts process.", e);
+ } catch (final IllegalStateException e) {
+ Log.e(TAG, "Contacts DB is having problems", e);
}
}
@@ -173,14 +176,18 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
private int getContactCount() {
// TODO: consider switching to a rawQuery("select count(*)...") on the database if
// performance is a bottleneck.
- final Cursor cursor = mContext.getContentResolver().query(
- Contacts.CONTENT_URI, PROJECTION_ID_ONLY, null, null, null);
- if (cursor != null) {
- try {
- return cursor.getCount();
- } finally {
- cursor.close();
+ try {
+ final Cursor cursor = mContext.getContentResolver().query(
+ Contacts.CONTENT_URI, PROJECTION_ID_ONLY, null, null, null);
+ if (cursor != null) {
+ try {
+ return cursor.getCount();
+ } finally {
+ cursor.close();
+ }
}
+ } catch (final SQLiteException e) {
+ Log.e(TAG, "SQLiteException in the remote Contacts process.", e);
}
return 0;
}