Avoid sync when UID network is disconnected.

During maybeStartNextSyncLocked(), check the network connectivity for
the target UID, and skip when disconnected.

Bug: 4519115
Change-Id: I8adee8e04521cb878624b19e557d01869f984c4c
This commit is contained in:
Jeff Sharkey
2011-07-13 10:44:07 -07:00
parent 19f773bc96
commit 34821881c1

View File

@@ -1691,12 +1691,28 @@ public class SyncManager implements OnAccountsUpdateListener {
continue;
}
// skip the sync if it isn't manual and auto sync or
// background data usage is disabled
final RegisteredServicesCache.ServiceInfo<SyncAdapterType> syncAdapterInfo;
syncAdapterInfo = mSyncAdapters.getServiceInfo(
SyncAdapterType.newKey(op.authority, op.account.type));
// only proceed if network is connected for requesting UID
final boolean uidNetworkConnected;
if (syncAdapterInfo != null) {
final NetworkInfo networkInfo = getConnectivityManager()
.getActiveNetworkInfoForUid(syncAdapterInfo.uid);
uidNetworkConnected = networkInfo != null && networkInfo.isConnected();
} else {
uidNetworkConnected = false;
}
// skip the sync if it isn't manual, and auto sync or
// background data usage is disabled or network is
// disconnected for the target UID.
if (!op.extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_SETTINGS, false)
&& (syncableState > 0)
&& (!masterSyncAutomatically
|| !backgroundDataUsageAllowed
|| !uidNetworkConnected
|| !mSyncStorageEngine.getSyncAutomatically(
op.account, op.authority))) {
operationIterator.remove();