40
40
import java .util .Iterator ;
41
41
import java .util .Locale ;
42
42
import java .util .Map ;
43
- import java .util .Random ;
44
43
import java .util .Set ;
45
44
import java .util .WeakHashMap ;
46
45
import java .util .concurrent .locks .ReentrantLock ;
@@ -368,7 +367,6 @@ public static synchronized void loadLibs (Context context, File workingDir) {
368
367
private static int sQueryLogTimeInMillis = 0 ; // lazily initialized
369
368
private static final int QUERY_LOG_SQL_LENGTH = 64 ;
370
369
private static final String COMMIT_SQL = "COMMIT;" ;
371
- private final Random mRandom = new Random ();
372
370
private String mLastSqlStatement = null ;
373
371
374
372
// String prefix for slow database query EventLog records that show
@@ -2181,7 +2179,6 @@ public void execSQL(String sql) throws SQLException {
2181
2179
if (!isOpen ()) {
2182
2180
throw new IllegalStateException ("database not open" );
2183
2181
}
2184
- logTimeStat (mLastSqlStatement , timeStart , GET_LOCK_LOG_PREFIX );
2185
2182
try {
2186
2183
native_execSQL (sql );
2187
2184
} catch (SQLiteDatabaseCorruptException e ) {
@@ -2190,15 +2187,6 @@ public void execSQL(String sql) throws SQLException {
2190
2187
} finally {
2191
2188
unlock ();
2192
2189
}
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
- }
2202
2190
}
2203
2191
2204
2192
public void rawExecSQL (String sql ){
@@ -2207,7 +2195,6 @@ public void rawExecSQL(String sql){
2207
2195
if (!isOpen ()) {
2208
2196
throw new IllegalStateException ("database not open" );
2209
2197
}
2210
- logTimeStat (mLastSqlStatement , timeStart , GET_LOCK_LOG_PREFIX );
2211
2198
try {
2212
2199
native_rawExecSQL (sql );
2213
2200
} catch (SQLiteDatabaseCorruptException e ) {
@@ -2216,15 +2203,6 @@ public void rawExecSQL(String sql){
2216
2203
} finally {
2217
2204
unlock ();
2218
2205
}
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
- }
2228
2206
}
2229
2207
2230
2208
/**
@@ -2266,7 +2244,6 @@ public void execSQL(String sql, Object[] bindArgs) throws SQLException {
2266
2244
}
2267
2245
unlock ();
2268
2246
}
2269
- logTimeStat (sql , timeStart );
2270
2247
}
2271
2248
2272
2249
@ Override
@@ -2469,67 +2446,6 @@ public final String getPath() {
2469
2446
return mPath ;
2470
2447
}
2471
2448
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
-
2533
2449
/**
2534
2450
* Removes email addresses from database filenames before they're
2535
2451
* logged to the EventLog where otherwise apps could potentially
0 commit comments