зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1229620 - Replace #ifdefs in b2g/ code by AppConstants r=timdream
This commit is contained in:
Родитель
e20ba29a1c
Коммит
73cba43755
|
@ -9,7 +9,6 @@ obj*/**
|
|||
# below.
|
||||
accessible/**
|
||||
addon-sdk/**
|
||||
b2g/**
|
||||
build/**
|
||||
caps/**
|
||||
chrome/**
|
||||
|
@ -55,6 +54,11 @@ xpcom/**
|
|||
xpfe/**
|
||||
xulrunner/**
|
||||
|
||||
# b2g exclusions (pref files).
|
||||
b2g/app/b2g.js
|
||||
b2g/graphene/graphene.js
|
||||
b2g/locales/en-US/b2g-l10n.js
|
||||
|
||||
# browser/ exclusions
|
||||
browser/app/**
|
||||
browser/base/content/browser-social.js
|
||||
|
|
|
@ -219,11 +219,11 @@ var RemoteDebugger = {
|
|||
return root;
|
||||
};
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
DebuggerServer.on("connectionchange", function() {
|
||||
AdbController.updateState();
|
||||
});
|
||||
#endif
|
||||
if (isGonk) {
|
||||
DebuggerServer.on("connectionchange", function() {
|
||||
AdbController.updateState();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -373,9 +373,7 @@ var WiFiRemoteDebugger = {
|
|||
e + "\n" + e.stack + "\n");
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
AdbController.setRemoteDebuggerState(value != "disabled");
|
||||
#endif
|
||||
isGonk && AdbController.setRemoteDebuggerState(value != "disabled");
|
||||
});
|
||||
|
||||
SettingsListener.observe("devtools.remote.wifi.enabled", false,
|
||||
|
|
|
@ -22,12 +22,14 @@ Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
|||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
Cu.import('resource://gre/modules/AppConstants.jsm');
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
XPCOMUtils.defineLazyGetter(this, "libcutils", function () {
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
return libcutils;
|
||||
});
|
||||
#endif
|
||||
const isGonk = AppConstants.platform === 'gonk';
|
||||
|
||||
if (isGonk) {
|
||||
XPCOMUtils.defineLazyGetter(this, "libcutils", function () {
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
return libcutils;
|
||||
});
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "uuidgen",
|
||||
"@mozilla.org/uuid-generator;1",
|
||||
|
@ -152,10 +154,8 @@ Components.utils.import('resource://gre/modules/ctypes.jsm');
|
|||
(function DeviceInfoToSettings() {
|
||||
// MOZ_B2G_VERSION is set in b2g/confvars.sh, and is output as a #define value
|
||||
// from configure.in, defaults to 1.0.0 if this value is not exist.
|
||||
#filter attemptSubstitution
|
||||
let os_version = '@MOZ_B2G_VERSION@';
|
||||
let os_name = '@MOZ_B2G_OS_NAME@';
|
||||
#unfilter attemptSubstitution
|
||||
let os_version = AppConstants.MOZ_B2G_VERSION;
|
||||
let os_name = AppConstants.MOZ_B2G_OS_NAME;
|
||||
|
||||
let appInfo = Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsIXULAppInfo);
|
||||
|
@ -167,14 +167,14 @@ Components.utils.import('resource://gre/modules/ctypes.jsm');
|
|||
let product_model = null;
|
||||
let product_device = null;
|
||||
let build_number = null;
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (isGonk) {
|
||||
hardware_info = libcutils.property_get('ro.hardware');
|
||||
firmware_revision = libcutils.property_get('ro.firmware_revision');
|
||||
product_manufacturer = libcutils.property_get('ro.product.manufacturer');
|
||||
product_model = libcutils.property_get('ro.product.model');
|
||||
product_device = libcutils.property_get('ro.product.device');
|
||||
build_number = libcutils.property_get('ro.build.version.incremental');
|
||||
#endif
|
||||
}
|
||||
|
||||
// Populate deviceinfo settings,
|
||||
// copying any existing deviceinfo.os into deviceinfo.previous_os
|
||||
|
@ -218,32 +218,31 @@ SettingsListener.observe('devtools.overlay', false, (value) => {
|
|||
}
|
||||
});
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (isGonk) {
|
||||
var LogShake;
|
||||
(function() {
|
||||
let scope = {};
|
||||
Cu.import('resource://gre/modules/LogShake.jsm', scope);
|
||||
LogShake = scope.LogShake;
|
||||
LogShake.init();
|
||||
})();
|
||||
|
||||
var LogShake;
|
||||
(function() {
|
||||
let scope = {};
|
||||
Cu.import('resource://gre/modules/LogShake.jsm', scope);
|
||||
LogShake = scope.LogShake;
|
||||
LogShake.init();
|
||||
})();
|
||||
SettingsListener.observe('devtools.logshake.enabled', false, value => {
|
||||
if (value) {
|
||||
LogShake.enableDeviceMotionListener();
|
||||
} else {
|
||||
LogShake.disableDeviceMotionListener();
|
||||
}
|
||||
});
|
||||
|
||||
SettingsListener.observe('devtools.logshake.enabled', false, value => {
|
||||
if (value) {
|
||||
LogShake.enableDeviceMotionListener();
|
||||
} else {
|
||||
LogShake.disableDeviceMotionListener();
|
||||
}
|
||||
});
|
||||
|
||||
SettingsListener.observe('devtools.logshake.qa_enabled', false, value => {
|
||||
if (value) {
|
||||
LogShake.enableQAMode();
|
||||
} else {
|
||||
LogShake.disableQAMode();
|
||||
}
|
||||
});
|
||||
#endif
|
||||
SettingsListener.observe('devtools.logshake.qa_enabled', false, value => {
|
||||
if (value) {
|
||||
LogShake.enableQAMode();
|
||||
} else {
|
||||
LogShake.disableQAMode();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// =================== Device Storage ====================
|
||||
SettingsListener.observe('device.storage.writable.name', 'sdcard', function(value) {
|
||||
|
@ -380,15 +379,13 @@ setUpdateTrackingId();
|
|||
var enabled = false;
|
||||
if (Services.prefs.getPrefType('layers.composer2d.enabled') == Ci.nsIPrefBranch.PREF_BOOL) {
|
||||
enabled = Services.prefs.getBoolPref('layers.composer2d.enabled');
|
||||
} else {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
} else if (isGonk) {
|
||||
let androidVersion = libcutils.property_get("ro.build.version.sdk");
|
||||
if (androidVersion >= 17 ) {
|
||||
enabled = true;
|
||||
} else {
|
||||
enabled = (libcutils.property_get('ro.display.colorfill') === '1');
|
||||
}
|
||||
#endif
|
||||
}
|
||||
navigator.mozSettings.createLock().set({'layers.composer2d.enabled': enabled });
|
||||
}
|
||||
|
@ -443,11 +440,7 @@ setUpdateTrackingId();
|
|||
return;
|
||||
}
|
||||
// Gaia setting has not been set; set the gaia setting to default.
|
||||
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
|
||||
let prefValue = true;
|
||||
#else
|
||||
let prefValue = false;
|
||||
#endif
|
||||
let prefValue = AppConstants.MOZ_TELEMETRY_ON_BY_DEFAULT;
|
||||
try {
|
||||
prefValue = Services.prefs.getBoolPref(geckoPrefName);
|
||||
} catch (e) {
|
||||
|
@ -571,47 +564,47 @@ SettingsListener.observe("theme.selected",
|
|||
setPAC();
|
||||
})();
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "AppsUtils",
|
||||
"resource://gre/modules/AppsUtils.jsm");
|
||||
|
||||
// ======================= Dogfooders FOTA ==========================
|
||||
SettingsListener.observe('debug.performance_data.dogfooding', false,
|
||||
isDogfooder => {
|
||||
if (!isDogfooder) {
|
||||
dump('AUS:Settings: Not a dogfooder!\n');
|
||||
return;
|
||||
}
|
||||
if (AppConstants.MOZ_B2G_RIL) {
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "AppsUtils",
|
||||
"resource://gre/modules/AppsUtils.jsm");
|
||||
|
||||
if (!('mozTelephony' in navigator)) {
|
||||
dump('AUS:Settings: There is no mozTelephony!\n');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!('mozMobileConnections' in navigator)) {
|
||||
dump('AUS:Settings: There is no mozMobileConnections!\n');
|
||||
return;
|
||||
}
|
||||
|
||||
let conn = navigator.mozMobileConnections[0];
|
||||
conn.addEventListener('radiostatechange', function onradiostatechange() {
|
||||
if (conn.radioState !== 'enabled') {
|
||||
SettingsListener.observe('debug.performance_data.dogfooding', false,
|
||||
isDogfooder => {
|
||||
if (!isDogfooder) {
|
||||
dump('AUS:Settings: Not a dogfooder!\n');
|
||||
return;
|
||||
}
|
||||
|
||||
conn.removeEventListener('radiostatechange', onradiostatechange);
|
||||
navigator.mozTelephony.dial('*#06#').then(call => {
|
||||
return call.result.then(res => {
|
||||
if (res.success && res.statusMessage
|
||||
&& (res.serviceCode === 'scImei')) {
|
||||
Services.prefs.setCharPref("app.update.imei_hash",
|
||||
AppsUtils.computeHash(res.statusMessage, "SHA512"));
|
||||
}
|
||||
if (!('mozTelephony' in navigator)) {
|
||||
dump('AUS:Settings: There is no mozTelephony!\n');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!('mozMobileConnections' in navigator)) {
|
||||
dump('AUS:Settings: There is no mozMobileConnections!\n');
|
||||
return;
|
||||
}
|
||||
|
||||
let conn = navigator.mozMobileConnections[0];
|
||||
conn.addEventListener('radiostatechange', function onradiostatechange() {
|
||||
if (conn.radioState !== 'enabled') {
|
||||
return;
|
||||
}
|
||||
|
||||
conn.removeEventListener('radiostatechange', onradiostatechange);
|
||||
navigator.mozTelephony.dial('*#06#').then(call => {
|
||||
return call.result.then(res => {
|
||||
if (res.success && res.statusMessage
|
||||
&& (res.serviceCode === 'scImei')) {
|
||||
Services.prefs.setCharPref("app.update.imei_hash",
|
||||
AppsUtils.computeHash(res.statusMessage, "SHA512"));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
// =================== Various simple mapping ======================
|
||||
var settingsToObserve = {
|
||||
|
@ -663,18 +656,11 @@ var settingsToObserve = {
|
|||
'layers.draw-borders': false,
|
||||
'layers.draw-tile-borders': false,
|
||||
'layers.dump': false,
|
||||
#ifdef XP_WIN
|
||||
'layers.enable-tiles': false,
|
||||
#else
|
||||
'layers.enable-tiles': AppConstants.platform !== "win",
|
||||
'layers.enable-tiles': true,
|
||||
#endif
|
||||
'layers.effect.invert': false,
|
||||
'layers.effect.grayscale': false,
|
||||
'layers.effect.contrast': '0.0',
|
||||
#ifdef MOZ_GRAPHENE
|
||||
// Restart required
|
||||
'layers.async-pan-zoom.enabled': false,
|
||||
#endif
|
||||
'layout.display-list.dump': false,
|
||||
'mms.debugging.enabled': false,
|
||||
'network.debugging.enabled': false,
|
||||
|
@ -729,6 +715,11 @@ var settingsToObserve = {
|
|||
'wap.UAProf.url': ''
|
||||
};
|
||||
|
||||
if (AppConstants.MOZ_GRAPHENE) {
|
||||
// Restart required
|
||||
settingsToObserve['layers.async-pan-zoom.enabled'] = false;
|
||||
}
|
||||
|
||||
function settingObserver(setPref, prefName, setting) {
|
||||
return value => {
|
||||
setPref(prefName, value);
|
||||
|
|
|
@ -19,11 +19,13 @@ Cu.import('resource://gre/modules/ErrorPage.jsm');
|
|||
Cu.import('resource://gre/modules/AlertsHelper.jsm');
|
||||
Cu.import('resource://gre/modules/RequestSyncService.jsm');
|
||||
Cu.import('resource://gre/modules/SystemUpdateService.jsm');
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
Cu.import('resource://gre/modules/MultiscreenHandler.jsm');
|
||||
Cu.import('resource://gre/modules/NetworkStatsService.jsm');
|
||||
Cu.import('resource://gre/modules/ResourceStatsService.jsm');
|
||||
#endif
|
||||
|
||||
if (isGonk) {
|
||||
Cu.import('resource://gre/modules/MultiscreenHandler.jsm');
|
||||
Cu.import('resource://gre/modules/NetworkStatsService.jsm');
|
||||
Cu.import('resource://gre/modules/ResourceStatsService.jsm');
|
||||
}
|
||||
|
||||
Cu.import('resource://gre/modules/KillSwitchMain.jsm');
|
||||
|
||||
// Identity
|
||||
|
@ -62,21 +64,21 @@ XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
|
|||
.getService(Ci.nsIMessageListenerManager);
|
||||
});
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
XPCOMUtils.defineLazyGetter(this, "libcutils", function () {
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
return libcutils;
|
||||
});
|
||||
#endif
|
||||
if (isGonk) {
|
||||
XPCOMUtils.defineLazyGetter(this, "libcutils", function () {
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
return libcutils;
|
||||
});
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(Services, 'captivePortalDetector',
|
||||
'@mozilla.org/toolkit/captive-detector;1',
|
||||
'nsICaptivePortalDetector');
|
||||
|
||||
#ifdef MOZ_SAFE_BROWSING
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
|
||||
"resource://gre/modules/SafeBrowsing.jsm");
|
||||
#endif
|
||||
if (AppConstants.MOZ_SAFE_BROWSING) {
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
|
||||
"resource://gre/modules/SafeBrowsing.jsm");
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SafeMode",
|
||||
"resource://gre/modules/SafeMode.jsm");
|
||||
|
@ -120,25 +122,21 @@ function restart() {
|
|||
appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
function debugCrashReport(aStr) {
|
||||
dump('Crash reporter : ' + aStr);
|
||||
AppConstants.MOZ_CRASHREPORTER && dump('Crash reporter : ' + aStr);
|
||||
}
|
||||
#else
|
||||
function debugCrashReport(aStr) {}
|
||||
#endif
|
||||
|
||||
var shell = {
|
||||
|
||||
get CrashSubmit() {
|
||||
delete this.CrashSubmit;
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
Cu.import("resource://gre/modules/CrashSubmit.jsm", this);
|
||||
return this.CrashSubmit;
|
||||
#else
|
||||
dump('Crash reporter : disabled at build time.');
|
||||
return this.CrashSubmit = null;
|
||||
#endif
|
||||
if (AppConstants.MOZ_CRASHREPORTER) {
|
||||
Cu.import("resource://gre/modules/CrashSubmit.jsm", this);
|
||||
return this.CrashSubmit;
|
||||
} else {
|
||||
dump('Crash reporter : disabled at build time.');
|
||||
return this.CrashSubmit = null;
|
||||
}
|
||||
},
|
||||
|
||||
onlineForCrashReport: function shell_onlineForCrashReport() {
|
||||
|
@ -265,10 +263,10 @@ var shell = {
|
|||
},
|
||||
|
||||
bootstrap: function() {
|
||||
#ifdef MOZ_B2GDROID
|
||||
Cc["@mozilla.org/b2g/b2gdroid-setup;1"]
|
||||
.getService(Ci.nsIObserver).observe(window, "shell-startup", null);
|
||||
#endif
|
||||
if (AppConstants.MOZ_B2GDROID) {
|
||||
Cc["@mozilla.org/b2g/b2gdroid-setup;1"]
|
||||
.getService(Ci.nsIObserver).observe(window, "shell-startup", null);
|
||||
}
|
||||
|
||||
window.performance.mark('gecko-shell-bootstrap');
|
||||
|
||||
|
@ -278,15 +276,13 @@ var shell = {
|
|||
Cc['@mozilla.org/commandlinehandler/general-startup;1?type=b2gbootstrap']
|
||||
.getService(Ci.nsISupports).wrappedJSObject.startManifestURL;
|
||||
|
||||
#ifdef MOZ_GRAPHENE
|
||||
// If --start-manifest hasn't been specified, we re-use the latest specified manifest.
|
||||
// If it's the first launch, we will fallback to b2g.default.start_manifest_url
|
||||
if (!startManifestURL) {
|
||||
if (AppConstants.MOZ_GRAPHENE && !startManifestURL) {
|
||||
try {
|
||||
startManifestURL = Services.prefs.getCharPref("b2g.system_manifest_url");
|
||||
} catch(e) {}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!startManifestURL) {
|
||||
try {
|
||||
|
@ -296,13 +292,13 @@ var shell = {
|
|||
|
||||
if (startManifestURL) {
|
||||
Cu.import('resource://gre/modules/Bootstraper.jsm');
|
||||
#ifdef MOZ_GRAPHENE
|
||||
if (Bootstraper.isInstallRequired(startManifestURL)) {
|
||||
|
||||
if (AppConstants.MOZ_GRAPHENE && Bootstraper.isInstallRequired(startManifestURL)) {
|
||||
// Installing the app my take some time. We don't want to keep the
|
||||
// native window hidden.
|
||||
showInstallScreen();
|
||||
}
|
||||
#endif
|
||||
|
||||
Bootstraper.ensureSystemAppInstall(startManifestURL)
|
||||
.then(this.start.bind(this))
|
||||
.catch(Bootstraper.bailout);
|
||||
|
@ -334,34 +330,34 @@ var shell = {
|
|||
}
|
||||
catch (e) { }
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// Annotate crash report
|
||||
let annotations = [ [ "Android_Hardware", "ro.hardware" ],
|
||||
[ "Android_Device", "ro.product.device" ],
|
||||
[ "Android_CPU_ABI2", "ro.product.cpu.abi2" ],
|
||||
[ "Android_CPU_ABI", "ro.product.cpu.abi" ],
|
||||
[ "Android_Manufacturer", "ro.product.manufacturer" ],
|
||||
[ "Android_Brand", "ro.product.brand" ],
|
||||
[ "Android_Model", "ro.product.model" ],
|
||||
[ "Android_Board", "ro.product.board" ],
|
||||
];
|
||||
if (isGonk) {
|
||||
// Annotate crash report
|
||||
let annotations = [ [ "Android_Hardware", "ro.hardware" ],
|
||||
[ "Android_Device", "ro.product.device" ],
|
||||
[ "Android_CPU_ABI2", "ro.product.cpu.abi2" ],
|
||||
[ "Android_CPU_ABI", "ro.product.cpu.abi" ],
|
||||
[ "Android_Manufacturer", "ro.product.manufacturer" ],
|
||||
[ "Android_Brand", "ro.product.brand" ],
|
||||
[ "Android_Model", "ro.product.model" ],
|
||||
[ "Android_Board", "ro.product.board" ],
|
||||
];
|
||||
|
||||
annotations.forEach(function (element) {
|
||||
cr.annotateCrashReport(element[0], libcutils.property_get(element[1]));
|
||||
annotations.forEach(function (element) {
|
||||
cr.annotateCrashReport(element[0], libcutils.property_get(element[1]));
|
||||
});
|
||||
|
||||
let androidVersion = libcutils.property_get("ro.build.version.sdk") +
|
||||
"(" + libcutils.property_get("ro.build.version.codename") + ")";
|
||||
cr.annotateCrashReport("Android_Version", androidVersion);
|
||||
|
||||
SettingsListener.observe("deviceinfo.os", "", function(value) {
|
||||
try {
|
||||
let cr = Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsICrashReporter);
|
||||
cr.annotateCrashReport("B2G_OS_Version", value);
|
||||
} catch(e) { }
|
||||
});
|
||||
|
||||
let androidVersion = libcutils.property_get("ro.build.version.sdk") +
|
||||
"(" + libcutils.property_get("ro.build.version.codename") + ")";
|
||||
cr.annotateCrashReport("Android_Version", androidVersion);
|
||||
|
||||
SettingsListener.observe("deviceinfo.os", "", function(value) {
|
||||
try {
|
||||
let cr = Cc["@mozilla.org/xre/app-info;1"]
|
||||
.getService(Ci.nsICrashReporter);
|
||||
cr.annotateCrashReport("B2G_OS_Version", value);
|
||||
} catch(e) { }
|
||||
});
|
||||
#endif
|
||||
}
|
||||
} catch(e) {
|
||||
debugCrashReport('exception: ' + e);
|
||||
}
|
||||
|
@ -385,13 +381,15 @@ var shell = {
|
|||
systemAppFrame.setAttribute('allowfullscreen', 'true');
|
||||
systemAppFrame.setAttribute('src', 'blank.html');
|
||||
let container = document.getElementById('container');
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
// See shell.html
|
||||
let hotfix = document.getElementById('placeholder');
|
||||
if (hotfix) {
|
||||
container.removeChild(hotfix);
|
||||
|
||||
if (AppConstants.platform == 'macosx') {
|
||||
// See shell.html
|
||||
let hotfix = document.getElementById('placeholder');
|
||||
if (hotfix) {
|
||||
container.removeChild(hotfix);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
this.contentBrowser = container.appendChild(systemAppFrame);
|
||||
|
||||
let webNav = systemAppFrame.contentWindow
|
||||
|
@ -399,9 +397,9 @@ var shell = {
|
|||
.getInterface(Ci.nsIWebNavigation);
|
||||
webNav.sessionHistory = Cc["@mozilla.org/browser/shistory;1"].createInstance(Ci.nsISHistory);
|
||||
|
||||
#ifdef MOZ_GRAPHENE
|
||||
webNav.QueryInterface(Ci.nsIDocShell).windowDraggingAllowed = true;
|
||||
#endif
|
||||
if (AppConstants.MOZ_GRAPHENE) {
|
||||
webNav.QueryInterface(Ci.nsIDocShell).windowDraggingAllowed = true;
|
||||
}
|
||||
|
||||
let audioChannels = systemAppFrame.allowedAudioChannels;
|
||||
audioChannels && audioChannels.forEach(function(audioChannel) {
|
||||
|
@ -451,11 +449,12 @@ var shell = {
|
|||
ppmm.addMessageListener("sms-handler", this);
|
||||
ppmm.addMessageListener("mail-handler", this);
|
||||
ppmm.addMessageListener("file-picker", this);
|
||||
#ifdef MOZ_SAFE_BROWSING
|
||||
setTimeout(function() {
|
||||
SafeBrowsing.init();
|
||||
}, 5000);
|
||||
#endif
|
||||
|
||||
if (AppConstants.MOZ_SAFE_BROWSING) {
|
||||
setTimeout(function() {
|
||||
SafeBrowsing.init();
|
||||
}, 5000);
|
||||
}
|
||||
},
|
||||
|
||||
stop: function shell_stop() {
|
||||
|
@ -754,45 +753,40 @@ var shell = {
|
|||
|
||||
Services.obs.notifyObservers(null, 'content-start', null);
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
Cu.import('resource://gre/modules/OperatorApps.jsm');
|
||||
#endif
|
||||
isGonk && Cu.import('resource://gre/modules/OperatorApps.jsm');
|
||||
|
||||
#ifdef MOZ_GRAPHENE
|
||||
if (Services.prefs.getBoolPref("b2g.nativeWindowGeometry.fullscreen")) {
|
||||
if (AppConstants.MOZ_GRAPHENE &&
|
||||
Services.prefs.getBoolPref("b2g.nativeWindowGeometry.fullscreen")) {
|
||||
window.fullScreen = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
shell.handleCmdLine();
|
||||
},
|
||||
|
||||
handleCmdLine: function() {
|
||||
// This isn't supported on devices.
|
||||
#ifndef ANDROID
|
||||
let b2gcmds = Cc["@mozilla.org/commandlinehandler/general-startup;1?type=b2gcmds"]
|
||||
.getService(Ci.nsISupports);
|
||||
let args = b2gcmds.wrappedJSObject.cmdLine;
|
||||
try {
|
||||
// Returns null if -url is not present.
|
||||
let url = args.handleFlagWithParam("url", false);
|
||||
if (url) {
|
||||
this.sendChromeEvent({type: "mozbrowseropenwindow", url});
|
||||
args.preventDefault = true;
|
||||
// This isn't supported on devices.
|
||||
if (!isGonk && !AppConstants.MOZ_B2GDROID) {
|
||||
let b2gcmds = Cc["@mozilla.org/commandlinehandler/general-startup;1?type=b2gcmds"]
|
||||
.getService(Ci.nsISupports);
|
||||
let args = b2gcmds.wrappedJSObject.cmdLine;
|
||||
try {
|
||||
// Returns null if -url is not present.
|
||||
let url = args.handleFlagWithParam("url", false);
|
||||
if (url) {
|
||||
this.sendChromeEvent({type: "mozbrowseropenwindow", url});
|
||||
args.preventDefault = true;
|
||||
}
|
||||
} catch(e) {
|
||||
// Throws if -url is present with no params.
|
||||
}
|
||||
} catch(e) {
|
||||
// Throws if -url is present with no params.
|
||||
}
|
||||
#endif
|
||||
},
|
||||
|
||||
// This gets called when window.onload fires on the System app content window,
|
||||
// which means things in <html> are parsed and statically referenced <script>s
|
||||
// and <script defer>s are loaded and run.
|
||||
notifyContentWindowLoaded: function shell_notifyContentWindowLoaded() {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
libcutils.property_set('sys.boot_completed', '1');
|
||||
#endif
|
||||
isGonk && libcutils.property_set('sys.boot_completed', '1');
|
||||
|
||||
// This will cause Gonk Widget to remove boot animation from the screen
|
||||
// and reveals the page.
|
||||
|
@ -1124,7 +1118,10 @@ window.addEventListener('ContentStart', function update_onContentStart() {
|
|||
Cu.import('resource://gre/modules/WebappsUpdater.jsm');
|
||||
WebappsUpdater.handleContentStart(shell);
|
||||
|
||||
#ifdef MOZ_UPDATER
|
||||
if (!AppConstants.MOZ_UPDATER) {
|
||||
return;
|
||||
}
|
||||
|
||||
let promptCc = Cc["@mozilla.org/updates/update-prompt;1"];
|
||||
if (!promptCc) {
|
||||
return;
|
||||
|
@ -1136,7 +1133,6 @@ window.addEventListener('ContentStart', function update_onContentStart() {
|
|||
}
|
||||
|
||||
updatePrompt.wrappedJSObject.handleContentStart(shell);
|
||||
#endif
|
||||
});
|
||||
|
||||
(function geolocationStatusTracker() {
|
||||
|
@ -1313,36 +1309,34 @@ window.addEventListener('ContentStart', function update_onContentStart() {
|
|||
}, 'volume-state-changed', false);
|
||||
})();
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// Devices don't have all the same partition size for /cache where we
|
||||
// store the http cache.
|
||||
(function setHTTPCacheSize() {
|
||||
let path = Services.prefs.getCharPref("browser.cache.disk.parent_directory");
|
||||
let volumeService = Cc["@mozilla.org/telephony/volume-service;1"]
|
||||
.getService(Ci.nsIVolumeService);
|
||||
if (isGonk) {
|
||||
// Devices don't have all the same partition size for /cache where we
|
||||
// store the http cache.
|
||||
(function setHTTPCacheSize() {
|
||||
let path = Services.prefs.getCharPref("browser.cache.disk.parent_directory");
|
||||
let volumeService = Cc["@mozilla.org/telephony/volume-service;1"]
|
||||
.getService(Ci.nsIVolumeService);
|
||||
|
||||
let stats = volumeService.createOrGetVolumeByPath(path).getStats();
|
||||
let stats = volumeService.createOrGetVolumeByPath(path).getStats();
|
||||
|
||||
// We must set the size in KB, and keep a bit of free space.
|
||||
let size = Math.floor(stats.totalBytes / 1024) - 1024;
|
||||
// We must set the size in KB, and keep a bit of free space.
|
||||
let size = Math.floor(stats.totalBytes / 1024) - 1024;
|
||||
|
||||
// keep the default value if it is smaller than the physical partition size.
|
||||
let oldSize = Services.prefs.getIntPref("browser.cache.disk.capacity");
|
||||
if (size < oldSize) {
|
||||
Services.prefs.setIntPref("browser.cache.disk.capacity", size);
|
||||
// keep the default value if it is smaller than the physical partition size.
|
||||
let oldSize = Services.prefs.getIntPref("browser.cache.disk.capacity");
|
||||
if (size < oldSize) {
|
||||
Services.prefs.setIntPref("browser.cache.disk.capacity", size);
|
||||
}
|
||||
})();
|
||||
|
||||
try {
|
||||
let gmpService = Cc["@mozilla.org/gecko-media-plugin-service;1"]
|
||||
.getService(Ci.mozIGeckoMediaPluginChromeService);
|
||||
gmpService.addPluginDirectory("/system/b2g/gmp-clearkey/0.1");
|
||||
} catch(e) {
|
||||
dump("Failed to add clearkey path! " + e + "\n");
|
||||
}
|
||||
})();
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
try {
|
||||
let gmpService = Cc["@mozilla.org/gecko-media-plugin-service;1"]
|
||||
.getService(Ci.mozIGeckoMediaPluginChromeService);
|
||||
gmpService.addPluginDirectory("/system/b2g/gmp-clearkey/0.1");
|
||||
} catch(e) {
|
||||
dump("Failed to add clearkey path! " + e + "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Calling this observer will cause a shutdown an a profile reset.
|
||||
// Use eg. : Services.obs.notifyObservers(null, 'b2g-reset-profile', null);
|
||||
|
@ -1353,42 +1347,42 @@ Services.obs.addObserver(function resetProfile(subject, topic, data) {
|
|||
// sequence, but still has xpcom access.
|
||||
Services.obs.addObserver(function clearProfile(subject, topic, data) {
|
||||
Services.obs.removeObserver(clearProfile, topic);
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
let json = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
|
||||
json.initWithPath('/system/b2g/webapps/webapps.json');
|
||||
let toRemove = json.exists()
|
||||
// This is a user build, just rm -r /data/local /data/b2g/mozilla
|
||||
? ['/data/local', '/data/b2g/mozilla']
|
||||
// This is an eng build. We clear the profile and a set of files
|
||||
// under /data/local.
|
||||
: ['/data/b2g/mozilla',
|
||||
'/data/local/permissions.sqlite',
|
||||
'/data/local/storage',
|
||||
'/data/local/OfflineCache'];
|
||||
if (isGonk) {
|
||||
let json = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
|
||||
json.initWithPath('/system/b2g/webapps/webapps.json');
|
||||
let toRemove = json.exists()
|
||||
// This is a user build, just rm -r /data/local /data/b2g/mozilla
|
||||
? ['/data/local', '/data/b2g/mozilla']
|
||||
// This is an eng build. We clear the profile and a set of files
|
||||
// under /data/local.
|
||||
: ['/data/b2g/mozilla',
|
||||
'/data/local/permissions.sqlite',
|
||||
'/data/local/storage',
|
||||
'/data/local/OfflineCache'];
|
||||
|
||||
toRemove.forEach(function(dir) {
|
||||
try {
|
||||
let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
|
||||
file.initWithPath(dir);
|
||||
file.remove(true);
|
||||
} catch(e) { dump(e); }
|
||||
});
|
||||
#else
|
||||
// Desktop builds.
|
||||
let profile = Services.dirsvc.get('ProfD', Ci.nsIFile);
|
||||
toRemove.forEach(function(dir) {
|
||||
try {
|
||||
let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
|
||||
file.initWithPath(dir);
|
||||
file.remove(true);
|
||||
} catch(e) { dump(e); }
|
||||
});
|
||||
} else {
|
||||
// Desktop builds.
|
||||
let profile = Services.dirsvc.get('ProfD', Ci.nsIFile);
|
||||
|
||||
// We don't want to remove everything from the profile, since this
|
||||
// would prevent us from starting up.
|
||||
let whitelist = ['defaults', 'extensions', 'settings.json',
|
||||
'user.js', 'webapps'];
|
||||
let enumerator = profile.directoryEntries;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let file = enumerator.getNext().QueryInterface(Ci.nsIFile);
|
||||
if (whitelist.indexOf(file.leafName) == -1) {
|
||||
file.remove(true);
|
||||
// We don't want to remove everything from the profile, since this
|
||||
// would prevent us from starting up.
|
||||
let whitelist = ['defaults', 'extensions', 'settings.json',
|
||||
'user.js', 'webapps'];
|
||||
let enumerator = profile.directoryEntries;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let file = enumerator.getNext().QueryInterface(Ci.nsIFile);
|
||||
if (whitelist.indexOf(file.leafName) == -1) {
|
||||
file.remove(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
},
|
||||
'profile-before-change2', false);
|
||||
|
||||
|
@ -1397,63 +1391,61 @@ Services.obs.addObserver(function resetProfile(subject, topic, data) {
|
|||
appStartup.quit(Ci.nsIAppStartup.eForceQuit);
|
||||
}, 'b2g-reset-profile', false);
|
||||
|
||||
#ifdef MOZ_GRAPHENE
|
||||
if (AppConstants.MOZ_GRAPHENE) {
|
||||
const restoreWindowGeometry = () => {
|
||||
let screenX = Services.prefs.getIntPref("b2g.nativeWindowGeometry.screenX");
|
||||
let screenY = Services.prefs.getIntPref("b2g.nativeWindowGeometry.screenY");
|
||||
let width = Services.prefs.getIntPref("b2g.nativeWindowGeometry.width");
|
||||
let height = Services.prefs.getIntPref("b2g.nativeWindowGeometry.height");
|
||||
|
||||
const restoreWindowGeometry = () => {
|
||||
let screenX = Services.prefs.getIntPref("b2g.nativeWindowGeometry.screenX");
|
||||
let screenY = Services.prefs.getIntPref("b2g.nativeWindowGeometry.screenY");
|
||||
let width = Services.prefs.getIntPref("b2g.nativeWindowGeometry.width");
|
||||
let height = Services.prefs.getIntPref("b2g.nativeWindowGeometry.height");
|
||||
if (screenX == -1) {
|
||||
// Center
|
||||
screenX = (screen.width - width) / 2;
|
||||
screenY = (screen.height - height) / 2;
|
||||
}
|
||||
|
||||
if (screenX == -1) {
|
||||
// Center
|
||||
screenX = (screen.width - width) / 2;
|
||||
screenY = (screen.height - height) / 2;
|
||||
moveTo(screenX, screenY);
|
||||
resizeTo(width, height);
|
||||
}
|
||||
restoreWindowGeometry();
|
||||
|
||||
const saveWindowGeometry = () => {
|
||||
window.removeEventListener("unload", saveWindowGeometry);
|
||||
Services.prefs.setIntPref("b2g.nativeWindowGeometry.screenX", screenX);
|
||||
Services.prefs.setIntPref("b2g.nativeWindowGeometry.screenY", screenY);
|
||||
Services.prefs.setIntPref("b2g.nativeWindowGeometry.width", outerWidth);
|
||||
Services.prefs.setIntPref("b2g.nativeWindowGeometry.height", outerHeight);
|
||||
}
|
||||
window.addEventListener("unload", saveWindowGeometry);
|
||||
|
||||
var baseWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIBaseWindow);
|
||||
|
||||
const showNativeWindow = () => baseWindow.visibility = true;
|
||||
const hideNativeWindow = () => baseWindow.visibility = false;
|
||||
|
||||
const showInstallScreen = () => {
|
||||
const grapheneStrings =
|
||||
Services.strings.createBundle('chrome://b2g-l10n/locale/graphene.properties');
|
||||
document.querySelector('#installing > .message').textContent =
|
||||
grapheneStrings.GetStringFromName('installing');
|
||||
showNativeWindow();
|
||||
}
|
||||
|
||||
moveTo(screenX, screenY);
|
||||
resizeTo(width, height);
|
||||
}
|
||||
restoreWindowGeometry();
|
||||
const hideInstallScreen = () => {
|
||||
document.body.classList.add('content-loaded');
|
||||
}
|
||||
|
||||
const saveWindowGeometry = () => {
|
||||
window.removeEventListener("unload", saveWindowGeometry);
|
||||
Services.prefs.setIntPref("b2g.nativeWindowGeometry.screenX", screenX);
|
||||
Services.prefs.setIntPref("b2g.nativeWindowGeometry.screenY", screenY);
|
||||
Services.prefs.setIntPref("b2g.nativeWindowGeometry.width", outerWidth);
|
||||
Services.prefs.setIntPref("b2g.nativeWindowGeometry.height", outerHeight);
|
||||
}
|
||||
window.addEventListener("unload", saveWindowGeometry);
|
||||
|
||||
var baseWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIBaseWindow);
|
||||
|
||||
const showNativeWindow = () => baseWindow.visibility = true;
|
||||
const hideNativeWindow = () => baseWindow.visibility = false;
|
||||
|
||||
const showInstallScreen = () => {
|
||||
const grapheneStrings =
|
||||
Services.strings.createBundle('chrome://b2g-l10n/locale/graphene.properties');
|
||||
document.querySelector('#installing > .message').textContent =
|
||||
grapheneStrings.GetStringFromName('installing');
|
||||
showNativeWindow();
|
||||
}
|
||||
|
||||
const hideInstallScreen = () => {
|
||||
document.body.classList.add('content-loaded');
|
||||
}
|
||||
|
||||
window.addEventListener('ContentStart', () => {
|
||||
shell.contentBrowser.contentWindow.addEventListener('load', () => {
|
||||
hideInstallScreen();
|
||||
showNativeWindow();
|
||||
window.addEventListener('ContentStart', () => {
|
||||
shell.contentBrowser.contentWindow.addEventListener('load', () => {
|
||||
hideInstallScreen();
|
||||
showNativeWindow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
hideNativeWindow();
|
||||
|
||||
#endif
|
||||
hideNativeWindow();
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ chrome.jar:
|
|||
% content b2g %content/
|
||||
|
||||
content/arrow.svg (content/arrow.svg)
|
||||
* content/settings.js (content/settings.js)
|
||||
content/settings.js (content/settings.js)
|
||||
* content/shell.html (content/shell.html)
|
||||
* content/shell.js (content/shell.js)
|
||||
content/shell.js (content/shell.js)
|
||||
content/shell_remote.html (content/shell_remote.html)
|
||||
content/shell_remote.js (content/shell_remote.js)
|
||||
* content/shell.css (content/shell.css)
|
||||
|
@ -20,7 +20,7 @@ chrome.jar:
|
|||
#ifdef MOZ_WIDGET_GONK
|
||||
content/devtools/adb.js (content/devtools/adb.js)
|
||||
#endif
|
||||
* content/devtools/debugger.js (content/devtools/debugger.js)
|
||||
content/devtools/debugger.js (content/devtools/debugger.js)
|
||||
content/devtools/hud.js (content/devtools/hud.js)
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
content/desktop.css (content/desktop.css)
|
||||
|
|
|
@ -9,6 +9,7 @@ const Cr = Components.results;
|
|||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
const XRE_OS_UPDATE_APPLY_TO_DIR = "OSUpdApplyToD"
|
||||
const UPDATE_ARCHIVE_DIR = "UpdArchD"
|
||||
|
@ -57,8 +58,14 @@ DirectoryProvider.prototype = {
|
|||
|
||||
_profD: null,
|
||||
|
||||
getFile: function dp_getFile(prop, persistent) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
getFile: function(prop, persistent) {
|
||||
if (AppConstants.platform === "gonk") {
|
||||
return this.getFileOnGonk(prop, persistent);
|
||||
}
|
||||
return this.getFileNotGonk(prop, persistent);
|
||||
},
|
||||
|
||||
getFileOnGonk: function(prop, persistent) {
|
||||
let localProps = ["cachePDir", "webappsDir", "PrefD", "indexedDBPDir",
|
||||
"permissionDBPDir", "UpdRootD"];
|
||||
if (localProps.indexOf(prop) != -1) {
|
||||
|
@ -97,7 +104,10 @@ DirectoryProvider.prototype = {
|
|||
// before apply, check if free space is 1.1 times of update.mar
|
||||
return this.getUpdateDir(persistent, FOTA_DIR, 1.1);
|
||||
}
|
||||
#else
|
||||
return null;
|
||||
},
|
||||
|
||||
getFileNotGonk: function(prop, persistent) {
|
||||
// In desktop builds, coreAppsDir is the same as the profile
|
||||
// directory unless otherwise specified. We just need to get the
|
||||
// path from the parent, and it is then used to build
|
||||
|
@ -137,7 +147,6 @@ DirectoryProvider.prototype = {
|
|||
persistent.value = true;
|
||||
return file;
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
},
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ HelperAppLauncherDialog.prototype = {
|
|||
aSuggestedFileExt,
|
||||
aForcePrompt) {
|
||||
// Retrieve the user's default download directory.
|
||||
Task.spawn(function() {
|
||||
Task.spawn(function*() {
|
||||
let file = null;
|
||||
try {
|
||||
let defaultFolder = yield Downloads.getPreferredDownloadsDirectory();
|
||||
|
|
|
@ -10,6 +10,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise", "resource://gre/modules/Promise.jsm");
|
||||
|
@ -27,14 +28,14 @@ XPCOMUtils.defineLazyGetter(this, "permMgr", function() {
|
|||
.getService(Ci.nsIPermissionManager);
|
||||
});
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
XPCOMUtils.defineLazyGetter(this, "libcutils", function () {
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
return libcutils;
|
||||
});
|
||||
#else
|
||||
this.libcutils = null;
|
||||
#endif
|
||||
if (AppConstants.platform === "gonk") {
|
||||
XPCOMUtils.defineLazyGetter(this, "libcutils", function () {
|
||||
Cu.import("resource://gre/modules/systemlibs.js");
|
||||
return libcutils;
|
||||
});
|
||||
} else {
|
||||
this.libcutils = null;
|
||||
}
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/ctypes.jsm");
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
const RECOVERYSERVICE_CID = Components.ID("{b3caca5d-0bb0-48c6-912b-6be6cbf08832}");
|
||||
const RECOVERYSERVICE_CONTRACTID = "@mozilla.org/recovery-service;1";
|
||||
|
@ -17,43 +18,45 @@ function log(msg) {
|
|||
dump("-*- RecoveryService: " + msg + "\n");
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
var librecovery = (function() {
|
||||
let library;
|
||||
try {
|
||||
library = ctypes.open("librecovery.so");
|
||||
} catch (e) {
|
||||
log("Unable to open librecovery.so");
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
// Bug 1163956, modify updatePath from ctyps.char.ptr to ctype.char.array(4096)
|
||||
// align with librecovery.h. 4096 comes from PATH_MAX
|
||||
let FotaUpdateStatus = new ctypes.StructType("FotaUpdateStatus", [
|
||||
{ result: ctypes.int },
|
||||
{ updatePath: ctypes.char.array(4096) }
|
||||
]);
|
||||
const isGonk = AppConstants.platform === 'gonk';
|
||||
|
||||
return {
|
||||
factoryReset: library.declare("factoryReset",
|
||||
ctypes.default_abi,
|
||||
ctypes.int),
|
||||
installFotaUpdate: library.declare("installFotaUpdate",
|
||||
ctypes.default_abi,
|
||||
ctypes.int,
|
||||
ctypes.char.ptr,
|
||||
ctypes.int),
|
||||
if (isGonk) {
|
||||
var librecovery = (function() {
|
||||
let library;
|
||||
try {
|
||||
library = ctypes.open("librecovery.so");
|
||||
} catch (e) {
|
||||
log("Unable to open librecovery.so");
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
// Bug 1163956, modify updatePath from ctyps.char.ptr to ctype.char.array(4096)
|
||||
// align with librecovery.h. 4096 comes from PATH_MAX
|
||||
let FotaUpdateStatus = new ctypes.StructType("FotaUpdateStatus", [
|
||||
{ result: ctypes.int },
|
||||
{ updatePath: ctypes.char.array(4096) }
|
||||
]);
|
||||
|
||||
FotaUpdateStatus: FotaUpdateStatus,
|
||||
getFotaUpdateStatus: library.declare("getFotaUpdateStatus",
|
||||
ctypes.default_abi,
|
||||
ctypes.int,
|
||||
FotaUpdateStatus.ptr)
|
||||
};
|
||||
})();
|
||||
return {
|
||||
factoryReset: library.declare("factoryReset",
|
||||
ctypes.default_abi,
|
||||
ctypes.int),
|
||||
installFotaUpdate: library.declare("installFotaUpdate",
|
||||
ctypes.default_abi,
|
||||
ctypes.int,
|
||||
ctypes.char.ptr,
|
||||
ctypes.int),
|
||||
|
||||
const gFactoryResetFile = "__post_reset_cmd__";
|
||||
FotaUpdateStatus: FotaUpdateStatus,
|
||||
getFotaUpdateStatus: library.declare("getFotaUpdateStatus",
|
||||
ctypes.default_abi,
|
||||
ctypes.int,
|
||||
FotaUpdateStatus.ptr)
|
||||
};
|
||||
})();
|
||||
|
||||
#endif
|
||||
const gFactoryResetFile = "__post_reset_cmd__";
|
||||
|
||||
}
|
||||
|
||||
function RecoveryService() {}
|
||||
|
||||
|
@ -68,7 +71,10 @@ RecoveryService.prototype = {
|
|||
}),
|
||||
|
||||
factoryReset: function RS_factoryReset(reason) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (!isGonk) {
|
||||
Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
function doReset() {
|
||||
// If this succeeds, then the device reboots and this never returns
|
||||
if (librecovery.factoryReset() != 0) {
|
||||
|
@ -119,12 +125,13 @@ RecoveryService.prototype = {
|
|||
} else {
|
||||
doReset();
|
||||
}
|
||||
#endif
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
},
|
||||
|
||||
installFotaUpdate: function RS_installFotaUpdate(updatePath) {
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (!isGonk) {
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// If this succeeds, then the device reboots and this never returns
|
||||
if (librecovery.installFotaUpdate(updatePath, updatePath.length) != 0) {
|
||||
log("Error: FOTA install failed. Trying again after clearing cache.");
|
||||
|
@ -134,20 +141,18 @@ RecoveryService.prototype = {
|
|||
if (librecovery.installFotaUpdate(updatePath, updatePath.length) != 0) {
|
||||
log("Error: FOTA install failed again");
|
||||
}
|
||||
#endif
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
},
|
||||
|
||||
getFotaUpdateStatus: function RS_getFotaUpdateStatus() {
|
||||
let status = Ci.nsIRecoveryService.FOTA_UPDATE_UNKNOWN;
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
let cStatus = librecovery.FotaUpdateStatus();
|
||||
|
||||
if (librecovery.getFotaUpdateStatus(cStatus.address()) == 0) {
|
||||
status = cStatus.result;
|
||||
if (isGonk) {
|
||||
let cStatus = librecovery.FotaUpdateStatus();
|
||||
|
||||
if (librecovery.getFotaUpdateStatus(cStatus.address()) == 0) {
|
||||
status = cStatus.result;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,6 +13,7 @@ const Cr = Components.results;
|
|||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/WebappsUpdater.jsm");
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
const VERBOSE = 1;
|
||||
var log =
|
||||
|
@ -399,30 +400,30 @@ UpdatePrompt.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
let window = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let pinReq = window.navigator.mozIccManager.getCardLock("pin");
|
||||
pinReq.onsuccess = function(e) {
|
||||
if (e.target.result.enabled) {
|
||||
// The SIM is pin locked. Don't use a fallback timer. This means that
|
||||
// the user has to press Install to apply the update. If we use the
|
||||
// timer, and the timer reboots the phone, then the phone will be
|
||||
// unusable until the SIM is unlocked.
|
||||
log("SIM is pin locked. Not starting fallback timer.");
|
||||
} else {
|
||||
// This means that no pin lock is enabled, so we go ahead and start
|
||||
// the fallback timer.
|
||||
if (AppConstants.MOZ_B2G_RIL) {
|
||||
let window = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let pinReq = window.navigator.mozIccManager.getCardLock("pin");
|
||||
pinReq.onsuccess = function(e) {
|
||||
if (e.target.result.enabled) {
|
||||
// The SIM is pin locked. Don't use a fallback timer. This means that
|
||||
// the user has to press Install to apply the update. If we use the
|
||||
// timer, and the timer reboots the phone, then the phone will be
|
||||
// unusable until the SIM is unlocked.
|
||||
log("SIM is pin locked. Not starting fallback timer.");
|
||||
} else {
|
||||
// This means that no pin lock is enabled, so we go ahead and start
|
||||
// the fallback timer.
|
||||
this._applyPromptTimer = this.createTimer(this.applyPromptTimeout);
|
||||
}
|
||||
}.bind(this);
|
||||
pinReq.onerror = function(e) {
|
||||
this._applyPromptTimer = this.createTimer(this.applyPromptTimeout);
|
||||
}
|
||||
}.bind(this);
|
||||
pinReq.onerror = function(e) {
|
||||
}.bind(this);
|
||||
} else {
|
||||
// Schedule a fallback timeout in case the UI is unable to respond or show
|
||||
// a prompt for some reason.
|
||||
this._applyPromptTimer = this.createTimer(this.applyPromptTimeout);
|
||||
}.bind(this);
|
||||
#else
|
||||
// Schedule a fallback timeout in case the UI is unable to respond or show
|
||||
// a prompt for some reason.
|
||||
this._applyPromptTimer = this.createTimer(this.applyPromptTimeout);
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
_copyProperties: ["appVersion", "buildID", "detailsURL", "displayVersion",
|
||||
|
@ -553,16 +554,16 @@ UpdatePrompt.prototype = {
|
|||
log("Update downloaded, restarting to apply it");
|
||||
|
||||
let callbackAfterSet = function() {
|
||||
#ifndef MOZ_WIDGET_GONK
|
||||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Ci.nsIAppStartup);
|
||||
appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
|
||||
#else
|
||||
// NB: on Gonk, we rely on the system process manager to restart us.
|
||||
let pmService = Cc["@mozilla.org/power/powermanagerservice;1"]
|
||||
.getService(Ci.nsIPowerManagerService);
|
||||
pmService.restart();
|
||||
#endif
|
||||
if (AppConstants.platform !== "gonk") {
|
||||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Ci.nsIAppStartup);
|
||||
appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
|
||||
} else {
|
||||
// NB: on Gonk, we rely on the system process manager to restart us.
|
||||
let pmService = Cc["@mozilla.org/power/powermanagerservice;1"]
|
||||
.getService(Ci.nsIPowerManagerService);
|
||||
pmService.restart();
|
||||
}
|
||||
}
|
||||
|
||||
if (useSettings()) {
|
||||
|
|
|
@ -44,13 +44,13 @@ EXTRA_PP_COMPONENTS += [
|
|||
]
|
||||
|
||||
if CONFIG['MOZ_B2G'] and not CONFIG['MOZ_B2GDROID']:
|
||||
EXTRA_PP_COMPONENTS += [
|
||||
EXTRA_COMPONENTS += [
|
||||
'DirectoryProvider.js',
|
||||
'RecoveryService.js',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_UPDATER']:
|
||||
EXTRA_PP_COMPONENTS += [
|
||||
EXTRA_COMPONENTS += [
|
||||
'UpdatePrompt.js',
|
||||
]
|
||||
|
||||
|
@ -64,6 +64,7 @@ EXTRA_JS_MODULES += [
|
|||
'ErrorPage.jsm',
|
||||
'Frames.jsm',
|
||||
'FxAccountsMgmtService.jsm',
|
||||
'KillSwitchMain.jsm',
|
||||
'LogCapture.jsm',
|
||||
'LogParser.jsm',
|
||||
'LogShake.jsm',
|
||||
|
@ -77,10 +78,6 @@ EXTRA_JS_MODULES += [
|
|||
'WebappsUpdater.jsm',
|
||||
]
|
||||
|
||||
EXTRA_PP_JS_MODULES += [
|
||||
'KillSwitchMain.jsm'
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
|
||||
EXTRA_JS_MODULES += [
|
||||
'GlobalSimulatorScreen.jsm'
|
||||
|
|
|
@ -94,6 +94,13 @@ this.AppConstants = Object.freeze({
|
|||
false,
|
||||
#endif
|
||||
|
||||
MOZ_TELEMETRY_ON_BY_DEFAULT:
|
||||
#ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
|
||||
MOZ_SERVICES_CLOUDSYNC:
|
||||
#ifdef MOZ_SERVICES_CLOUDSYNC
|
||||
true,
|
||||
|
@ -198,8 +205,8 @@ this.AppConstants = Object.freeze({
|
|||
false,
|
||||
#endif
|
||||
|
||||
MOZ_B2G:
|
||||
#ifdef MOZ_B2G
|
||||
MOZ_B2G_RIL:
|
||||
#ifdef MOZ_B2G_RIL
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
|
@ -212,6 +219,13 @@ this.AppConstants = Object.freeze({
|
|||
false,
|
||||
#endif
|
||||
|
||||
MOZ_GRAPHENE:
|
||||
#ifdef MOZ_GRAPHENE
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
|
||||
MOZ_PLACES:
|
||||
#ifdef MOZ_PLACES
|
||||
true,
|
||||
|
@ -237,6 +251,8 @@ this.AppConstants = Object.freeze({
|
|||
INSTALL_LOCALE: "@AB_CD@",
|
||||
MOZ_WIDGET_TOOLKIT: "@MOZ_WIDGET_TOOLKIT@",
|
||||
ANDROID_PACKAGE_NAME: "@ANDROID_PACKAGE_NAME@",
|
||||
MOZ_B2G_VERSION: @MOZ_B2G_VERSION@,
|
||||
MOZ_B2G_OS_NAME: @MOZ_B2G_OS_NAME@,
|
||||
|
||||
MOZ_ANDROID_APZ:
|
||||
#ifdef MOZ_ANDROID_APZ
|
||||
|
|
Загрузка…
Ссылка в новой задаче