Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34821881 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

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
parent 19f773bc
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -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();