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

Commit ba35271e authored by Matthew Williams's avatar Matthew Williams
Browse files

Use pending.xml to persist sync ops.

Support pending ops by producing badly formed xml.
fixed bug that stopped alarm manager from updating if the
next alarm time is in the past.
Use new AlarmManager API for old AM behaviour - to set
exact alarms.

Change-Id: I57090f9c7155996298be7ec968a88f17ac1938a7
parent 2241d45c
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));

    }

    /**