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

Commit 16e1678d authored by Fred Quintana's avatar Fred Quintana Committed by Android (Google) Code Review
Browse files

Merge "Make the SyncManager have wakelocks per account, not per account type,...

Merge "Make the SyncManager have wakelocks per account, not per account type, otherwise the parallel sync behavior of gmail can cause the first account to finish to release the wakelock that is used for the other account, which will result in the device going to sleep before the sync is complete."
parents 0669577b fdb2dca4
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -924,7 +924,7 @@ public class SyncManager implements OnAccountsUpdateListener {
            mStartTime = SystemClock.elapsedRealtime();
            mTimeoutStartTime = mStartTime;
            mSyncWakeLock = mSyncHandler.getSyncWakeLock(
                    mSyncOperation.account.type, mSyncOperation.authority);
                    mSyncOperation.account, mSyncOperation.authority);
            mSyncWakeLock.setWorkSource(new WorkSource(syncAdapterUid));
            mSyncWakeLock.acquire();
        }
@@ -1365,7 +1365,7 @@ public class SyncManager implements OnAccountsUpdateListener {
        public final SyncNotificationInfo mSyncNotificationInfo = new SyncNotificationInfo();
        private Long mAlarmScheduleTime = null;
        public final SyncTimeTracker mSyncTimeTracker = new SyncTimeTracker();
        private final HashMap<Pair<String, String>, PowerManager.WakeLock> mWakeLocks =
        private final HashMap<Pair<Account, String>, PowerManager.WakeLock> mWakeLocks =
                Maps.newHashMap();

        private volatile CountDownLatch mReadyToRunLatch = new CountDownLatch(1);
@@ -1377,11 +1377,11 @@ public class SyncManager implements OnAccountsUpdateListener {
            }
        }

        private PowerManager.WakeLock getSyncWakeLock(String accountType, String authority) {
            final Pair<String, String> wakeLockKey = Pair.create(accountType, authority);
        private PowerManager.WakeLock getSyncWakeLock(Account account, String authority) {
            final Pair<Account, String> wakeLockKey = Pair.create(account, authority);
            PowerManager.WakeLock wakeLock = mWakeLocks.get(wakeLockKey);
            if (wakeLock == null) {
                final String name = SYNC_WAKE_LOCK_PREFIX + "_" + authority + "_" + accountType;
                final String name = SYNC_WAKE_LOCK_PREFIX + "_" + authority + "_" + account;
                wakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, name);
                wakeLock.setReferenceCounted(false);
                mWakeLocks.put(wakeLockKey, wakeLock);