17
17
package net .sqlcipher .database ;
18
18
19
19
import net .sqlcipher .AbstractWindowedCursor ;
20
+ import net .sqlcipher .BuildConfig ;
20
21
import net .sqlcipher .CursorWindow ;
21
22
import net .sqlcipher .SQLException ;
22
23
@@ -252,7 +253,7 @@ public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver,
252
253
for (int i = 0 ; i < columnCount ; i ++) {
253
254
String columnName = mQuery .columnNameLocked (i );
254
255
mColumns [i ] = columnName ;
255
- if ( Config . LOGV ) {
256
+ if ( BuildConfig . DEBUG ) {
256
257
Log .v ("DatabaseWindow" , "mColumns[" + i + "] is "
257
258
+ mColumns [i ]);
258
259
}
@@ -316,8 +317,10 @@ private void fillWindow (int requiredPos) {
316
317
}
317
318
mWindow .setStartPosition (startPos );
318
319
mWindow .setRequiredPosition (requiredPos );
319
- Log .v (TAG , String .format ("Filling cursor window with start position:%d required position:%d" ,
320
- startPos , requiredPos ));
320
+ if (BuildConfig .DEBUG ){
321
+ Log .v (TAG , String .format ("Filling cursor window with start position:%d required position:%d" ,
322
+ startPos , requiredPos ));
323
+ }
321
324
mCount = mQuery .fillWindow (mWindow , mInitialRead , 0 );
322
325
if (mCursorWindowCapacity == 0 ) {
323
326
mCursorWindowCapacity = mWindow .getNumRows ();
@@ -347,8 +350,10 @@ public int getColumnIndex(String columnName) {
347
350
final int periodIndex = columnName .lastIndexOf ('.' );
348
351
if (periodIndex != -1 ) {
349
352
Exception e = new Exception ();
350
- Log .e (TAG , "requesting column name with table name -- " + columnName , e );
351
- columnName = columnName .substring (periodIndex + 1 );
353
+ if (BuildConfig .DEBUG ){
354
+ Log .e (TAG , "requesting column name with table name -- " + columnName , e );
355
+ columnName = columnName .substring (periodIndex + 1 );
356
+ }
352
357
}
353
358
354
359
Integer i = mColumnNameMap .get (columnName );
@@ -369,10 +374,12 @@ public boolean deleteRow() {
369
374
370
375
// Only allow deletes if there is an ID column, and the ID has been read from it
371
376
if (mRowIdColumnIndex == -1 || mCurrentRowID == null ) {
377
+ if (BuildConfig .DEBUG ){
372
378
Log .e (TAG ,
373
- "Could not delete row because either the row ID column is not available or it" +
374
- "has not been read." );
375
- return false ;
379
+ "Could not delete row because either the row ID column is not available or it" +
380
+ "has not been read." );
381
+ }
382
+ return false ;
376
383
}
377
384
378
385
boolean success ;
@@ -436,9 +443,11 @@ public boolean supportsUpdates() {
436
443
public boolean commitUpdates (Map <? extends Long ,
437
444
? extends Map <String , Object >> additionalValues ) {
438
445
if (!supportsUpdates ()) {
446
+ if (BuildConfig .DEBUG ){
439
447
Log .e (TAG , "commitUpdates not supported on this cursor, did you "
440
- + "include the _id column?" );
441
- return false ;
448
+ + "include the _id column?" );
449
+ }
450
+ return false ;
442
451
}
443
452
444
453
/*
@@ -521,13 +530,13 @@ public boolean commitUpdates(Map<? extends Long,
521
530
}
522
531
523
532
private void deactivateCommon () {
524
- if ( Config . LOGV ) Log .v (TAG , "<<< Releasing cursor " + this );
533
+ if ( BuildConfig . DEBUG ) Log .v (TAG , "<<< Releasing cursor " + this );
525
534
mCursorState = 0 ;
526
535
if (mWindow != null ) {
527
536
mWindow .close ();
528
537
mWindow = null ;
529
538
}
530
- if ( Config . LOGV ) Log .v ("DatabaseWindow" , "closing window in release()" );
539
+ if ( BuildConfig . DEBUG ) Log .v ("DatabaseWindow" , "closing window in release()" );
531
540
}
532
541
533
542
@ Override
@@ -578,15 +587,15 @@ public boolean requery() {
578
587
mDatabase .unlock ();
579
588
}
580
589
581
- if ( Config . LOGV ) {
582
- Log .v ("DatabaseWindow" , "closing window in requery()" );
583
- Log .v (TAG , "--- Requery()ed cursor " + this + ": " + mQuery );
590
+ if ( BuildConfig . DEBUG ) {
591
+ Log .v ("DatabaseWindow" , "closing window in requery()" );
592
+ Log .v (TAG , "--- Requery()ed cursor " + this + ": " + mQuery );
584
593
}
585
594
586
595
boolean result = super .requery ();
587
- if ( Config . LOGV ) {
588
- long timeEnd = System .currentTimeMillis ();
589
- Log .v (TAG , "requery (" + (timeEnd - timeStart ) + " ms): " + mDriver .toString ());
596
+ if ( BuildConfig . DEBUG ) {
597
+ long timeEnd = System .currentTimeMillis ();
598
+ Log .v (TAG , "requery (" + (timeEnd - timeStart ) + " ms): " + mDriver .toString ());
590
599
}
591
600
return result ;
592
601
}
@@ -622,16 +631,18 @@ protected void finalize() {
622
631
// if the cursor hasn't been closed yet, close it first
623
632
if (mWindow != null ) {
624
633
int len = mQuery .mSql .length ();
625
- Log .e (TAG , "Finalizing a Cursor that has not been deactivated or closed. " +
634
+ if (BuildConfig .DEBUG ){
635
+ Log .e (TAG , "Finalizing a Cursor that has not been deactivated or closed. " +
626
636
"database = " + mDatabase .getPath () + ", table = " + mEditTable +
627
637
", query = " + mQuery .mSql .substring (0 , (len > 100 ) ? 100 : len ),
628
638
mStackTrace );
639
+ }
629
640
close ();
630
641
SQLiteDebug .notifyActiveCursorFinalized ();
631
642
} else {
632
- if ( Config . LOGV ) {
633
- Log .v (TAG , "Finalizing cursor on database = " + mDatabase .getPath () +
634
- ", table = " + mEditTable + ", query = " + mQuery .mSql );
643
+ if ( BuildConfig . DEBUG ) {
644
+ Log .v (TAG , "Finalizing cursor on database = " + mDatabase .getPath () +
645
+ ", table = " + mEditTable + ", query = " + mQuery .mSql );
635
646
}
636
647
}
637
648
} finally {
@@ -665,8 +676,10 @@ public void fillWindow(int requiredPos, android.database.CursorWindow window) {
665
676
}
666
677
mWindow .setStartPosition (startPos );
667
678
mWindow .setRequiredPosition (requiredPos );
668
- Log .v (TAG , String .format ("Filling cursor window with start position:%d required position:%d" ,
669
- startPos , requiredPos ));
679
+ if (BuildConfig .DEBUG ) {
680
+ Log .v (TAG , String .format ("Filling cursor window with start position:%d required position:%d" ,
681
+ startPos , requiredPos ));
682
+ }
670
683
mCount = mQuery .fillWindow (mWindow , mInitialRead , 0 );
671
684
if (mCursorWindowCapacity == 0 ) {
672
685
mCursorWindowCapacity = mWindow .getNumRows ();
0 commit comments