diff options
author | 2020-09-14 12:37:16 -0700 | |
---|---|---|
committer | 2020-09-14 12:37:22 -0700 | |
commit | 56e7a5f9a8dcea2c8d61725907ce306f469d67cd (patch) | |
tree | a1deffc2ff4c1862a9517083cb6ceb13321657c0 | |
parent | 964f189fc85e8cc0f449705cebd27811c9f62be9 (diff) |
Check if cursor is closed for staleDataException
Test: atest DocumentsUIGoogleTests
Bug: 162292209
Change-Id: Ia4df46e4a1938bc421754763fa9d8ca12fde6280
-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; } |