summaryrefslogtreecommitdiff
path: root/services/core/java/com/android/server/content/SyncManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/core/java/com/android/server/content/SyncManager.java')
-rw-r--r--services/core/java/com/android/server/content/SyncManager.java59
1 files changed, 34 insertions, 25 deletions
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java
index 0a640b8a76c6..132bf0bc9978 100644
--- a/services/core/java/com/android/server/content/SyncManager.java
+++ b/services/core/java/com/android/server/content/SyncManager.java
@@ -16,6 +16,8 @@
package com.android.server.content;
+import static com.android.server.content.SyncLogger.logSafe;
+
import android.accounts.Account;
import android.accounts.AccountAndUser;
import android.accounts.AccountManager;
@@ -1175,7 +1177,7 @@ public class SyncManager {
/* ignore - local call */
}
if (checkAccountAccess && !canAccessAccount(account, owningPackage, owningUid)) {
- Log.w(TAG, "Access to " + account + " denied for package "
+ Log.w(TAG, "Access to " + logSafe(account) + " denied for package "
+ owningPackage + " in UID " + syncAdapterInfo.uid);
return AuthorityInfo.SYNCABLE_NO_ACCOUNT_ACCESS;
}
@@ -1508,7 +1510,8 @@ public class SyncManager {
if (!syncOperation.ignoreBackoff()) {
Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(syncOperation.target);
if (backoff == null) {
- Slog.e(TAG, "Couldn't find backoff values for " + syncOperation.target);
+ Slog.e(TAG, "Couldn't find backoff values for "
+ + logSafe(syncOperation.target));
backoff = new Pair<Long, Long>(SyncStorageEngine.NOT_IN_BACKOFF_MODE,
SyncStorageEngine.NOT_IN_BACKOFF_MODE);
}
@@ -1779,8 +1782,8 @@ public class SyncManager {
scheduleSyncOperationH(operation);
} else {
// Otherwise do not reschedule.
- Log.d(TAG, "not retrying sync operation because the error is a hard error: "
- + operation);
+ Log.e(TAG, "not retrying sync operation because the error is a hard error: "
+ + logSafe(operation));
}
}
@@ -1914,11 +1917,12 @@ public class SyncManager {
sendSyncFinishedOrCanceledMessage(this, result);
}
- public void toString(StringBuilder sb) {
+ public void toString(StringBuilder sb, boolean logSafe) {
sb.append("startTime ").append(mStartTime)
.append(", mTimeoutStartTime ").append(mTimeoutStartTime)
.append(", mHistoryRowId ").append(mHistoryRowId)
- .append(", syncOperation ").append(mSyncOperation);
+ .append(", syncOperation ").append(
+ logSafe ? logSafe(mSyncOperation) : mSyncOperation);
}
public void onServiceConnected(ComponentName name, IBinder service) {
@@ -1980,7 +1984,13 @@ public class SyncManager {
public String toString() {
StringBuilder sb = new StringBuilder();
- toString(sb);
+ toString(sb, false);
+ return sb.toString();
+ }
+
+ public String toSafeString() {
+ StringBuilder sb = new StringBuilder();
+ toString(sb, true);
return sb.toString();
}
@@ -2069,7 +2079,7 @@ public class SyncManager {
int count = 0;
for (SyncOperation op: pendingSyncs) {
if (!op.isPeriodic) {
- pw.println(op.dump(null, false, buckets));
+ pw.println(op.dump(null, false, buckets, /*logSafe=*/ false));
count++;
}
}
@@ -2086,7 +2096,7 @@ public class SyncManager {
int count = 0;
for (SyncOperation op: pendingSyncs) {
if (op.isPeriodic) {
- pw.println(op.dump(null, false, buckets));
+ pw.println(op.dump(null, false, buckets, /*logSafe=*/ false));
count++;
}
}
@@ -2219,7 +2229,7 @@ public class SyncManager {
sb.setLength(0);
pw.print(formatDurationHMS(sb, durationInSeconds));
pw.print(" - ");
- pw.print(activeSyncContext.mSyncOperation.dump(pm, false, buckets));
+ pw.print(activeSyncContext.mSyncOperation.dump(pm, false, buckets, /*logSafe=*/ false));
pw.println();
}
pw.println();
@@ -3050,7 +3060,7 @@ public class SyncManager {
case SyncHandler.MESSAGE_CANCEL:
SyncStorageEngine.EndPoint endpoint = (SyncStorageEngine.EndPoint) msg.obj;
Bundle extras = msg.peekData();
- if (Log.isLoggable(TAG, Log.DEBUG)) {
+ if (isLoggable) {
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_CANCEL: "
+ endpoint + " bundle: " + extras);
}
@@ -3061,9 +3071,11 @@ public class SyncManager {
SyncFinishedOrCancelledMessagePayload payload =
(SyncFinishedOrCancelledMessagePayload) msg.obj;
if (!isSyncStillActiveH(payload.activeSyncContext)) {
- Log.d(TAG, "handleSyncHandlerMessage: dropping since the "
- + "sync is no longer active: "
- + payload.activeSyncContext);
+ if (isLoggable) {
+ Log.d(TAG, "handleSyncHandlerMessage: dropping since the "
+ + "sync is no longer active: "
+ + payload.activeSyncContext);
+ }
break;
}
if (isLoggable) {
@@ -3078,7 +3090,7 @@ public class SyncManager {
case SyncHandler.MESSAGE_SERVICE_CONNECTED: {
ServiceConnectionData msgData = (ServiceConnectionData) msg.obj;
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (isLoggable) {
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_SERVICE_CONNECTED: "
+ msgData.activeSyncContext);
}
@@ -3094,7 +3106,7 @@ public class SyncManager {
case SyncHandler.MESSAGE_SERVICE_DISCONNECTED: {
final ActiveSyncContext currentSyncContext =
((ServiceConnectionData) msg.obj).activeSyncContext;
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ if (isLoggable) {
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_SERVICE_DISCONNECTED: "
+ currentSyncContext);
}
@@ -3129,7 +3141,7 @@ public class SyncManager {
case SyncHandler.MESSAGE_MONITOR_SYNC:
ActiveSyncContext monitoredSyncContext = (ActiveSyncContext) msg.obj;
- if (Log.isLoggable(TAG, Log.DEBUG)) {
+ if (isLoggable) {
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_MONITOR_SYNC: " +
monitoredSyncContext.mSyncOperation.target);
}
@@ -3137,7 +3149,7 @@ public class SyncManager {
if (isSyncNotUsingNetworkH(monitoredSyncContext)) {
Log.w(TAG, String.format(
"Detected sync making no progress for %s. cancelling.",
- monitoredSyncContext));
+ logSafe(monitoredSyncContext)));
mSyncJobService.callJobFinished(
monitoredSyncContext.mSyncOperation.jobId, false,
"no network activity");
@@ -3636,7 +3648,8 @@ public class SyncManager {
} catch (RuntimeException exc) {
mLogger.log("Sync failed with RuntimeException: ", exc.toString());
closeActiveSyncContext(activeSyncContext);
- Slog.e(TAG, "Caught RuntimeException while starting the sync " + syncOperation, exc);
+ Slog.e(TAG, "Caught RuntimeException while starting the sync "
+ + logSafe(syncOperation), exc);
}
}
@@ -3736,7 +3749,8 @@ public class SyncManager {
reschedulePeriodicSyncH(syncOperation);
}
} else {
- Log.w(TAG, "failed sync operation " + syncOperation + ", " + syncResult);
+ Log.w(TAG, "failed sync operation "
+ + logSafe(syncOperation) + ", " + syncResult);
syncOperation.retries++;
if (syncOperation.retries > mConstants.getMaxRetriesWithAppStandbyExemption()) {
@@ -4120,11 +4134,6 @@ public class SyncManager {
getJobScheduler().cancel(op.jobId);
}
- private void wtfWithLog(String message) {
- Slog.wtf(TAG, message);
- mLogger.log("WTF: ", message);
- }
-
public void resetTodayStats() {
mSyncStorageEngine.resetTodayStats(/*force=*/ true);
}