Quiet down a lot of logging.
Also fix a little problem where the USER_STARTED broadcasts
were not being sent as ordered broadcasts(!).
Change-Id: I3aa3e0a9b3900967cdd2d115ee103371b0a50c41
diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java
index bdc5a3f..1ecab09 100644
--- a/core/java/android/content/SyncStorageEngine.java
+++ b/core/java/android/content/SyncStorageEngine.java
@@ -64,6 +64,7 @@
public class SyncStorageEngine extends Handler {
private static final String TAG = "SyncManager";
+ private static final boolean DEBUG = false;
private static final boolean DEBUG_FILE = false;
private static final String XML_ATTR_NEXT_AUTHORITY_ID = "nextAuthorityId";
@@ -443,7 +444,7 @@
mChangeListeners.finishBroadcast();
}
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "reportChange " + which + " to: " + reports);
}
@@ -484,13 +485,17 @@
public void setSyncAutomatically(Account account, int userId, String providerName,
boolean sync) {
- Log.d(TAG, "setSyncAutomatically: " + /* account + */" provider " + providerName
- + ", user " + userId + " -> " + sync);
+ if (DEBUG) {
+ Log.d(TAG, "setSyncAutomatically: " + /* account + */" provider " + providerName
+ + ", user " + userId + " -> " + sync);
+ }
synchronized (mAuthorities) {
AuthorityInfo authority = getOrCreateAuthorityLocked(account, userId, providerName, -1,
false);
if (authority.enabled == sync) {
- Log.d(TAG, "setSyncAutomatically: already set to " + sync + ", doing nothing");
+ if (DEBUG) {
+ Log.d(TAG, "setSyncAutomatically: already set to " + sync + ", doing nothing");
+ }
return;
}
authority.enabled = sync;
@@ -532,13 +537,17 @@
} else if (syncable < -1) {
syncable = -1;
}
- Log.d(TAG, "setIsSyncable: " + account + ", provider " + providerName
- + ", user " + userId + " -> " + syncable);
+ if (DEBUG) {
+ Log.d(TAG, "setIsSyncable: " + account + ", provider " + providerName
+ + ", user " + userId + " -> " + syncable);
+ }
synchronized (mAuthorities) {
AuthorityInfo authority = getOrCreateAuthorityLocked(account, userId, providerName, -1,
false);
if (authority.syncable == syncable) {
- Log.d(TAG, "setIsSyncable: already set to " + syncable + ", doing nothing");
+ if (DEBUG) {
+ Log.d(TAG, "setIsSyncable: already set to " + syncable + ", doing nothing");
+ }
return;
}
authority.syncable = syncable;
@@ -564,7 +573,7 @@
public void setBackoff(Account account, int userId, String providerName,
long nextSyncTime, long nextDelay) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "setBackoff: " + account + ", provider " + providerName
+ ", user " + userId
+ " -> nextSyncTime " + nextSyncTime + ", nextDelay " + nextDelay);
@@ -615,7 +624,7 @@
for (AuthorityInfo authorityInfo : accountInfo.authorities.values()) {
if (authorityInfo.backoffTime != NOT_IN_BACKOFF_MODE
|| authorityInfo.backoffDelay != NOT_IN_BACKOFF_MODE) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "clearAllBackoffs:"
+ " authority:" + authorityInfo.authority
+ " account:" + accountInfo.accountAndUser.account.name
@@ -641,7 +650,7 @@
public void setDelayUntilTime(Account account, int userId, String providerName,
long delayUntil) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "setDelayUntil: " + account + ", provider " + providerName
+ ", user " + userId + " -> delayUntil " + delayUntil);
}
@@ -677,7 +686,7 @@
if (extras == null) {
extras = new Bundle();
}
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "addOrRemovePeriodicSync: " + account + ", user " + userId
+ ", provider " + providerName
+ " -> period " + period + ", extras " + extras);
@@ -833,7 +842,7 @@
public PendingOperation insertIntoPending(PendingOperation op) {
synchronized (mAuthorities) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "insertIntoPending: account=" + op.account
+ " user=" + op.userId
+ " auth=" + op.authority
@@ -865,7 +874,7 @@
public boolean deleteFromPending(PendingOperation op) {
boolean res = false;
synchronized (mAuthorities) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "deleteFromPending: account=" + op.account
+ " user=" + op.userId
+ " auth=" + op.authority
@@ -884,7 +893,7 @@
AuthorityInfo authority = getAuthorityLocked(op.account, op.userId, op.authority,
"deleteFromPending");
if (authority != null) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "removing - " + authority);
+ if (DEBUG) Log.v(TAG, "removing - " + authority);
final int N = mPendingOperations.size();
boolean morePending = false;
for (int i=0; i<N; i++) {
@@ -898,7 +907,7 @@
}
if (!morePending) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "no more pending!");
+ if (DEBUG) Log.v(TAG, "no more pending!");
SyncStatusInfo status = getOrCreateSyncStatusLocked(authority.ident);
status.pending = false;
}
@@ -938,7 +947,7 @@
*/
public void doDatabaseCleanup(Account[] accounts, int userId) {
synchronized (mAuthorities) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) Log.w(TAG, "Updating for new accounts...");
+ if (DEBUG) Log.v(TAG, "Updating for new accounts...");
SparseArray<AuthorityInfo> removing = new SparseArray<AuthorityInfo>();
Iterator<AccountInfo> accIt = mAccounts.values().iterator();
while (accIt.hasNext()) {
@@ -946,8 +955,8 @@
if (!ArrayUtils.contains(accounts, acc.accountAndUser.account)
&& acc.accountAndUser.userId == userId) {
// This account no longer exists...
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.w(TAG, "Account removed: " + acc.accountAndUser);
+ if (DEBUG) {
+ Log.v(TAG, "Account removed: " + acc.accountAndUser);
}
for (AuthorityInfo auth : acc.authorities.values()) {
removing.put(auth.ident, auth);
@@ -993,7 +1002,7 @@
public SyncInfo addActiveSync(SyncManager.ActiveSyncContext activeSyncContext) {
final SyncInfo syncInfo;
synchronized (mAuthorities) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "setActiveSync: account="
+ activeSyncContext.mSyncOperation.account
+ " auth=" + activeSyncContext.mSyncOperation.authority
@@ -1021,7 +1030,7 @@
*/
public void removeActiveSync(SyncInfo syncInfo, int userId) {
synchronized (mAuthorities) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "removeActiveSync: account=" + syncInfo.account
+ " user=" + userId
+ " auth=" + syncInfo.authority);
@@ -1046,7 +1055,7 @@
long now, int source, boolean initialization) {
long id;
synchronized (mAuthorities) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "insertStartSyncEvent: account=" + accountName + "user=" + userId
+ " auth=" + authorityName + " source=" + source);
}
@@ -1068,7 +1077,7 @@
mSyncHistory.remove(mSyncHistory.size()-1);
}
id = item.historyId;
- if (Log.isLoggable(TAG, Log.VERBOSE)) Log.v(TAG, "returning historyId " + id);
+ if (DEBUG) Log.v(TAG, "returning historyId " + id);
}
reportChange(ContentResolver.SYNC_OBSERVER_TYPE_STATUS);
@@ -1096,7 +1105,7 @@
public void stopSyncEvent(long historyId, long elapsedTime, String resultMessage,
long downstreamActivity, long upstreamActivity) {
synchronized (mAuthorities) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "stopSyncEvent: historyId=" + historyId);
}
SyncHistoryItem item = null;
@@ -1358,7 +1367,7 @@
AccountInfo accountInfo = mAccounts.get(au);
if (accountInfo == null) {
if (tag != null) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, tag + ": unknown account " + au);
}
}
@@ -1367,7 +1376,7 @@
AuthorityInfo authority = accountInfo.authorities.get(authorityName);
if (authority == null) {
if (tag != null) {
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, tag + ": unknown authority " + authorityName);
}
}
@@ -1392,7 +1401,7 @@
mNextAuthorityId++;
doWrite = true;
}
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (DEBUG) {
Log.v(TAG, "created a new AuthorityInfo for " + accountName
+ ", user " + userId
+ ", provider " + authorityName);