Merge "Don't log account name on logcat (cherry-pick from master)" into pi-dev
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.server.content;
|
package com.android.server.content;
|
||||||
|
|
||||||
|
import android.accounts.Account;
|
||||||
import android.app.job.JobParameters;
|
import android.app.job.JobParameters;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
@@ -26,6 +27,8 @@ import android.util.Log;
|
|||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
|
import com.android.server.content.SyncManager.ActiveSyncContext;
|
||||||
|
import com.android.server.content.SyncStorageEngine.EndPoint;
|
||||||
|
|
||||||
import libcore.io.IoUtils;
|
import libcore.io.IoUtils;
|
||||||
|
|
||||||
@@ -273,4 +276,20 @@ public class SyncLogger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String logSafe(Account account) {
|
||||||
|
return account == null ? "[null]" : "***/" + account.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static String logSafe(EndPoint endPoint) {
|
||||||
|
return endPoint == null ? "[null]" : endPoint.toSafeString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String logSafe(SyncOperation operation) {
|
||||||
|
return operation == null ? "[null]" : operation.toSafeString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static String logSafe(ActiveSyncContext asc) {
|
||||||
|
return asc == null ? "[null]" : asc.toSafeString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.server.content;
|
package com.android.server.content;
|
||||||
|
|
||||||
|
import static com.android.server.content.SyncLogger.logSafe;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountAndUser;
|
import android.accounts.AccountAndUser;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
@@ -1175,7 +1177,7 @@ public class SyncManager {
|
|||||||
/* ignore - local call */
|
/* ignore - local call */
|
||||||
}
|
}
|
||||||
if (checkAccountAccess && !canAccessAccount(account, owningPackage, owningUid)) {
|
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);
|
+ owningPackage + " in UID " + syncAdapterInfo.uid);
|
||||||
return AuthorityInfo.SYNCABLE_NO_ACCOUNT_ACCESS;
|
return AuthorityInfo.SYNCABLE_NO_ACCOUNT_ACCESS;
|
||||||
}
|
}
|
||||||
@@ -1508,7 +1510,8 @@ public class SyncManager {
|
|||||||
if (!syncOperation.ignoreBackoff()) {
|
if (!syncOperation.ignoreBackoff()) {
|
||||||
Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(syncOperation.target);
|
Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(syncOperation.target);
|
||||||
if (backoff == null) {
|
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,
|
backoff = new Pair<Long, Long>(SyncStorageEngine.NOT_IN_BACKOFF_MODE,
|
||||||
SyncStorageEngine.NOT_IN_BACKOFF_MODE);
|
SyncStorageEngine.NOT_IN_BACKOFF_MODE);
|
||||||
}
|
}
|
||||||
@@ -1779,8 +1782,8 @@ public class SyncManager {
|
|||||||
scheduleSyncOperationH(operation);
|
scheduleSyncOperationH(operation);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise do not reschedule.
|
// Otherwise do not reschedule.
|
||||||
Log.d(TAG, "not retrying sync operation because the error is a hard error: "
|
Log.e(TAG, "not retrying sync operation because the error is a hard error: "
|
||||||
+ operation);
|
+ logSafe(operation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1914,11 +1917,12 @@ public class SyncManager {
|
|||||||
sendSyncFinishedOrCanceledMessage(this, result);
|
sendSyncFinishedOrCanceledMessage(this, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toString(StringBuilder sb) {
|
public void toString(StringBuilder sb, boolean logSafe) {
|
||||||
sb.append("startTime ").append(mStartTime)
|
sb.append("startTime ").append(mStartTime)
|
||||||
.append(", mTimeoutStartTime ").append(mTimeoutStartTime)
|
.append(", mTimeoutStartTime ").append(mTimeoutStartTime)
|
||||||
.append(", mHistoryRowId ").append(mHistoryRowId)
|
.append(", mHistoryRowId ").append(mHistoryRowId)
|
||||||
.append(", syncOperation ").append(mSyncOperation);
|
.append(", syncOperation ").append(
|
||||||
|
logSafe ? logSafe(mSyncOperation) : mSyncOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
@@ -1980,7 +1984,13 @@ public class SyncManager {
|
|||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
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();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2069,7 +2079,7 @@ public class SyncManager {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for (SyncOperation op: pendingSyncs) {
|
for (SyncOperation op: pendingSyncs) {
|
||||||
if (!op.isPeriodic) {
|
if (!op.isPeriodic) {
|
||||||
pw.println(op.dump(null, false, buckets));
|
pw.println(op.dump(null, false, buckets, /*logSafe=*/ false));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2086,7 +2096,7 @@ public class SyncManager {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for (SyncOperation op: pendingSyncs) {
|
for (SyncOperation op: pendingSyncs) {
|
||||||
if (op.isPeriodic) {
|
if (op.isPeriodic) {
|
||||||
pw.println(op.dump(null, false, buckets));
|
pw.println(op.dump(null, false, buckets, /*logSafe=*/ false));
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2219,7 +2229,7 @@ public class SyncManager {
|
|||||||
sb.setLength(0);
|
sb.setLength(0);
|
||||||
pw.print(formatDurationHMS(sb, durationInSeconds));
|
pw.print(formatDurationHMS(sb, durationInSeconds));
|
||||||
pw.print(" - ");
|
pw.print(" - ");
|
||||||
pw.print(activeSyncContext.mSyncOperation.dump(pm, false, buckets));
|
pw.print(activeSyncContext.mSyncOperation.dump(pm, false, buckets, /*logSafe=*/ false));
|
||||||
pw.println();
|
pw.println();
|
||||||
}
|
}
|
||||||
pw.println();
|
pw.println();
|
||||||
@@ -3050,7 +3060,7 @@ public class SyncManager {
|
|||||||
case SyncHandler.MESSAGE_CANCEL:
|
case SyncHandler.MESSAGE_CANCEL:
|
||||||
SyncStorageEngine.EndPoint endpoint = (SyncStorageEngine.EndPoint) msg.obj;
|
SyncStorageEngine.EndPoint endpoint = (SyncStorageEngine.EndPoint) msg.obj;
|
||||||
Bundle extras = msg.peekData();
|
Bundle extras = msg.peekData();
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
if (isLoggable) {
|
||||||
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_CANCEL: "
|
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_CANCEL: "
|
||||||
+ endpoint + " bundle: " + extras);
|
+ endpoint + " bundle: " + extras);
|
||||||
}
|
}
|
||||||
@@ -3061,9 +3071,11 @@ public class SyncManager {
|
|||||||
SyncFinishedOrCancelledMessagePayload payload =
|
SyncFinishedOrCancelledMessagePayload payload =
|
||||||
(SyncFinishedOrCancelledMessagePayload) msg.obj;
|
(SyncFinishedOrCancelledMessagePayload) msg.obj;
|
||||||
if (!isSyncStillActiveH(payload.activeSyncContext)) {
|
if (!isSyncStillActiveH(payload.activeSyncContext)) {
|
||||||
Log.d(TAG, "handleSyncHandlerMessage: dropping since the "
|
if (isLoggable) {
|
||||||
+ "sync is no longer active: "
|
Log.d(TAG, "handleSyncHandlerMessage: dropping since the "
|
||||||
+ payload.activeSyncContext);
|
+ "sync is no longer active: "
|
||||||
|
+ payload.activeSyncContext);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isLoggable) {
|
if (isLoggable) {
|
||||||
@@ -3078,7 +3090,7 @@ public class SyncManager {
|
|||||||
|
|
||||||
case SyncHandler.MESSAGE_SERVICE_CONNECTED: {
|
case SyncHandler.MESSAGE_SERVICE_CONNECTED: {
|
||||||
ServiceConnectionData msgData = (ServiceConnectionData) msg.obj;
|
ServiceConnectionData msgData = (ServiceConnectionData) msg.obj;
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
if (isLoggable) {
|
||||||
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_SERVICE_CONNECTED: "
|
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_SERVICE_CONNECTED: "
|
||||||
+ msgData.activeSyncContext);
|
+ msgData.activeSyncContext);
|
||||||
}
|
}
|
||||||
@@ -3094,7 +3106,7 @@ public class SyncManager {
|
|||||||
case SyncHandler.MESSAGE_SERVICE_DISCONNECTED: {
|
case SyncHandler.MESSAGE_SERVICE_DISCONNECTED: {
|
||||||
final ActiveSyncContext currentSyncContext =
|
final ActiveSyncContext currentSyncContext =
|
||||||
((ServiceConnectionData) msg.obj).activeSyncContext;
|
((ServiceConnectionData) msg.obj).activeSyncContext;
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
if (isLoggable) {
|
||||||
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_SERVICE_DISCONNECTED: "
|
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_SERVICE_DISCONNECTED: "
|
||||||
+ currentSyncContext);
|
+ currentSyncContext);
|
||||||
}
|
}
|
||||||
@@ -3129,7 +3141,7 @@ public class SyncManager {
|
|||||||
|
|
||||||
case SyncHandler.MESSAGE_MONITOR_SYNC:
|
case SyncHandler.MESSAGE_MONITOR_SYNC:
|
||||||
ActiveSyncContext monitoredSyncContext = (ActiveSyncContext) msg.obj;
|
ActiveSyncContext monitoredSyncContext = (ActiveSyncContext) msg.obj;
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
if (isLoggable) {
|
||||||
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_MONITOR_SYNC: " +
|
Log.d(TAG, "handleSyncHandlerMessage: MESSAGE_MONITOR_SYNC: " +
|
||||||
monitoredSyncContext.mSyncOperation.target);
|
monitoredSyncContext.mSyncOperation.target);
|
||||||
}
|
}
|
||||||
@@ -3137,7 +3149,7 @@ public class SyncManager {
|
|||||||
if (isSyncNotUsingNetworkH(monitoredSyncContext)) {
|
if (isSyncNotUsingNetworkH(monitoredSyncContext)) {
|
||||||
Log.w(TAG, String.format(
|
Log.w(TAG, String.format(
|
||||||
"Detected sync making no progress for %s. cancelling.",
|
"Detected sync making no progress for %s. cancelling.",
|
||||||
monitoredSyncContext));
|
logSafe(monitoredSyncContext)));
|
||||||
mSyncJobService.callJobFinished(
|
mSyncJobService.callJobFinished(
|
||||||
monitoredSyncContext.mSyncOperation.jobId, false,
|
monitoredSyncContext.mSyncOperation.jobId, false,
|
||||||
"no network activity");
|
"no network activity");
|
||||||
@@ -3636,7 +3648,8 @@ public class SyncManager {
|
|||||||
} catch (RuntimeException exc) {
|
} catch (RuntimeException exc) {
|
||||||
mLogger.log("Sync failed with RuntimeException: ", exc.toString());
|
mLogger.log("Sync failed with RuntimeException: ", exc.toString());
|
||||||
closeActiveSyncContext(activeSyncContext);
|
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);
|
reschedulePeriodicSyncH(syncOperation);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "failed sync operation " + syncOperation + ", " + syncResult);
|
Log.w(TAG, "failed sync operation "
|
||||||
|
+ logSafe(syncOperation) + ", " + syncResult);
|
||||||
|
|
||||||
syncOperation.retries++;
|
syncOperation.retries++;
|
||||||
if (syncOperation.retries > mConstants.getMaxRetriesWithAppStandbyExemption()) {
|
if (syncOperation.retries > mConstants.getMaxRetriesWithAppStandbyExemption()) {
|
||||||
@@ -4120,11 +4134,6 @@ public class SyncManager {
|
|||||||
getJobScheduler().cancel(op.jobId);
|
getJobScheduler().cancel(op.jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void wtfWithLog(String message) {
|
|
||||||
Slog.wtf(TAG, message);
|
|
||||||
mLogger.log("WTF: ", message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetTodayStats() {
|
public void resetTodayStats() {
|
||||||
mSyncStorageEngine.resetTodayStats(/*force=*/ true);
|
mSyncStorageEngine.resetTodayStats(/*force=*/ true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,14 +363,19 @@ public class SyncOperation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return dump(null, true, null);
|
return dump(null, true, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
String dump(PackageManager pm, boolean shorter, SyncAdapterStateFetcher appStates) {
|
public String toSafeString() {
|
||||||
|
return dump(null, true, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
String dump(PackageManager pm, boolean shorter, SyncAdapterStateFetcher appStates,
|
||||||
|
boolean logSafe) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("JobId=").append(jobId)
|
sb.append("JobId=").append(jobId)
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(target.account.name)
|
.append(logSafe ? "***" : target.account.name)
|
||||||
.append("/")
|
.append("/")
|
||||||
.append(target.account.type)
|
.append(target.account.type)
|
||||||
.append(" u")
|
.append(" u")
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.server.content;
|
package com.android.server.content;
|
||||||
|
|
||||||
|
import static com.android.server.content.SyncLogger.logSafe;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountAndUser;
|
import android.accounts.AccountAndUser;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
@@ -228,6 +230,15 @@ public class SyncStorageEngine {
|
|||||||
sb.append(":u" + userId);
|
sb.append(":u" + userId);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toSafeString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(account == null ? "ALL ACCS" : logSafe(account))
|
||||||
|
.append("/")
|
||||||
|
.append(provider == null ? "ALL PDRS" : provider);
|
||||||
|
sb.append(":u" + userId);
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AuthorityInfo {
|
public static class AuthorityInfo {
|
||||||
@@ -1863,8 +1874,8 @@ public class SyncStorageEngine {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Slog.w(TAG, "Failure adding authority: account="
|
Slog.w(TAG, "Failure adding authority:"
|
||||||
+ accountName + " auth=" + authorityName
|
+ " auth=" + authorityName
|
||||||
+ " enabled=" + enabled
|
+ " enabled=" + enabled
|
||||||
+ " syncable=" + syncable);
|
+ " syncable=" + syncable);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user