Loading core/java/android/database/sqlite/DatabaseConnectionPool.java +76 −87 Original line number Diff line number Diff line Loading @@ -58,8 +58,7 @@ import java.util.Random; /** * close all database connections in the pool - even if they are in use! */ /* package */ void close() { synchronized(mParentDbObj) { /* package */ synchronized void close() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Closing the connection pool on " + mParentDbObj.getPath() + toString()); } Loading @@ -68,7 +67,6 @@ import java.util.Random; } mPool.clear(); } } /** * get a free connection from the pool Loading @@ -77,10 +75,9 @@ import java.util.Random; * the compiled statement for this sql. * @return the Database connection that the caller can use */ /* package */ SQLiteDatabase get(String sql) { /* package */ synchronized SQLiteDatabase get(String sql) { SQLiteDatabase db = null; PoolObj poolObj = null; synchronized(mParentDbObj) { int poolSize = mPool.size(); if (Log.isLoggable(TAG, Log.DEBUG)) { assert sql != null; Loading Loading @@ -145,8 +142,6 @@ import java.util.Random; assert poolObj.mDb == db; poolObj.acquire(); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "END get-connection: " + toString() + poolObj.toString()); } Loading @@ -159,16 +154,14 @@ import java.util.Random; * release the given database connection back to the pool. * @param db the connection to be released */ /* package */ void release(SQLiteDatabase db) { PoolObj poolObj; synchronized(mParentDbObj) { /* package */ synchronized void release(SQLiteDatabase db) { if (Log.isLoggable(TAG, Log.DEBUG)) { assert db.mConnectionNum > 0; doAsserts(); assert mPool.get(db.mConnectionNum - 1).mDb == db; } poolObj = mPool.get(db.mConnectionNum - 1); PoolObj poolObj = mPool.get(db.mConnectionNum - 1); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "BEGIN release-conn: " + toString() + poolObj.toString()); Loading @@ -180,8 +173,6 @@ import java.util.Random; } poolObj.release(); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "END release-conn: " + toString() + poolObj.toString()); } Loading @@ -191,13 +182,11 @@ import java.util.Random; * Returns a list of all database connections in the pool (both free and busy connections). * This method is used when "adb bugreport" is done. */ /* package */ ArrayList<SQLiteDatabase> getConnectionList() { /* package */ synchronized ArrayList<SQLiteDatabase> getConnectionList() { ArrayList<SQLiteDatabase> list = new ArrayList<SQLiteDatabase>(); synchronized(mParentDbObj) { for (int i = mPool.size() - 1; i >= 0; i--) { list.add(mPool.get(i).mDb); } } return list; } Loading Loading
core/java/android/database/sqlite/DatabaseConnectionPool.java +76 −87 Original line number Diff line number Diff line Loading @@ -58,8 +58,7 @@ import java.util.Random; /** * close all database connections in the pool - even if they are in use! */ /* package */ void close() { synchronized(mParentDbObj) { /* package */ synchronized void close() { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Closing the connection pool on " + mParentDbObj.getPath() + toString()); } Loading @@ -68,7 +67,6 @@ import java.util.Random; } mPool.clear(); } } /** * get a free connection from the pool Loading @@ -77,10 +75,9 @@ import java.util.Random; * the compiled statement for this sql. * @return the Database connection that the caller can use */ /* package */ SQLiteDatabase get(String sql) { /* package */ synchronized SQLiteDatabase get(String sql) { SQLiteDatabase db = null; PoolObj poolObj = null; synchronized(mParentDbObj) { int poolSize = mPool.size(); if (Log.isLoggable(TAG, Log.DEBUG)) { assert sql != null; Loading Loading @@ -145,8 +142,6 @@ import java.util.Random; assert poolObj.mDb == db; poolObj.acquire(); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "END get-connection: " + toString() + poolObj.toString()); } Loading @@ -159,16 +154,14 @@ import java.util.Random; * release the given database connection back to the pool. * @param db the connection to be released */ /* package */ void release(SQLiteDatabase db) { PoolObj poolObj; synchronized(mParentDbObj) { /* package */ synchronized void release(SQLiteDatabase db) { if (Log.isLoggable(TAG, Log.DEBUG)) { assert db.mConnectionNum > 0; doAsserts(); assert mPool.get(db.mConnectionNum - 1).mDb == db; } poolObj = mPool.get(db.mConnectionNum - 1); PoolObj poolObj = mPool.get(db.mConnectionNum - 1); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "BEGIN release-conn: " + toString() + poolObj.toString()); Loading @@ -180,8 +173,6 @@ import java.util.Random; } poolObj.release(); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "END release-conn: " + toString() + poolObj.toString()); } Loading @@ -191,13 +182,11 @@ import java.util.Random; * Returns a list of all database connections in the pool (both free and busy connections). * This method is used when "adb bugreport" is done. */ /* package */ ArrayList<SQLiteDatabase> getConnectionList() { /* package */ synchronized ArrayList<SQLiteDatabase> getConnectionList() { ArrayList<SQLiteDatabase> list = new ArrayList<SQLiteDatabase>(); synchronized(mParentDbObj) { for (int i = mPool.size() - 1; i >= 0; i--) { list.add(mPool.get(i).mDb); } } return list; } Loading