diff options
| author | Brad Fitzpatrick <bradfitz@android.com> | 2010-06-03 16:09:35 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2010-06-03 16:09:35 -0700 |
| commit | 7d6362de0645470f3b02176b1e06660149f872ac (patch) | |
| tree | 2f3426691972f7d2856ef19c5cb912687bd9898d | |
| parent | 17dabbdf866cd07dd282f7c7061678ed254cab9a (diff) | |
| parent | 266b74e8759e76fedec60ec1ffa88cfbd86cc91d (diff) | |
| download | frameworks_base-7d6362de0645470f3b02176b1e06660149f872ac.zip frameworks_base-7d6362de0645470f3b02176b1e06660149f872ac.tar.gz frameworks_base-7d6362de0645470f3b02176b1e06660149f872ac.tar.bz2 | |
am 266b74e8: Merge "Sprinkle new BlockGuard around SQLiteDatabase." into kraken
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteDatabase.java | 8 | ||||
| -rw-r--r-- | core/java/android/database/sqlite/SQLiteStatement.java | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index d4f9b20..0e798dc 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -33,6 +33,8 @@ import android.util.EventLog; import android.util.Log; import android.util.Pair; +import dalvik.system.BlockGuard; + import java.io.File; import java.lang.ref.WeakReference; import java.text.SimpleDateFormat; @@ -1339,6 +1341,7 @@ public class SQLiteDatabase extends SQLiteClosable { if (!isOpen()) { throw new IllegalStateException("database not open"); } + BlockGuard.getThreadPolicy().onReadFromDisk(); long timeStart = 0; if (Config.LOGV || mSlowQueryThreshold != -1) { @@ -1497,6 +1500,7 @@ public class SQLiteDatabase extends SQLiteClosable { */ public long insertWithOnConflict(String table, String nullColumnHack, ContentValues initialValues, int conflictAlgorithm) { + BlockGuard.getThreadPolicy().onWriteToDisk(); if (!isOpen()) { throw new IllegalStateException("database not open"); } @@ -1588,6 +1592,7 @@ public class SQLiteDatabase extends SQLiteClosable { * whereClause. */ public int delete(String table, String whereClause, String[] whereArgs) { + BlockGuard.getThreadPolicy().onWriteToDisk(); lock(); if (!isOpen()) { throw new IllegalStateException("database not open"); @@ -1643,6 +1648,7 @@ public class SQLiteDatabase extends SQLiteClosable { */ public int updateWithOnConflict(String table, ContentValues values, String whereClause, String[] whereArgs, int conflictAlgorithm) { + BlockGuard.getThreadPolicy().onWriteToDisk(); if (values == null || values.size() == 0) { throw new IllegalArgumentException("Empty values"); } @@ -1725,6 +1731,7 @@ public class SQLiteDatabase extends SQLiteClosable { * @throws SQLException If the SQL string is invalid for some reason */ public void execSQL(String sql) throws SQLException { + BlockGuard.getThreadPolicy().onWriteToDisk(); long timeStart = SystemClock.uptimeMillis(); lock(); if (!isOpen()) { @@ -1760,6 +1767,7 @@ public class SQLiteDatabase extends SQLiteClosable { * @throws SQLException If the SQL string is invalid for some reason */ public void execSQL(String sql, Object[] bindArgs) throws SQLException { + BlockGuard.getThreadPolicy().onWriteToDisk(); if (bindArgs == null) { throw new IllegalArgumentException("Empty bindArgs"); } diff --git a/core/java/android/database/sqlite/SQLiteStatement.java b/core/java/android/database/sqlite/SQLiteStatement.java index 47cca87..9e425c3 100644 --- a/core/java/android/database/sqlite/SQLiteStatement.java +++ b/core/java/android/database/sqlite/SQLiteStatement.java @@ -18,6 +18,8 @@ package android.database.sqlite; import android.os.SystemClock; +import dalvik.system.BlockGuard; + /** * A pre-compiled statement against a {@link SQLiteDatabase} that can be reused. * The statement cannot return multiple rows, but 1x1 result sets are allowed. @@ -47,6 +49,7 @@ public class SQLiteStatement extends SQLiteProgram * some reason */ public void execute() { + BlockGuard.getThreadPolicy().onWriteToDisk(); if (!mDatabase.isOpen()) { throw new IllegalStateException("database " + mDatabase.getPath() + " already closed"); } @@ -73,6 +76,7 @@ public class SQLiteStatement extends SQLiteProgram * some reason */ public long executeInsert() { + BlockGuard.getThreadPolicy().onWriteToDisk(); if (!mDatabase.isOpen()) { throw new IllegalStateException("database " + mDatabase.getPath() + " already closed"); } @@ -99,6 +103,7 @@ public class SQLiteStatement extends SQLiteProgram * @throws android.database.sqlite.SQLiteDoneException if the query returns zero rows */ public long simpleQueryForLong() { + BlockGuard.getThreadPolicy().onReadFromDisk(); if (!mDatabase.isOpen()) { throw new IllegalStateException("database " + mDatabase.getPath() + " already closed"); } @@ -125,6 +130,7 @@ public class SQLiteStatement extends SQLiteProgram * @throws android.database.sqlite.SQLiteDoneException if the query returns zero rows */ public String simpleQueryForString() { + BlockGuard.getThreadPolicy().onReadFromDisk(); if (!mDatabase.isOpen()) { throw new IllegalStateException("database " + mDatabase.getPath() + " already closed"); } |
