mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Merge b-i to m-c
This commit is contained in:
commit
361e1fc9d9
@ -125,6 +125,9 @@ function initResponsiveDesign() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable transition as they mess up with screen size handler
|
||||
responsive.transitionsEnabled = false;
|
||||
|
||||
responsive.buildPhoneUI();
|
||||
|
||||
responsive.rotatebutton.addEventListener('command', function (evt) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let isMulet = "ResponsiveUI" in browserWindow;
|
||||
Cu.import("resource://gre/modules/GlobalSimulatorScreen.jsm");
|
||||
|
||||
// We do this on ContentStart because querying the displayDPI fails otherwise.
|
||||
window.addEventListener('ContentStart', function() {
|
||||
@ -98,26 +99,18 @@ window.addEventListener('ContentStart', function() {
|
||||
return;
|
||||
}
|
||||
|
||||
let rescale = false;
|
||||
|
||||
// If the value of --screen ends with !, we'll be scaling the output
|
||||
if (screenarg[screenarg.length - 1] === '!') {
|
||||
rescale = true;
|
||||
screenarg = screenarg.substring(0, screenarg.length-1);
|
||||
}
|
||||
|
||||
let width, height, dpi;
|
||||
let width, height, ratio = 1.0;
|
||||
|
||||
if (screenarg in screens) {
|
||||
// If this is a named screen, get its data
|
||||
let screen = screens[screenarg];
|
||||
width = screen.width;
|
||||
height = screen.height;
|
||||
dpi = screen.dpi;
|
||||
ratio = screen.ratio;
|
||||
} else {
|
||||
// Otherwise, parse the resolution and density from the --screen value.
|
||||
// The supported syntax is WIDTHxHEIGHT[@DPI]
|
||||
let match = screenarg.match(/^(\d+)x(\d+)(@(\d+))?$/);
|
||||
let match = screenarg.match(/^(\d+)x(\d+)(@(\d+(\.\d+)?))?$/);
|
||||
|
||||
// Display usage information on syntax errors
|
||||
if (match == null)
|
||||
@ -127,17 +120,15 @@ window.addEventListener('ContentStart', function() {
|
||||
width = parseInt(match[1], 10);
|
||||
height = parseInt(match[2], 10);
|
||||
if (match[4])
|
||||
dpi = parseInt(match[4], 10);
|
||||
else // If no DPI, use the actual dpi of the host screen
|
||||
dpi = hostDPI;
|
||||
ratio = parseFloat(match[4], 10);
|
||||
|
||||
// If any of the values came out 0 or NaN or undefined, display usage
|
||||
if (!width || !height || !dpi)
|
||||
if (!width || !height || !ratio) {
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
Cu.import("resource://gre/modules/GlobalSimulatorScreen.jsm");
|
||||
function resize(width, height, dpi, shouldFlip) {
|
||||
function resize(width, height, ratio, shouldFlip) {
|
||||
GlobalSimulatorScreen.width = width;
|
||||
GlobalSimulatorScreen.height = height;
|
||||
|
||||
@ -145,7 +136,7 @@ window.addEventListener('ContentStart', function() {
|
||||
// width and height, and then use a CSS transform to scale it so that
|
||||
// it appears at the correct size on the host display. We also set
|
||||
// the size of the <window> element to that scaled target size.
|
||||
let scale = rescale ? hostDPI / dpi : 1;
|
||||
let scale = 1.0;
|
||||
|
||||
// Set the window width and height to desired size plus chrome
|
||||
// Include the size of the toolbox displayed under the system app
|
||||
@ -158,7 +149,7 @@ window.addEventListener('ContentStart', function() {
|
||||
let chromeheight = window.outerHeight - window.innerHeight + controlsHeight;
|
||||
if (isMulet) {
|
||||
let responsive = browserWindow.gBrowser.selectedTab.__responsiveUI;
|
||||
responsive.setSize((Math.round(width * scale) + 14*2),
|
||||
responsive.setSize((Math.round(width * scale) + 16*2),
|
||||
(Math.round(height * scale) + controlsHeight + 61));
|
||||
} else {
|
||||
window.resizeTo(Math.round(width * scale) + chromewidth,
|
||||
@ -173,20 +164,9 @@ window.addEventListener('ContentStart', function() {
|
||||
|
||||
// Set the browser element to the full unscaled size of the screen
|
||||
let style = browser.style;
|
||||
style.width = style.minWidth = style.maxWidth =
|
||||
frameWidth + 'px';
|
||||
style.height = style.minHeight = style.maxHeight =
|
||||
frameHeight + 'px';
|
||||
browser.setAttribute('flex', '0'); // Don't let it stretch
|
||||
|
||||
style.transformOrigin = '';
|
||||
style.transform = '';
|
||||
|
||||
// Now scale the browser element as needed
|
||||
if (scale !== 1) {
|
||||
style.transformOrigin = 'top left';
|
||||
style.transform += ' scale(' + scale + ',' + scale + ')';
|
||||
}
|
||||
style.height = 'calc(100% - ' + controlsHeight + 'px)';
|
||||
style.bottom = controlsHeight;
|
||||
|
||||
if (shouldFlip) {
|
||||
// Display the system app with a 90° clockwise rotation
|
||||
@ -195,16 +175,26 @@ window.addEventListener('ContentStart', function() {
|
||||
' rotate(0.25turn) translate(-' + shift + 'px, -' + shift + 'px)';
|
||||
}
|
||||
|
||||
// Set the pixel density that we want to simulate.
|
||||
// This doesn't change the on-screen size, but makes
|
||||
// CSS media queries and mozmm units work right.
|
||||
Services.prefs.setIntPref('layout.css.dpi', dpi);
|
||||
Services.prefs.setCharPref('layout.css.devPixelsPerPx', ratio);
|
||||
}
|
||||
|
||||
// Resize on startup
|
||||
resize(width, height, dpi, false);
|
||||
resize(width, height, ratio, false);
|
||||
|
||||
let defaultOrientation = width < height ? 'portrait' : 'landscape';
|
||||
GlobalSimulatorScreen.mozOrientation = GlobalSimulatorScreen.screenOrientation = defaultOrientation;
|
||||
|
||||
// Catch manual resizes to update the internal device size.
|
||||
window.onresize = function() {
|
||||
width = browser.clientWidth;
|
||||
height = browser.clientHeight;
|
||||
if ((defaultOrientation == 'portrait' && width > height) ||
|
||||
(defaultOrientation == 'landscape' && width < height)) {
|
||||
let w = width;
|
||||
width = height;
|
||||
height = w;
|
||||
}
|
||||
};
|
||||
|
||||
// Then resize on each rotation button click,
|
||||
// or when the system app lock/unlock the orientation
|
||||
@ -226,7 +216,7 @@ window.addEventListener('ContentStart', function() {
|
||||
// it is displayed rotated on the side
|
||||
let shouldFlip = mozOrientation != screenOrientation;
|
||||
|
||||
resize(newWidth, newHeight, dpi, shouldFlip);
|
||||
resize(newWidth, newHeight, ratio, shouldFlip);
|
||||
}, 'simulator-adjust-window-size', false);
|
||||
|
||||
// A utility function like console.log() for printing to the terminal window
|
||||
@ -256,12 +246,6 @@ window.addEventListener('ContentStart', function() {
|
||||
'\nYou can also specify certain device names:\n';
|
||||
for(let p in screens)
|
||||
msg += '\t--screen=' + p + '\t// ' + screens[p].name + '\n';
|
||||
msg +=
|
||||
'\nAdd a ! to the end of a screen specification to rescale the\n' +
|
||||
'screen so that it is shown at actual size on your monitor:\n' +
|
||||
'\t--screen=nexus_s!\n' +
|
||||
'\t--screen=320x480@200!\n'
|
||||
;
|
||||
|
||||
// Display the usage message
|
||||
print(msg);
|
||||
|
@ -290,7 +290,7 @@ var shell = {
|
||||
systemAppFrame.setAttribute('mozbrowser', 'true');
|
||||
systemAppFrame.setAttribute('mozapp', manifestURL);
|
||||
systemAppFrame.setAttribute('allowfullscreen', 'true');
|
||||
systemAppFrame.setAttribute('style', "overflow: hidden; height: 100%; width: 100%; border: none;");
|
||||
systemAppFrame.setAttribute('style', "overflow: hidden; height: 100%; width: 100%; border: none; position: absolute; left: 0; top: 0; right: 0; bottom: 0;");
|
||||
systemAppFrame.setAttribute('src', "data:text/html;charset=utf-8,%3C!DOCTYPE html>%3Cbody style='background:black;");
|
||||
let container = document.getElementById('container');
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="e0c735ec89df011ea7dd435087a9045ecff9ff9e">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
@ -129,7 +129,7 @@
|
||||
<!-- Stock Android things -->
|
||||
<project name="platform/external/icu4c" path="external/icu4c" revision="2bb01561780583cc37bc667f0ea79f48a122d8a2"/>
|
||||
<!-- dolphin specific things -->
|
||||
<project name="device/sprd" path="device/sprd" revision="14267a1ca51dcefe56d031245c6252c9d7402ce5"/>
|
||||
<project name="device/sprd" path="device/sprd" revision="a229a5650aab7ff9ce47d1ca2c998ffbf6119ed7"/>
|
||||
<project name="platform/external/wpa_supplicant_8" path="external/wpa_supplicant_8" revision="4e58336019b5cbcfd134caf55b142236cf986618"/>
|
||||
<project name="platform/frameworks/av" path="frameworks/av" revision="4387fe988e5a1001f29ce05fcfda03ed2d32137b"/>
|
||||
<project name="platform/hardware/akm" path="hardware/akm" revision="6d3be412647b0eab0adff8a2768736cf4eb68039"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d5d3f93914558b6f168447b805cd799c8233e300"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f11d3c6500659e3232fbe6fe7ea0204c40ab7fdd"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="e0c735ec89df011ea7dd435087a9045ecff9ff9e">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d5d3f93914558b6f168447b805cd799c8233e300"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<project name="platform_build" path="build" remote="b2g" revision="e0c735ec89df011ea7dd435087a9045ecff9ff9e">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f11d3c6500659e3232fbe6fe7ea0204c40ab7fdd"/>
|
||||
|
@ -4,6 +4,6 @@
|
||||
"remote": "",
|
||||
"branch": ""
|
||||
},
|
||||
"revision": "71b84df868bbdae9ebf334234db1660148c9741b",
|
||||
"revision": "c0d86bd82a03eb99343e4746ce0d2bba5ff4c8de",
|
||||
"repo_path": "integration/gaia-central"
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="f11d3c6500659e3232fbe6fe7ea0204c40ab7fdd"/>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cb1dad4881533bff9f06d47e34983c7b10c04a8c"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ab41c35eed35404b632a4841714b81b56364ba32"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="8aee09c106f479f36c57b2a29af72d455e359211"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
|
||||
|
@ -112,7 +112,7 @@ const MOBILE_DUN_RETRY_INTERVAL = 5000;
|
||||
const MOBILE_DUN_MAX_RETRIES = 5;
|
||||
|
||||
// Connection Type for Network Information API
|
||||
const CONNECTION_TYPE_CULLULAR = 0;
|
||||
const CONNECTION_TYPE_CELLULAR = 0;
|
||||
const CONNECTION_TYPE_BLUETOOTH = 1;
|
||||
const CONNECTION_TYPE_ETHERNET = 2;
|
||||
const CONNECTION_TYPE_WIFI = 3;
|
||||
@ -233,10 +233,9 @@ NetworkManager.prototype = {
|
||||
case TOPIC_XPCOM_SHUTDOWN:
|
||||
Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN);
|
||||
Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
||||
this.dunConnectTimer.cancel();
|
||||
this.dunRetryTimer.cancel();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
},
|
||||
@ -244,23 +243,20 @@ NetworkManager.prototype = {
|
||||
receiveMessage: function(aMsg) {
|
||||
switch (aMsg.name) {
|
||||
case "NetworkInterfaceList:ListInterface": {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
let excludeMms = aMsg.json.excludeMms;
|
||||
let excludeSupl = aMsg.json.excludeSupl;
|
||||
let excludeIms = aMsg.json.excludeIms;
|
||||
let excludeDun = aMsg.json.excludeDun;
|
||||
#endif
|
||||
let interfaces = [];
|
||||
|
||||
for each (let i in this.networkInterfaces) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if ((i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
|
||||
(i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL && excludeSupl) ||
|
||||
(i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS && excludeIms) ||
|
||||
(i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN && excludeDun)) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
let ips = {};
|
||||
let prefixLengths = {};
|
||||
i.getAddresses(ips, prefixLengths);
|
||||
@ -284,12 +280,12 @@ NetworkManager.prototype = {
|
||||
|
||||
getNetworkId: function(network) {
|
||||
let id = "device";
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (network instanceof Ci.nsIRilNetworkInterface) {
|
||||
let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
|
||||
id = "ril" + rilNetwork.serviceId;
|
||||
}
|
||||
#endif
|
||||
try {
|
||||
if (network instanceof Ci.nsIRilNetworkInterface) {
|
||||
let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
|
||||
id = "ril" + rilNetwork.serviceId;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return id + "-" + network.type;
|
||||
},
|
||||
@ -326,7 +322,6 @@ NetworkManager.prototype = {
|
||||
" changed state to " + network.state);
|
||||
switch (network.state) {
|
||||
case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED:
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Add host route for data calls
|
||||
if (this.isNetworkTypeMobile(network.type)) {
|
||||
gNetworkService.removeHostRoutes(network.name);
|
||||
@ -337,19 +332,17 @@ NetworkManager.prototype = {
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
|
||||
this.setSecondaryDefaultRoute(network);
|
||||
}
|
||||
#endif
|
||||
// Remove pre-created default route and let setAndConfigureActive()
|
||||
// to set default route only on preferred network
|
||||
gNetworkService.removeDefaultRoute(network);
|
||||
this.setAndConfigureActive();
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
||||
// Update data connection when Wifi connected/disconnected
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && this.mRil) {
|
||||
for (let i = 0; i < this.mRil.numRadioInterfaces; i++) {
|
||||
this.mRil.getRadioInterface(i).updateRILNetworkInterface();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
this.onConnectionChanged(network);
|
||||
|
||||
@ -358,46 +351,40 @@ NetworkManager.prototype = {
|
||||
.notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active);
|
||||
break;
|
||||
case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED:
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Remove host route for data calls
|
||||
if (this.isNetworkTypeMobile(network.type)) {
|
||||
this.removeHostRoutes(network);
|
||||
}
|
||||
|
||||
// Remove secondary default route for dun.
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
|
||||
this.removeSecondaryDefaultRoute(network);
|
||||
}
|
||||
#endif
|
||||
// Remove routing table in /proc/net/route
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
gNetworkService.resetRoutingTable(network);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
} else if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
|
||||
gNetworkService.removeDefaultRoute(network);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Abort ongoing captive portal detection on the wifi interface
|
||||
CaptivePortalDetectionHelper
|
||||
.notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, network);
|
||||
this.setAndConfigureActive();
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
||||
// Update data connection when Wifi connected/disconnected
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && this.mRil) {
|
||||
for (let i = 0; i < this.mRil.numRadioInterfaces; i++) {
|
||||
this.mRil.getRadioInterface(i).updateRILNetworkInterface();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
||||
// Notify outer modules like MmsService to start the transaction after
|
||||
// the configuration of the network interface is done.
|
||||
Services.obs.notifyObservers(network, TOPIC_CONNECTION_STATE_CHANGED,
|
||||
this.convertConnectionType(network));
|
||||
#endif
|
||||
},
|
||||
|
||||
unregisterNetworkInterface: function(network) {
|
||||
@ -427,12 +414,8 @@ NetworkManager.prototype = {
|
||||
return this._preferredNetworkType;
|
||||
},
|
||||
set preferredNetworkType(val) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
|
||||
#else
|
||||
if (val != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
#endif
|
||||
throw "Invalid network type";
|
||||
}
|
||||
this._preferredNetworkType = val;
|
||||
@ -442,11 +425,11 @@ NetworkManager.prototype = {
|
||||
_overriddenActive: null,
|
||||
|
||||
overrideActive: function(network) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (this.isNetworkTypeSecondaryMobile(network.type)) {
|
||||
if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
|
||||
throw "Invalid network type";
|
||||
}
|
||||
#endif
|
||||
|
||||
this._overriddenActive = network;
|
||||
this.setAndConfigureActive();
|
||||
},
|
||||
@ -501,7 +484,6 @@ NetworkManager.prototype = {
|
||||
network.getGateways()));
|
||||
},
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
isNetworkTypeSecondaryMobile: function(type) {
|
||||
return (type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
|
||||
type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL ||
|
||||
@ -525,7 +507,6 @@ NetworkManager.prototype = {
|
||||
|
||||
return this._updateRoutes(false, hosts, network.name, network.getGateways());
|
||||
},
|
||||
#endif
|
||||
|
||||
selectGateway: function(gateways, host) {
|
||||
for (let i = 0; i < gateways.length; i++) {
|
||||
@ -538,7 +519,6 @@ NetworkManager.prototype = {
|
||||
return null;
|
||||
},
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
setSecondaryDefaultRoute: function(network) {
|
||||
let gateways = network.getGateways();
|
||||
for (let i = 0; i < gateways.length; i++) {
|
||||
@ -579,7 +559,6 @@ NetworkManager.prototype = {
|
||||
gNetworkService.removeSecondaryRoute(network.name, route);
|
||||
}
|
||||
},
|
||||
#endif // MOZ_B2G_RIL
|
||||
|
||||
/**
|
||||
* Determine the active interface and configure it.
|
||||
@ -611,29 +590,28 @@ NetworkManager.prototype = {
|
||||
|
||||
// Find a suitable network interface to activate.
|
||||
this.active = null;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
||||
let defaultDataNetwork;
|
||||
#endif
|
||||
for each (let network in this.networkInterfaces) {
|
||||
if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
|
||||
continue;
|
||||
}
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
|
||||
defaultDataNetwork = network;
|
||||
}
|
||||
#endif
|
||||
|
||||
this.active = network;
|
||||
if (network.type == this.preferredNetworkType) {
|
||||
debug("Found our preferred type of network: " + network.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.active) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Give higher priority to default data APN than seconary APN.
|
||||
// Give higher priority to default data APN than secondary APN.
|
||||
// If default data APN is not connected, we still set default route
|
||||
// and DNS on seconary APN.
|
||||
// and DNS on secondary APN.
|
||||
if (defaultDataNetwork &&
|
||||
this.isNetworkTypeSecondaryMobile(this.active.type) &&
|
||||
this.active.type != this.preferredNetworkType) {
|
||||
@ -643,11 +621,8 @@ NetworkManager.prototype = {
|
||||
if (this.isNetworkTypeSecondaryMobile(this.active.type)) {
|
||||
gNetworkService.setDNS(this.active, function() {});
|
||||
} else {
|
||||
#endif // MOZ_B2G_RIL
|
||||
this._setDefaultRouteAndDNS(this.active, oldActive);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (this.active != oldActive) {
|
||||
@ -727,7 +702,7 @@ NetworkManager.prototype = {
|
||||
case Ci.nsINetworkInterface.NETWORK_TYPE_WIFI:
|
||||
return CONNECTION_TYPE_WIFI;
|
||||
case Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE:
|
||||
return CONNECTION_TYPE_CULLULAR;
|
||||
return CONNECTION_TYPE_CELLULAR;
|
||||
}
|
||||
},
|
||||
|
||||
@ -747,10 +722,8 @@ NetworkManager.prototype = {
|
||||
this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_STARTIP] = DEFAULT_WIFI_DHCPSERVER_STARTIP;
|
||||
this.tetheringSettings[SETTINGS_WIFI_DHCPSERVER_ENDIP] = DEFAULT_WIFI_DHCPSERVER_ENDIP;
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
this.tetheringSettings[SETTINGS_DUN_REQUIRED] =
|
||||
libcutils.property_get("ro.tethering.dun_required") === "1";
|
||||
#endif
|
||||
},
|
||||
|
||||
_usbTetheringRequestCount: 0,
|
||||
@ -813,14 +786,14 @@ NetworkManager.prototype = {
|
||||
getNetworkInterface: function(type, serviceId) {
|
||||
for each (let network in this.networkInterfaces) {
|
||||
if (network.type == type) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (network instanceof Ci.nsIRilNetworkInterface) {
|
||||
let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
|
||||
if (rilNetwork.serviceId != serviceId) {
|
||||
continue;
|
||||
try {
|
||||
if (network instanceof Ci.nsIRilNetworkInterface) {
|
||||
let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
|
||||
if (rilNetwork.serviceId != serviceId) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} catch (e) {}
|
||||
return network;
|
||||
}
|
||||
}
|
||||
@ -864,7 +837,6 @@ NetworkManager.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
dunConnectTimer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
|
||||
/**
|
||||
* Callback when dun connection fails to connect within timeout.
|
||||
@ -887,8 +859,10 @@ NetworkManager.prototype = {
|
||||
gMobileConnectionService.getItemByServiceId(this._dataDefaultServiceId);
|
||||
let data = connection && connection.data;
|
||||
if (data && data.state === "registered") {
|
||||
let ril = this.mRil.getRadioInterface(this._dataDefaultServiceId);
|
||||
|
||||
this.dunRetryTimes = 0;
|
||||
ril.setupDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_DUN);
|
||||
ril.setupDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN);
|
||||
this.dunConnectTimer.cancel();
|
||||
this.dunConnectTimer.
|
||||
initWithCallback(this.onDunConnectTimerTimeout.bind(this),
|
||||
@ -931,7 +905,7 @@ NetworkManager.prototype = {
|
||||
|
||||
if (dun && (dun.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED)) {
|
||||
this.mRil.getRadioInterface(this._dataDefaultServiceId)
|
||||
.deactivateDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_DUN);
|
||||
.deactivateDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -948,7 +922,6 @@ NetworkManager.prototype = {
|
||||
this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = dun.name;
|
||||
callback(dun);
|
||||
},
|
||||
#endif
|
||||
|
||||
handleUSBTetheringToggle: function(enable) {
|
||||
debug("handleUSBTetheringToggle: " + enable);
|
||||
@ -978,7 +951,6 @@ NetworkManager.prototype = {
|
||||
this.tetheringSettings[SETTINGS_USB_ENABLED] = true;
|
||||
this._usbTetheringAction = TETHERING_STATE_ONGOING;
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
|
||||
this.handleDunConnection(true, function(network) {
|
||||
if (!network){
|
||||
@ -990,7 +962,6 @@ NetworkManager.prototype = {
|
||||
}.bind(this));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this.active) {
|
||||
this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = this.active.name;
|
||||
@ -1076,13 +1047,12 @@ NetworkManager.prototype = {
|
||||
|
||||
this._wifiTetheringRequestOngoing = true;
|
||||
gNetworkService.setWifiTethering(enable, config, (function(error) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Disconnect dun on error or when wifi tethering is disabled.
|
||||
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
|
||||
(!enable || error)) {
|
||||
this.handleDunConnection(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
let resetSettings = error;
|
||||
debug('gNetworkService.setWifiTethering finished');
|
||||
this.notifyError(resetSettings, callback, error);
|
||||
@ -1125,7 +1095,6 @@ NetworkManager.prototype = {
|
||||
|
||||
this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface = network.name;
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
|
||||
this.handleDunConnection(true, function(config, callback, network) {
|
||||
if (!network) {
|
||||
@ -1137,7 +1106,6 @@ NetworkManager.prototype = {
|
||||
}.bind(this, config, callback));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
let mobile = this.getNetworkInterface(
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
|
||||
@ -1210,21 +1178,17 @@ NetworkManager.prototype = {
|
||||
// Skip others request when we found an error.
|
||||
this._usbTetheringRequestCount = 0;
|
||||
this._usbTetheringAction = TETHERING_STATE_IDLE;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
|
||||
this.handleDunConnection(false);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (enable) {
|
||||
this._usbTetheringAction = TETHERING_STATE_ACTIVE;
|
||||
} else {
|
||||
this._usbTetheringAction = TETHERING_STATE_IDLE;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
|
||||
this.handleDunConnection(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
this.handleLastUsbTetheringRequest();
|
||||
@ -1247,7 +1211,6 @@ NetworkManager.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
|
||||
network.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
|
||||
this.dunConnectTimer.cancel();
|
||||
@ -1260,14 +1223,12 @@ NetworkManager.prototype = {
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!this.tetheringSettings[SETTINGS_USB_ENABLED]) {
|
||||
debug("Usb tethering settings is not enabled");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
|
||||
network.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN &&
|
||||
this._tetheringInterface[TETHERING_TYPE_USB].externalInterface ===
|
||||
@ -1275,7 +1236,6 @@ NetworkManager.prototype = {
|
||||
debug("Dun required and dun interface is the same");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this._tetheringInterface[TETHERING_TYPE_USB].externalInterface ===
|
||||
this.active.name) {
|
||||
@ -1392,11 +1352,13 @@ let CaptivePortalDetectionHelper = (function() {
|
||||
};
|
||||
}());
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
XPCOMUtils.defineLazyServiceGetter(NetworkManager.prototype, "mRil",
|
||||
"@mozilla.org/ril;1",
|
||||
"nsIRadioInterfaceLayer");
|
||||
#endif
|
||||
XPCOMUtils.defineLazyGetter(NetworkManager.prototype, "mRil", function() {
|
||||
try {
|
||||
return Cc["@mozilla.org/ril;1"].getService(Ci.nsIRadioInterfaceLayer);
|
||||
} catch (e) {}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NetworkManager]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user