Bug 1247557 - Close Cursors in AndroidImport. r=sebastian
MozReview-Commit-ID: KcKAXLxJr7l
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/AndroidImport.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/AndroidImport.java
@@ -146,24 +146,33 @@ public class AndroidImport implements Ru
} finally {
if (cursor != null)
cursor.close();
}
flushBatchOperations();
}
- protected Cursor query (Uri mainUri, Uri fallbackUri, String condition) {
- Cursor cursor = mCr.query(mainUri, null, condition, null, null);
+ protected Cursor query(Uri mainUri, Uri fallbackUri, String condition) {
+ final Cursor cursor = mCr.query(mainUri, null, condition, null, null);
+ try {
+ if (Build.MANUFACTURER.equals(SAMSUNG_MANUFACTURER) && (cursor == null || cursor.getCount() == 0)) {
+ if (cursor != null) {
+ cursor.close();
+ }
+ return mCr.query(fallbackUri, null, null, null, null);
+ }
+ return cursor;
- if (Build.MANUFACTURER.equals(SAMSUNG_MANUFACTURER) && (cursor == null || cursor.getCount() == 0)) {
- cursor = mCr.query(fallbackUri, null, null, null, null);
+ } catch (final Exception e) {
+ if (cursor != null) {
+ cursor.close();
+ }
+ throw e;
}
-
- return cursor;
}
protected void flushBatchOperations() {
Log.d(LOGTAG, "Flushing " + mOperations.size() + " DB operations");
try {
// We don't really care for the results, this is best-effort.
mCr.applyBatch(BrowserContract.AUTHORITY, mOperations);
} catch (RemoteException e) {