benjymous/MWM-for-Android — pull request #21 by firetech (2012-05-11 17:36:45+00:00)
Title: Avoid instantly disappearing notifications (and a minor cleanup)

I'm not 100% sure if this patch is a good idea, but it seems to solve a problem I'm having.

Since flashing firmware 0.10.X on my watch, I started having issues with notifications disappearing more or less immediately after they were sent (while the watch was still vibrating). Some investigations showed that this was because MWM sometimes started the timeout countdown well before the notification actually was shown (probably because of sniff mode ), causing MWM to call Protocol.exitNotification() too early.

This patch waits for a mode change message from the watch before starting the timeout. Since I don't have an analog watch, I don't know if it sends a mode change message when it receives notifications, so this patch seriously needs analog testing. As I said, I'm not entirely sure that this patch is a good idea, but the limited testing I have done has been successful. Based on log output, the timeout seems to start quite instantly after the notification is shown. The question is if the notification system can lock up somehow, especially on the analog watch. I have tested quick series of notifications without issues.

I also cleaned up calls to Protocol.updateLcdDisplay(), replacing explicitly given parameters (like 0 or 2) with the already existing named constants MetaWatchService.WatchBuffers.*, mostly because I was thinking about a different way to fix the problem.