6464public class SyncStorageEngine extends Handler {
6565
6666 private static final String TAG = "SyncManager" ;
67+ private static final boolean DEBUG = false ;
6768 private static final boolean DEBUG_FILE = false ;
6869
6970 private static final String XML_ATTR_NEXT_AUTHORITY_ID = "nextAuthorityId" ;
@@ -443,7 +444,7 @@ private void reportChange(int which) {
443444 mChangeListeners .finishBroadcast ();
444445 }
445446
446- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
447+ if (DEBUG ) {
447448 Log .v (TAG , "reportChange " + which + " to: " + reports );
448449 }
449450
@@ -484,13 +485,17 @@ public boolean getSyncAutomatically(Account account, int userId, String provider
484485
485486 public void setSyncAutomatically (Account account , int userId , String providerName ,
486487 boolean sync ) {
487- Log .d (TAG , "setSyncAutomatically: " + /* account + */ " provider " + providerName
488- + ", user " + userId + " -> " + sync );
488+ if (DEBUG ) {
489+ Log .d (TAG , "setSyncAutomatically: " + /* account + */ " provider " + providerName
490+ + ", user " + userId + " -> " + sync );
491+ }
489492 synchronized (mAuthorities ) {
490493 AuthorityInfo authority = getOrCreateAuthorityLocked (account , userId , providerName , -1 ,
491494 false );
492495 if (authority .enabled == sync ) {
493- Log .d (TAG , "setSyncAutomatically: already set to " + sync + ", doing nothing" );
496+ if (DEBUG ) {
497+ Log .d (TAG , "setSyncAutomatically: already set to " + sync + ", doing nothing" );
498+ }
494499 return ;
495500 }
496501 authority .enabled = sync ;
@@ -532,13 +537,17 @@ public void setIsSyncable(Account account, int userId, String providerName, int
532537 } else if (syncable < -1 ) {
533538 syncable = -1 ;
534539 }
535- Log .d (TAG , "setIsSyncable: " + account + ", provider " + providerName
536- + ", user " + userId + " -> " + syncable );
540+ if (DEBUG ) {
541+ Log .d (TAG , "setIsSyncable: " + account + ", provider " + providerName
542+ + ", user " + userId + " -> " + syncable );
543+ }
537544 synchronized (mAuthorities ) {
538545 AuthorityInfo authority = getOrCreateAuthorityLocked (account , userId , providerName , -1 ,
539546 false );
540547 if (authority .syncable == syncable ) {
541- Log .d (TAG , "setIsSyncable: already set to " + syncable + ", doing nothing" );
548+ if (DEBUG ) {
549+ Log .d (TAG , "setIsSyncable: already set to " + syncable + ", doing nothing" );
550+ }
542551 return ;
543552 }
544553 authority .syncable = syncable ;
@@ -564,7 +573,7 @@ public Pair<Long, Long> getBackoff(Account account, int userId, String providerN
564573
565574 public void setBackoff (Account account , int userId , String providerName ,
566575 long nextSyncTime , long nextDelay ) {
567- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
576+ if (DEBUG ) {
568577 Log .v (TAG , "setBackoff: " + account + ", provider " + providerName
569578 + ", user " + userId
570579 + " -> nextSyncTime " + nextSyncTime + ", nextDelay " + nextDelay );
@@ -615,7 +624,7 @@ public void clearAllBackoffs(SyncQueue syncQueue) {
615624 for (AuthorityInfo authorityInfo : accountInfo .authorities .values ()) {
616625 if (authorityInfo .backoffTime != NOT_IN_BACKOFF_MODE
617626 || authorityInfo .backoffDelay != NOT_IN_BACKOFF_MODE ) {
618- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
627+ if (DEBUG ) {
619628 Log .v (TAG , "clearAllBackoffs:"
620629 + " authority:" + authorityInfo .authority
621630 + " account:" + accountInfo .accountAndUser .account .name
@@ -641,7 +650,7 @@ public void clearAllBackoffs(SyncQueue syncQueue) {
641650
642651 public void setDelayUntilTime (Account account , int userId , String providerName ,
643652 long delayUntil ) {
644- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
653+ if (DEBUG ) {
645654 Log .v (TAG , "setDelayUntil: " + account + ", provider " + providerName
646655 + ", user " + userId + " -> delayUntil " + delayUntil );
647656 }
@@ -677,7 +686,7 @@ private void updateOrRemovePeriodicSync(Account account, int userId, String prov
677686 if (extras == null ) {
678687 extras = new Bundle ();
679688 }
680- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
689+ if (DEBUG ) {
681690 Log .v (TAG , "addOrRemovePeriodicSync: " + account + ", user " + userId
682691 + ", provider " + providerName
683692 + " -> period " + period + ", extras " + extras );
@@ -833,7 +842,7 @@ public boolean isSyncActive(Account account, int userId, String authority) {
833842
834843 public PendingOperation insertIntoPending (PendingOperation op ) {
835844 synchronized (mAuthorities ) {
836- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
845+ if (DEBUG ) {
837846 Log .v (TAG , "insertIntoPending: account=" + op .account
838847 + " user=" + op .userId
839848 + " auth=" + op .authority
@@ -865,7 +874,7 @@ public PendingOperation insertIntoPending(PendingOperation op) {
865874 public boolean deleteFromPending (PendingOperation op ) {
866875 boolean res = false ;
867876 synchronized (mAuthorities ) {
868- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
877+ if (DEBUG ) {
869878 Log .v (TAG , "deleteFromPending: account=" + op .account
870879 + " user=" + op .userId
871880 + " auth=" + op .authority
@@ -884,7 +893,7 @@ public boolean deleteFromPending(PendingOperation op) {
884893 AuthorityInfo authority = getAuthorityLocked (op .account , op .userId , op .authority ,
885894 "deleteFromPending" );
886895 if (authority != null ) {
887- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) Log .v (TAG , "removing - " + authority );
896+ if (DEBUG ) Log .v (TAG , "removing - " + authority );
888897 final int N = mPendingOperations .size ();
889898 boolean morePending = false ;
890899 for (int i =0 ; i <N ; i ++) {
@@ -898,7 +907,7 @@ public boolean deleteFromPending(PendingOperation op) {
898907 }
899908
900909 if (!morePending ) {
901- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) Log .v (TAG , "no more pending!" );
910+ if (DEBUG ) Log .v (TAG , "no more pending!" );
902911 SyncStatusInfo status = getOrCreateSyncStatusLocked (authority .ident );
903912 status .pending = false ;
904913 }
@@ -938,16 +947,16 @@ public int getPendingOperationCount() {
938947 */
939948 public void doDatabaseCleanup (Account [] accounts , int userId ) {
940949 synchronized (mAuthorities ) {
941- if (Log . isLoggable ( TAG , Log . VERBOSE )) Log .w (TAG , "Updating for new accounts..." );
950+ if (DEBUG ) Log .v (TAG , "Updating for new accounts..." );
942951 SparseArray <AuthorityInfo > removing = new SparseArray <AuthorityInfo >();
943952 Iterator <AccountInfo > accIt = mAccounts .values ().iterator ();
944953 while (accIt .hasNext ()) {
945954 AccountInfo acc = accIt .next ();
946955 if (!ArrayUtils .contains (accounts , acc .accountAndUser .account )
947956 && acc .accountAndUser .userId == userId ) {
948957 // This account no longer exists...
949- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
950- Log .w (TAG , "Account removed: " + acc .accountAndUser );
958+ if (DEBUG ) {
959+ Log .v (TAG , "Account removed: " + acc .accountAndUser );
951960 }
952961 for (AuthorityInfo auth : acc .authorities .values ()) {
953962 removing .put (auth .ident , auth );
@@ -993,7 +1002,7 @@ public void doDatabaseCleanup(Account[] accounts, int userId) {
9931002 public SyncInfo addActiveSync (SyncManager .ActiveSyncContext activeSyncContext ) {
9941003 final SyncInfo syncInfo ;
9951004 synchronized (mAuthorities ) {
996- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
1005+ if (DEBUG ) {
9971006 Log .v (TAG , "setActiveSync: account="
9981007 + activeSyncContext .mSyncOperation .account
9991008 + " auth=" + activeSyncContext .mSyncOperation .authority
@@ -1021,7 +1030,7 @@ public SyncInfo addActiveSync(SyncManager.ActiveSyncContext activeSyncContext) {
10211030 */
10221031 public void removeActiveSync (SyncInfo syncInfo , int userId ) {
10231032 synchronized (mAuthorities ) {
1024- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
1033+ if (DEBUG ) {
10251034 Log .v (TAG , "removeActiveSync: account=" + syncInfo .account
10261035 + " user=" + userId
10271036 + " auth=" + syncInfo .authority );
@@ -1046,7 +1055,7 @@ public long insertStartSyncEvent(Account accountName, int userId, String authori
10461055 long now , int source , boolean initialization ) {
10471056 long id ;
10481057 synchronized (mAuthorities ) {
1049- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
1058+ if (DEBUG ) {
10501059 Log .v (TAG , "insertStartSyncEvent: account=" + accountName + "user=" + userId
10511060 + " auth=" + authorityName + " source=" + source );
10521061 }
@@ -1068,7 +1077,7 @@ public long insertStartSyncEvent(Account accountName, int userId, String authori
10681077 mSyncHistory .remove (mSyncHistory .size ()-1 );
10691078 }
10701079 id = item .historyId ;
1071- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) Log .v (TAG , "returning historyId " + id );
1080+ if (DEBUG ) Log .v (TAG , "returning historyId " + id );
10721081 }
10731082
10741083 reportChange (ContentResolver .SYNC_OBSERVER_TYPE_STATUS );
@@ -1096,7 +1105,7 @@ public static boolean equals(Bundle b1, Bundle b2) {
10961105 public void stopSyncEvent (long historyId , long elapsedTime , String resultMessage ,
10971106 long downstreamActivity , long upstreamActivity ) {
10981107 synchronized (mAuthorities ) {
1099- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
1108+ if (DEBUG ) {
11001109 Log .v (TAG , "stopSyncEvent: historyId=" + historyId );
11011110 }
11021111 SyncHistoryItem item = null ;
@@ -1358,7 +1367,7 @@ private AuthorityInfo getAuthorityLocked(Account accountName, int userId, String
13581367 AccountInfo accountInfo = mAccounts .get (au );
13591368 if (accountInfo == null ) {
13601369 if (tag != null ) {
1361- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
1370+ if (DEBUG ) {
13621371 Log .v (TAG , tag + ": unknown account " + au );
13631372 }
13641373 }
@@ -1367,7 +1376,7 @@ private AuthorityInfo getAuthorityLocked(Account accountName, int userId, String
13671376 AuthorityInfo authority = accountInfo .authorities .get (authorityName );
13681377 if (authority == null ) {
13691378 if (tag != null ) {
1370- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
1379+ if (DEBUG ) {
13711380 Log .v (TAG , tag + ": unknown authority " + authorityName );
13721381 }
13731382 }
@@ -1392,7 +1401,7 @@ private AuthorityInfo getOrCreateAuthorityLocked(Account accountName, int userId
13921401 mNextAuthorityId ++;
13931402 doWrite = true ;
13941403 }
1395- if (Log . isLoggable ( TAG , Log . VERBOSE ) ) {
1404+ if (DEBUG ) {
13961405 Log .v (TAG , "created a new AuthorityInfo for " + accountName
13971406 + ", user " + userId
13981407 + ", provider " + authorityName );
0 commit comments