Loading services/java/com/android/server/content/SyncManager.java +5 −4 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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; Loading services/java/com/android/server/content/SyncStorageEngine.java +217 −222 File changed.Preview size limit exceeded, changes collapsed. Show changes services/tests/servicestests/src/com/android/server/content/SyncStorageEngineTest.java +12 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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)); } /** Loading Loading
services/java/com/android/server/content/SyncManager.java +5 −4 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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; Loading
services/java/com/android/server/content/SyncStorageEngine.java +217 −222 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/tests/servicestests/src/com/android/server/content/SyncStorageEngineTest.java +12 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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)); } /** Loading