Merge "Log sync enable/disable too" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
04ce26d840
@@ -786,7 +786,7 @@ public final class ContentService extends IContentService.Stub {
|
||||
SyncManager syncManager = getSyncManager();
|
||||
if (syncManager != null) {
|
||||
syncManager.getSyncStorageEngine().setSyncAutomatically(account, userId,
|
||||
providerName, sync, syncExemptionFlag);
|
||||
providerName, sync, syncExemptionFlag, callingUid);
|
||||
}
|
||||
} finally {
|
||||
restoreCallingIdentity(identityToken);
|
||||
@@ -913,6 +913,7 @@ public final class ContentService extends IContentService.Stub {
|
||||
"no permission to write the sync settings");
|
||||
|
||||
syncable = normalizeSyncable(syncable);
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
|
||||
int userId = UserHandle.getCallingUserId();
|
||||
long identityToken = clearCallingIdentity();
|
||||
@@ -920,7 +921,7 @@ public final class ContentService extends IContentService.Stub {
|
||||
SyncManager syncManager = getSyncManager();
|
||||
if (syncManager != null) {
|
||||
syncManager.getSyncStorageEngine().setIsSyncable(
|
||||
account, userId, providerName, syncable);
|
||||
account, userId, providerName, syncable, callingUid);
|
||||
}
|
||||
} finally {
|
||||
restoreCallingIdentity(identityToken);
|
||||
@@ -974,7 +975,7 @@ public final class ContentService extends IContentService.Stub {
|
||||
SyncManager syncManager = getSyncManager();
|
||||
if (syncManager != null) {
|
||||
syncManager.getSyncStorageEngine().setMasterSyncAutomatically(flag, userId,
|
||||
getSyncExemptionForCaller(callingUid));
|
||||
getSyncExemptionForCaller(callingUid), callingUid);
|
||||
}
|
||||
} finally {
|
||||
restoreCallingIdentity(identityToken);
|
||||
|
||||
@@ -54,6 +54,9 @@ public class SyncLogger {
|
||||
|
||||
private static SyncLogger sInstance;
|
||||
|
||||
// Special UID used for logging to denote the self process.
|
||||
public static final int CALLING_UID_SELF = -1;
|
||||
|
||||
SyncLogger() {
|
||||
}
|
||||
|
||||
@@ -62,8 +65,10 @@ public class SyncLogger {
|
||||
*/
|
||||
public static synchronized SyncLogger getInstance() {
|
||||
if (sInstance == null) {
|
||||
final boolean enable = "1".equals(SystemProperties.get("debug.synclog",
|
||||
Build.IS_DEBUGGABLE ? "1" : "0"));
|
||||
final boolean enable =
|
||||
Build.IS_DEBUGGABLE
|
||||
|| "1".equals(SystemProperties.get("debug.synclog"))
|
||||
|| Log.isLoggable(TAG, Log.VERBOSE);
|
||||
if (enable) {
|
||||
sInstance = new RotatingFileLogger();
|
||||
} else {
|
||||
|
||||
@@ -51,8 +51,8 @@ import android.content.SyncStatusInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.content.pm.RegisteredServicesCache;
|
||||
import android.content.pm.RegisteredServicesCacheListener;
|
||||
@@ -88,26 +88,25 @@ import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.internal.notification.SystemNotificationChannels;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.server.DeviceIdleController;
|
||||
import com.android.server.DeviceIdleController.LocalService;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.job.JobSchedulerInternal;
|
||||
import com.google.android.collect.Lists;
|
||||
import com.google.android.collect.Maps;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.app.IBatteryStats;
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.internal.notification.SystemNotificationChannels;
|
||||
import com.android.internal.os.BackgroundThread;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.server.DeviceIdleController;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.accounts.AccountManagerService;
|
||||
import com.android.server.backup.AccountSyncSettingsBackupHelper;
|
||||
import com.android.server.content.SyncStorageEngine.AuthorityInfo;
|
||||
import com.android.server.content.SyncStorageEngine.EndPoint;
|
||||
import com.android.server.content.SyncStorageEngine.OnSyncRequestListener;
|
||||
import com.android.server.job.JobSchedulerInternal;
|
||||
|
||||
import com.google.android.collect.Lists;
|
||||
import com.google.android.collect.Maps;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -1028,7 +1027,8 @@ public class SyncManager {
|
||||
final boolean isAlwaysSyncable = syncAdapterInfo.type.isAlwaysSyncable();
|
||||
if (!checkIfAccountReady && isSyncable < 0 && isAlwaysSyncable) {
|
||||
mSyncStorageEngine.setIsSyncable(
|
||||
account.account, account.userId, authority, AuthorityInfo.SYNCABLE);
|
||||
account.account, account.userId, authority, AuthorityInfo.SYNCABLE,
|
||||
SyncLogger.CALLING_UID_SELF);
|
||||
isSyncable = AuthorityInfo.SYNCABLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,14 @@ import android.os.Parcel;
|
||||
import android.os.RemoteCallbackList;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.util.*;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.AtomicFile;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.Xml;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
@@ -466,11 +473,13 @@ public class SyncStorageEngine {
|
||||
private boolean mGrantSyncAdaptersAccountAccess;
|
||||
|
||||
private final MyHandler mHandler;
|
||||
private final SyncLogger mLogger;
|
||||
|
||||
private SyncStorageEngine(Context context, File dataDir, Looper looper) {
|
||||
mHandler = new MyHandler(looper);
|
||||
mContext = context;
|
||||
sSyncStorageEngine = this;
|
||||
mLogger = SyncLogger.getInstance();
|
||||
|
||||
mCal = Calendar.getInstance(TimeZone.getTimeZone("GMT+0"));
|
||||
|
||||
@@ -494,6 +503,14 @@ public class SyncStorageEngine {
|
||||
writeAccountInfoLocked();
|
||||
writeStatusLocked();
|
||||
writeStatisticsLocked();
|
||||
|
||||
if (mLogger.enabled()) {
|
||||
final int size = mAuthorities.size();
|
||||
mLogger.log("Loaded ", size, " items");
|
||||
for (int i = 0; i < size; i++) {
|
||||
mLogger.log(mAuthorities.valueAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static SyncStorageEngine newTestInstance(Context context) {
|
||||
@@ -648,11 +665,16 @@ public class SyncStorageEngine {
|
||||
}
|
||||
|
||||
public void setSyncAutomatically(Account account, int userId, String providerName,
|
||||
boolean sync, @SyncExemption int syncExemptionFlag) {
|
||||
boolean sync, @SyncExemption int syncExemptionFlag, int callingUid) {
|
||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
||||
Slog.d(TAG, "setSyncAutomatically: " + /* account + */" provider " + providerName
|
||||
+ ", user " + userId + " -> " + sync);
|
||||
}
|
||||
mLogger.log("Set sync auto account=", account,
|
||||
" user=", userId,
|
||||
" authority=", providerName,
|
||||
" value=", Boolean.toString(sync),
|
||||
" callingUid=", callingUid);
|
||||
synchronized (mAuthorities) {
|
||||
AuthorityInfo authority =
|
||||
getOrCreateAuthorityLocked(
|
||||
@@ -709,8 +731,10 @@ public class SyncStorageEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsSyncable(Account account, int userId, String providerName, int syncable) {
|
||||
setSyncableStateForEndPoint(new EndPoint(account, providerName, userId), syncable);
|
||||
public void setIsSyncable(Account account, int userId, String providerName, int syncable,
|
||||
int callingUid) {
|
||||
setSyncableStateForEndPoint(new EndPoint(account, providerName, userId), syncable,
|
||||
callingUid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -719,8 +743,10 @@ public class SyncStorageEngine {
|
||||
* @param target target to set value for.
|
||||
* @param syncable 0 indicates unsyncable, <0 unknown, >0 is active/syncable.
|
||||
*/
|
||||
private void setSyncableStateForEndPoint(EndPoint target, int syncable) {
|
||||
private void setSyncableStateForEndPoint(EndPoint target, int syncable, int callingUid) {
|
||||
AuthorityInfo aInfo;
|
||||
mLogger.log("Set syncable ", target, " value=", Integer.toString(syncable),
|
||||
" callingUid=", callingUid);
|
||||
synchronized (mAuthorities) {
|
||||
aInfo = getOrCreateAuthorityLocked(target, -1, false);
|
||||
if (syncable < AuthorityInfo.NOT_INITIALIZED) {
|
||||
@@ -902,7 +928,9 @@ public class SyncStorageEngine {
|
||||
}
|
||||
|
||||
public void setMasterSyncAutomatically(boolean flag, int userId,
|
||||
@SyncExemption int syncExemptionFlag) {
|
||||
@SyncExemption int syncExemptionFlag, int callingUid) {
|
||||
mLogger.log("Set master enabled=", flag, " user=", userId,
|
||||
" caller=" + callingUid);
|
||||
synchronized (mAuthorities) {
|
||||
Boolean auto = mMasterSyncAutomatically.get(userId);
|
||||
if (auto != null && auto.equals(flag)) {
|
||||
@@ -2049,7 +2077,7 @@ public class SyncStorageEngine {
|
||||
if (name == null) continue;
|
||||
if (name.equals("listen_for_tickles")) {
|
||||
setMasterSyncAutomatically(value == null || Boolean.parseBoolean(value), 0,
|
||||
ContentResolver.SYNC_EXEMPTION_NONE);
|
||||
ContentResolver.SYNC_EXEMPTION_NONE, SyncLogger.CALLING_UID_SELF);
|
||||
} else if (name.startsWith("sync_provider_")) {
|
||||
String provider = name.substring("sync_provider_".length(),
|
||||
name.length());
|
||||
|
||||
Reference in New Issue
Block a user