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

Commit

Permalink
Merge pull request #20540 from snowmantw/issue970824
Browse files Browse the repository at this point in the history
Bug 970824 - [LockScreen][System] Stop directly use 'lockScreen.locked'
  • Loading branch information
snowmantw committed Jun 19, 2014
2 parents 2107546 + 6b64df6 commit fa1ecd7
Show file tree
Hide file tree
Showing 31 changed files with 144 additions and 151 deletions.
2 changes: 2 additions & 0 deletions apps/calendar/test/marionette/month_view_test.js
Expand Up @@ -13,6 +13,8 @@ marionette('month view', function() {
// Do not require the B2G-desktop app window to have focus (as per the
// system window manager) in order for it to do focus-related things.
'focusmanager.testmode': true,
// We should disable LockScreen in the correct way.
'lockscreen.enabled': false
}
});

Expand Down
4 changes: 2 additions & 2 deletions apps/system/js/app_window_manager.js
@@ -1,5 +1,5 @@
/* global SettingsListener, homescreenLauncher, KeyboardManager,
layoutManager, lockScreen, System */
layoutManager, System */
'use strict';

(function(exports) {
Expand Down Expand Up @@ -386,7 +386,7 @@
// XXX: There's a race between lockscreenWindow and homescreenWindow.
// If lockscreenWindow is instantiated before homescreenWindow,
// we should not display the homescreen here.
if (!lockScreen.locked) {
if (!System.locked) {
this.display();
} else {
homescreenLauncher.getHomescreen().setVisible(false);
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/carrier_info_notifier.js
Expand Up @@ -36,7 +36,7 @@ var CarrierInfoNotifier = {

// If we are not inside the lockscreen, show the dialog
// immediately, dispatch an event to hide
if (!window.lockScreen || !window.lockScreen.locked) {
if (!window.System.locked) {
this.dispatchEvent('emergencyalert');
this.playNotification();
showDialog();
Expand Down
4 changes: 2 additions & 2 deletions apps/system/js/dialer_agent.js
@@ -1,6 +1,6 @@
'use strict';

/* global SettingsListener, SettingsURL, AttentionScreen, lockScreen */
/* global SettingsListener, SettingsURL, AttentionScreen, System*/
/* r=? dialer+system peers for changes in this file. */

(function(exports) {
Expand Down Expand Up @@ -197,7 +197,7 @@
var timestamp = new Date().getTime();

var src = CSORIGIN + 'index.html' + '#' +
(lockScreen.locked ? 'locked' : '');
(System.locked ? 'locked' : '');
src = src + '&timestamp=' + timestamp;
callScreen.src = src;
callScreen.setVisible(true);
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/lockscreen.js
Expand Up @@ -36,7 +36,7 @@
* Must not multate directly - use unlock()/lockIfEnabled()
* Listen to 'lock' and 'unlock' event to properly handle status changes
*/
_locked: true,
locked: true,

/*
* Boolean return whether if the lock screen is enabled or not.
Expand Down
17 changes: 13 additions & 4 deletions apps/system/js/lockscreen_window_manager.js
Expand Up @@ -16,10 +16,10 @@
* @constructor LockScreenWindowManager
*/
var LockScreenWindowManager = function() {
this.initElements();
this.initWindow();
this.startEventListeners();
this.startObserveSettings();
this.initElements();
this.initWindow();
};
LockScreenWindowManager.prototype = {
/**
Expand All @@ -40,7 +40,9 @@
FTUOccurs: false,
enabled: true,
unlockDetail: null,
instance: null
instance: null,
active: false,
windowCreating: false
},

/**
Expand Down Expand Up @@ -218,11 +220,12 @@
*/
LockScreenWindowManager.prototype.closeApp =
function lwm_closeApp(instant) {
if (!this.states.enabled) {
if (!this.states.enabled && !this.states.active) {
return;
}
this.states.instance.close(instant ? 'immediate': undefined);
this.elements.screen.classList.remove('locked');
this.states.active = false;
};

/**
Expand All @@ -245,6 +248,7 @@
this.states.instance.open();
}
this.elements.screen.classList.add('locked');
this.states.active = true;
};

/**
Expand Down Expand Up @@ -295,8 +299,13 @@
*/
LockScreenWindowManager.prototype.createWindow =
function lwm_createWindow() {
if (this.states.windowCreating) {
return false;
}
this.states.windowCreating = true;
var app = new window.LockScreenWindow();
app.open();
this.states.windowCreating = false;
};

/**
Expand Down
6 changes: 3 additions & 3 deletions apps/system/js/nfc_manager.js
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

/* globals dump, lockScreen, CustomEvent, MozActivity,
/* globals dump, CustomEvent, MozActivity, System,
NfcHandoverManager, NfcUtils, NDEF, ScreenManager */
'use strict';

Expand Down Expand Up @@ -65,7 +65,7 @@ var NfcManager = {
var self = this;
window.SettingsListener.observe('nfc.enabled', false, function(enabled) {
var state = enabled ?
(lockScreen.locked ?
(System.locked ?
self.NFC_HW_STATE_DISABLE_DISCOVERY :
self.NFC_HW_STATE_ON) :
self.NFC_HW_STATE_OFF;
Expand All @@ -75,7 +75,7 @@ var NfcManager = {

isScreenUnlockAndEnabled: function nm_isScreenUnlockAndEnabled() {
// Policy:
if (ScreenManager.screenEnabled && lockScreen && !lockScreen.locked) {
if (ScreenManager.screenEnabled && !System.locked) {
return true;
} else {
return false;
Expand Down
6 changes: 2 additions & 4 deletions apps/system/js/notifications.js
Expand Up @@ -384,8 +384,7 @@ var NotificationScreen = {
// Notification toaster
if (notify) {
this.updateToaster(detail, type, dir);
if (this.lockscreenPreview || !window.lockScreen ||
!window.lockScreen.locked) {
if (this.lockscreenPreview || !window.System.locked) {
this.toaster.classList.add('displayed');
this._toasterGD.startDetecting();

Expand All @@ -403,8 +402,7 @@ var NotificationScreen = {

// Adding it to the lockscreen if locked and the privacy setting
// does not prevent it.
if (typeof(window.lockScreen) !== 'undefined' &&
window.lockScreen.locked && this.lockscreenPreview) {
if (System.locked && this.lockscreenPreview) {
var lockScreenNode = notificationNode.cloneNode(true);

// First we try and find an existing notification with the same id.
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/orientation_manager.js
Expand Up @@ -51,7 +51,7 @@
case 'will-unlock':
case 'searchclosing':
// We don't need to reset orientation if lockscreen is locked.
if (window.lockScreen && window.lockScreen.locked) {
if (System.locked) {
return;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/screen_manager.js
Expand Up @@ -446,7 +446,7 @@ var ScreenManager = {
// The screen should be turn off with shorter timeout if
// it was never unlocked.
} else if (!this._unlocking) {
if (window.lockScreen && window.lockScreen.locked) {
if (window.System.locked) {
this._setIdleTimeout(10, true);
window.addEventListener('will-unlock', this);
window.addEventListener('lockpanelchange', this);
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/sim_lock.js
Expand Up @@ -145,7 +145,7 @@ var SimLock = {
},

showIfLocked: function sl_showIfLocked(currentSlotIndex, skipped) {
if (lockScreen && lockScreen.locked)
if (System.locked)
return false;

// FTU has its specific SIM PIN UI
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/sound_manager.js
Expand Up @@ -464,7 +464,7 @@
return defaultVolumeControlChannel;
} else {
return homescreenVisible ||
(window.lockScreen && window.lockScreen.locked) ||
(System.locked) ||
FtuLauncher.isFtuRunning() ? 'notification' : 'content';
}
}
Expand Down
3 changes: 1 addition & 2 deletions apps/system/js/statusbar.js
Expand Up @@ -1238,8 +1238,7 @@ var StatusBar = {

// To reduce the duplicated code
isLocked: function() {
return 'undefined' !== typeof window.lockScreen &&
window.lockScreen.locked;
return System.locked;
}
};

Expand Down
4 changes: 2 additions & 2 deletions apps/system/js/storage.js
@@ -1,5 +1,5 @@
'use strict';
/* global SettingsListener */
/* global SettingsListener, System */

(function(exports) {

Expand All @@ -18,7 +18,7 @@

SettingsListener.observe(this.umsEnabled, false, function umsChanged(val) {
this._mode = this.modeFromBool(val);
if (window.lockScreen && window.lockScreen.locked) {
if (System.locked) {
// covers startup
// Setting mode due to screen locked
this.setMode(this.automounterDisable);
Expand Down
9 changes: 9 additions & 0 deletions apps/system/js/system.js
Expand Up @@ -69,6 +69,15 @@
detail: detail
});
window.dispatchEvent(evt);
},

get locked() {
// Someone ask this state too early.
if ('undefined' === typeof window.lockScreenWindowManager) {
return false;
} else {
return window.lockScreenWindowManager.states.active;
}
}
};
}(this));
5 changes: 2 additions & 3 deletions apps/system/js/task_manager.js
@@ -1,6 +1,6 @@
/* global Card, TaskCard,
AppWindowManager, sleepMenu, SettingsListener, AttentionScreen,
OrientationManager,
OrientationManager, System,
GestureDetector, UtilityTray, StackManager, Event */

'use strict';
Expand Down Expand Up @@ -706,8 +706,7 @@
break;

case 'holdhome':
if (this.isShown() ||
(window.lockScreen && window.lockScreen.locked)) {
if (this.isShown() || System.locked) {
return;
}
sleepMenu.hide();
Expand Down
19 changes: 11 additions & 8 deletions apps/system/js/utility_tray.js
Expand Up @@ -53,7 +53,7 @@ var UtilityTray = {
this.overlay.addEventListener('transitionend', this);

if (window.navigator.mozMobileConnections) {
LazyLoader.load('js/cost_control.js');
window.LazyLoader.load('js/cost_control.js');
}
},

Expand Down Expand Up @@ -98,12 +98,13 @@ var UtilityTray = {
break;

case 'screenchange':
if (this.shown && !evt.detail.screenEnabled)
if (this.shown && !evt.detail.screenEnabled) {
this.hide(true);
}
break;

case 'touchstart':
if (lockScreen.locked) {
if (window.System.locked) {
return;
}

Expand Down Expand Up @@ -135,8 +136,9 @@ var UtilityTray = {
evt.stopImmediatePropagation();
var touch = evt.changedTouches[0];

if (!this.active)
if (!this.active) {
return;
}

this.active = false;

Expand All @@ -154,8 +156,9 @@ var UtilityTray = {
break;

case 'transitionend':
if (!this.shown)
if (!this.shown) {
this.screen.classList.remove('utility-tray');
}
break;
}
},
Expand All @@ -170,7 +173,7 @@ var UtilityTray = {
// If the active app was tracking touches it won't get any more events
// because of the pointer-events:none we're adding.
// Sending a touchcancel accordingly.
var app = AppWindowManager.getActiveApp();
var app = window.AppWindowManager.getActiveApp();
if (app) {
app.iframe.sendTouchEvent('touchcancel', [touch.identifier],
[touch.pageX], [touch.pageY],
Expand Down Expand Up @@ -205,7 +208,7 @@ var UtilityTray = {

onTouchEnd: function ut_onTouchEnd(touch) {
// Prevent utility tray shows while the screen got black out.
if (window.lockScreen && window.lockScreen.locked) {
if (window.System.locked) {
this.hide(true);
} else {
var significant = (Math.abs(this.lastDelta) > (this.screenHeight / 5));
Expand All @@ -227,7 +230,7 @@ var UtilityTray = {

// If the transition has not started yet there won't be any transitionend
// event so let's not wait in order to remove the utility-tray class.
if (instant || style.MozTransform == '') {
if (instant || style.MozTransform === '') {
this.screen.classList.remove('utility-tray');
}
window.dispatchEvent(new CustomEvent('utility-tray-overlayclosed'));
Expand Down
19 changes: 11 additions & 8 deletions apps/system/js/visibility_manager.js
Expand Up @@ -20,8 +20,8 @@
this._normalAudioChannelActive = false;
this._deviceLockedTimer = 0;
this.overlayEvents = [
'lock',
'will-unlock',
'lockscreen-appopened',
'lockscreen-appclosing',
'attentionscreenshow',
'attentionscreenhide',
'status-active',
Expand Down Expand Up @@ -63,18 +63,22 @@
break;
case 'status-active':
case 'attentionscreenhide':
case 'will-unlock':
if (window.lockScreen && window.lockScreen.locked) {
if (window.System.locked) {
this.publish('showlockscreenwindow');
return;
}

if (!AttentionScreen.isFullyVisible()) {
this.publish('showwindow', { type: evt.type });
}
this._resetDeviceLockedTimer();
break;
case 'lock':
case 'lockscreen-appclosing':
if (!AttentionScreen.isFullyVisible()) {
this.publish('showwindow', { type: evt.type });
}
this._resetDeviceLockedTimer();
break;
case 'lockscreen-appopened':
// If the audio is active, the app should not set non-visible
// otherwise it will be muted.
// TODO: Remove this hack.
Expand Down Expand Up @@ -110,8 +114,7 @@
this._resetDeviceLockedTimer();

if (this._normalAudioChannelActive &&
evt.detail.channel !== 'normal' &&
window.lockScreen && window.lockScreen.locked) {
evt.detail.channel !== 'normal' && window.System.locked) {
this._deviceLockedTimer = setTimeout(function setVisibility() {
this.publish('hidewindow',
{ screenshoting: false, type: evt.type });
Expand Down

0 comments on commit fa1ecd7

Please sign in to comment.