Permalink
Browse files

Merge pull request #6816 from ian-liu/clock/Bug814632_silent_alarm_sc…

…reen_underneath_call_screen

Bug 814632 - [Clock] Put a silent alarm screen underneath the oncall screen if the alarm goes off during a phone call r=timdream
  • Loading branch information...
2 parents 1734754 + 7157fb8 commit df38f7984aa7d4067177567262ace4e402efcc7f @ian-liu ian-liu committed Dec 5, 2012
Showing with 20 additions and 7 deletions.
  1. +20 −7 apps/clock/js/onring.js
View
@@ -36,9 +36,14 @@ var RingView = {
init: function rv_init() {
this.setAlarmTime();
this.setAlarmLabel();
- this.setWakeLockEnabled(true);
- this.ring();
- this.vibrate();
+ // If mozHidden is true in init state,
+ // it means that alarm screen underneath the oncall screen.
+ // Don't let the alarm ring and vibrate.
+ if (!document.mozHidden) {
+ this.setWakeLockEnabled(true);
+ this.ring();
+ this.vibrate();
+ }
document.addEventListener('mozvisibilitychange', this);
this.snoozeButton.addEventListener('click', this);
this.closeButton.addEventListener('click', this);
@@ -107,14 +112,22 @@ var RingView = {
stopAlarmNotification: function rv_stopAlarmNotification(action) {
switch (action) {
case 'ring':
- this._ringtonePlayer.pause();
+ if (this._ringtonePlayer)
+ this._ringtonePlayer.pause();
+
break;
case 'vibrate':
- window.clearInterval(this._vibrateInterval);
+ if (this._vibrateInterval)
+ window.clearInterval(this._vibrateInterval);
+
break;
default:
- this._ringtonePlayer.pause();
- window.clearInterval(this._vibrateInterval);
+ if (this._ringtonePlayer)
+ this._ringtonePlayer.pause();
+
+ if (this._vibrateInterval)
+ window.clearInterval(this._vibrateInterval);
+
break;
}
this.setWakeLockEnabled(false);

0 comments on commit df38f79

Please sign in to comment.