Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 830480 - [Lockscreen] Tapping camera and unlock buttons rapidly o…
Browse files Browse the repository at this point in the history
…n passcoded phone hangs lockscreen r=timdream

Prevent switching to a panel when we're already switching.
Changed some synchronous callbacks to asynchronous.
Also, The callback for camera was called too soon.
  • Loading branch information
julienw committed Jan 25, 2013
1 parent bdbafdb commit 8bbd1b7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions apps/system/js/lockscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ var LockScreen = {
*/
passCodeEntered: '',

/**
* Are we currently switching panels ?
*/
_switchingPanel: false,

/*
* Timeout after incorrect attempt
*/
Expand Down Expand Up @@ -144,8 +149,9 @@ var LockScreen = {
this.updateConnState();
this.connstate.hidden = false;
}

var self = this;
if (navigator && navigator.mozCellBroadcast) {
var self = this;
navigator.mozCellBroadcast.onreceived = function onReceived(event) {
var msg = event.message;
if (conn &&
Expand All @@ -157,7 +163,6 @@ var LockScreen = {
};
}

var self = this;
SettingsListener.observe('lockscreen.enabled', true, function(value) {
self.setEnabled(value);
});
Expand Down Expand Up @@ -588,11 +593,12 @@ var LockScreen = {
},

loadPanel: function ls_loadPanel(panel, callback) {
this._loadingPanel = true;
switch (panel) {
case 'passcode':
case 'main':
if (callback)
callback();
setTimeout(callback);
break;

case 'emergency-call':
Expand All @@ -616,12 +622,12 @@ var LockScreen = {
var mainScreen = this.mainScreen;
frame.onload = function cameraLoaded() {
mainScreen.classList.add('lockscreen-camera');
if (callback)
callback();
};
this.overlay.classList.remove('no-transition');
this.camera.appendChild(frame);

if (callback)
callback();
break;
}
},
Expand Down Expand Up @@ -691,21 +697,27 @@ var LockScreen = {
}

if (callback)
callback();
setTimeout(callback);
},

switchPanel: function ls_switchPanel(panel) {
if (this._switchingPanel) {
return;
}

var overlay = this.overlay;
var self = this;
panel = panel || 'main';

this._switchingPanel = true;
this.loadPanel(panel, function panelLoaded() {
self.unloadPanel(overlay.dataset.panel, panel,
function panelUnloaded() {
if (overlay.dataset.panel !== panel)
self.dispatchEvent('lockpanelchange');

overlay.dataset.panel = panel;
self._switchingPanel = false;
});
});
},
Expand Down

0 comments on commit 8bbd1b7

Please sign in to comment.