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

Commit 44c4ddfd authored by Georgi Nikolov's avatar Georgi Nikolov
Browse files

Bugfix 9603757

master/flo tremendous Gallery battery drain on idle device (syncing pathology?)

Change-Id: I52797fe428a817ac0bdafcf2ab2b0b565839f84c
parent 1f3ad678
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -1442,17 +1442,25 @@ public class SyncStorageEngine extends Handler {
     */
    public void setPeriodicSyncTime(
            int authorityId, Pair<Bundle, Long> targetPeriodicSync, long when) {
        boolean found = false;
        final AuthorityInfo authorityInfo;
        synchronized (mAuthorities) {
            final AuthorityInfo authority = mAuthorities.get(authorityId);
            for (int i = 0; i < authority.periodicSyncs.size(); i++) {
                Pair<Bundle, Long> periodicSync = authority.periodicSyncs.get(i);
                if (periodicSync.first == targetPeriodicSync.first
            authorityInfo = mAuthorities.get(authorityId);
            for (int i = 0; i < authorityInfo.periodicSyncs.size(); i++) {
                Pair<Bundle, Long> periodicSync = authorityInfo.periodicSyncs.get(i);
                if (PeriodicSync.syncExtrasEquals(periodicSync.first, targetPeriodicSync.first)
                        && periodicSync.second == targetPeriodicSync.second) {
                    mSyncStatus.get(authorityId).setPeriodicSyncTime(i, when);
                    found = true;
                    break;
                }
            }
        }

        if (!found) {
            Log.w(TAG, "Ignoring setPeriodicSyncTime request for a sync that does not exist. " +
                    "Authority: " + authorityInfo.authority);
        }
    }

    private SyncStatusInfo getOrCreateSyncStatusLocked(int authorityId) {