手机更新时间后,过期的闹钟异常响起

前段时间测试提了一个bug,是这样的,设置一个闹铃,等待闹铃时间到,闹铃响应,然后插拔电池,让手机系统时间恢复到出厂默认时间,让手机联网,等待手机时间更新后,已经过期的闹钟突然响了,这让人百思不得其解,我在试图修改的时候发现在Desclock里竟然没有比对系统时间与设置闹铃时间比对然后执行响铃的逻辑(可能是本人水平有限),在解析唯一一个传入进来的Intent的时候发现唯一一个没被处理的消息类型TIME_TICk,然后追踪发现在framework的AlrmManagerService中有一个PengdingIntent是发送这个消息的(猜想比对时间的逻辑可能更加底层),当时在想如果在发送PengdingIntent的时候加个判断,如果当前时间与系统时间的差值大于一分钟,就停止响铃,可一想又不对,如果我在这里禁止里一分钟意外的响铃,那么延时闹钟也会被禁掉,所以将此问题提交给MTK平台,他们给出的回复是这样的:

After change the system time, System will send TIME_SET broadcast, DeckClock receives it and set the passed alarm as MISSED state.
however, because the user has set an valid alarm before, AlarmManager will send the alarm broadcast either, and this action will make the alarm rings.
That is the problem, if DeskClock receives the AlarmManager’s action first, it will ring, then receive TIME_SET, that it makes the alarm dismiss.
The behavior is expected as per Google default design.
The processsing of broadcast for TIME_SET may be parsed as per the system scheduling.
In some cases the AlarmManager action for alarm expiry may be parsed before processing TIME_SET by alarm service.
This causes the Alarm screen to appear. However, as soon as the TIME_SET is processed, we configure the MISSED_STATE for the alarm and dismiss the screen.

由此可知这根本不是bug,而是谷歌设计师当初设计的时候就是这样的

你可能感兴趣的:(技术总结)