Loading core/java/android/content/SyncService.java +4 −2 Original line number Diff line number Diff line Loading @@ -86,8 +86,10 @@ public abstract class SyncService extends Service { boolean alreadyInProgress = false; final int extrasAsKey = extrasToKey(extras); synchronized (mSyncThreadLock) { if (mSyncThreads.get(extrasAsKey) != null) { Log.e(TAG, "starting sync for : " + mServiceComponent); if (mSyncThreads.get(extrasAsKey) == null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "starting sync for : " + mServiceComponent); } // Start sync. SyncThread syncThread = new SyncThread(syncContextClient, extras); mSyncThreads.put(extrasAsKey, syncThread); Loading services/java/com/android/server/content/ContentService.java +2 −1 Original line number Diff line number Diff line Loading @@ -649,7 +649,8 @@ public final class ContentService extends IContentService.Stub { public boolean isServiceActive(ComponentName cname) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), "getIsEnabled"); verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), "isServiceActive"); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); Loading services/java/com/android/server/content/SyncManager.java +57 −82 Original line number Diff line number Diff line Loading @@ -536,7 +536,7 @@ public class SyncManager { * then all users' accounts are considered. * @param uid Linux uid of the application that is performing the sync. * @param extras a Map of SyncAdapter-specific information to control * syncs of a specific provider. Can be null. * syncs of a specific provider. Cannot be null. * @param beforeRunTimeMillis milliseconds before <code>runtimeMillis</code> that this sync may * be run. * @param runtimeMillis milliseconds from now by which this sync must be run. Loading @@ -547,7 +547,6 @@ public class SyncManager { if (isLoggable) { Log.d(TAG, "one off sync for: " + cname + " " + extras.toString()); } Boolean expedited = extras.getBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false); if (expedited) { runtimeMillis = -1; // this means schedule at the front of the queue Loading @@ -569,7 +568,7 @@ public class SyncManager { } return; } if (isEnabled) { if (!isEnabled) { if (isLoggable) { Log.d(TAG, "scheduleSync: " + cname + " is not enabled, dropping request"); } Loading @@ -579,25 +578,6 @@ public class SyncManager { Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(info); long delayUntil = mSyncStorageEngine.getDelayUntilTime(info); final long backoffTime = backoff != null ? backoff.first : 0; if (isEnabled) { // Initialisation sync. Bundle newExtras = new Bundle(); newExtras.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true); if (isLoggable) { Log.v(TAG, "schedule initialisation Sync:" + ", delay until " + delayUntil + ", run now " + ", source " + source + ", sync service " + cname + ", extras " + newExtras); } scheduleSyncOperation( new SyncOperation(cname, userId, uid, source, newExtras, 0 /* runtime */, 0 /* flextime */, backoffTime, delayUntil)); } else { if (isLoggable) { Log.v(TAG, "schedule Sync:" + ", delay until " + delayUntil Loading @@ -615,8 +595,6 @@ public class SyncManager { delayUntil)); } } /** * Initiate a sync. This can start a sync for all providers * (pass null to url, set onlyTicklable to false), only those Loading Loading @@ -955,8 +933,8 @@ public class SyncManager { } /** * Cancel the active sync if it matches the authority and account. * @param info object containing info about which syncs to cancel. The authority can * Cancel the active sync if it matches the target. * @param info object containing info about which syncs to cancel. The target can * have null account/provider info to specify all accounts/providers. * @param extras if non-null, specifies the exact sync to remove. */ Loading Loading @@ -990,7 +968,7 @@ public class SyncManager { /** * Remove scheduled sync operations. * @param info limit the removals to operations that match this authority. The authority can * @param info limit the removals to operations that match this target. The target can * have null account/provider info to specify all accounts/providers. */ public void clearScheduledSyncOperations(SyncStorageEngine.EndPoint info) { Loading Loading @@ -1193,11 +1171,6 @@ public class SyncManager { public void onServiceConnected(ComponentName name, IBinder service) { Message msg = mSyncHandler.obtainMessage(); msg.what = SyncHandler.MESSAGE_SERVICE_CONNECTED; if (mSyncOperation.target.target_provider) { msg.arg1 = SyncOperation.SYNC_TARGET_ADAPTER; } else { msg.arg1 = SyncOperation.SYNC_TARGET_SERVICE; } msg.obj = new ServiceConnectionData(this, service); mSyncHandler.sendMessage(msg); } Loading Loading @@ -1392,8 +1365,7 @@ public class SyncManager { account.userId)); SyncStorageEngine.AuthorityInfo settings = syncAuthoritySyncStatus.first; SyncStatusInfo status = syncAuthoritySyncStatus.second; String authority = settings.base.provider; String authority = settings.target.provider; if (authority.length() > 50) { authority = authority.substring(authority.length() - 50); } Loading Loading @@ -1519,15 +1491,15 @@ public class SyncManager { final String authorityName; final String accountKey; if (authorityInfo != null) { if (authorityInfo.base.target_provider) { authorityName = authorityInfo.base.provider; accountKey = authorityInfo.base.account.name + "/" + authorityInfo.base.account.type + " u" + authorityInfo.base.userId; } else if (authorityInfo.base.target_service) { authorityName = authorityInfo.base.service.getPackageName() + "/" + authorityInfo.base.service.getClassName() + " u" + authorityInfo.base.userId; if (authorityInfo.target.target_provider) { authorityName = authorityInfo.target.provider; accountKey = authorityInfo.target.account.name + "/" + authorityInfo.target.account.type + " u" + authorityInfo.target.userId; } else if (authorityInfo.target.target_service) { authorityName = authorityInfo.target.service.getPackageName() + "/" + authorityInfo.target.service.getClassName() + " u" + authorityInfo.target.userId; accountKey = "no account"; } else { authorityName = "Unknown"; Loading Loading @@ -1658,15 +1630,15 @@ public class SyncManager { final String authorityName; final String accountKey; if (authorityInfo != null) { if (authorityInfo.base.target_provider) { authorityName = authorityInfo.base.provider; accountKey = authorityInfo.base.account.name + "/" + authorityInfo.base.account.type + " u" + authorityInfo.base.userId; } else if (authorityInfo.base.target_service) { authorityName = authorityInfo.base.service.getPackageName() + "/" + authorityInfo.base.service.getClassName() + " u" + authorityInfo.base.userId; if (authorityInfo.target.target_provider) { authorityName = authorityInfo.target.provider; accountKey = authorityInfo.target.account.name + "/" + authorityInfo.target.account.type + " u" + authorityInfo.target.userId; } else if (authorityInfo.target.target_service) { authorityName = authorityInfo.target.service.getPackageName() + "/" + authorityInfo.target.service.getClassName() + " u" + authorityInfo.target.userId; accountKey = "none"; } else { authorityName = "Unknown"; Loading Loading @@ -1735,15 +1707,15 @@ public class SyncManager { final String authorityName; final String accountKey; if (authorityInfo != null) { if (authorityInfo.base.target_provider) { authorityName = authorityInfo.base.provider; accountKey = authorityInfo.base.account.name + "/" + authorityInfo.base.account.type + " u" + authorityInfo.base.userId; } else if (authorityInfo.base.target_service) { authorityName = authorityInfo.base.service.getPackageName() + "/" + authorityInfo.base.service.getClassName() + " u" + authorityInfo.base.userId; if (authorityInfo.target.target_provider) { authorityName = authorityInfo.target.provider; accountKey = authorityInfo.target.account.name + "/" + authorityInfo.target.account.type + " u" + authorityInfo.target.userId; } else if (authorityInfo.target.target_service) { authorityName = authorityInfo.target.service.getPackageName() + "/" + authorityInfo.target.service.getClassName() + " u" + authorityInfo.target.userId; accountKey = "none"; } else { authorityName = "Unknown"; Loading Loading @@ -2039,8 +2011,7 @@ public class SyncManager { if (isSyncStillActive(msgData.activeSyncContext)) { runBoundToAdapter( msgData.activeSyncContext, msgData.adapter, msg.arg1 /* target */); msgData.adapter); } break; } Loading Loading @@ -2167,8 +2138,7 @@ public class SyncManager { for (Pair<AuthorityInfo, SyncStatusInfo> info : infos) { final AuthorityInfo authorityInfo = info.first; final SyncStatusInfo status = info.second; if (!isDispatchable(authorityInfo.base)) { if (!isDispatchable(authorityInfo.target)) { continue; } Loading Loading @@ -2196,7 +2166,7 @@ public class SyncManager { boolean runEarly = remainingMillis <= flexInMillis && timeSinceLastRunMillis > periodInMillis - flexInMillis; if (isLoggable) { Log.v(TAG, "sync: " + i + " for " + authorityInfo.base + "." Log.v(TAG, "sync: " + i + " for " + authorityInfo.target + "." + " period: " + (periodInMillis) + " flex: " + (flexInMillis) + " remaining: " + (remainingMillis) Loading Loading @@ -2224,7 +2194,7 @@ public class SyncManager { || timeSinceLastRunMillis >= periodInMillis // Case 3 || runEarly) { // Case 4 // Sync now SyncStorageEngine.EndPoint target = authorityInfo.base; SyncStorageEngine.EndPoint target = authorityInfo.target; final Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(target); mSyncStorageEngine.setPeriodicSyncTime(authorityInfo.ident, Loading Loading @@ -2660,7 +2630,7 @@ public class SyncManager { } private void runBoundToAdapter(final ActiveSyncContext activeSyncContext, IBinder syncAdapter, int target) { IBinder syncAdapter) { final SyncOperation syncOperation = activeSyncContext.mSyncOperation; try { activeSyncContext.mIsLinkedToDeath = true; Loading Loading @@ -2690,8 +2660,8 @@ public class SyncManager { } /** * Cancel the sync for the provided authority that matches the given bundle. Info here * can have null fields to indicate all the active syncs for that field. * Cancel the sync for the provided target that matches the given bundle. * @param info can have null fields to indicate all the active syncs for that field. */ private void cancelActiveSyncLocked(SyncStorageEngine.EndPoint info, Bundle extras) { ArrayList<ActiveSyncContext> activeSyncs = Loading @@ -2700,7 +2670,7 @@ public class SyncManager { if (activeSyncContext != null) { final SyncStorageEngine.EndPoint opInfo = activeSyncContext.mSyncOperation.target; if (!opInfo.matches(info)) { if (!opInfo.matchesSpec(info)) { continue; } if (extras != null && Loading @@ -2726,7 +2696,8 @@ public class SyncManager { if (info.target_provider) { activeSyncContext.mSyncAdapter.asBinder().unlinkToDeath(activeSyncContext, 0); } else { activeSyncContext.mSyncServiceAdapter.asBinder().unlinkToDeath(activeSyncContext, 0); activeSyncContext.mSyncServiceAdapter.asBinder() .unlinkToDeath(activeSyncContext, 0); } activeSyncContext.mIsLinkedToDeath = false; } Loading Loading @@ -3122,17 +3093,20 @@ public class SyncManager { if (b1 == b2) { return true; } // Exit early if we can. if (includeSyncSettings && b1.size() != b2.size()) { return false; } for (String key : b1.keySet()) { Bundle bigger = b1.size() > b2.size() ? b1 : b2; Bundle smaller = b1.size() > b2.size() ? b2 : b1; for (String key : bigger.keySet()) { if (!includeSyncSettings && isSyncSetting(key)) { continue; } if (!b2.containsKey(key)) { if (!smaller.containsKey(key)) { return false; } if (!b1.get(key).equals(b2.get(key))) { if (!bigger.get(key).equals(smaller.get(key))) { return false; } } Loading @@ -3140,6 +3114,7 @@ public class SyncManager { } /** * TODO: Get rid of this when we separate sync settings extras from dev specified extras. * @return true if the provided key is used by the SyncManager in scheduling the sync. */ private static boolean isSyncSetting(String key) { Loading services/java/com/android/server/content/SyncOperation.java +3 −3 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class SyncOperation implements Comparable { public static final int SYNC_TARGET_ADAPTER = 1; public static final int SYNC_TARGET_SERVICE = 2; /** Identifying info for the authority for this operation. */ /** Identifying info for the target for this operation. */ public final SyncStorageEngine.EndPoint target; /** Why this sync was kicked off. {@link #REASON_NAMES} */ public final int reason; Loading Loading @@ -143,11 +143,11 @@ public class SyncOperation implements Comparable { this.flexTime = flexTime; } updateEffectiveRunTime(); return toKey(info, extras); return toKey(info, this.extras); } public boolean matchesAuthority(SyncOperation other) { return this.target.matches(other.target); return this.target.matchesSpec(other.target); } /** Loading services/java/com/android/server/content/SyncQueue.java +11 −11 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class SyncQueue { public void addPendingOperations(int userId) { for (SyncStorageEngine.PendingOperation op : mSyncStorageEngine.getPendingOperations()) { final SyncStorageEngine.EndPoint info = op.authority; final SyncStorageEngine.EndPoint info = op.target; if (info.userId != userId) continue; final Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(info); Loading @@ -69,7 +69,7 @@ public class SyncQueue { SyncAdapterType.newKey(info.provider, info.account.type), info.userId); if (syncAdapterInfo == null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.w(TAG, "Missing sync adapter info for authority " + op.authority); Log.v(TAG, "Missing sync adapter info for authority " + op.target); } continue; } Loading @@ -89,7 +89,7 @@ public class SyncQueue { mPackageManager.getServiceInfo(info.service, 0); } catch (PackageManager.NameNotFoundException e) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.w(TAG, "Missing sync servce for authority " + op.authority); Log.w(TAG, "Missing sync service for authority " + op.target); } continue; } Loading Loading @@ -174,14 +174,14 @@ public class SyncQueue { * @param operation the operation to remove */ public void remove(SyncOperation operation) { boolean isLoggable = Log.isLoggable(TAG, Log.DEBUG); boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE); SyncOperation operationToRemove = mOperationsMap.remove(operation.key); if (isLoggable) { Log.d(TAG, "Attempting to remove: " + operation.key); Log.v(TAG, "Attempting to remove: " + operation.key); } if (operationToRemove == null) { if (isLoggable) { Log.d(TAG, "Could not find: " + operation.key); Log.v(TAG, "Could not find: " + operation.key); } return; } Loading @@ -200,10 +200,10 @@ public class SyncQueue { } public void onBackoffChanged(SyncStorageEngine.EndPoint target, long backoff) { // For each op that matches the authority of the changed op, update its // For each op that matches the target of the changed op, update its // backoff and effectiveStartTime for (SyncOperation op : mOperationsMap.values()) { if (op.target.matches(target)) { if (op.target.matchesSpec(target)) { op.backoff = backoff; op.updateEffectiveRunTime(); } Loading @@ -211,9 +211,9 @@ public class SyncQueue { } public void onDelayUntilTimeChanged(SyncStorageEngine.EndPoint target, long delayUntil) { // for each op that matches the authority info of the provided op, change the delay time. // for each op that matches the target info of the provided op, change the delay time. for (SyncOperation op : mOperationsMap.values()) { if (op.target.matches(target)) { if (op.target.matchesSpec(target)) { op.delayUntil = delayUntil; op.updateEffectiveRunTime(); } Loading @@ -235,7 +235,7 @@ public class SyncQueue { Map.Entry<String, SyncOperation> entry = entries.next(); SyncOperation syncOperation = entry.getValue(); final SyncStorageEngine.EndPoint opInfo = syncOperation.target; if (!opInfo.matches(info)) { if (!opInfo.matchesSpec(info)) { continue; } if (extras != null Loading Loading
core/java/android/content/SyncService.java +4 −2 Original line number Diff line number Diff line Loading @@ -86,8 +86,10 @@ public abstract class SyncService extends Service { boolean alreadyInProgress = false; final int extrasAsKey = extrasToKey(extras); synchronized (mSyncThreadLock) { if (mSyncThreads.get(extrasAsKey) != null) { Log.e(TAG, "starting sync for : " + mServiceComponent); if (mSyncThreads.get(extrasAsKey) == null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "starting sync for : " + mServiceComponent); } // Start sync. SyncThread syncThread = new SyncThread(syncContextClient, extras); mSyncThreads.put(extrasAsKey, syncThread); Loading
services/java/com/android/server/content/ContentService.java +2 −1 Original line number Diff line number Diff line Loading @@ -649,7 +649,8 @@ public final class ContentService extends IContentService.Stub { public boolean isServiceActive(ComponentName cname) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), "getIsEnabled"); verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), "isServiceActive"); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); Loading
services/java/com/android/server/content/SyncManager.java +57 −82 Original line number Diff line number Diff line Loading @@ -536,7 +536,7 @@ public class SyncManager { * then all users' accounts are considered. * @param uid Linux uid of the application that is performing the sync. * @param extras a Map of SyncAdapter-specific information to control * syncs of a specific provider. Can be null. * syncs of a specific provider. Cannot be null. * @param beforeRunTimeMillis milliseconds before <code>runtimeMillis</code> that this sync may * be run. * @param runtimeMillis milliseconds from now by which this sync must be run. Loading @@ -547,7 +547,6 @@ public class SyncManager { if (isLoggable) { Log.d(TAG, "one off sync for: " + cname + " " + extras.toString()); } Boolean expedited = extras.getBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false); if (expedited) { runtimeMillis = -1; // this means schedule at the front of the queue Loading @@ -569,7 +568,7 @@ public class SyncManager { } return; } if (isEnabled) { if (!isEnabled) { if (isLoggable) { Log.d(TAG, "scheduleSync: " + cname + " is not enabled, dropping request"); } Loading @@ -579,25 +578,6 @@ public class SyncManager { Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(info); long delayUntil = mSyncStorageEngine.getDelayUntilTime(info); final long backoffTime = backoff != null ? backoff.first : 0; if (isEnabled) { // Initialisation sync. Bundle newExtras = new Bundle(); newExtras.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true); if (isLoggable) { Log.v(TAG, "schedule initialisation Sync:" + ", delay until " + delayUntil + ", run now " + ", source " + source + ", sync service " + cname + ", extras " + newExtras); } scheduleSyncOperation( new SyncOperation(cname, userId, uid, source, newExtras, 0 /* runtime */, 0 /* flextime */, backoffTime, delayUntil)); } else { if (isLoggable) { Log.v(TAG, "schedule Sync:" + ", delay until " + delayUntil Loading @@ -615,8 +595,6 @@ public class SyncManager { delayUntil)); } } /** * Initiate a sync. This can start a sync for all providers * (pass null to url, set onlyTicklable to false), only those Loading Loading @@ -955,8 +933,8 @@ public class SyncManager { } /** * Cancel the active sync if it matches the authority and account. * @param info object containing info about which syncs to cancel. The authority can * Cancel the active sync if it matches the target. * @param info object containing info about which syncs to cancel. The target can * have null account/provider info to specify all accounts/providers. * @param extras if non-null, specifies the exact sync to remove. */ Loading Loading @@ -990,7 +968,7 @@ public class SyncManager { /** * Remove scheduled sync operations. * @param info limit the removals to operations that match this authority. The authority can * @param info limit the removals to operations that match this target. The target can * have null account/provider info to specify all accounts/providers. */ public void clearScheduledSyncOperations(SyncStorageEngine.EndPoint info) { Loading Loading @@ -1193,11 +1171,6 @@ public class SyncManager { public void onServiceConnected(ComponentName name, IBinder service) { Message msg = mSyncHandler.obtainMessage(); msg.what = SyncHandler.MESSAGE_SERVICE_CONNECTED; if (mSyncOperation.target.target_provider) { msg.arg1 = SyncOperation.SYNC_TARGET_ADAPTER; } else { msg.arg1 = SyncOperation.SYNC_TARGET_SERVICE; } msg.obj = new ServiceConnectionData(this, service); mSyncHandler.sendMessage(msg); } Loading Loading @@ -1392,8 +1365,7 @@ public class SyncManager { account.userId)); SyncStorageEngine.AuthorityInfo settings = syncAuthoritySyncStatus.first; SyncStatusInfo status = syncAuthoritySyncStatus.second; String authority = settings.base.provider; String authority = settings.target.provider; if (authority.length() > 50) { authority = authority.substring(authority.length() - 50); } Loading Loading @@ -1519,15 +1491,15 @@ public class SyncManager { final String authorityName; final String accountKey; if (authorityInfo != null) { if (authorityInfo.base.target_provider) { authorityName = authorityInfo.base.provider; accountKey = authorityInfo.base.account.name + "/" + authorityInfo.base.account.type + " u" + authorityInfo.base.userId; } else if (authorityInfo.base.target_service) { authorityName = authorityInfo.base.service.getPackageName() + "/" + authorityInfo.base.service.getClassName() + " u" + authorityInfo.base.userId; if (authorityInfo.target.target_provider) { authorityName = authorityInfo.target.provider; accountKey = authorityInfo.target.account.name + "/" + authorityInfo.target.account.type + " u" + authorityInfo.target.userId; } else if (authorityInfo.target.target_service) { authorityName = authorityInfo.target.service.getPackageName() + "/" + authorityInfo.target.service.getClassName() + " u" + authorityInfo.target.userId; accountKey = "no account"; } else { authorityName = "Unknown"; Loading Loading @@ -1658,15 +1630,15 @@ public class SyncManager { final String authorityName; final String accountKey; if (authorityInfo != null) { if (authorityInfo.base.target_provider) { authorityName = authorityInfo.base.provider; accountKey = authorityInfo.base.account.name + "/" + authorityInfo.base.account.type + " u" + authorityInfo.base.userId; } else if (authorityInfo.base.target_service) { authorityName = authorityInfo.base.service.getPackageName() + "/" + authorityInfo.base.service.getClassName() + " u" + authorityInfo.base.userId; if (authorityInfo.target.target_provider) { authorityName = authorityInfo.target.provider; accountKey = authorityInfo.target.account.name + "/" + authorityInfo.target.account.type + " u" + authorityInfo.target.userId; } else if (authorityInfo.target.target_service) { authorityName = authorityInfo.target.service.getPackageName() + "/" + authorityInfo.target.service.getClassName() + " u" + authorityInfo.target.userId; accountKey = "none"; } else { authorityName = "Unknown"; Loading Loading @@ -1735,15 +1707,15 @@ public class SyncManager { final String authorityName; final String accountKey; if (authorityInfo != null) { if (authorityInfo.base.target_provider) { authorityName = authorityInfo.base.provider; accountKey = authorityInfo.base.account.name + "/" + authorityInfo.base.account.type + " u" + authorityInfo.base.userId; } else if (authorityInfo.base.target_service) { authorityName = authorityInfo.base.service.getPackageName() + "/" + authorityInfo.base.service.getClassName() + " u" + authorityInfo.base.userId; if (authorityInfo.target.target_provider) { authorityName = authorityInfo.target.provider; accountKey = authorityInfo.target.account.name + "/" + authorityInfo.target.account.type + " u" + authorityInfo.target.userId; } else if (authorityInfo.target.target_service) { authorityName = authorityInfo.target.service.getPackageName() + "/" + authorityInfo.target.service.getClassName() + " u" + authorityInfo.target.userId; accountKey = "none"; } else { authorityName = "Unknown"; Loading Loading @@ -2039,8 +2011,7 @@ public class SyncManager { if (isSyncStillActive(msgData.activeSyncContext)) { runBoundToAdapter( msgData.activeSyncContext, msgData.adapter, msg.arg1 /* target */); msgData.adapter); } break; } Loading Loading @@ -2167,8 +2138,7 @@ public class SyncManager { for (Pair<AuthorityInfo, SyncStatusInfo> info : infos) { final AuthorityInfo authorityInfo = info.first; final SyncStatusInfo status = info.second; if (!isDispatchable(authorityInfo.base)) { if (!isDispatchable(authorityInfo.target)) { continue; } Loading Loading @@ -2196,7 +2166,7 @@ public class SyncManager { boolean runEarly = remainingMillis <= flexInMillis && timeSinceLastRunMillis > periodInMillis - flexInMillis; if (isLoggable) { Log.v(TAG, "sync: " + i + " for " + authorityInfo.base + "." Log.v(TAG, "sync: " + i + " for " + authorityInfo.target + "." + " period: " + (periodInMillis) + " flex: " + (flexInMillis) + " remaining: " + (remainingMillis) Loading Loading @@ -2224,7 +2194,7 @@ public class SyncManager { || timeSinceLastRunMillis >= periodInMillis // Case 3 || runEarly) { // Case 4 // Sync now SyncStorageEngine.EndPoint target = authorityInfo.base; SyncStorageEngine.EndPoint target = authorityInfo.target; final Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(target); mSyncStorageEngine.setPeriodicSyncTime(authorityInfo.ident, Loading Loading @@ -2660,7 +2630,7 @@ public class SyncManager { } private void runBoundToAdapter(final ActiveSyncContext activeSyncContext, IBinder syncAdapter, int target) { IBinder syncAdapter) { final SyncOperation syncOperation = activeSyncContext.mSyncOperation; try { activeSyncContext.mIsLinkedToDeath = true; Loading Loading @@ -2690,8 +2660,8 @@ public class SyncManager { } /** * Cancel the sync for the provided authority that matches the given bundle. Info here * can have null fields to indicate all the active syncs for that field. * Cancel the sync for the provided target that matches the given bundle. * @param info can have null fields to indicate all the active syncs for that field. */ private void cancelActiveSyncLocked(SyncStorageEngine.EndPoint info, Bundle extras) { ArrayList<ActiveSyncContext> activeSyncs = Loading @@ -2700,7 +2670,7 @@ public class SyncManager { if (activeSyncContext != null) { final SyncStorageEngine.EndPoint opInfo = activeSyncContext.mSyncOperation.target; if (!opInfo.matches(info)) { if (!opInfo.matchesSpec(info)) { continue; } if (extras != null && Loading @@ -2726,7 +2696,8 @@ public class SyncManager { if (info.target_provider) { activeSyncContext.mSyncAdapter.asBinder().unlinkToDeath(activeSyncContext, 0); } else { activeSyncContext.mSyncServiceAdapter.asBinder().unlinkToDeath(activeSyncContext, 0); activeSyncContext.mSyncServiceAdapter.asBinder() .unlinkToDeath(activeSyncContext, 0); } activeSyncContext.mIsLinkedToDeath = false; } Loading Loading @@ -3122,17 +3093,20 @@ public class SyncManager { if (b1 == b2) { return true; } // Exit early if we can. if (includeSyncSettings && b1.size() != b2.size()) { return false; } for (String key : b1.keySet()) { Bundle bigger = b1.size() > b2.size() ? b1 : b2; Bundle smaller = b1.size() > b2.size() ? b2 : b1; for (String key : bigger.keySet()) { if (!includeSyncSettings && isSyncSetting(key)) { continue; } if (!b2.containsKey(key)) { if (!smaller.containsKey(key)) { return false; } if (!b1.get(key).equals(b2.get(key))) { if (!bigger.get(key).equals(smaller.get(key))) { return false; } } Loading @@ -3140,6 +3114,7 @@ public class SyncManager { } /** * TODO: Get rid of this when we separate sync settings extras from dev specified extras. * @return true if the provided key is used by the SyncManager in scheduling the sync. */ private static boolean isSyncSetting(String key) { Loading
services/java/com/android/server/content/SyncOperation.java +3 −3 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class SyncOperation implements Comparable { public static final int SYNC_TARGET_ADAPTER = 1; public static final int SYNC_TARGET_SERVICE = 2; /** Identifying info for the authority for this operation. */ /** Identifying info for the target for this operation. */ public final SyncStorageEngine.EndPoint target; /** Why this sync was kicked off. {@link #REASON_NAMES} */ public final int reason; Loading Loading @@ -143,11 +143,11 @@ public class SyncOperation implements Comparable { this.flexTime = flexTime; } updateEffectiveRunTime(); return toKey(info, extras); return toKey(info, this.extras); } public boolean matchesAuthority(SyncOperation other) { return this.target.matches(other.target); return this.target.matchesSpec(other.target); } /** Loading
services/java/com/android/server/content/SyncQueue.java +11 −11 Original line number Diff line number Diff line Loading @@ -59,7 +59,7 @@ public class SyncQueue { public void addPendingOperations(int userId) { for (SyncStorageEngine.PendingOperation op : mSyncStorageEngine.getPendingOperations()) { final SyncStorageEngine.EndPoint info = op.authority; final SyncStorageEngine.EndPoint info = op.target; if (info.userId != userId) continue; final Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(info); Loading @@ -69,7 +69,7 @@ public class SyncQueue { SyncAdapterType.newKey(info.provider, info.account.type), info.userId); if (syncAdapterInfo == null) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.w(TAG, "Missing sync adapter info for authority " + op.authority); Log.v(TAG, "Missing sync adapter info for authority " + op.target); } continue; } Loading @@ -89,7 +89,7 @@ public class SyncQueue { mPackageManager.getServiceInfo(info.service, 0); } catch (PackageManager.NameNotFoundException e) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.w(TAG, "Missing sync servce for authority " + op.authority); Log.w(TAG, "Missing sync service for authority " + op.target); } continue; } Loading Loading @@ -174,14 +174,14 @@ public class SyncQueue { * @param operation the operation to remove */ public void remove(SyncOperation operation) { boolean isLoggable = Log.isLoggable(TAG, Log.DEBUG); boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE); SyncOperation operationToRemove = mOperationsMap.remove(operation.key); if (isLoggable) { Log.d(TAG, "Attempting to remove: " + operation.key); Log.v(TAG, "Attempting to remove: " + operation.key); } if (operationToRemove == null) { if (isLoggable) { Log.d(TAG, "Could not find: " + operation.key); Log.v(TAG, "Could not find: " + operation.key); } return; } Loading @@ -200,10 +200,10 @@ public class SyncQueue { } public void onBackoffChanged(SyncStorageEngine.EndPoint target, long backoff) { // For each op that matches the authority of the changed op, update its // For each op that matches the target of the changed op, update its // backoff and effectiveStartTime for (SyncOperation op : mOperationsMap.values()) { if (op.target.matches(target)) { if (op.target.matchesSpec(target)) { op.backoff = backoff; op.updateEffectiveRunTime(); } Loading @@ -211,9 +211,9 @@ public class SyncQueue { } public void onDelayUntilTimeChanged(SyncStorageEngine.EndPoint target, long delayUntil) { // for each op that matches the authority info of the provided op, change the delay time. // for each op that matches the target info of the provided op, change the delay time. for (SyncOperation op : mOperationsMap.values()) { if (op.target.matches(target)) { if (op.target.matchesSpec(target)) { op.delayUntil = delayUntil; op.updateEffectiveRunTime(); } Loading @@ -235,7 +235,7 @@ public class SyncQueue { Map.Entry<String, SyncOperation> entry = entries.next(); SyncOperation syncOperation = entry.getValue(); final SyncStorageEngine.EndPoint opInfo = syncOperation.target; if (!opInfo.matches(info)) { if (!opInfo.matchesSpec(info)) { continue; } if (extras != null Loading