SIP: fix bugs in WakeupTimer

Bug1: when the second event becomes the first event, its period should be
reset to its max period.
Bug2: when adding a new event and that event becomes the first event (with
smallest max period), need to make sure its trigger time not larger than the
trigger time of the second event (that used to be the first event).

Replace PriorityQueue with TreeSet in order to print events in the correct order
in the log.

Change-Id: Ib1961cb38ed0d0281216c833dd46da217faae396
1 file changed