From d1b7c58a1c14229873987af728c4c598f86bd107 Mon Sep 17 00:00:00 2001 From: Benson Huang Date: Tue, 18 Nov 2014 17:18:48 +0800 Subject: 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 Change-Id: I484bd535ddebee09824a10f12241f6b2ce086b94 --- src/com/android/providers/media/MediaProvider.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') 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 dbList = new ArrayList(); + 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; -- cgit v1.2.3