diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-01-20 14:07:59 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-01-20 14:07:59 -0800 |
commit | 1bf599a01e7ad720150d8cc12416ba67bebd74c9 (patch) | |
tree | db2d5edc57a18a125f1576987b1daf119862d142 /core/java/android/database | |
parent | 2f9510ca50b0fd2925bc7e349f76136ed403a386 (diff) | |
parent | 4b57553e693c9705e8363d3e0e9d881261b3e6fa (diff) | |
download | frameworks_base-1bf599a01e7ad720150d8cc12416ba67bebd74c9.zip frameworks_base-1bf599a01e7ad720150d8cc12416ba67bebd74c9.tar.gz frameworks_base-1bf599a01e7ad720150d8cc12416ba67bebd74c9.tar.bz2 |
Merge "Initialize SQLite as part of the android runtime."
Diffstat (limited to 'core/java/android/database')
-rw-r--r-- | core/java/android/database/sqlite/SQLiteConnection.java | 2 | ||||
-rw-r--r-- | core/java/android/database/sqlite/SQLiteDebug.java | 1 | ||||
-rw-r--r-- | core/java/android/database/sqlite/SQLiteGlobal.java | 42 |
3 files changed, 10 insertions, 35 deletions
diff --git a/core/java/android/database/sqlite/SQLiteConnection.java b/core/java/android/database/sqlite/SQLiteConnection.java index 2ea936e..72f62fd 100644 --- a/core/java/android/database/sqlite/SQLiteConnection.java +++ b/core/java/android/database/sqlite/SQLiteConnection.java @@ -194,8 +194,6 @@ public final class SQLiteConnection { } private void open() { - SQLiteGlobal.initializeOnce(); - mConnectionPtr = nativeOpen(mConfiguration.path, mConfiguration.openFlags, mConfiguration.label, SQLiteDebug.DEBUG_SQL_STATEMENTS, SQLiteDebug.DEBUG_SQL_TIME); diff --git a/core/java/android/database/sqlite/SQLiteDebug.java b/core/java/android/database/sqlite/SQLiteDebug.java index 95350ba..204483d 100644 --- a/core/java/android/database/sqlite/SQLiteDebug.java +++ b/core/java/android/database/sqlite/SQLiteDebug.java @@ -138,7 +138,6 @@ public final class SQLiteDebug { */ public static PagerStats getDatabaseInfo() { PagerStats stats = new PagerStats(); - SQLiteGlobal.initializeOnce(); nativeGetPagerStats(stats); stats.dbStats = SQLiteDatabase.getDbStats(); return stats; diff --git a/core/java/android/database/sqlite/SQLiteGlobal.java b/core/java/android/database/sqlite/SQLiteGlobal.java index 5e129be..dbefd63 100644 --- a/core/java/android/database/sqlite/SQLiteGlobal.java +++ b/core/java/android/database/sqlite/SQLiteGlobal.java @@ -22,57 +22,35 @@ import android.os.StatFs; * Provides access to SQLite functions that affect all database connection, * such as memory management. * + * The native code associated with SQLiteGlobal is also sets global configuration options + * using sqlite3_config() then calls sqlite3_initialize() to ensure that the SQLite + * library is properly initialized exactly once before any other framework or application + * code has a chance to run. + * + * Verbose SQLite logging is enabled if the "log.tag.SQLiteLog" property is set to "V". + * (per {@link SQLiteDebug#DEBUG_SQL_LOG}). + * * @hide */ public final class SQLiteGlobal { private static final String TAG = "SQLiteGlobal"; private static final Object sLock = new Object(); - private static boolean sInitialized; - private static int sSoftHeapLimit; private static int sDefaultPageSize; - private static native void nativeConfig(boolean verboseLog, int softHeapLimit); - private static native int nativeReleaseMemory(int bytesToFree); + private static native int nativeReleaseMemory(); private SQLiteGlobal() { } /** - * Initializes global SQLite settings the first time it is called. - * Should be called before opening the first (or any) database. - * Does nothing on repeated subsequent calls. - */ - public static void initializeOnce() { - synchronized (sLock) { - if (!sInitialized) { - sInitialized = true; - - // Limit to 8MB for now. This is 4 times the maximum cursor window - // size, as has been used by the original code in SQLiteDatabase for - // a long time. - // TODO: We really do need to test whether this helps or hurts us. - sSoftHeapLimit = 8 * 1024 * 1024; - - // Configure SQLite. - nativeConfig(SQLiteDebug.DEBUG_SQL_LOG, sSoftHeapLimit); - } - } - } - - /** * Attempts to release memory by pruning the SQLite page cache and other * internal data structures. * * @return The number of bytes that were freed. */ public static int releaseMemory() { - synchronized (sLock) { - if (!sInitialized) { - return 0; - } - return nativeReleaseMemory(sSoftHeapLimit); - } + return nativeReleaseMemory(); } /** |