4040import java .util .Iterator ;
4141import java .util .Locale ;
4242import java .util .Map ;
43- import java .util .Random ;
4443import java .util .Set ;
4544import java .util .WeakHashMap ;
4645import java .util .concurrent .locks .ReentrantLock ;
@@ -368,7 +367,6 @@ public static synchronized void loadLibs (Context context, File workingDir) {
368367 private static int sQueryLogTimeInMillis = 0 ; // lazily initialized
369368 private static final int QUERY_LOG_SQL_LENGTH = 64 ;
370369 private static final String COMMIT_SQL = "COMMIT;" ;
371- private final Random mRandom = new Random ();
372370 private String mLastSqlStatement = null ;
373371
374372 // String prefix for slow database query EventLog records that show
@@ -2181,7 +2179,6 @@ public void execSQL(String sql) throws SQLException {
21812179 if (!isOpen ()) {
21822180 throw new IllegalStateException ("database not open" );
21832181 }
2184- logTimeStat (mLastSqlStatement , timeStart , GET_LOCK_LOG_PREFIX );
21852182 try {
21862183 native_execSQL (sql );
21872184 } catch (SQLiteDatabaseCorruptException e ) {
@@ -2190,15 +2187,6 @@ public void execSQL(String sql) throws SQLException {
21902187 } finally {
21912188 unlock ();
21922189 }
2193-
2194- // Log commit statements along with the most recently executed
2195- // SQL statement for disambiguation. Note that instance
2196- // equality to COMMIT_SQL is safe here.
2197- if (sql == COMMIT_SQL ) {
2198- logTimeStat (mLastSqlStatement , timeStart , COMMIT_SQL );
2199- } else {
2200- logTimeStat (sql , timeStart , null );
2201- }
22022190 }
22032191
22042192 public void rawExecSQL (String sql ){
@@ -2207,7 +2195,6 @@ public void rawExecSQL(String sql){
22072195 if (!isOpen ()) {
22082196 throw new IllegalStateException ("database not open" );
22092197 }
2210- logTimeStat (mLastSqlStatement , timeStart , GET_LOCK_LOG_PREFIX );
22112198 try {
22122199 native_rawExecSQL (sql );
22132200 } catch (SQLiteDatabaseCorruptException e ) {
@@ -2216,15 +2203,6 @@ public void rawExecSQL(String sql){
22162203 } finally {
22172204 unlock ();
22182205 }
2219-
2220- // Log commit statements along with the most recently executed
2221- // SQL statement for disambiguation. Note that instance
2222- // equality to COMMIT_SQL is safe here.
2223- if (sql == COMMIT_SQL ) {
2224- logTimeStat (mLastSqlStatement , timeStart , COMMIT_SQL );
2225- } else {
2226- logTimeStat (sql , timeStart , null );
2227- }
22282206 }
22292207
22302208 /**
@@ -2266,7 +2244,6 @@ public void execSQL(String sql, Object[] bindArgs) throws SQLException {
22662244 }
22672245 unlock ();
22682246 }
2269- logTimeStat (sql , timeStart );
22702247 }
22712248
22722249 @ Override
@@ -2469,67 +2446,6 @@ public final String getPath() {
24692446 return mPath ;
24702447 }
24712448
2472- /* package */ void logTimeStat (String sql , long beginMillis ) {
2473- logTimeStat (sql , beginMillis , null );
2474- }
2475-
2476- /* package */ void logTimeStat (String sql , long beginMillis , String prefix ) {
2477- // Keep track of the last statement executed here, as this is
2478- // the common funnel through which all methods of hitting
2479- // libsqlite eventually flow.
2480- mLastSqlStatement = sql ;
2481-
2482- // Sample fast queries in proportion to the time taken.
2483- // Quantize the % first, so the logged sampling probability
2484- // exactly equals the actual sampling rate for this query.
2485-
2486- int samplePercent ;
2487- long durationMillis = SystemClock .uptimeMillis () - beginMillis ;
2488- if (durationMillis == 0 && prefix == GET_LOCK_LOG_PREFIX ) {
2489- // The common case is locks being uncontended. Don't log those,
2490- // even at 1%, which is our default below.
2491- return ;
2492- }
2493- if (sQueryLogTimeInMillis == 0 ) {
2494- sQueryLogTimeInMillis = 500 ;//SystemProperties.getInt("db.db_operation.threshold_ms", 500);
2495- }
2496- if (durationMillis >= sQueryLogTimeInMillis ) {
2497- samplePercent = 100 ;
2498- } else {;
2499- samplePercent = (int ) (100 * durationMillis / sQueryLogTimeInMillis ) + 1 ;
2500- if (mRandom .nextInt (100 ) >= samplePercent ) return ;
2501- }
2502-
2503- // Note: the prefix will be "COMMIT;" or "GETLOCK:" when non-null. We wait to do
2504- // it here so we avoid allocating in the common case.
2505- if (prefix != null ) {
2506- sql = prefix + sql ;
2507- }
2508-
2509- if (sql .length () > QUERY_LOG_SQL_LENGTH ) sql = sql .substring (0 , QUERY_LOG_SQL_LENGTH );
2510-
2511- // ActivityThread.currentPackageName() only returns non-null if the
2512- // current thread is an application main thread. This parameter tells
2513- // us whether an event loop is blocked, and if so, which app it is.
2514- //
2515- // Sadly, there's no fast way to determine app name if this is *not* a
2516- // main thread, or when we are invoked via Binder (e.g. ContentProvider).
2517- // Hopefully the full path to the database will be informative enough.
2518-
2519- //TODO get the current package name
2520- String blockingPackage = "unknown" ;//ActivityThread.currentPackageName();
2521- if (blockingPackage == null ) blockingPackage = "" ;
2522-
2523- /*
2524- EventLog.writeEvent(
2525- EVENT_DB_OPERATION,
2526- getPathForLogs(),
2527- sql,
2528- durationMillis,
2529- blockingPackage,
2530- samplePercent);*/
2531- }
2532-
25332449 /**
25342450 * Removes email addresses from database filenames before they're
25352451 * logged to the EventLog where otherwise apps could potentially
0 commit comments