Loading core/java/android/database/sqlite/SQLiteDatabase.java +26 −9 Original line number Diff line number Diff line Loading @@ -22,10 +22,11 @@ import android.database.DatabaseUtils; import android.database.SQLException; import android.os.Debug; import android.os.SystemClock; import android.os.SystemProperties; import android.text.TextUtils; import android.util.Config; import android.util.Log; import android.util.EventLog; import android.util.Log; import java.io.File; import java.util.HashMap; Loading Loading @@ -221,6 +222,10 @@ public class SQLiteDatabase extends SQLiteClosable { // that logging is not enabled. /* package */ final boolean mLogStats; // System property that enables logging of slow queries. Specify the threshold in ms. private static final String LOG_SLOW_QUERIES_PROPERTY = "db.log.slow_query_threshold"; private final int mSlowQueryThreshold; /** * @param closable */ Loading Loading @@ -1202,20 +1207,29 @@ public class SQLiteDatabase extends SQLiteClosable { String editTable) { long timeStart = 0; if (Config.LOGV) { if (Config.LOGV || mSlowQueryThreshold != -1) { timeStart = System.currentTimeMillis(); } SQLiteCursorDriver driver = new SQLiteDirectCursorDriver(this, sql, editTable); Cursor cursor = null; try { return driver.query( cursor = driver.query( cursorFactory != null ? cursorFactory : mFactory, selectionArgs); } finally { if (Config.LOGV) { if (Config.LOGV || mSlowQueryThreshold != -1) { // Force query execution if (cursor != null) { cursor.moveToFirst(); cursor.moveToPosition(-1); } long duration = System.currentTimeMillis() - timeStart; if (Config.LOGV || duration >= mSlowQueryThreshold) { Log.v(SQLiteCursor.TAG, "query (" + duration + " ms): " + driver.toString() + ", args are " + (selectionArgs != null Loading @@ -1224,6 +1238,8 @@ public class SQLiteDatabase extends SQLiteClosable { } } } return cursor; } /** * Runs the provided SQL and returns a cursor over the result set. Loading Loading @@ -1671,6 +1687,7 @@ public class SQLiteDatabase extends SQLiteClosable { mFlags = flags; mPath = path; mLogStats = "1".equals(android.os.SystemProperties.get("db.logstats")); mSlowQueryThreshold = SystemProperties.getInt(LOG_SLOW_QUERIES_PROPERTY, -1); mLeakedException = new IllegalStateException(path + " SQLiteDatabase created and never closed"); Loading Loading
core/java/android/database/sqlite/SQLiteDatabase.java +26 −9 Original line number Diff line number Diff line Loading @@ -22,10 +22,11 @@ import android.database.DatabaseUtils; import android.database.SQLException; import android.os.Debug; import android.os.SystemClock; import android.os.SystemProperties; import android.text.TextUtils; import android.util.Config; import android.util.Log; import android.util.EventLog; import android.util.Log; import java.io.File; import java.util.HashMap; Loading Loading @@ -221,6 +222,10 @@ public class SQLiteDatabase extends SQLiteClosable { // that logging is not enabled. /* package */ final boolean mLogStats; // System property that enables logging of slow queries. Specify the threshold in ms. private static final String LOG_SLOW_QUERIES_PROPERTY = "db.log.slow_query_threshold"; private final int mSlowQueryThreshold; /** * @param closable */ Loading Loading @@ -1202,20 +1207,29 @@ public class SQLiteDatabase extends SQLiteClosable { String editTable) { long timeStart = 0; if (Config.LOGV) { if (Config.LOGV || mSlowQueryThreshold != -1) { timeStart = System.currentTimeMillis(); } SQLiteCursorDriver driver = new SQLiteDirectCursorDriver(this, sql, editTable); Cursor cursor = null; try { return driver.query( cursor = driver.query( cursorFactory != null ? cursorFactory : mFactory, selectionArgs); } finally { if (Config.LOGV) { if (Config.LOGV || mSlowQueryThreshold != -1) { // Force query execution if (cursor != null) { cursor.moveToFirst(); cursor.moveToPosition(-1); } long duration = System.currentTimeMillis() - timeStart; if (Config.LOGV || duration >= mSlowQueryThreshold) { Log.v(SQLiteCursor.TAG, "query (" + duration + " ms): " + driver.toString() + ", args are " + (selectionArgs != null Loading @@ -1224,6 +1238,8 @@ public class SQLiteDatabase extends SQLiteClosable { } } } return cursor; } /** * Runs the provided SQL and returns a cursor over the result set. Loading Loading @@ -1671,6 +1687,7 @@ public class SQLiteDatabase extends SQLiteClosable { mFlags = flags; mPath = path; mLogStats = "1".equals(android.os.SystemProperties.get("db.logstats")); mSlowQueryThreshold = SystemProperties.getInt(LOG_SLOW_QUERIES_PROPERTY, -1); mLeakedException = new IllegalStateException(path + " SQLiteDatabase created and never closed"); Loading