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

Commit 0c5b96b1 authored by Matthew Williams's avatar Matthew Williams Committed by Android (Google) Code Review
Browse files

Merge "Use pending.xml to persist sync ops." into klp-dev

parents df717aaa ba35271e
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2889,11 +2889,12 @@ public class SyncManager {
            // determine if we need to set or cancel the alarm
            boolean shouldSet = false;
            boolean shouldCancel = false;
            final boolean alarmIsActive = mAlarmScheduleTime != null;
            final boolean alarmIsActive = (mAlarmScheduleTime != null) && (now < mAlarmScheduleTime);
            final boolean needAlarm = alarmTime != Long.MAX_VALUE;
            if (needAlarm) {
                // Need the alarm if it's currently not set, or if our time is before the currently
                // set time.
                // Need the alarm if
                //  - it's currently not set
                //  - if the alarm is set in the past.
                if (!alarmIsActive || alarmTime < mAlarmScheduleTime) {
                    shouldSet = true;
                }
@@ -2910,7 +2911,7 @@ public class SyncManager {
                            + " secs from now");
                }
                mAlarmScheduleTime = alarmTime;
                mAlarmService.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, alarmTime,
                mAlarmService.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, alarmTime,
                        mSyncAlarmIntent);
            } else if (shouldCancel) {
                mAlarmScheduleTime = null;
+217 −222

File changed.

Preview size limit exceeded, changes collapsed.

+12 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public class SyncStorageEngineTest extends AndroidTestCase {

    /**
     * Test that we handle the case of a history row being old enough to purge before the
     * correcponding sync is finished. This can happen if the clock changes while we are syncing.
     * corresponding sync is finished. This can happen if the clock changes while we are syncing.
     *
     */
    // TODO: this test causes AidlTest to fail. Omit for now
@@ -104,6 +104,17 @@ public class SyncStorageEngineTest extends AndroidTestCase {
        engine.clearAndReadState();

        assert(engine.getPendingOperationCount() == 1);
        List<SyncStorageEngine.PendingOperation> pops = engine.getPendingOperations();
        SyncStorageEngine.PendingOperation popRetrieved = pops.get(0);
        assertEquals(pop.account, popRetrieved.account);
        assertEquals(pop.reason, popRetrieved.reason);
        assertEquals(pop.userId, popRetrieved.userId);
        assertEquals(pop.syncSource, popRetrieved.syncSource);
        assertEquals(pop.authority, popRetrieved.authority);
        assertEquals(pop.expedited, popRetrieved.expedited);
        assertEquals(pop.serviceName, popRetrieved.serviceName);
        assert(android.content.PeriodicSync.syncExtrasEquals(pop.extras, popRetrieved.extras));

    }

    /**