Bug 772747 - B2G RIL: Add method to connect to different APN type. r=philikon

This commit is contained in:
Shian-Yow Wu 2012-09-26 20:57:37 +08:00
Родитель ef6ff5ca55
Коммит f3fdc22098
3 изменённых файлов: 128 добавлений и 11 удалений

Просмотреть файл

@ -174,8 +174,9 @@ NetworkManager.prototype = {
debug("Network " + network.name + " changed state to " + network.state);
switch (network.state) {
case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED:
// Add host route on secondary APN
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
// Add host route for data calls
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
this.addHostRoute(network);
}
@ -185,8 +186,9 @@ NetworkManager.prototype = {
this.setAndConfigureActive();
break;
case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED:
// Remove host route on secondary APN
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
// Remove host route for data calls
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
this.removeHostRoute(network);
}
@ -218,8 +220,9 @@ NetworkManager.prototype = {
Cr.NS_ERROR_INVALID_ARG);
}
this.networkInterfaces[network.name] = network;
// Add host route on secondary APN
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
// Add host route for data calls
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
this.addHostRoute(network);
}
@ -241,8 +244,9 @@ NetworkManager.prototype = {
Cr.NS_ERROR_INVALID_ARG);
}
delete this.networkInterfaces[network.name];
// Remove host route on secondary APN
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
// Remove host route for data calls
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
this.removeHostRoute(network);
}
@ -260,7 +264,8 @@ NetworkManager.prototype = {
set preferredNetworkType(val) {
if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE,
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS].indexOf(val) == -1) {
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS,
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL].indexOf(val) == -1) {
throw "Invalid network type";
}
this._preferredNetworkType = val;

Просмотреть файл

@ -199,7 +199,7 @@ function RadioInterfaceLayer() {
let lock = gSettingsService.createLock();
lock.get("ril.radio.disabled", this);
// Read the APN data form the setting DB.
// Read the APN data from the settings DB.
lock.get("ril.data.apn", this);
lock.get("ril.data.user", this);
lock.get("ril.data.passwd", this);
@ -215,6 +215,21 @@ function RadioInterfaceLayer() {
"ril.data.httpProxyHost",
"ril.data.httpProxyPort"];
// Read secondary APNs from the settings DB.
lock.get("ril.mms.apn", this);
lock.get("ril.mms.user", this);
lock.get("ril.mms.passwd", this);
lock.get("ril.mms.httpProxyHost", this);
lock.get("ril.mms.httpProxyPort", this);
lock.get("ril.mms.mmsc", this);
lock.get("ril.mms.mmsproxy", this);
lock.get("ril.mms.mmsport", this);
lock.get("ril.supl.apn", this);
lock.get("ril.supl.user", this);
lock.get("ril.supl.passwd", this);
lock.get("ril.supl.httpProxyHost", this);
lock.get("ril.supl.httpProxyPort", this);
// Read the desired setting of call waiting from the settings DB.
lock.get("ril.callwaiting.enabled", this);
@ -1227,6 +1242,8 @@ RadioInterfaceLayer.prototype = {
// APN data for making data calls.
dataCallSettings: {},
dataCallSettingsMMS: {},
dataCallSettingsSUPL: {},
_dataCallSettingsToRead: [],
_oldRilDataEnabledState: null,
@ -1257,6 +1274,25 @@ RadioInterfaceLayer.prototype = {
}
this.updateRILNetworkInterface();
break;
case "ril.mms.apn":
case "ril.mms.user":
case "ril.mms.passwd":
case "ril.mms.httpProxyHost":
case "ril.mms.httpProxyPort":
case "ril.mms.mmsc":
case "ril.mms.mmsproxy":
case "ril.mms.mmsport":
key = aName.slice(8);
this.dataCallSettingsMMS[key] = aResult;
break;
case "ril.supl.apn":
case "ril.supl.user":
case "ril.supl.passwd":
case "ril.supl.httpProxyHost":
case "ril.supl.httpProxyPort":
key = aName.slice(9);
this.dataCallSettingsSUPL[key] = aResult;
break;
case "ril.callwaiting.enabled":
this._callWaitingEnabled = aResult;
this.setCallWaitingEnabled(this._callWaitingEnabled);
@ -1853,6 +1889,74 @@ RadioInterfaceLayer.prototype = {
}
},
/**
* Determine whether secondary APN goes through default APN.
*/
usingDefaultAPN: function usingDefaultAPN(apntype) {
switch (apntype) {
case "mms":
return (this.dataCallSettingsMMS["apn"] == this.dataCallSettings["apn"]);
case "supl":
return (this.dataCallSettingsSUPL["apn"] == this.dataCallSettings["apn"]);
return false;
}
},
setupDataCallByType: function setupDataCallByType(apntype) {
if (apntype != "default" && this.usingDefaultAPN(apntype)) {
debug("Secondary APN type " + apntype + " goes through default APN, nothing to do.");
return;
}
switch (apntype) {
case "default":
this.dataNetworkInterface.connect(this.dataCallSettings);
break;
case "mms":
this.mmsNetworkInterface.connect(this.dataCallSettingsMMS);
break;
case "supl":
this.suplNetworkInterface.connect(this.dataCallSettingsSUPL);
break;
default:
debug("Unsupported APN type " + apntype);
break;
}
},
deactivateDataCallByType: function deactivateDataCallByType(apntype) {
if (apntype != "default" && this.usingDefaultAPN(apntype)) {
debug("Secondary APN type " + apntype + " goes through default APN, nothing to do.");
return;
}
switch (apntype) {
case "default":
this.dataNetworkInterface.disconnect();
break;
case "mms":
this.mmsNetworkInterface.disconnect();
break;
case "supl":
this.suplNetworkInterface.disconnect();
break;
default:
debug("Unsupported APN type " + apntype);
break;
}
},
getDataCallStateByType: function getDataCallStateByType(apntype) {
switch (apntype) {
case "default":
return this.dataNetworkInterface.state;
case "mms":
return this.mmsNetworkInterface.state;
case "supl":
return this.suplNetworkInterface.state;
default:
return RIL.GECKO_NETWORK_STATE_UNKNOWN;
}
},
setupDataCall: function setupDataCall(radioTech, apn, user, passwd, chappap, pdptype) {
this.worker.postMessage({rilMessageType: "setupDataCall",
radioTech: radioTech,
@ -2051,6 +2155,11 @@ RILNetworkInterface.prototype = {
this.dataCallSettings = options;
}
if (!this.dataCallSettings["apn"]) {
debug("APN name is empty, nothing to do.");
return;
}
this.httpProxyHost = this.dataCallSettings["httpProxyHost"];
this.httpProxyPort = this.dataCallSettings["httpProxyPort"];

Просмотреть файл

@ -230,7 +230,7 @@ interface nsIRilContext : nsISupports
readonly attribute nsIDOMMozMobileConnectionInfo data;
};
[scriptable, uuid(0a05f286-608d-4d2e-ab72-16bd36e93c15)]
[scriptable, uuid(a90fef2c-44aa-4f2b-a0ee-a590e9dd345e)]
interface nsIRadioInterfaceLayer : nsISupports
{
const unsigned short CALL_STATE_UNKNOWN = 0;
@ -256,6 +256,9 @@ interface nsIRadioInterfaceLayer : nsISupports
/**
* PDP APIs
*/
void setupDataCallByType(in DOMString apntype);
void deactivateDataCallByType(in DOMString apntype);
long getDataCallStateByType(in DOMString apntype);
void setupDataCall(in long radioTech,
in DOMString apn,
in DOMString user,