diff options
author | Benson Huang <benson.huang@mediatek.com> | 2014-11-18 17:18:48 +0800 |
---|---|---|
committer | leozwang <leozwang@google.com> | 2014-11-21 09:16:35 -0800 |
commit | d1b7c58a1c14229873987af728c4c598f86bd107 (patch) | |
tree | 39f7186e160d41a1b770090c95f9a50b8ea2ae5c /src/com/android/providers | |
parent | 407c6ddc5ac8eced85ce82fae59a75ac27a989a5 (diff) | |
download | android_packages_providers_MediaProvider-d1b7c58a1c14229873987af728c4c598f86bd107.tar.gz android_packages_providers_MediaProvider-d1b7c58a1c14229873987af728c4c598f86bd107.tar.bz2 android_packages_providers_MediaProvider-d1b7c58a1c14229873987af728c4c598f86bd107.zip |
Fix SQLiteDiskIOException in stability test
Because Sprout has removable storage, the framework needs to maintain
external database for keeping multiple databases between SD cards.
When cleaning up databases for old external storage volumes, we can't
delete .db-shm and .db-wal because these two files always have the
latest data and .db doesn't have. Using camera or Google+ will access
.db-shm and .db-wal to get the latest data and will cause SQLite Disk
I/O exception if they are deleted.
The fix is to modify the logic of cleaning up databases (only delete
.db file, not to delete .db-shm and .db-wal file).
Bug 18412563
Review: https://partner-android-review.git.corp.google.com/#/c/187072
Signed-off-by: Benson Huang <benson.huang@mediatek.com>
Change-Id: I484bd535ddebee09824a10f12241f6b2ce086b94
Diffstat (limited to 'src/com/android/providers')
-rwxr-xr-x | src/com/android/providers/media/MediaProvider.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java index 990bd710..ee4aad3e 100755 --- a/src/com/android/providers/media/MediaProvider.java +++ b/src/com/android/providers/media/MediaProvider.java @@ -441,6 +441,15 @@ public class MediaProvider extends ContentProvider { // delete least recently used databases if we are over the limit String[] databases = mContext.databaseList(); + // Don't delete wal auxiliary files(db-shm and db-wal) directly because db file may + // not be deleted, and it will cause Disk I/O error when accessing this database. + List<String> dbList = new ArrayList<String>(); + for (String database : databases) { + if (database != null && database.endsWith(".db")) { + dbList.add(database); + } + } + databases = dbList.toArray(new String[0]); int count = databases.length; int limit = MAX_EXTERNAL_DATABASES; |