Last Comment Bug 777226 - Alarm API - If an alarm cannot be fired when the device shuts down, it should be fired when powering up.
: Alarm API - If an alarm cannot be fired when the device shuts down, it should...
Status: RESOLVED FIXED
[LOE:S]
:
Product: Core
Classification: Components
Component: DOM: Device Interfaces (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla17
Assigned To: Gene Lian [:gene] (I already quit Mozilla)
:
Mentors:
Depends on: 783149
Blocks: alarm-api
  Show dependency treegraph
 
Reported: 2012-07-24 20:31 PDT by Gene Lian [:gene] (I already quit Mozilla)
Modified: 2012-09-05 04:25 PDT (History)
8 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch (2.26 KB, patch)
2012-08-15 19:55 PDT, Gene Lian [:gene] (I already quit Mozilla)
21: review+
Details | Diff | Splinter Review

Description Gene Lian [:gene] (I already quit Mozilla) 2012-07-24 20:31:20 PDT
Please see: https://groups.google.com/d/msg/mozilla.dev.webapi/pkx1uz_pnhQ/qzCco0g1414J
Comment 1 Gene Lian [:gene] (I already quit Mozilla) 2012-08-08 21:43:59 PDT
Hi Fabrice,

We encountered an interesting problem when solving this. If we attempt to fire a system message when the device is "powering up", the shell's observer can receive "system-messages-open-app" but cannot further open the Alarm-Colock app because the Gaia's window_manager.js has not yet been ready for catching the "open-app". Under this circumstance, we have to manually open the Alarm-Clock app and then it can response to the pending system message.

Sending the system message in a delayed 10 seconds will work (from Alarm API), but it doesn't sound an optimal approach. Any better solution to tackle the problem?
Comment 2 [:fabrice] Fabrice Desré 2012-08-13 18:27:40 PDT
(In reply to Gene Lian [:gene] from comment #1)

> Sending the system message in a delayed 10 seconds will work (from Alarm
> API), but it doesn't sound an optimal approach. Any better solution to
> tackle the problem?

It looks like we should buffer messages in shell.js until the system app has started.
Comment 3 Gene Lian [:gene] (I already quit Mozilla) 2012-08-13 18:58:16 PDT
(In reply to Fabrice Desré [:fabrice] from comment #2)
> (In reply to Gene Lian [:gene] from comment #1)
> 
> > Sending the system message in a delayed 10 seconds will work (from Alarm
> > API), but it doesn't sound an optimal approach. Any better solution to
> > tackle the problem?
> 
> It looks like we should buffer messages in shell.js until the system app has
> started.

Sounds good! But how to detect if the system app has been started or not in shell.js? Can we really do that at the platform level?
Comment 4 Gene Lian [:gene] (I already quit Mozilla) 2012-08-14 00:38:48 PDT
(In reply to Gene Lian [:gene] from comment #3)
> (In reply to Fabrice Desré [:fabrice] from comment #2)
> > (In reply to Gene Lian [:gene] from comment #1)
> > 
> > > Sending the system message in a delayed 10 seconds will work (from Alarm
> > > API), but it doesn't sound an optimal approach. Any better solution to
> > > tackle the problem?
> > 
> > It looks like we should buffer messages in shell.js until the system app has
> > started.
> 
> Sounds good! But how to detect if the system app has been started or not in
> shell.js? Can we really do that at the platform level?

Respond to myself: I think we can follow something like http://mxr.mozilla.org/mozilla-central/source/b2g/chrome/content/shell.js#121 to listen to an "onload" event. As mentioned by Fabrice, We won't send "open-app" chromEvent until "onload" event is caught.
Comment 5 Gene Lian [:gene] (I already quit Mozilla) 2012-08-15 19:55:42 PDT
Created attachment 652301 [details] [diff] [review]
Patch

Hi Vivien,

Changes are super trivial:

1. Fire alarms that should have been fired during power-down and remove it from DB.

2. To decide if alarms are expired by comparing them with a more precise Date.now().

3. Although we still have a potential issue at comment #1, I've already fired another bug to keep track of that. For the Alarm API part, these changes are for sure.

Thanks very much for your review again :)
Comment 6 Kan-Ru Chen [:kanru] (UTC+8) 2012-08-22 00:42:59 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/d51a3bf72b9c
Comment 7 Ed Morley [:emorley] 2012-08-23 03:52:06 PDT
https://hg.mozilla.org/mozilla-central/rev/d51a3bf72b9c

Note You need to log in before you can comment on or make changes to this bug.