diff options
author | 2020-09-17 03:28:32 +0000 | |
---|---|---|
committer | 2020-09-17 03:28:32 +0000 | |
commit | d55deb36c8f801b2411b9c2c338617a022a86380 (patch) | |
tree | 48e334665ea9723c209077957a0f4b591c21dcff | |
parent | 88b277876130e5a13ceba9ef81e6956e6062d375 (diff) | |
parent | 56e7a5f9a8dcea2c8d61725907ce306f469d67cd (diff) |
Check if cursor is closed for staleDataException am: 56e7a5f9a8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/DocumentsUI/+/12586926
Change-Id: I2ab570f70b32050cbe0bb4823586b710aefda15e
-rw-r--r-- | src/com/android/documentsui/DirectoryLoader.java | 12 | ||||
-rw-r--r-- | src/com/android/documentsui/MultiRootDocumentsLoader.java | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/com/android/documentsui/DirectoryLoader.java b/src/com/android/documentsui/DirectoryLoader.java index 2775ec4bb..eb4e0a9f0 100644 --- a/src/com/android/documentsui/DirectoryLoader.java +++ b/src/com/android/documentsui/DirectoryLoader.java @@ -314,19 +314,19 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> { } private boolean checkIfCursorStale(DirectoryResult result) { - if (mResult == null) { + if (result == null || result.cursor == null || result.cursor.isClosed()) { return true; } Cursor cursor = result.cursor; - cursor.moveToPosition(-1); - for (int pos = 0; pos < cursor.getCount(); ++pos) { - try { + try { + cursor.moveToPosition(-1); + for (int pos = 0; pos < cursor.getCount(); ++pos) { if (!cursor.moveToNext()) { return true; } - } catch (Exception e) { - return true; } + } catch (Exception e) { + return true; } return false; } diff --git a/src/com/android/documentsui/MultiRootDocumentsLoader.java b/src/com/android/documentsui/MultiRootDocumentsLoader.java index b25828dda..74e44a14a 100644 --- a/src/com/android/documentsui/MultiRootDocumentsLoader.java +++ b/src/com/android/documentsui/MultiRootDocumentsLoader.java @@ -458,19 +458,19 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory } private boolean checkIfCursorStale(DirectoryResult result) { - if (mResult == null) { + if (result == null || result.cursor == null || result.cursor.isClosed()) { return true; } Cursor cursor = result.cursor; - cursor.moveToPosition(-1); - for (int pos = 0; pos < cursor.getCount(); ++pos) { - try { + try { + cursor.moveToPosition(-1); + for (int pos = 0; pos < cursor.getCount(); ++pos) { if (!cursor.moveToNext()) { return true; } - } catch (Exception e) { - return true; } + } catch (Exception e) { + return true; } return false; } |