Merge "Revert "Add defaultPeriodic to every authority"" into nyc-dev
am: e17575d3b5
* commit 'e17575d3b5461866c7b2812432b7798ee04e775e':
Revert "Add defaultPeriodic to every authority"
This commit is contained in:
@@ -453,48 +453,10 @@ public class SyncManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
ensureDefaultPeriodicSyncsH();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ensureDefaultPeriodicSyncsH() {
|
||||
|
||||
long defaultPeriod = SyncStorageEngine.DEFAULT_POLL_FREQUENCY_SECONDS;
|
||||
long defaultFlex = SyncStorageEngine.calculateDefaultFlexTime(defaultPeriod);
|
||||
|
||||
List<AuthorityInfo> authorities = mSyncStorageEngine.getAllAuthorities();
|
||||
List<SyncOperation> syncs = getAllPendingSyncsFromCache();
|
||||
for (AuthorityInfo authority: authorities) {
|
||||
boolean foundPeriodicSync = false;
|
||||
for (SyncOperation op: syncs) {
|
||||
if (op.isPeriodic && authority.target.matchesSpec(op.target)) {
|
||||
foundPeriodicSync = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundPeriodicSync) {
|
||||
EndPoint target = authority.target;
|
||||
final RegisteredServicesCache.ServiceInfo<SyncAdapterType>
|
||||
syncAdapterInfo = mSyncAdapters.getServiceInfo(
|
||||
SyncAdapterType.newKey(
|
||||
target.provider, target.account.type),
|
||||
target.userId);
|
||||
if (syncAdapterInfo == null) {
|
||||
continue;
|
||||
}
|
||||
scheduleSyncOperationH(
|
||||
new SyncOperation(target, syncAdapterInfo.uid,
|
||||
syncAdapterInfo.componentName.getPackageName(),
|
||||
SyncOperation.REASON_PERIODIC, SyncStorageEngine.SOURCE_PERIODIC,
|
||||
new Bundle(), syncAdapterInfo.type.allowParallelSyncs(),
|
||||
true /* periodic */, SyncOperation.NO_JOB_ID, defaultPeriod * 1000L,
|
||||
defaultFlex * 1000L)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void verifyJobScheduler() {
|
||||
if (mJobScheduler != null) {
|
||||
return;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class SyncStorageEngine extends Handler {
|
||||
private static final String XML_TAG_LISTEN_FOR_TICKLES = "listenForTickles";
|
||||
|
||||
/** Default time for a periodic sync. */
|
||||
static final long DEFAULT_POLL_FREQUENCY_SECONDS = 60 * 60 * 24; // One day
|
||||
private static final long DEFAULT_POLL_FREQUENCY_SECONDS = 60 * 60 * 24; // One day
|
||||
|
||||
/** Percentage of period that is flex by default, if no flexMillis is set. */
|
||||
private static final double DEFAULT_FLEX_PERCENT_SYNC = 0.04;
|
||||
@@ -857,16 +857,6 @@ public class SyncStorageEngine extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
List<AuthorityInfo> getAllAuthorities() {
|
||||
List<AuthorityInfo> authorities = new ArrayList<AuthorityInfo>();
|
||||
synchronized (mAuthorities) {
|
||||
for (int i = 0; i < mAuthorities.size(); i++) {
|
||||
authorities.add(mAuthorities.valueAt(i));
|
||||
}
|
||||
}
|
||||
return authorities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if there is currently a sync operation being actively processed for the given
|
||||
* target.
|
||||
|
||||
Reference in New Issue
Block a user