Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa59cfbc authored by Jeff Brown's avatar Jeff Brown
Browse files

resolved conflicts for merge of bce45617 to master

Change-Id: Ieb966e674dca3ec46cd3cd25e4de281f1be747c2
parents c86b8730 bce45617
Loading
Loading
Loading
Loading
+0 −28
Original line number Diff line number Diff line
@@ -306,10 +306,6 @@ public class SQLiteDatabase extends SQLiteClosable {
    /** Used to find out where this object was created in case it never got closed. */
    private final Throwable mStackTrace;

    // 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;

    /** stores the list of statement ids that need to be finalized by sqlite */
    private final ArrayList<Integer> mClosedStatementIds = new ArrayList<Integer>();

@@ -1559,11 +1555,6 @@ public class SQLiteDatabase extends SQLiteClosable {
            String editTable) {
        verifyDbIsOpen();
        BlockGuard.getThreadPolicy().onReadFromDisk();
        long timeStart = 0;

        if (false || mSlowQueryThreshold != -1) {
            timeStart = System.currentTimeMillis();
        }

        SQLiteDatabase db = getDbConnection(sql);
        SQLiteCursorDriver driver = new SQLiteDirectCursorDriver(db, sql, editTable);
@@ -1574,24 +1565,6 @@ public class SQLiteDatabase extends SQLiteClosable {
                    cursorFactory != null ? cursorFactory : mFactory,
                    selectionArgs);
        } finally {
            if (false || mSlowQueryThreshold != -1) {

                // Force query execution
                int count = -1;
                if (cursor != null) {
                    count = cursor.getCount();
                }

                long duration = System.currentTimeMillis() - timeStart;

                if (false || duration >= mSlowQueryThreshold) {
                    Log.v(SQLiteCursor.TAG,
                          "query (" + duration + " ms): " + driver.toString() + ", args are "
                                  + (selectionArgs != null
                                  ? TextUtils.join(",", selectionArgs)
                                  : "<null>")  + ", count is " + count);
                }
            }
            releaseDbConnection(db);
        }
        return cursor;
@@ -1967,7 +1940,6 @@ public class SQLiteDatabase extends SQLiteClosable {
        setMaxSqlCacheSize(DEFAULT_SQL_CACHE_SIZE);
        mFlags = flags;
        mPath = path;
        mSlowQueryThreshold = SystemProperties.getInt(LOG_SLOW_QUERIES_PROPERTY, -1);
        mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace();
        mFactory = factory;
        mPrograms = new WeakHashMap<SQLiteClosable,Object>();
+24 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package android.database.sqlite;

import java.util.ArrayList;

import android.os.Build;
import android.os.SystemProperties;
import android.util.Log;

/**
@@ -64,6 +66,28 @@ public final class SQLiteDebug {
    public static final boolean DEBUG_LOCK_TIME_TRACKING_STACK_TRACE =
            Log.isLoggable("SQLiteLockStackTrace", Log.VERBOSE);

    /**
     * True to enable database performance testing instrumentation.
     * @hide
     */
    public static final boolean DEBUG_LOG_SLOW_QUERIES = Build.IS_DEBUGGABLE;

    /**
     * Determines whether a query should be logged.
     *
     * Reads the "db.log.slow_query_threshold" system property, which can be changed
     * by the user at any time.  If the value is zero, then all queries will
     * be considered slow.  If the value does not exist, then no queries will
     * be considered slow.
     *
     * This value can be changed dynamically while the system is running.
     * @hide
     */
    public static final boolean shouldLogSlowQuery(long elapsedTimeMillis) {
        int slowQueryMillis = SystemProperties.getInt("db.log.slow_query_threshold", -1);
        return slowQueryMillis >= 0 && elapsedTimeMillis > slowQueryMillis;
    }

    /**
     * Contains statistics about the active pagers in the current process.
     *
+18 −11
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.database.sqlite;

import android.database.CursorWindow;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Log;

/**
@@ -30,10 +31,9 @@ import android.util.Log;
public class SQLiteQuery extends SQLiteProgram {
    private static final String TAG = "SQLiteQuery";

    private static final boolean DEBUG_FILL_WINDOW_PERFORMANCE = false;

    private static native long nativeFillWindow(int databasePtr, int statementPtr, int windowPtr,
            int offsetParam, int startPos, int requiredPos, boolean countAllRows);

    private static native int nativeColumnCount(int statementPtr);
    private static native String nativeColumnName(int statementPtr, int columnIndex);

@@ -94,15 +94,22 @@ public class SQLiteQuery extends SQLiteProgram {
                int actualPos = (int)(result >> 32);
                int countedRows = (int)result;
                window.setStartPosition(actualPos);
                if (DEBUG_FILL_WINDOW_PERFORMANCE) {
                    Log.d(TAG, "fillWindow: window=\"" + window
                            + "\", startPos=" + startPos + ", requiredPos=" + requiredPos
                            + ", countAllRows=" + countAllRows
                if (SQLiteDebug.DEBUG_LOG_SLOW_QUERIES) {
                    long elapsed = SystemClock.uptimeMillis() - timeStart;
                    if (SQLiteDebug.shouldLogSlowQuery(elapsed)) {
                        Log.d(TAG, "fillWindow took " + elapsed
                                + " ms: window=\"" + window
                                + "\", startPos=" + startPos
                                + ", requiredPos=" + requiredPos
                                + ", offset=" + mOffsetIndex
                            + ", actualPos=" + actualPos + ", filledRows=" + window.getNumRows()
                                + ", actualPos=" + actualPos
                                + ", filledRows=" + window.getNumRows()
                                + ", countedRows=" + countedRows
                            + ", took " + (SystemClock.uptimeMillis() - timeStart)
                            + " ms, query=\"" + mSql + "\"");
                                + ", query=\"" + mSql + "\""
                                + ", args=[" + (mBindArgs != null ?
                                        TextUtils.join(", ", mBindArgs.values()) : "")
                                + "]");
                    }
                }
                mDatabase.logTimeStat(mSql, timeStart);
                return countedRows;
+7 −0
Original line number Diff line number Diff line
@@ -325,6 +325,13 @@ public class Build {
    public static final String USER = getString("ro.build.user");
    public static final String HOST = getString("ro.build.host");

    /**
     * Returns true if we are running a debug build such as "user-debug" or "eng".
     * @hide
     */
    public static final boolean IS_DEBUGGABLE =
            SystemProperties.getInt("ro.debuggable", 0) == 1;

    /**
     * Returns the version string for the radio firmware.  May return
     * null (if, for instance, the radio is not currently on).