diff options
author | Brad Fitzpatrick <bradfitz@android.com> | 2010-06-03 12:52:54 -0700 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@android.com> | 2010-06-03 12:52:54 -0700 |
commit | cfda9f3a4756c71b3aadd1387419cb3b513dd400 (patch) | |
tree | af4e30debab7180d5ac2e7a92c522169eedd952c /core | |
parent | 57ad07039a63e8454d8a73cdce9c5e269f13205c (diff) | |
download | frameworks_base-cfda9f3a4756c71b3aadd1387419cb3b513dd400.zip frameworks_base-cfda9f3a4756c71b3aadd1387419cb3b513dd400.tar.gz frameworks_base-cfda9f3a4756c71b3aadd1387419cb3b513dd400.tar.bz2 |
Sprinkle new BlockGuard around SQLiteDatabase.
SQLite is JNI to native code and doesn't go via IFileSystem, so it
needs custom sprinkling, at least for now.
Change-Id: Ic7fded1b64a4f483dfc17b3a7b136c803df1e111
Diffstat (limited to 'core')
-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"); } |