Bug 1021424 - Verify network.type and network.state before applying mms settings. f=btseng r=vicamo

This commit is contained in:
Jessica Jong 2014-06-24 02:16:00 +02:00
Родитель 438cc71c8b
Коммит a1426eec5e
1 изменённых файлов: 3 добавлений и 27 удалений

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

@ -283,28 +283,6 @@ MmsConnection.prototype = {
Services.obs.addObserver(this, kNetworkConnStateChangedTopic,
false);
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
this.connected = this.radioInterface.getDataCallStateByType("mms") ==
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
// If the MMS network is connected during the initialization, it means the
// MMS network must share the same APN with the mobile network by default.
// Under this case, |networkManager.active| should keep the mobile network,
// which is supposed be an instance of |nsIRilNetworkInterface| for sure.
if (this.connected) {
let networkManager =
Cc["@mozilla.org/network/manager;1"].getService(Ci.nsINetworkManager);
let activeNetwork = networkManager.active;
let rilNetwork = activeNetwork.QueryInterface(Ci.nsIRilNetworkInterface);
if (rilNetwork.serviceId != this.serviceId) {
if (DEBUG) debug("Sevice ID between active/MMS network doesn't match.");
return;
}
// Set up the MMS APN setting based on the connected MMS network,
// which is going to be used for the HTTP requests later.
this.setApnSetting(rilNetwork);
}
},
/**
@ -473,15 +451,13 @@ MmsConnection.prototype = {
// Check if the network state change belongs to this service.
let network = subject.QueryInterface(Ci.nsIRilNetworkInterface);
if (network.serviceId != this.serviceId) {
if (network.serviceId != this.serviceId ||
network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
return;
}
// We only need to capture the state change of MMS network. Using
// |network.state| isn't reliable due to the possibilty of shared APN.
let connected =
this.radioInterface.getDataCallStateByType("mms") ==
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
// Return if the MMS network state doesn't change, where the network
// state change can come from other non-MMS networks.