1717package net .sqlcipher .database ;
1818
1919import net .sqlcipher .AbstractWindowedCursor ;
20+ import net .sqlcipher .BuildConfig ;
2021import net .sqlcipher .CursorWindow ;
2122import net .sqlcipher .SQLException ;
2223
@@ -252,7 +253,7 @@ public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver,
252253 for (int i = 0 ; i < columnCount ; i ++) {
253254 String columnName = mQuery .columnNameLocked (i );
254255 mColumns [i ] = columnName ;
255- if ( Config . LOGV ) {
256+ if ( BuildConfig . DEBUG ) {
256257 Log .v ("DatabaseWindow" , "mColumns[" + i + "] is "
257258 + mColumns [i ]);
258259 }
@@ -316,8 +317,10 @@ private void fillWindow (int requiredPos) {
316317 }
317318 mWindow .setStartPosition (startPos );
318319 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+ }
321324 mCount = mQuery .fillWindow (mWindow , mInitialRead , 0 );
322325 if (mCursorWindowCapacity == 0 ) {
323326 mCursorWindowCapacity = mWindow .getNumRows ();
@@ -347,8 +350,10 @@ public int getColumnIndex(String columnName) {
347350 final int periodIndex = columnName .lastIndexOf ('.' );
348351 if (periodIndex != -1 ) {
349352 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+ }
352357 }
353358
354359 Integer i = mColumnNameMap .get (columnName );
@@ -369,10 +374,12 @@ public boolean deleteRow() {
369374
370375 // Only allow deletes if there is an ID column, and the ID has been read from it
371376 if (mRowIdColumnIndex == -1 || mCurrentRowID == null ) {
377+ if (BuildConfig .DEBUG ){
372378 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 ;
376383 }
377384
378385 boolean success ;
@@ -436,9 +443,11 @@ public boolean supportsUpdates() {
436443 public boolean commitUpdates (Map <? extends Long ,
437444 ? extends Map <String , Object >> additionalValues ) {
438445 if (!supportsUpdates ()) {
446+ if (BuildConfig .DEBUG ){
439447 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 ;
442451 }
443452
444453 /*
@@ -521,13 +530,13 @@ public boolean commitUpdates(Map<? extends Long,
521530 }
522531
523532 private void deactivateCommon () {
524- if ( Config . LOGV ) Log .v (TAG , "<<< Releasing cursor " + this );
533+ if ( BuildConfig . DEBUG ) Log .v (TAG , "<<< Releasing cursor " + this );
525534 mCursorState = 0 ;
526535 if (mWindow != null ) {
527536 mWindow .close ();
528537 mWindow = null ;
529538 }
530- if ( Config . LOGV ) Log .v ("DatabaseWindow" , "closing window in release()" );
539+ if ( BuildConfig . DEBUG ) Log .v ("DatabaseWindow" , "closing window in release()" );
531540 }
532541
533542 @ Override
@@ -578,15 +587,15 @@ public boolean requery() {
578587 mDatabase .unlock ();
579588 }
580589
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 );
584593 }
585594
586595 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 ());
590599 }
591600 return result ;
592601 }
@@ -622,16 +631,18 @@ protected void finalize() {
622631 // if the cursor hasn't been closed yet, close it first
623632 if (mWindow != null ) {
624633 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. " +
626636 "database = " + mDatabase .getPath () + ", table = " + mEditTable +
627637 ", query = " + mQuery .mSql .substring (0 , (len > 100 ) ? 100 : len ),
628638 mStackTrace );
639+ }
629640 close ();
630641 SQLiteDebug .notifyActiveCursorFinalized ();
631642 } 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 );
635646 }
636647 }
637648 } finally {
@@ -665,8 +676,10 @@ public void fillWindow(int requiredPos, android.database.CursorWindow window) {
665676 }
666677 mWindow .setStartPosition (startPos );
667678 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+ }
670683 mCount = mQuery .fillWindow (mWindow , mInitialRead , 0 );
671684 if (mCursorWindowCapacity == 0 ) {
672685 mCursorWindowCapacity = mWindow .getNumRows ();
0 commit comments