diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index aacc8c9e3fdd..0825cdd3bd4e 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -30,14 +30,8 @@ XPCOMUtils.defineLazyGetter(Services, 'idle', function() { }); XPCOMUtils.defineLazyGetter(Services, 'audioManager', function() { -#ifdef MOZ_WIDGET_GONK return Cc['@mozilla.org/telephony/audiomanager;1'] .getService(Ci.nsIAudioManager); -#else - return { - "masterVolume": 0 - }; -#endif }); XPCOMUtils.defineLazyServiceGetter(Services, 'fm', function() { @@ -85,12 +79,11 @@ var shell = { return Services.prefs.getCharPref('browser.homescreenURL'); }, - start: function shell_start() { + start: function shell_init() { let homeURL = this.homeURL; if (!homeURL) { let msg = 'Fatal error during startup: No homescreen found: try setting B2G_HOMESCREEN'; - alert(msg); - return; + return alert(msg); } ['keydown', 'keypress', 'keyup'].forEach((function listenKey(type) { @@ -107,7 +100,9 @@ var shell = { // a specific value when the device starts. This way the front-end // can display a notification when the volume change and show a volume // level modified from this point. - Services.audioManager.masterVolume = 0.5; + try { + Services.audioManager.masterVolume = 0.5; + } catch(e) {} let domains = ""; try { @@ -302,7 +297,6 @@ var shell = { } } } - let wakeLockHandler = function wakeLockHandler(topic, state) { // Turn off the screen when no one needs the it or all of them are // invisible, otherwise turn the screen on. Note that the CPU @@ -319,11 +313,7 @@ var shell = { } } } - let idleTimeout = Services.prefs.getIntPref("power.screen.timeout"); - if (!('mozSettings' in navigator)) - return; - let request = navigator.mozSettings.getLock().get("power.screen.timeout"); request.onsuccess = function onSuccess() { idleTimeout = request.result["power.screen.timeout"] || idleTimeout; @@ -332,14 +322,12 @@ var shell = { power.addWakeLockListener(wakeLockHandler); } } - request.onerror = function onError() { if (idleTimeout) { Services.idle.addIdleObserver(idleHandler, idleTimeout); power.addWakeLockListener(wakeLockHandler); } } - // XXX We may override other's callback here, but this is the only // user of mozSettings in shell.js at this moment. navigator.mozSettings.onsettingchange = function onSettingChange(e) { @@ -437,7 +425,7 @@ Services.obs.addObserver(function onConsoleAPILogEvent(subject, topic, data) { serverSocket.asyncListen(listener); })(); -var CustomEventManager = { +CustomEventManager = { init: function custevt_init() { window.addEventListener("ContentStart", (function(evt) { content.addEventListener("mozContentEvent", this, false, true); @@ -461,7 +449,7 @@ var CustomEventManager = { } } -var AlertsHelper = { +AlertsHelper = { _listeners: {}, _count: 0, @@ -492,7 +480,7 @@ var AlertsHelper = { } } -var WebappsHelper = { +WebappsHelper = { _installers: {}, _count: 0, diff --git a/b2g/chrome/content/shell.xul b/b2g/chrome/content/shell.xul index 222a8172e7a9..d4e623a565e0 100644 --- a/b2g/chrome/content/shell.xul +++ b/b2g/chrome/content/shell.xul @@ -19,11 +19,14 @@ #ifndef MOZ_TOUCH