Merge change 23066 into eclair
* changes: - don't schedule syncs that we will never dispatch - expedite the INITIALIZATION sync
This commit is contained in:
@@ -148,6 +148,7 @@ class SyncManager implements OnAccountsUpdatedListener {
|
|||||||
private volatile boolean mSyncPollInitialized;
|
private volatile boolean mSyncPollInitialized;
|
||||||
private final PendingIntent mSyncAlarmIntent;
|
private final PendingIntent mSyncAlarmIntent;
|
||||||
private final PendingIntent mSyncPollAlarmIntent;
|
private final PendingIntent mSyncPollAlarmIntent;
|
||||||
|
private final ConnectivityManager mConnManager;
|
||||||
|
|
||||||
private final SyncAdaptersCache mSyncAdapters;
|
private final SyncAdaptersCache mSyncAdapters;
|
||||||
|
|
||||||
@@ -288,6 +289,7 @@ class SyncManager implements OnAccountsUpdatedListener {
|
|||||||
SyncStorageEngine.init(context);
|
SyncStorageEngine.init(context);
|
||||||
mSyncStorageEngine = SyncStorageEngine.getSingleton();
|
mSyncStorageEngine = SyncStorageEngine.getSingleton();
|
||||||
mSyncQueue = new SyncQueue(mSyncStorageEngine);
|
mSyncQueue = new SyncQueue(mSyncStorageEngine);
|
||||||
|
mConnManager = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
@@ -536,6 +538,14 @@ class SyncManager implements OnAccountsUpdatedListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mConnManager.getBackgroundDataSetting()) {
|
||||||
|
if (isLoggable) {
|
||||||
|
Log.v(TAG, "not syncing because background data usage isn't allowed");
|
||||||
|
}
|
||||||
|
setStatusText("Sync is disabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mAccounts == null) setStatusText("The accounts aren't known yet.");
|
if (mAccounts == null) setStatusText("The accounts aren't known yet.");
|
||||||
if (!mDataConnectionIsConnected) setStatusText("No data connection");
|
if (!mDataConnectionIsConnected) setStatusText("No data connection");
|
||||||
if (mStorageIsLow) setStatusText("Memory low");
|
if (mStorageIsLow) setStatusText("Memory low");
|
||||||
@@ -602,6 +612,8 @@ class SyncManager implements OnAccountsUpdatedListener {
|
|||||||
if (hasSyncAdapter) syncableAuthorities.add(requestedAuthority);
|
if (hasSyncAdapter) syncableAuthorities.add(requestedAuthority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean masterSyncAutomatically = mSyncStorageEngine.getMasterSyncAutomatically();
|
||||||
|
|
||||||
for (String authority : syncableAuthorities) {
|
for (String authority : syncableAuthorities) {
|
||||||
for (Account account : accounts) {
|
for (Account account : accounts) {
|
||||||
int isSyncable = mSyncStorageEngine.getIsSyncable(account, authority);
|
int isSyncable = mSyncStorageEngine.getIsSyncable(account, authority);
|
||||||
@@ -618,22 +630,36 @@ class SyncManager implements OnAccountsUpdatedListener {
|
|||||||
if (!syncAdapterInfo.type.supportsUploading() && uploadOnly) {
|
if (!syncAdapterInfo.type.supportsUploading() && uploadOnly) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make this an initialization sync if the isSyncable state is unknown
|
// make this an initialization sync if the isSyncable state is unknown
|
||||||
Bundle extrasCopy = extras;
|
Bundle extrasCopy = extras;
|
||||||
|
long delayCopy = delay;
|
||||||
if (isSyncable < 0) {
|
if (isSyncable < 0) {
|
||||||
extrasCopy = new Bundle(extras);
|
extrasCopy = new Bundle(extras);
|
||||||
extrasCopy.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true);
|
extrasCopy.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true);
|
||||||
|
delayCopy = -1; // expedite this
|
||||||
|
} else {
|
||||||
|
final boolean syncAutomatically = masterSyncAutomatically
|
||||||
|
&& mSyncStorageEngine.getSyncAutomatically(account, authority);
|
||||||
|
boolean syncAllowed = manualSync || syncAutomatically;
|
||||||
|
if (!syncAllowed) {
|
||||||
|
if (isLoggable) {
|
||||||
|
Log.d(TAG, "scheduleSync: sync of " + account + ", " + authority
|
||||||
|
+ " is not allowed, dropping request");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isLoggable) {
|
if (isLoggable) {
|
||||||
Log.v(TAG, "scheduleSync:"
|
Log.v(TAG, "scheduleSync:"
|
||||||
+ " delay " + delay
|
+ " delay " + delayCopy
|
||||||
+ ", source " + source
|
+ ", source " + source
|
||||||
+ ", account " + account
|
+ ", account " + account
|
||||||
+ ", authority " + authority
|
+ ", authority " + authority
|
||||||
+ ", extras " + extrasCopy);
|
+ ", extras " + extrasCopy);
|
||||||
}
|
}
|
||||||
scheduleSyncOperation(
|
scheduleSyncOperation(
|
||||||
new SyncOperation(account, source, authority, extrasCopy, delay));
|
new SyncOperation(account, source, authority, extrasCopy, delayCopy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1591,9 +1617,7 @@ class SyncManager implements OnAccountsUpdatedListener {
|
|||||||
// found that is runnable (not disabled, etc). If that one is ready to run then
|
// found that is runnable (not disabled, etc). If that one is ready to run then
|
||||||
// start it, otherwise just get out.
|
// start it, otherwise just get out.
|
||||||
SyncOperation op;
|
SyncOperation op;
|
||||||
final ConnectivityManager connManager = (ConnectivityManager)
|
final boolean backgroundDataUsageAllowed = mConnManager.getBackgroundDataSetting();
|
||||||
mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
final boolean backgroundDataUsageAllowed = connManager.getBackgroundDataSetting();
|
|
||||||
synchronized (mSyncQueue) {
|
synchronized (mSyncQueue) {
|
||||||
while (true) {
|
while (true) {
|
||||||
op = mSyncQueue.head();
|
op = mSyncQueue.head();
|
||||||
|
|||||||
Reference in New Issue
Block a user