Merge "Catch SQLiteException from remote processes"
commit
262b867200
|
@ -22,6 +22,7 @@ import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
|
@ -145,8 +146,10 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalStateException e) {
|
} catch (final SQLiteException e) {
|
||||||
Log.e(TAG, "Contacts DB is having problems");
|
Log.e(TAG, "SQLiteException in the remote Contacts process.", e);
|
||||||
|
} catch (final IllegalStateException e) {
|
||||||
|
Log.e(TAG, "Contacts DB is having problems", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +176,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
private int getContactCount() {
|
private int getContactCount() {
|
||||||
// TODO: consider switching to a rawQuery("select count(*)...") on the database if
|
// TODO: consider switching to a rawQuery("select count(*)...") on the database if
|
||||||
// performance is a bottleneck.
|
// performance is a bottleneck.
|
||||||
|
try {
|
||||||
final Cursor cursor = mContext.getContentResolver().query(
|
final Cursor cursor = mContext.getContentResolver().query(
|
||||||
Contacts.CONTENT_URI, PROJECTION_ID_ONLY, null, null, null);
|
Contacts.CONTENT_URI, PROJECTION_ID_ONLY, null, null, null);
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
|
@ -182,6 +186,9 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
cursor.close();
|
cursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (final SQLiteException e) {
|
||||||
|
Log.e(TAG, "SQLiteException in the remote Contacts process.", e);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,12 @@ import android.content.ContentUris;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.provider.UserDictionary.Words;
|
import android.provider.UserDictionary.Words;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.UserDictionaryCompatUtils;
|
import com.android.inputmethod.compat.UserDictionaryCompatUtils;
|
||||||
import com.android.inputmethod.latin.utils.LocaleUtils;
|
import com.android.inputmethod.latin.utils.LocaleUtils;
|
||||||
|
@ -39,6 +41,7 @@ import java.util.Locale;
|
||||||
* dictionary file to use it from native code.
|
* dictionary file to use it from native code.
|
||||||
*/
|
*/
|
||||||
public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
|
private static final String TAG = ExpandableBinaryDictionary.class.getSimpleName();
|
||||||
|
|
||||||
// The user dictionary provider uses an empty string to mean "all languages".
|
// The user dictionary provider uses an empty string to mean "all languages".
|
||||||
private static final String USER_DICTIONARY_ALL_LANGUAGES = "";
|
private static final String USER_DICTIONARY_ALL_LANGUAGES = "";
|
||||||
|
@ -168,12 +171,19 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
|
||||||
} else {
|
} else {
|
||||||
requestArguments = localeElements;
|
requestArguments = localeElements;
|
||||||
}
|
}
|
||||||
final Cursor cursor = mContext.getContentResolver().query(
|
Cursor cursor = null;
|
||||||
Words.CONTENT_URI, PROJECTION_QUERY, request.toString(), requestArguments, null);
|
|
||||||
try {
|
try {
|
||||||
|
cursor = mContext.getContentResolver().query(
|
||||||
|
Words.CONTENT_URI, PROJECTION_QUERY, request.toString(), requestArguments, null);
|
||||||
addWords(cursor);
|
addWords(cursor);
|
||||||
|
} catch (final SQLiteException e) {
|
||||||
|
Log.e(TAG, "SQLiteException in the remote User dictionary process.", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
try {
|
||||||
if (null != cursor) cursor.close();
|
if (null != cursor) cursor.close();
|
||||||
|
} catch (final SQLiteException e) {
|
||||||
|
Log.e(TAG, "SQLiteException in the remote User dictionary process.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue