From c44b7312ad60c76ddd1c303d10b4f8e66ea9e605 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 20 Feb 2014 14:18:14 +0900 Subject: [PATCH] Remove a call to a deprecated method ...that would cause a crash Bug: 13082186 Change-Id: Ie12575c27dfdd2029bc9d5f0647e444f69770afc --- .../android/inputmethod/latin/ContactsBinaryDictionary.java | 2 -- .../com/android/inputmethod/latin/UserBinaryDictionary.java | 2 -- .../inputmethod/latin/userdictionary/UserDictionaryList.java | 3 +-- .../latin/userdictionary/UserDictionarySettings.java | 5 ++++- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java index 11a9d1fe4..ae9bdf3fc 100644 --- a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java @@ -89,8 +89,6 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { } private synchronized void registerObserver(final Context context) { - // Perform a managed query. The Activity will handle closing and requerying the cursor - // when needed. if (mObserver != null) return; ContentResolver cres = context.getContentResolver(); cres.registerContentObserver(Contacts.CONTENT_URI, true, mObserver = diff --git a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java index 2a195f58b..3e3cbf063 100644 --- a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java @@ -97,8 +97,6 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary { mLocale = localeStr; } mAlsoUseMoreRestrictiveLocales = alsoUseMoreRestrictiveLocales; - // Perform a managed query. The Activity will handle closing and re-querying the cursor - // when needed. ContentResolver cres = context.getContentResolver(); mObserver = new ContentObserver(null) { diff --git a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java index 2f41ce9ce..97a924d7b 100644 --- a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java +++ b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionaryList.java @@ -53,8 +53,7 @@ public class UserDictionaryList extends PreferenceFragment { } public static TreeSet getUserDictionaryLocalesSet(Activity activity) { - @SuppressWarnings("deprecation") - final Cursor cursor = activity.managedQuery(UserDictionary.Words.CONTENT_URI, + final Cursor cursor = activity.getContentResolver().query(UserDictionary.Words.CONTENT_URI, new String[] { UserDictionary.Words.LOCALE }, null, null, null); final TreeSet localeSet = new TreeSet(); diff --git a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionarySettings.java b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionarySettings.java index 220efb5d3..cf2014a1a 100644 --- a/java/src/com/android/inputmethod/latin/userdictionary/UserDictionarySettings.java +++ b/java/src/com/android/inputmethod/latin/userdictionary/UserDictionarySettings.java @@ -141,7 +141,10 @@ public class UserDictionarySettings extends ListFragment { mLocale = locale; // WARNING: The following cursor is never closed! TODO: don't put that in a member, and - // make sure all cursors are correctly closed. + // make sure all cursors are correctly closed. Also, this comes from a call to + // Activity#managedQuery, which has been deprecated for a long time (and which FORBIDS + // closing the cursor, so take care when resolving this TODO). We should either use a + // regular query and close the cursor, or switch to a LoaderManager and a CursorLoader. mCursor = createCursor(locale); TextView emptyView = (TextView) getView().findViewById(android.R.id.empty); emptyView.setText(R.string.user_dict_settings_empty_text);