Fix movement of RTC alarms with time changes

Whenever the system time changes, we re-add all the alarms but the
re-adding logic was not resetting the expectedWhenElapsed fields,
resulting in wrong assignment of the final whenElapsed upon app-standby
adjustment evaluation which assumes expectedWhenElapsed >= whenElapsed.

Also, whenever app-standby adjusted delivery of a repeating alarm, it
was incorrectly scheduling its subsequent occurrence.

Test: atest com.android.server.AlarmManagerServiceTest
atest CtsAlarmManagerTestCases:TimeChangeTests

Bug: 120187902
Bug: 110910377
Change-Id: I4bdb72ae55bad45ef666f7caa5d125e8278d85fd
2 files changed