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 #10633 from alivedise/bugzilla/814840_v1-train
Browse files Browse the repository at this point in the history
Bug 814840 - Uplift FTU launcher to v1-train,
Backout bug 854842, bug 875646, bug 831697, bug 877062 on v1-train. r=timdream, a=leo+
  • Loading branch information
alivedise committed Jun 26, 2013
2 parents 41a03e0 + 33c621b commit 84b027e
Show file tree
Hide file tree
Showing 17 changed files with 266 additions and 224 deletions.
2 changes: 1 addition & 1 deletion apps/communications/ftu/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<link rel="stylesheet" type="text/css" href="/shared/style/confirm.css">
<link rel="stylesheet" type="text/css" href="/shared/style_unstable/lists.css">
<link rel="stylesheet" type="text/css" href="/shared/style_unstable/progress_activity.css">
<link rel="stylesheet" type="text/css" href="/shared/style/status.css">
<link rel="stylesheet"type="text/css" href="/shared/style/status.css" rel="stylesheet">

<!-- Specific style -->
<link rel="stylesheet" type="text/css" href="/contacts/style/transitions.css">
Expand Down
19 changes: 1 addition & 18 deletions apps/communications/ftu/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var _ = navigator.mozL10n.get;

var AppManager = {
settings: navigator.mozSettings,

init: function init() {
this.isLocalized = true;
Expand All @@ -15,7 +14,6 @@ var AppManager = {
Navigation.init();
DataMobile.init();
var kSplashTimeout = 700;

// Retrieve mobile connection if available
var conn = window.navigator.mozMobileConnection;
if (!conn) {
Expand All @@ -39,22 +37,7 @@ var AppManager = {
// Remove the splash
UIManager.splashScreen.classList.remove('show');
}, kSplashTimeout);
},

disableLockscreen: function disableLockscreen() {
if (this.settings) {
var req = this.settings.createLock().set({'lockscreen.enabled': false});
}
},

finish: function finish() {
WifiManager.finish();
if (this.settings) {
var req = this.settings.createLock().set({'lockscreen.enabled': true});
}
window.close();
}

}
};

navigator.mozL10n.ready(function showBody() {
Expand Down
6 changes: 0 additions & 6 deletions apps/communications/ftu/js/sim_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ var SimManager = {
this.showXckScreen();
break;
default:
// Quick fix for bug 831697 (only for v1.0.1),
// should be fixed when uplifting 814840
if (this.mobConn.cardState === 'ready') {
AppManager.disableLockscreen();
}

if (this.accessCallback) {
this.accessCallback(this.mobConn.cardState === 'ready');
}
Expand Down
3 changes: 2 additions & 1 deletion apps/communications/ftu/js/tutorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ var Tutorial = {

this.tutorialFinish.addEventListener('click', function ftuEnd() {
self.tutorialFinish.removeEventListener('click', ftuEnd);
AppManager.finish();
WifiManager.finish();
window.close();
});
window.addEventListener('hashchange', this);
window.location.hash = tutorialSteps[this.currentStep].hash;
Expand Down
4 changes: 2 additions & 2 deletions apps/communications/ftu/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ var UIManager = {
}.bind(this));

this.skipTutorialButton.addEventListener('click', function() {
AppManager.finish();
WifiManager.finish();
window.close();
});

this.letsGoButton.addEventListener('click', function() {
UIManager.activationScreen.classList.remove('show');
UIManager.finishScreen.classList.remove('show');
Expand Down
3 changes: 3 additions & 0 deletions apps/system/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
<script defer src="js/icc_worker.js"></script>
<script defer src="js/icc.js"></script>

<!-- FTU launcher -->
<script defer src="js/ftu_launcher.js"></script>

<!-- LockScreen -->
<link rel="stylesheet" type="text/css" href="style/lockscreen/lockscreen.css">
<script defer src="js/lockscreen.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

window.addEventListener('load', function startup() {
function safelyLaunchFTU() {
WindowManager.retrieveHomescreen(WindowManager.retrieveFTU);
WindowManager.retrieveHomescreen(FtuLauncher.retrieve.bind(FtuLauncher));
}

if (Applications.ready) {
Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/captive_portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var CaptivePortal = {
currentNetwork.ssid : '';
var message = _('captive-wifi-available', { networkName: networkName });

if (WindowManager.isFtuRunning()) {
if (FtuLauncher.isFtuRunning()) {
settings.createLock().set({'wifi.connect_via_settings': false});

this.entrySheet = new EntrySheet(document.getElementById('screen'),
Expand Down
3 changes: 0 additions & 3 deletions apps/system/js/cards_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,6 @@ var CardsView = (function() {
if (LockScreen.locked)
return;

if (WindowManager.isFtuRunning())
return;

SleepMenu.hide();
showCardSwitcher();
break;
Expand Down
131 changes: 131 additions & 0 deletions apps/system/js/ftu_launcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
'use strict';
/* This module deals with FTU stuff.
FTU is known as First Time Usage,
which is the first app the users would use, to configure their phone. */

var FtuLauncher = {

/* The application object of ftu got from Application module */
_ftu: null,

/* The manifest URL of FTU */
_ftuManifestURL: '',

/* The url of FTU */
_ftuURL: '',

/* Store that if FTU is currently running */
_isRunningFirstTime: false,

isFtuRunning: function fl_isFtuRunning() {
return this._isRunningFirstTime;
},

getFtuOrigin: function fl_getFtuOrigin() {
return this._ftuURL;
},

init: function fl_init() {
// We have to block home/holdhome event if FTU is first time running.
// Note: FTU could be launched from Settings app too.
// We don't want to block home/holdhome in that case.
window.addEventListener('home', this);
window.addEventListener('holdhome', this);

// Listen to appterminated event
window.addEventListener('appterminated', this);

// Avoid race condition that
// lockscreen is locked after FTU inited.
window.addEventListener('lock', this);

// Monitor appopen event
// to unlock lockscreen if we are running FTU at first time
window.addEventListener('appopen', this);
},

handleEvent: function fl_init(evt) {
switch (evt.type) {
case 'appopen':
if (evt.detail.origin == this._ftuURL && this._isRunningFirstTime) {
LockScreen.unlock(true);
}
break;

case 'home':
case 'holdhome':
if (this._isRunningFirstTime) {
evt.stopImmediatePropagation();
}
break;

case 'appterminated':
if (evt.detail.origin == this._ftuURL) {
this.close();
}
break;

case 'lock':
if (this._isRunningFirstTime)
LockScreen.unlock(true);
break;
}
},

close: function fl_close() {
this._isRunningFirstTime = false;
window.asyncStorage.setItem('ftu.enabled', false);
// Done with FTU, letting everyone know
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent('ftudone',
/* canBubble */ true, /* cancelable */ false, {});
window.dispatchEvent(evt);
},

skip: function fl_skip() {
this._isRunningFirstTime = false;
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent('ftuskip',
/* canBubble */ true, /* cancelable */ false, {});
window.dispatchEvent(evt);
},

// Check if the FTU was executed or not, if not, get a
// reference to the app and launch it.
// Used by Bootstrap module.
retrieve: function fl_retrieve() {
var self = this;
window.asyncStorage.getItem('ftu.enabled', function getItem(launchFTU) {
if (launchFTU === false) {
self.skip();
return;
}
var lock = navigator.mozSettings.createLock();
var req = lock.get('ftu.manifestURL');
req.onsuccess = function() {
self._ftuManifestURL = this.result['ftu.manifestURL'];
if (!self._ftuManifestURL) {
dump('FTU manifest cannot be found skipping.\n');
self.skip();
return;
}
self._ftu = Applications.getByManifestURL(self._ftuManifestURL);
if (!self._ftu) {
dump('Opps, bogus FTU manifest.\n');
self.skip();
return;
}
self._ftuURL = self._ftu.origin + self._ftu.manifest.entry_points['ftu'].launch_path;
self._isRunningFirstTime = true;
// Open FTU
self._ftu.launch('ftu');
};
req.onerror = function() {
dump('Couldn\'t get the ftu manifestURL.\n');
self.skip();
};
});
}
};

FtuLauncher.init();
5 changes: 5 additions & 0 deletions apps/system/js/lockscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ var LockScreen = {
},

lockIfEnabled: function ls_lockIfEnabled(instant) {
if (FtuLauncher && FtuLauncher.isFtuRunning()) {
this.unlock(instant);
return;
}

if (this.enabled) {
this.lock(instant);
} else {
Expand Down
4 changes: 1 addition & 3 deletions apps/system/js/screen_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,7 @@ var ScreenManager = {
};

if (instant) {
if (!WindowManager.isFtuRunning()) {
screenOff();
}
screenOff();
return true;
}

Expand Down
41 changes: 9 additions & 32 deletions apps/system/js/sim_lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
'use strict';

var SimLock = {
//XXX: A hack to remember ftu state.
_ftuEnabled: null,
_duringCall: false,

init: function sl_init() {
Expand All @@ -23,17 +21,13 @@ var SimLock = {
// To prevent keyboard being displayed behind it.
window.addEventListener('unlock', this);

// always monitor card state change
conn.addEventListener('cardstatechange', this._bypassFTU.bind(this));

window.addEventListener('skipftu', function() {
this._ftuEnabled = false;
}.bind(this));

// Listen to callscreenwillopen and callscreenwillclose event
// to discard the cardstatechange event.
window.addEventListener('callscreenwillopen', this);
window.addEventListener('callscreenwillclose', this);
// always monitor card state change
conn.addEventListener('cardstatechange', this.showIfLocked.bind(this));
},

handleEvent: function sl_handleEvent(evt) {
Expand All @@ -51,7 +45,7 @@ var SimLock = {
if (evt.detail && evt.detail.areaCamera)
return;

this._bypassFTU();
this.showIfLocked();
break;
case 'appwillopen':
// If an app needs 'telephony' or 'sms' permissions (i.e. mobile
Expand All @@ -65,7 +59,8 @@ var SimLock = {
return;

// Ignore first time usage app which already ask for SIM code
if (evt.target.classList.contains('ftu'))
// XXX: We should have a better way to detect this app is FTU or not.
if (evt.target.dataset.frameOrigin == FtuLauncher.getFtuOrigin())
return;

// Ignore apps that don't require a mobile connection
Expand Down Expand Up @@ -98,28 +93,6 @@ var SimLock = {
}
},

// XXX: This is a hack.
// Because FTU tries to disable lockscreen,
// and lockscreen fires 'unlock' event immediately.
// after the setting value is change and
// the device is rebooting.
_bypassFTU: function sl__bypassFTU() {
if (this._ftuEnabled === false) {
this.showIfLocked();
}

// Furthermore checking ftu.enabled state.

var showFunc = this.showIfLocked.bind(this);

window.asyncStorage.getItem('ftu.enabled',
function getItem(launchFTU) {
if (launchFTU === false) {
showFunc();
}
});
},

showIfLocked: function sl_showIfLocked() {
var conn = window.navigator.mozMobileConnection;
if (!conn)
Expand All @@ -128,6 +101,10 @@ var SimLock = {
if (LockScreen.locked)
return false;

// FTU has its specific SIM PIN UI
if (FtuLauncher.isFtuRunning())
return false;

if (this._duringCall)
return false;

Expand Down
2 changes: 1 addition & 1 deletion apps/system/js/sound_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
return 'notification';
default:
return homescreenVisible || LockScreen.locked ||
WindowManager.isFtuRunning() ? 'notification' : 'content';
FtuLauncher.isFtuRunning() ? 'notification' : 'content';
}
}

Expand Down
Loading

0 comments on commit 84b027e

Please sign in to comment.